ok probably silly question. so programming languages are different, but why aren't there more cross-language code generation tools? or why don't I see them used? like it seems like there is always information loss, but converting from a strongly typed language to something like python would lose less than vice versa. seems like you could at least get close?? !/

@jonny In certain contexts where it's useful it isn't actually that uncommon. Lots of web programming languages like TypeScript, CoffeeScript and Elm all get transpiled to JavaScript. I don't know of any reason to go in the other direction, though, similar to compiling something like C to Assembly

@njms @jonny I agree, and I think what drives it is not the desire to target a language, but the desire to target a platform. We transpile to JavaScript so everything can be on the web platform. So to understand (lack of) motivation of other transpilers, I would look at the target platforms.

@cstanhope @njms so thats what defines the utility of compilation/transpilation, and converges with the notion of using "native" in mobile web world -- the basin point isn't uniform, but is just the "platform default." hmm. So then the goals are very different if you just want a package for polyglots, for the sake of broader use and understanding rather than performance or reliability. you as usual thinking in the same vein about the social use of code <3

@jonny @cstanhope @njms Transpiling to C is another really common one. Zig, Nim, and a number of Schemes do it. This is another case of what @cstanhope talked about: targeting a platform.

Transpiling between languages for readability/understandability, as you seem to be proposing, is less common. Probably just because it is much harder to generate nice, readable code, than utilitarian working code. A transpiler won't have any idea of what makes for a nice readable program in the target language, unless it is taught. It's probably possible but I don't know anyone who's tried. Interesting idea!

Follow

@psf @cstanhope IIRC this is *kind of* what CoffeeScript attempts to do, or at least, here's their comparison and I'll let you judge:

coffeescript.org/#overview

Which is comically more readable than the compressed blocks of anonymous functions I've seen get spat out by other transpilers. But I agree with @jonny in that transpiling from CoffeeScript doesn't feel the same as what they were getting at. An idiomatic transpiler would be pretty cool and I'm surprised they don't seem more common

Sign in to participate in the conversation
social.coop

A Fediverse instance for people interested in cooperative and collective projects.