Earlier quoted context omitted.
You need to make languages fast on both dimensions, static and dynamic. A dynamically typed language can only be optimized in one dimension, which is why they usually trail behind statically typed languages in performances (since those are optimized along both axes).
I've not seen anything like the dynamic-dispatch optimisations the Self team came up with in the 1990s done in C++, nor problem-domain optimisations expressed as macros as is often done in Lisps, nor the aggressive constant-propagation of closures and their eventual inlining that Factor does. Perhaps some of them could be applied, but a highly complicated base language with extensive mutation semantics (including poi…
Why C++ is not my favourite language
41–50 of 53 posts
Re: Why C++ is not my favourite language
#42Earlier quoted context omitted.
C++ hits a certain sweet spot. In some cases - whether you like it or not - it's just the right tool for the job. Two examples I can think of are: * VM implementations (I mentioned Factor, but also HotSpot, Microsoft's CLR, SquirrelFish, TraceMonkey, V8 and Opera's Carakan are all high-performance VMs written in C++ (x). Note also that all major layout engines are written in C++. Complex but fast and highly-tuned bea…
How about D? A friend of mine uses it as a better C++ for mathematical programming (optimization, graphs and so on). Perhaps nobody would have invented C++ if D would have come earlier.
Re: Why C++ is not my favourite language
#43Earlier quoted context omitted.
I can't help feeling that Common Lisp should be doing better, considering that it's a language where you can effectively tell the compiler "It's OK to store this variable in a register". It's currently doing about the same as Mono, which IIRC doesn't JIT, and worse than Java. The king of dynamic language performance right now is LuaJIT, which crushes Perl, Python, and Ruby and performs admirably relative to Smalltalk…
The quality of the individual programs plays a large role. E.g. GHC (Haskell) has made huge strides in the past thanks to better libraries and implementations for the benchmark, despite nearly the same compiler. On a side note, a lot of the benchmarks had to be reformulated after lazy languages got fast. As far as I know, a benchmark at this side prescribes which algorithm you should use. Haskell (and e.g. Clean) jus…
As you don't say how far "in the past" maybe that's nonsense or maybe that's true.
> a lot of the benchmarks had to be reformulated after lazy languages got fast
That's nonsense.
Programs for one benchmark - binary-trees - had to be rewritten because "this is an adaptation of a benchmark for testing GC so we are interested in the whole tree being allocated before any nodes are GC'd" and with lazy evaluation GC gobbles up nodes before the whole tree's allocated -
http://shootout.alioth.debian.org/u32q/benchmark.php?test=bi...
Re: Why C++ is not my favourite language
#44Earlier quoted context omitted.
The quality of the individual programs plays a large role. E.g. GHC (Haskell) has made huge strides in the past thanks to better libraries and implementations for the benchmark, despite nearly the same compiler. On a side note, a lot of the benchmarks had to be reformulated after lazy languages got fast. As far as I know, a benchmark at this side prescribes which algorithm you should use. Haskell (and e.g. Clean) jus…
> despite nearly the same compiler As you don't say how far "in the past" maybe that's nonsense or maybe that's true. > a lot of the benchmarks had to be reformulated after lazy languages got fast That's nonsense. Programs for one benchmark - binary-trees - had to be rewritten because "this is an adaptation of a benchmark for testing GC so we are interested in the whole tree being allocated before any nodes are GC'd"…
Re: Why C++ is not my favourite language
#45Earlier quoted context omitted.
I've not seen anything like the dynamic-dispatch optimisations the Self team came up with in the 1990s done in C++, nor problem-domain optimisations expressed as macros as is often done in Lisps, nor the aggressive constant-propagation of closures and their eventual inlining that Factor does. Perhaps some of them could be applied, but a highly complicated base language with extensive mutation semantics (including poi…
Do you know Synthesis OS ( http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.29.4... ). The author made the OS specialize (and thus optimize) system calls during runtime (or something like that, it's been a while since I read the paper). The techniques might me applicable in higher-level languages than the assembler used there.
Re: Why C++ is not my favourite language
#46Earlier quoted context omitted.
FWIW, I'm working in C for my day job (and resisting calls to move up to C++), as my day job involves shuffling bytes around rather than particularly complex code; it's ~20KLOC. Then we build the tools to manage it in Python with a bit of shell scripting here and there. However, I code Scheme in my spare time, and would do the lot in that if I didn't then have to justify training new developers in Scheme! C's the rig…
Is there an easy way to shuffle bytes and bits in Scheme? I was quite delighted when I found Data.Binary ( http://code.haskell.org/binary/ ) for Haskell.
SRFI-4 (http://srfi.schemers.org/srfi-4/srfi-4.html) provides a standard interface for dealing with 'homogenous vectors' (eg, arrays of unboxed integers or floats), which is great for shuffling bytes.
For bits, there's the usual bitwise-or and all that.
However, both could be improved somewhat; what the Factor folks have done with their struct arrays is IMHO superier.
Re: Why C++ is not my favourite language
#47Earlier quoted context omitted.
OCaml does quite well against C++ in the shootout. OCaml's Functors and type inferrence are a big win over C++ templates. Yeah, the syntax takes some getting-used-to, but all in all the language seems to hang together much better than C++ (perhaps not saying much)
I agree. I like Haskell's syntax better. But their syntaxen are nearly isomorphic for the most common stuff.
Re: Why C++ is not my favourite language
#48The canonical anti-C++ link for me has to be http://yosefk.com/c++fqa/ - pretty thorough and reasonably well argued.
Now, let's just wait for my colleague to start ribbing me for keeping our project written in C again... ;-)
Re: Why C++ is not my favourite language
#49Earlier quoted context omitted.
> despite nearly the same compiler As you don't say how far "in the past" maybe that's nonsense or maybe that's true. > a lot of the benchmarks had to be reformulated after lazy languages got fast That's nonsense. Programs for one benchmark - binary-trees - had to be rewritten because "this is an adaptation of a benchmark for testing GC so we are interested in the whole tree being allocated before any nodes are GC'd"…
I love the shootout, by the way. Thanks for maintaining it.
Every week there are new programs, often from people who haven't contributed a program before.
One of these days someone will find a way to make effective use of all the cores for n-body, maybe.
Re: Why C++ is not my favourite language
#50Earlier quoted context omitted.
Do you know Synthesis OS ( http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.29.4... ). The author made the OS specialize (and thus optimize) system calls during runtime (or something like that, it's been a while since I read the paper). The techniques might me applicable in higher-level languages than the assembler used there.
Yeah! Synthesis is quite excellent. I've been interested in exploring using the FORTH model of easily-accessible-runtime-compiler in that sort of context...