2 ms·
I believe it to be the only language with the following features: - support on basically every platforms - ability to write parametrized, typed, compile-time c
by pbiggar 14y ago
I believe it to be the only language with the following features:
- support on basically every platforms
- ability to write parametrized, typed, compile-time constructs
- speed
- betterunix 14y agoI am not sure that "support on basically every platform" really qualifies as a language feature, but I can grant that it is a strong motivation for choosing C or C++. As for parameterized/typed/compile-time constructs, you can get that in other languages if you want it; in Lisp, you can get static typing as a macro library, and the support for compile-time processing in C++ does not hold a candle to Lisp's macro system. Speed is overrated for C++. Ada and Lisp can compete with C++ on speed in any task except in cases where there is some special hardware that is giving you a speed boost and which only has tools that support C/C++ (and even then, language support tends to expand over time, so this will only really be a short-term gain). C and C++ actually constrain a programmer's ability to optimize code in some cases; CL-PPCRE, for example, is faster than libpcre because rather than set up a pointer structure and interpret a regular expression, CL-PPCRE creates a compiled, callable function that matches the regex. The lack of support for high-level features winds up hurting C++ in some cases, by forcing programmers to come up with their own way to accomplish the task, which is usually slower than what a mature compiler produces. On the other hand, there are compilers for high level languages that do allow programmers to do low-level optimizations; CMUCL and SBCL, for example, support a form of inline assembly, and have mechanisms that allow programmers to access low-level pointers and other constructs. So really, what this boils down to is not that C++ is necessarily faster, nor that it's language features are unique, but that it is just a lingua franca of sorts that has some very limited support for some high-level features.
- pbiggar 14y agoYou are cherry-picking bits of my argument - to be clear, it has all those features at the same time, making it an exceptionally good systems programming language (even if it is ugly). The challenge is not to find better versions of one of C++s features - that is not hard. The challenge is to find a better systems programming language. I agree that people have made fast(ih) Lisp compilers, but I don't believe I've heard of large programs that run on any platform being made in them. My argument is not that C++ is the only language with a macro facility - far from it. However, of the languages which are suitable as systems languages (which means they must be fast), only C++ supports one. I've heard this argument that high-level stuff allows for more speed, but I've never seen it borne out in practice. (Before my startup, I worked in compilers, so I do have a decent perspective on this - nobody in the programming language community believes Lisp even approaches C++ in terms of speed). Actually, I lie. Naughty Dog games produced a Lisp compiler for the PS2 (I believe used in Jack and Daxter) that had an amazing reputation for being able use much more of the PS2's power than any other game, as it was able to compile to code that ran on the other vector units and not just the main CPU. The CL-PPCRE is all well and good, but bear in mind there are other regex libraries that compile to machine code, including YARR which is a JIT. pcre isn't the only option.