4 ms·
Concept of compiling things is awesome. But I refuse to understand how making compiled language -> interpreted language is a thing... It should be other way aro
by andrewshatnyy 11y ago
Concept of compiling things is awesome. But I refuse to understand how making compiled language -> interpreted language is a thing... It should be other way around. I'd love to see something solid like js -> c compiler so my js code runs quick and efficient.
- spion 11y agoA js -> c compiler would actually be much, much slower than current JITs because of the lack of type information.
- randyrand 11y agoJust declare a C union of an int, float, string, etc. All functions take these unions as function parameters. Have one field be an enum of its actual type. Or something along these lines. I don't see why this is any more difficult than a normal jit that also doesnt have type information.
- comex 11y agoBecause JITs are able to generate code that optimistically assumes variables have certain types (with appropriate deoptimization checks), which is much less expensive than performing full dynamic lookups on every single operation.
- TazeTSchnitzel 11y agoIt's easier to chuck away type information than mystically conjure it out of thin air. An ahead-of-time compiler can't make JS fast because it lacks the type information needed to do so. That's why you need just-in-time compilation for JS: you can only discover what types go where by running the code.
- andrewshatnyy 11y agoMeant to say JS -> binary so you can have a node/express server compiled and running. Browser JS is another story of cource
- tlrobinson 11y agoWith modern languages the line between compiled and interpreted is blurred, and can almost be thought of as an implementation detail. Most modern JavaScript engines incorporate a JIT compiler, for example.