Not logged in
Log in now
Create an account
Subscribe to LWN
LWN.net Weekly Edition for May 16, 2013
A look at the PyPy 2.0 release
PostgreSQL 9.3 beta: Federated databases and more
LWN.net Weekly Edition for May 9, 2013
(Nearly) full tickless operation in 3.10
If you have time one day, it might be worthwile to look at how these
things work in a language where such features are natural. The boost
lambda facility is a genuine crock.
Posted Dec 8, 2005 22:02 UTC (Thu) by ncm (subscriber, #165)
It's easy to build fancy features into the core of a toy language. It's hard to make a language powerful enough not to need fancy features coded in its core. In a very real sense, any directly-useful core-language feature that doesn't map to a machine instruction or two indicates a language design failure: the language isn't up to the job of letting a user express the feature using the primitives provided. In that sense, for example, LISP's CONS/CAR/CDR, not to mention the garbage collection they imply, indicate fundamental failures. Most languages taken seriously in academia repeat LISP's failures, which suffices to explain why they are not taken seriously in industry, and why there is *still* no credible alternative to C++ for industrial use.
If this sounds like an indictment of academic Computer Science, you read it right.
Posted Dec 8, 2005 22:24 UTC (Thu) by mvogt (guest, #34379)
If you read through the language change proposals for C++0x, a lot of them address cases where the current system has been found to run up against its limits. And for those who find the current templates-plus-overloading-plus-inheritance mechanisms too inelegant, Daveed Vandevoorde's Metacode proposal is a possible way this will be rationalised in a future language revision.
I won't touch your LISP... criticism... but I agree that there's no credible alternative to C++ for many industrial purposes. Where I think C++ shines especially, is the ability to do extremely low-level tasks, but to wrap those tasks in useful higher layer abstractions.
A good example of this would be the Spirit library (distributed in Boost), which wraps extremely low-level character-by-character text processing, into a syntax which is very similar to directly coding EBNF.
Posted Dec 9, 2005 1:49 UTC (Fri) by ncm (subscriber, #165)
The lack of a credible industrial alternative to C++ isn't just bad luck. It is incontrovertible proof of systematic failure, over decades, by those responsible for evaluating language designs.
By the way, the expressions "low-level" and "high-level", in my experience, are readily abused to prejudice discussion. Most usually this means disparaging concerns for performance and trying to distract the reader from fundamental inefficiencies. I'm not accusing Mr. Vogt of such usage. Rather, I'm pointing out that the words have acquired very slippery meanings, so that their use often obscures more than it reveals.
Posted Dec 17, 2005 20:06 UTC (Sat) by renox (subscriber, #23785)
Have you looked at Scala? I think that this language is a step in the right direction for this part, unfortunately it is only for JVM or .Net no native compilation currently.
Posted Dec 9, 2005 6:00 UTC (Fri) by dvdeug (subscriber, #10998)
When you say that "any directly-useful core-language feature that doesn't map to a machine instruction or two indicates a language design failure", do you really consider shell, make, Perl or python failed languages, which should be forgotten in favor of C++?
Posted Dec 9, 2005 8:17 UTC (Fri) by ncm (subscriber, #165)
FORTRAN, COBOL, and (yes) FORTH are almost as old as LISP. Even in their modernesque forms they implement no concepts more recent than the '70s. You omitted assembly language.
Posted Dec 9, 2005 9:08 UTC (Fri) by khim (subscriber, #9252)
Yes, it's very true that C, FORTRAN, COBOL and even Java/C# do not include a lot of modern ideas. The fact of the matter is: they are used more often by "industry" then C++. C++ has it's place but the only reason it's used at all are few good (and few not-so-good) toolkits: Qt, MFC, ATL, etc. In last 10 years I was involved in many projects and only tiny part was written in C++ - mostly things for Windows (Microsoft only recently switched away from C++).
While what you said is true (different languages are suitable for different purposes) it all looks to me like try to define "industrial use" in such a way as to make C++ winner.
Let's define "industrial use" as "something done by big boys". What ? They are using scripting laguages. Ok - let's explicitly exclude them. Oops - still no win: huge number of things is done in C or FORTRAN ? Let's say that "ancient laguages" are not of concern. Still C++ is not winner ? Ok - let's ignore VM-based laguages as well. And so on. In the end you'll define some niche where C++ is clear leader - but this can be done for almost any language. Even very obscure langauges.
Posted Dec 9, 2005 18:43 UTC (Fri) by ncm (subscriber, #165)
Any language suffices for easy problems. Hard problems demand range. If you confine yourself to easy problems, you won't notice the built-in limits of your language. When you do need the range, minor inconveniences are easy to overlook.
Of course most problems are easy, and most people spend their time solving easy problems. It's generally not hard to ignore the hard problems, and the people working on them.
Posted Dec 9, 2005 21:25 UTC (Fri) by dvdeug (subscriber, #10998)
C++ has less range than Common Lisp. If you demand that all core language features "map to a machine instruction or two", what more can you expect?
It's seriously absurd to dismiss all problems besides "industrial" problems as easy. There's no challenge to writing a paycheck generator. There's challenge to writing code to control a 757 (code written in Ada, BTW), but it's not in the range; it's in getting things done, always exactly correct, on a very tight time schedule.
A game is not a trivial thing; it's funny that many game programmers either refuse to use C++ for speed reasons, or use scripting languages to control much of the game's actions. Obviously, C++ doesn't provide the right range for them.
C++ Game development
Posted Dec 10, 2005 6:03 UTC (Sat) by mvogt (guest, #34379)
If you look at sourceforge, two categories I sampled as having high-performance requirements (simulations and first-person shooters) have more than half of their listed projects listed with C++ as a development language.
C++ can be used with almost no abstraction penalty over C, depending on what features you choose to employ. There is a good document establishing the efficiency costs of various C++ features available at http://www.research.att.com/~bs/Performance-TR.pdf
I agree that many games have a component written in scripting languages; I think that this is probably a reflection of the rapid time-to-market pressure in the game market as much as anything else.
Posted Dec 10, 2005 7:32 UTC (Sat) by dvdeug (subscriber, #10998)
Posted Dec 10, 2005 8:22 UTC (Sat) by mvogt (guest, #34379)
Ideally, C++ can be used together with a language designed for embedding (such as Lua) for game development.
That said, games are an unusual domain, where even correctness can be less important than performance or speed-to-market.
Posted Dec 10, 2005 8:53 UTC (Sat) by dvdeug (subscriber, #10998)
Posted Dec 10, 2005 22:05 UTC (Sat) by mvogt (guest, #34379)
C++ does not put correctness second to performance, it ensures that you needn't pay for what you don't use. (Ignoring legacy C built-in arrays,) if you can guarantee array bounds will not be violated you can use the subscript operator for unchecked access; you can use the 'at' member function to get runtime checking where desirable. 'Relegating... to the library' has been the favoured C++ evolution strategy, for right or wrong. It doesn't indicate that something is less correct or important.
I will admit that C++ puts guranateed correctness second to pragmatism. Languages that don't have not been conspicuously successful in general purpose programming.
Posted Dec 9, 2005 21:07 UTC (Fri) by dvdeug (subscriber, #10998)
Modern Fortran supports object-orientation and exception handling. If modern Fortran supports no concepts more recent than the 70s, I'm curious what features of C++ are more recent than the 70s?
Recent features of programming languages
Posted Dec 10, 2005 5:49 UTC (Sat) by mvogt (guest, #34379)
It's certainly not elegant, and was almost accidental in its design, but it combines very well with C++'s don't-pay-for-what-you-don't-use philosophy, and its ability to adjust its interface through operator overloading.
But, the point that these are all old ideas is valid. Their age probably indicates the amount of time and experience required to get a community of implementors and developers to assimilate a set of ideas.
Posted Dec 10, 2005 8:28 UTC (Sat) by ncm (subscriber, #165)
C++, in its original conception, supported one important new concept: the destructor. Languages conceived since have failed to adopt it, limiting the effectiveness of their exception handling, and the languages' industrial usefulness. (No, "finalize" doesn't help.)
Later additions, particularly templates in the form standardized by ISO, enabled STL, Boost, and a constellation of matrix- and signal-processing libraries that outperform languages specialized for the purpose. Only CAML has matched C++'s capability to define fast, powerful libraries, but often cannot be used industrially because of its limited support for resource management.
Object orientation has turned out not to be nearly so important as the '90s hype machine suggested. Languages designed to the hypesters' criteria have turned out peculiarly limited.
Why should academia care about industrial usefulness? Arguably, no reason; certainly academic art and literary criticism have precious little to do with actual art or literature. However, an academic who cares to avoid sterility and irrelevance must confront fundamentally hard, large real-world problems. Such problems are, by their nature, not limited to conveniently proscribed domains. Tools to address them must be equally well prepared for bit twiddling, lambda calculus, hard-core numerics, real-time hardware resource management, fancy data structures, and what-have-you. Academic CS department hostility to serious engineering needs leaves its graduates ill-prepared to contribute.
Posted Dec 10, 2005 8:46 UTC (Sat) by dvdeug (subscriber, #10998)
Once again, your definition of industrial usefulness ignores most real-life problems. A huge number of computer people run servers; they may not touch a compiled language for years on end, but write and edit in scripting languages all day long. Or they may maintain websites or write Java games to be played on line, or program off-line games in Python, like Civ 4. Not every real life problem is to be tackled with C++.
Posted Dec 10, 2005 10:21 UTC (Sat) by ncm (subscriber, #165)
You don't learn much from solving the same easy problem over and over, or even from solving lots of easy problems. Hard problems teach deep lessons, if you can bring yourself to pay attention. A problem that was impossible to solve until you invented something new is more precious than any book.
Design failure ? Yes - C++ is a design failure
Posted Dec 9, 2005 9:06 UTC (Fri) by khim (subscriber, #9252)
It's hard to make a language powerful enough not to need fancy features coded in its core. In a very real sense, any directly-useful core-language feature that doesn't map to a machine instruction or two indicates a language design failure
May be. But if you truly believe this then try to count number of machine instruction for single line cited above. Gosh. Even pointer assignment in C++ is quite non-trivial operation if youll take a look on machine instructions generated. If you really want language close to machine - you'll take C. If you need language with powerfull features - you'll take LISP, if you need "boss-approved" language - you'll take C++. C++ is all hype and marketing, really...
Design failure ?
Posted Dec 10, 2005 5:40 UTC (Sat) by ncm (subscriber, #165)
Posted Dec 13, 2005 22:26 UTC (Tue) by pimlott (guest, #1535)
The point is not how pretty it is (although it's remarkable how well they've done), but rather that it was possible to do this entirely in the library. In practical terms, it means that Boost's lambda library makes advanced techniques available for use in an industrially useful language.
It's hard to make a language powerful enough not to need fancy features coded in its core.
any directly-useful core-language feature that doesn't map to a machine instruction or two indicates a language design failure
.Most languages taken seriously in academia repeat LISP's failures, which suffices to explain why they are not taken seriously in industry, and why there is *still* no credible alternative to C++ for industrial use.
Posted Dec 13, 2005 23:36 UTC (Tue) by ncm (subscriber, #165)
By "directly useful", I mean operations that actually perform computation, resource management, control flow, and I/O, as opposed to primitives that organize code (e.g. types). Everybody's long since conceded that I/O belongs in the library. That was a radical notion until C thrashed Pascal. Threads were supposed to be built in, too, until C thrashed Ada too. Progress in language design lies in discovering that apparatus previously considered indispensable amounts to trivial applications of a more powerful core primitive.
CONS may be one or two instructions, but CONS implies garbage collection, which is enormously more intrusive than Ada's failed built-in threads. The presence of CONS in the core language concedes that the language is incapable of coding resource management as a library facility. GC is actually worse than that: even if the language is otherwise up to the job, GC interferes so as to make it impossible anyhow.
The MLs are almost expressive enough to take on C++, but are encumbered with too many of LISP's fundamental mistakes.
The belief that C++ was a shoe-in, and is now thoroughly entrenched, is the most pathetic sort of sour grapes. C, in the 80s, and now C++, got used because they have proven useful and usable where they are needed. Academic languages aren't used precisely because they have turned out not to be so. Instead of whining about industry's supposedly dogged conservatism, try rethinking your own dogmas. That's what science and engineering are all about: when experience says your idea is wrong, reject the idea, not the experience.
The world needs a language more powerful and cleaner than C++. It won't be built by people who can't even understand why C++ succeeds, or why its academic competitors have failed over and over again.
Companies that have used academic languages successfully have either used them as fancy scripting languages (e.g. Yahoo stores) or depend heavily on calling out to libraries coded in an industrial language (e.g. ITA Software). LISPies like to say that Python and Ruby are really just dressed up LISP, but they're wrong: LISP is really just stripped-down Python.
Posted Dec 14, 2005 2:26 UTC (Wed) by pimlott (guest, #1535)
I'm not sure why you say that CONS implies garbage collection; there could be free-cons. Your suggestion that memory management should be in a library is plausible for many languages; however, GC seems to be required for pure (or mostly pure, as in ML) functional languages, so in these cases GC must be in the core. Funtional languages usually have special constructs or a library for manually managing memory, when required. "GC makes it impossible" seems extreme to me.
Re "sour grapes": In my experience, the industry is indeed doggedly conservative--every language decision I have seen has been based on familiarity, programmer availability, risk-aversion, or political acceptability, never on technical merit per se. Not that these are unfounded considerations, but all work against new languages. And I could as easily lampoon your Panglossian dismissal of historical contingency. "Worse is Better" argues that C won because it was easier to implement, and ran well on small machines, not because it was better. Is this implausible to you?
Re ITA: I was not aware that they relied heavily on non-LISP code; I'll have to look that up.
Posted Dec 14, 2005 2:39 UTC (Wed) by pimlott (guest, #1535)
Funtional languages usually have special constructs or a library for manually managing memory, when required.
Posted Dec 9, 2005 9:09 UTC (Fri) by pkolloch (subscriber, #21709)
Posted Dec 15, 2005 18:55 UTC (Thu) by flewellyn (subscriber, #5047)
Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds