4 ms·
I'd say that it feels more like a scripting language in comparison to Rust and is more approachable than Haskell or Erlang while being fast since it's compiled
by madez 12y ago
I'd say that it feels more like a scripting language in comparison to Rust and is more approachable than Haskell or Erlang while being fast since it's compiled to C.
- mreiland 12y agobeing compiled to C doesn't imply fast :)
- def- 12y agoIt does have other advantages though, like inheriting C's excellent portability.
- coldtea 12y agoUnless done badly, it does. Transpiling to C gives you the opportunity to emit code that is straightforward clean and fast C for most operations, which avoid an abstraction overhead.
- jerf 12y agoNo, it doesn't. You could easily compile Python into C (basically, "just" inline the core interpreter loop), but it will still be slow, because the Python semantics still require a lot of dictionary resolutions on every operation. Getting efficient C still requires you to think about getting efficient code. You can not get it "for free" just by waving a C compiler over your language. Otherwise, everyone would just do that and there would be no languages slower than C. Before you reply to disagree, make sure to very, very carefully think through the implications of the last sentence there. It is not as if compiling to C is particularly hard; it is literally "homework assignment for a normal college senior in a compilers course"-difficult. Many languages have gone through a phase where they compile to C. Usually they deliberately leave C at some point, another thing to carefully ponder the implications of before replying in disagreement.
- coldtea 12y ago>No, it doesn't. You could easily compile Python into C (basically, "just" inline the core interpreter loop), but it will still be slow, because the Python semantics still require a lot of dictionary resolutions on every operation. Yeah, and you could do this too at the start of your emitted code from the transpiler: sleep(UINT_MAX) which would also make it slower than an interpreted language. But I specified I wasn't talking about that, or about "just inlining the core interpreter loop", but about transpiling letting you also emit straightforward and clean code without extra abstractions for most operations. A new language like Nim doesn't come with all the baggage of Python's runtime pre-existing, and doesn't need to recreate it.
- mreiland 12y agoHipHop doesn't support the entirety of the PHP runtime for exactly the reasons that have been laid out for you. That's reality from a company with a shitton of money and a vested interest in doing it successfully. They can't do it in the general case because reality disagrees with you.
- coldtea 12y agoNot sure what are you getting at. What I didn't say: transpiling is magic fairy dust for speed, and you don't have to care about language semantics at all. What I said: "unless done badly" (my words on the original comment), it's fast, as it gives you a chance to emit straightfoward C code for most operations. Now, regarding your example: First, HipHop is not transpiled to C. It's a runtime with a JIT. Second, what does "HipHop not supporting the entirety of the PHP runtime" has to do with anything? I take it you mean that the fact they had to skip some parts of the runtime for increased speed, proves something related to what I wrote. But (besides the JIT thing) PHP is not greenfield like Nim. They have a runtime, and it has to work in a certain way. PHP wasn't designed with transpiling in mind, and HipHop had to follow it closely as a design goal. I never said runtime decisions you have to mimic to be 100% compatible can't slow you down.
- 12y ago
- Dewie3 12y ago> while being fast since it's compiled to C. Which is fast compared to what? Being compiled to JS? It's not like being compiled to a "fast language" automatically makes that compiled program fast. You also have to consider how complex the runtime is, and other variables which are probably a direct result of the semantics of the language.