Reeks of an anti-C bias. This comment by the author is flat out wrong, and I quote: """ `int x[1000]` in C or C++ doesn’t have much meaning. It’s semantically equivalent to declaring “x” as `int *x`. You can reassign X any time you want, to make it point to a different location. """ C is also a pretty different language style-wise than C++. Aside from that, they're both good languages for building runtimes since thei…
The “C Is Efficient” Language Fallacy (2006)
71–80 of 106 posts
Re: The “C Is Efficient” Language Fallacy (2006)
#72Really good points! For me, the best approach to efficiency in terms of development speed and performance is to use a fast language for critical code paths and then make it accessible using a scripting language. Python and C++ work really great in this respect, as it's very easy to generate Python bindings for a C++ library using e.g. SWIG, SIP or Boost. Lua is also a good choice as an embedable scripting language an…
From your username & requirements, I'd definitely recommend looking at Julia: http://docs.julialang.org/en/release-0.4/manual/introduction... It can be very fast by itself, and can also be written extremely high level & is very easy to form bindings to other languages, thanks to the multiple dispatch. Even small things such as having full unicode support is very nice to write maths code in a very 'pen and paper' kind…
Re: The “C Is Efficient” Language Fallacy (2006)
#73Reeks of an anti-C bias. This comment by the author is flat out wrong, and I quote: """ `int x[1000]` in C or C++ doesn’t have much meaning. It’s semantically equivalent to declaring “x” as `int *x`. You can reassign X any time you want, to make it point to a different location. """ C is also a pretty different language style-wise than C++. Aside from that, they're both good languages for building runtimes since thei…
Obviously , the OP was talking about function parameters, where "int x[1000]" is semantically equivalent to "int *x", see C11, 6.9.1, item 10: http://www.iso-9899.info/n1570.html#6.9.1
"While I know that C compilers are really conservative about this, doesn’t it matter as to how x and y are declared? After all if they are dclared as: int x[1000], y[1000];"
Those array declarations aren't function argument declarations (except in pre-C89), so not sure why he would talk about semantic equivalence in response to that if it only applies to function arguments.
Re: The “C Is Efficient” Language Fallacy (2006)
#74Earlier quoted context omitted.
If you produced the exact same binary the language that was used to produce it would be inconsequential, no?
Something else that struck me as wrong: the op counts the time the JVM needs to startup in the time it takes for the program to complete. That should be completely wrong, right? Otherwise we should count the time the physical machine took to boot up -and then the OS to load- in the time each benchmarked implementation took to complete. The JVM is a virtual computer, so why treat it any different than the physical one…
Re: The “C Is Efficient” Language Fallacy (2006)
#75as much as it's not part of the standard, __restrict__ allows limiting the effects of pointer aliasing in C/C++. [1] [1] : https://en.wikipedia.org/wiki/Restrict
Re: The “C Is Efficient” Language Fallacy (2006)
#76Re: The “C Is Efficient” Language Fallacy (2006)
#77Earlier quoted context omitted.
If you produced the exact same binary the language that was used to produce it would be inconsequential, no?
Hah. You're right, missed that. But that's the point, isn't it? You can't ever compare two programs written in different languages claiming to test "the same program" written in different languages. Because in the end either they're not the same program, so there's no comparison, or they're the same program, so what are you really comparing?
Re: The “C Is Efficient” Language Fallacy (2006)
#78Re: The “C Is Efficient” Language Fallacy (2006)
#79True, the efficiency argument is wrong. Thinking about your algorithm and knowing where you actually need to be efficient are far more important. What I appreciate about C in particular is that it seems harder to "program by accident" than it is in most languages. C was my first language. After I learned C, I programmed in a higher level language for a while later before discovering that its runtime threw exceptions…
Re: The “C Is Efficient” Language Fallacy (2006)
#80An average C++ CPU-bound code isn’t radically faster compared to e.g. C#. I suppose that’s true for other higher-level compiled languages.
But the good thing about C++, after I’ve profiled which parts of the algorithm take most time, I can gradually replace my average C++ code with SSE or AVX intrinsics. Sure it’s harder to read, write and understand, but if done right, on modern hardware it can become several times faster.