4 ms·
If your software matters, you will write it in C++
- unimpressive 15y agoIs there anything stopping you from writing a compiler for your language that compiles to C and then optimizing anything that slows down the system? A bit easier on a hacker than messing with the binary. You then get the added benefit of not having to touch C++. I know that for a lot of people at least this would be considered worth the trouble alone.
- dalke 15y agoNo. But that doesn't necessarily help. A straight-forward Python to C 'compiler', which emits the code equivalent to running the VM main loop, has no significant performance increase. You have to do a lot more work (e.g., ShedSkin, Cython) to see better performance.
- unimpressive 15y agoThe idea was that you'd hand hack the performance critical parts. And I believe the correct term is transpiler. (Which can be really useful to have if your language sucks and it'd be easier to edit bad code in a better language. (Or in this case your language is slow and it'd be better to just hack the parts that need to be optimized before you compile the binary.)) Of course; the right thing is to use something like Cython. After all, if you don't get a performance increase anyway you may as well just hand hack the parts you need to optimize as C modules. EDIT: I'm aware I called it a compiler in my earlier post. The transpiler comment was in response to you putting "compiler" in quotation marks.
- dalke 15y agoI put 'compiler' in quotes because I was thinking of a research project a few years back which converted the Python byte code (parsed by CPython itself) into C code, along with a small bit of peephole optimization. I don't think it's worthy enough to be called a transpiler. The generated C code is still a stack machine. You could replace that with C code, but if you wanted to program to a stack machine then you likely wouldn't have been coding in Python in the first place. Part of the nuisance in replacing that C code would be wading through all of the extra code Python generates, just to add two numbers.
- abhaga 15y agoThe argument regarding the VM based languages is not correct. Having a JIT allows you to use dynamic compilation so you can adjust the running code depending on the context. For example you can do heavier optimization for hot code paths. This is something which might give a VM based language an edge. Doesn't Haskell come out better on certain benchmarks as compared to C/C++?
- ghc 15y agoThere are some instances of Haskell outperforming C/C++, but this is generally limited to situations where unboxing, strict application and Haskell's type system allow GHC to perform some amazing optimization. In other words, don't expect Haskell to outperform C/C++ in realistic circumstances.
- sbov 15y agoWriter admits (or seems to claim) Fortran is faster than C++. By ignoring Fortan it seems like they admit that there are things outside of what their proof is looking at to take into consideration.
- pjmlp 15y agoFortran implementations are usually faster than C++ implementations, because the language design allows for certain optimization algorithms to be used, which are not possible in C++, specially due to aliasing issues.
- dlsym 15y agoGreat excuse to compile your php application to C++ with hiphop ;-)
- lelele 15y ago"If your software matters, you will write it in C++ " If you don't know any better. Then please let me know what you are working on so that I can eat in your plate.
- aChrisSmith 15y agoOP here. For some reason nobody gets the point that it was a joke. While you could argue about the merits of the statement, the blog post on whole is just for entertainment.