I believe that C++ continues to be a standard because, for >99% of programs on >99% of machines, compiled C/C++ is faster than anything else (and C++ is nicer than C).
Why are compilers for high-level languages so much worse than human C++ programmers? My understanding is that you don't have to be a C++ programmer to write C++ code that can't be beaten by any other language. This is an AI question, but maybe also a systems question.
I would like to see a series of challenges for compilers, possibly in the style of a competition between programmers who work on compilers. Starting with really simple programs, make sure that they compile to something as fast as C++... and progressively, the test programs become more complex.
(1) Are all languages equally good at printing "Hello World" 1 million times?
Or better, a question that doesn't involve system calls:
(2) are all languages equally good at computing Fibonacci numbers, written with tail recursion?
Why are compilers for high-level languages so much worse than human C++ programmers? My understanding is that you don't have to be a C++ programmer to write C++ code that can't be beaten by any other language. This is an AI question, but maybe also a systems question.
I would like to see a series of challenges for compilers, possibly in the style of a competition between programmers who work on compilers. Starting with really simple programs, make sure that they compile to something as fast as C++... and progressively, the test programs become more complex.
(1) Are all languages equally good at printing "Hello World" 1 million times?
Or better, a question that doesn't involve system calls:
(2) are all languages equally good at computing Fibonacci numbers, written with tail recursion?
(no subject)
Date: 2009-10-18 10:34 pm (UTC)(no subject)
Date: 2009-10-19 02:56 am (UTC)In short, some languages just Don't Care about speed, and spend their time on things to make programming in them nicer. Others provide better abstractions and safety that can't generally be converted to C.
So yes, it's trivial to convert these short benchmarks to C. But it's not at all useful in a general compiler, since anything with any substance won't be as trivially converted, and it would take a tremendous amount of work to do so..
I can likewise look at the second example on this page, and ask "why does C not do tail recursion? We've shown in numerous languages how trivial it is and how tremendously useful it is!" That's not a design goal for the language/compiler, so they didn't bother with it. (Though I actually thought that gcc did do proper tail recursion, but it makes such a great point that I'll hope the page is right.)
(no subject)
Date: 2009-10-19 03:51 am (UTC)(no subject)
Date: 2009-10-19 07:20 am (UTC)(no subject)
Date: 2009-10-19 04:50 pm (UTC)(no subject)
Date: 2009-10-19 07:00 pm (UTC)This is what I'm surprised about...
If you had a "bilingual parallel corpus" with programs in your high-level-language and C, doesn't the translation task become easy?
(no subject)
Date: 2009-10-20 01:59 am (UTC)(no subject)
Date: 2009-10-20 02:10 am (UTC)(no subject)
Date: 2009-10-20 05:58 am (UTC)I don't mean to be inflammatory (well maybe a little), but I feel like you have a blindspot for things that machine learning is poor at that you deliberately ignore to your own detriment.
(no subject)
Date: 2009-10-20 06:08 am (UTC)I won't deny having an ideology. I reserve the right to be unhappy as long as I'm required to write low-level code in order for it to be efficient.
I am stubborn because this is the kind of thing that would seem to be easy to automate... but evidently it isn't. And neither is computer vision, despite Marvin Minsky's early opinions. Which is why they say the proof is in the pudding: if you say it's easy, you should do it!
Here's the old thread: translating between programming languages
(no subject)
Date: 2009-10-20 06:11 am (UTC)... a hope that is probably ridiculous and arrogant.
(no subject)
Date: 2009-10-20 02:17 am (UTC)I'm moderately..hmm.."irritated" is strong word, but maybe "perplexed" at your insistence on thinking about things this way? Why would you want a learned model when you can get an exact translation? I find your methods vaguely abhorrent--we should prefer exact solutions over heuristic ones when we have the capability to achieve them.
(no subject)
Date: 2009-10-20 02:44 am (UTC)I have trouble thinking of C++ programming as intelligent behavior.
It's probably my machine learning bias... just like I suggested using samples for audio synthesis. Although you can always simulate the physics, it's often too hard.
(no subject)
Date: 2009-10-19 12:29 am (UTC)Elaborate on the word nicer please.
(no subject)
Date: 2009-10-19 09:01 am (UTC)(no subject)
Date: 2009-10-19 03:21 am (UTC)http://shootout.alioth.debian.org/
Although the challenge is posed to the visitors, to create better source code implementations for the compiler, rather than posed to the compiler to compile better assembly.
(no subject)
Date: 2009-10-19 04:46 am (UTC)It used to be that the site was about a natural implementation in each language, but now it seems to be fair game to throw various libraries at the problems. Seems that hacking hard gets you big rewards in C/C++, and less so in higher-level languages. But that's a lot less interesting than knowing what you get by writing pretty much normal code without heavy optimization. For the binary-trees benchmark, the natural haskell code is about 3x faster than the natural C/C++ code, and ocaml is also pretty fast. For the reverse-complement benchmark, all the language implementations are essentially identical (all the time is in I/O). But you can use non-standard memory allocation routines in the one case, or nonstandard I/O routines in the other case, and have the C end up quite a bit faster; the ocaml programs seem to play around with the garbage collector settings, which gives much less of a win.