Technology Review - Published By MIT
Advertisement

More Trouble with Programming

Continued from page 3

By Jason Pontin

Thursday, December 07, 2006

smaller text tool iconmedium text tool iconlarger text tool icon

One problem with an evolutionary approach is that there are few academic outlets for incremental change--especially not when that incremental change directly relates to real-word systems. This is a sign that computer science and software engineering haven't yet emerged as the theoretically and empirically well-founded foundation of real-world software development. Theory and practice seem rarely to meet, and researchers are pushed away from real-world software towards less messy academic topics. Conversely, many developers completely ignore research results.

A major issue in language evolution is control of its direction. For a new language, users have a choice: they can adopt it or not (though this becomes less clear-cut if the new language is heavily pushed by their platform supplier). But once they use a language, it is harder to ignore new features (e.g., one user might not like a feature, but a colleague or a library supplier may think it great and use it). And it is impossible to ignore incompatible changes. The ISO C++ standards process relies on volunteers, who can devote only part of their time to the standards work. This implies that it is slow moving. It also seems to imply that end users are consistently underrepresented compared to suppliers of compilers and tools. Fortunately, the C++ committee has always been able to attract many dozens of active members for its meetings and many more online, so it avoided the parochialism of a small group. Until very recently, academics have been completely absent.

C++ provides a nice, extended case study in the evolutionary approach. C compatibility has been far harder to maintain than I or anyone else expected. Part of the reason is that C has kept evolving, partially guided by people who insist that C++ compatibility is neither necessary nor good for C. Another reason-- probably even more important--is that organizations prefer interfaces that are in the C/C++ subset so that they can support both languages with a single effort. This leads to a constant pressure on users not to use the most powerful C++ features and to myths about why they should be used "carefully," "infrequently," or "by experts only." That, combined with backwards-looking teaching of C++, has led to many failures to reap the potential benefits of C++ as a high-level language with powerful abstraction mechanisms.

TR: Would you consider Microsoft's heavily marketed language environment .NET one of your progeny? It does, after all, offer a high level of extrapolation and "pluggable" components. It's also the language most desired in corporate job candidates. What are its pros and cons?

BS: .Net is "the progeny" of a large organization, though Anders Hjelsberg has a large hand in it through C#, the language he designed, and its libraries. I suspect that C++ played a significant role, but primarily through MFC (which is not one of the more elegant C++ libraries) and as an example of something perceived as needing major improvement. C# as a language is in some ways closer to C++ than Java is, but the main inspiration for .Net and C# is Java (specifically, J2EE). Maybe C++ should be listed as a grandparent for .Net but as both a parent and a grandparent of C#.

.Net is a huge integrated system backed by Microsoft. That's its major advantage and disadvantage. Personally, I'm a great fan of portability. I want my software to run everywhere it makes sense to run it. I also want to be able to change suppliers of parts of my system if the suppliers are not the best. Obviously, suppliers of huge integrated systems, such as .Net and Java, see things differently. Their claim is that what they provide is worth more to users than independence. Sometimes they are right, and of course some degree of integration is necessary: you cannot write a complete application of any realistic size without introducing some system dependencies. The question is how deeply integrated into the application those system dependencies are. I prefer the application to be designed conceptually in isolation from the underlying system, with an explicitly defined interface to "the outer world," and then integrated through a thin layer of interface code.

Comments

  • Future developments
    The trouble with (many things including) programming:  that we assume without a second thought that our leading innovators will be arrogant enough to directly answer a question like:  "What will be the next big conceptual shift?"

    Seems more reasonable to ask for speculation about possible future developments.  Could/should C++ be adapted for use with programmable logic devices (FPGAs, CPLDs)?  Suppose that (as a consolation prizes for lack of faster clock speeds) CPU makers start including integrated indirect and/or associative lookup logic.  Might that result in languages like SmallTalk, eiffel being viable alternatives to C++ in more cases?

    Subroutines, libraries, O-O, generic programming are all capabilities for code reuse.  They do not obsolete or replace each other.  All of these have been around for a while.  It was compartively easy to think up these techniques, the hard part was getting them all in one low-overhead programming language.  Unless the chip makers force the machine model to change, it's hard to see any upcoming major dramatic changes or additions to C++.
    Rate this comment: 12345

    wkaras
    12/07/2006
    Posts:8
    Avg Rating:
    5/5
    • Re: Future developments
      C++ was designed based on an educated 1979 guess that traditional machine architectures would continue to outperform specialized architectures. Basically the sequences-of-small-objects model of memory and the conventional ALU served Fortran, C, and most language that interoperate with those languages well. It is also easy to optimize.

      To contrast, any architecture directly supporting high-level constructs becomes a burden to traditional programming languages and applications. And such architectures are harder and slower to design, so they tend to get to market a generation or two after a traditional hardware architecture.

      C++ relies on the traditional architecture plus compiler techniques for abstraction. With the current glut in transistors on a chip, the world for which C++ was designed may indeed be coming to an end. That's why I pointed to "something related to concurrency" as the likely next big thing in programming language constructs.

      However, given the amount of software designed for that world (essentially all we have) depending on the conventional style of hardware architecture, it might be a good idea to hedge any specific bet.

      -- Bjarne Stroustrup; http://www.research.att.com/~bs
      Rate this comment: 12345

      bs
      12/10/2006
      Posts:6
      Avg Rating:
      3/5
  • Complete Languages
    I think a critical distinction to make when discussing languages is whether or not they are what I call complete.

    A complete language is one whose compiler can be written in the language, an incomplete one requires an interpreter written in a complete language.

    Once you make this distinction, you can clearly see that the complete languages are going to be more complex and harder to use, but absolutely necessary. The incomplete ones will be considerably more numerous because there are a lot of different things that can be removed, resulting in many of the special-purpose languages we see today.
    Rate this comment: 12345

    mcsandberg
    12/12/2006
    Posts:1
  • I Respectfully Disagree
    Well I started my career before the C++ appeared in public. I've learnt C and then followed all the incarnations of C++ and actually tried in real life everything that was introduced in C++ in medium and big projects (even making compilers and linkers with more or less C++) and there are some points which I believe that Stroustrup got wrong (since I already mentioned it, I believe it's better using less C++ when writing a compiler then more). Specifically, following Stroustrup's statements are just wrong:

    "Another reason is that organizations prefer interfaces that are in the C/C++ subset so that they can support both languages with a single effort. This leads to a constant pressure on users not to use the most powerful C++ features and to myths about why they should be used "carefully," "infrequently," or "by experts only.""

    1) C++ as it now exists, is really better to be used "carefully". It's the nature of it. The "abstraction" and "separation" C++ promises breaks as soon as you want to have something like a DLL. And there I don't mean "Windows DLL" but just a concept of "something" which should be compiled and used separately. When you export only structures and C functions, you can do much better then when you start to export classes. I don't want to even mention the nightmares of exporting classes which use STL. It's not that it's impossible to do that initially, it's the maintenance nightmare afterwards that will kill you.

    2) Whoever uses C++ exceptions more than in some very extreme situations, (or to handle the exceptions of some other piece of software who unwisely introduced it) is doomed just to make the problems for himself, getting no gain, just pain.  Exceptions were introduced because the constructors work as they do, not separating allocation and construction and not being able to return errors. And then the hell break loose. Exceptions introduce unpredictability of the worst order. In fact, if you want to be sane, for most thing you do, much safer method is to separate the allocation and construction, constructing things with separate functions which can return error codes -- and that can be done with the "old" C equally well.

    The most of the gain from a lot of C++ "features" went to "experts" and "consultants" who were to explain to to the masses how to use latest and greatest (earning from the "expertize") when the users were better off not using these at all.

    There you have it. When you often have to avoid doing much in constructors and destructors, avoid C++ exceptions, avoid classes as such and particularly STL when you want to have a separately compiled library to get things safely done, what's left? I consider C++ as often useful syntactic sugar for the pieces of code that don't have to be exported (luckily there's enough such places too) but that's about it.
    Rate this comment: 12345

    acc1
    12/15/2006
    Posts:1
    Avg Rating:
    1/5
    • Re: I Respectfully Disagree
      If you link or pass binary data between code that was generated by two different compilers, there is no reason to expect that this will work properly.  This is true for C as well as C++.  Since C is much simpler than C++, it's generally much simpler to overcome the potential issues with using object code and binary data from different linked executables together.  But it would be unwise to just assume it will work with no problems.

      I don't understand specifically what you mean by exporting classes, but normally you can't just memcpy data structures that have pointers in them.  The C++ Standard has lots of requirements in it to make sure that any data structure you could memcpy in C, you can also memcpy it in C++.

      Exceptions are safe as long as any locked resource is mapped to an object, and would be released by the object's destructor (unless it had already been released).  Some people feel that use of exceptions, virtual functions, function pointers, etc. make programs harder to understand.  Programs that are more complicated than they need to be are harder to understand, but believe me, the true masters of obfuscation need only the "if" statement.  Time will tell if exceptions make programs more or less maintainable, but "more" is my guess.

      It takes more effort to learn to effectively use C++ than it takes for C.  It also takes more effort to learn to drive a tractor-trailer than it does a car.  That does not mean there is something wrong with tractor-trailers.  It could very well be that, in your particular situation, the effort needed to use C++ (or some of its features) would be more fruitfully spent on something else.  But it's not reasonable to criticize C++ because it can't give you something for nothing.
      Rate this comment: 12345

      wkaras
      12/18/2006
      Posts:8
      Avg Rating:
      5/5
    • Re: I Respectfully Disagree
      Hmm well learning C and then learning C++ isn't an optimal way to learn C++.  At worst you'll just turn structs into classes.

      Sure C is better than C++ in some places, but I don't think it's unreasonable to assume that the opposite may also be true.

      Anyways on to more constructive stuff:

      1) You can pass you user defined classes over the DLL boundary using the PIMPL design pattern to hide an STL filled implementation behind a pointer.  This does mean you have to write a facade class for every interface class - but it'll just a be a barebones pass-through class.

      2) Exceptions are great - programmers are lazy so returning false won't cut it anymore.  If someone ignores the return value only the really high level warnings will mention it.  You throw and exception and the whole world knows about it.  There is an important distinction here between passive (returning 1 or 0 or whatever) and active (exceptions, asserts) programming.  The only thing that would be nice is a java-esque way of enforcing that the exception will eventually be caught by something.
      Rate this comment: 12345

      bluemonki
      12/29/2006
      Posts:1
  • You love your code too much--code is used by people, coders work with people not machines
    BS has answered many criticisms of C++ simply by saying that most people shouldn't use it.  It designed for maximum freedom and expression and requires specialized skill to operate.  I agree, we need languages that offer specialized abilities for special programmers.  But where I take issue is where BS claims that we have highly specialized and skilled people as bankers and lawyers and what not.  Likewise, we need skilled programmers and that amateurs should not program.  Seems like a bad idea according to his own principle and argument:
    For someone who is most specialized at finance or law, time spent learning how to be a specialist at programming trades off with their ability to learn how to be specialist in finance or law.  Likewise, the specialist in programming may not know all the nuances of finance and may not create the perfect program for the financial specialist.  If the laity could program, so could those overspecialized in other areas.  They could create applications custom tailored to their specialized knowledge in the field that goes beyond the functions of a multi-purpose one size fits all program.  But this would be vision of the user knowing best what the user wants instead of the specialist programmer...seems like there should be some room for both.  Hopefully Simonyi in "anything you can do, I can do meta" will help create that meeting place. 

    BS's vision of programming is dismal as well as problematic.  If the specialist programmers aren't cutting it now, what incentive is their for change?  Programmers getting smarter won't happen magically, so what will make them do the work.  Maybe we just need to pay a higher price for a new set of higher quality programs.  These of course will have their own new compatibility issues with old programs, and issues with proprietary file formats, but...essentially people will have to pay more and hope that the new programs won't introduce any new bugs or complications that add additional cost to the already high price justified by their higher functionality.  If the specialists keep the system running kudos to them, and people should always try to excel in their field, but if many people can cut out the middleman: they will...question is when will someone finally tap into that market and who?
    Rate this comment: 12345

    ssargent
    01/09/2007
    Posts:11
    Avg Rating:
    3/5
    • Re: You love your code too much--code is used by people, coders work with people not machines
      Can't agree.  Simonyi's ideas rely on having some terrific library: which itself will probably be coded in something like C++, and a way of combining the functionality provided in a way to handle specific combinations.  Such systems are inherently limited by the imagination of the creator and the functionality of the libraries.  Only so many combinations are possible, dealing with so many problem spaces and profiles.  It's a bit like MS Access: it allows finance or medical experts to create their own simple databases and GUIs for them, and script up a few features, but you're not going to write the next great web browser with it.  C++ is much more than any such tool.
      Rate this comment: 12345

      tonyd
      01/17/2007
      Posts:1
      Avg Rating:
      1/5
      • Re: You love your code too much--code is used by people, coders work with people not machines
        That doesn't respond to what I said at all.  BS claims specialization is good.  But over-valuing one specialty over another has both benefits and deficits.  Sure C++ can make great programs, but if you don't know what I want there is no way you can possibly make a program that fulfills that function.  You should read things more thoroughly before commenting.  One of my parents is a programmer that does C++, Java, and SQL and maybe some others that aren't as notable.  So of course I understand the valuing of programmers and programming language.  But again, programmers don't work with computers, they work with people.  The people that buy and use the computers and programs.  Which means they need to understand those people and what they want if they expect to write what they would consider a good and useful program.  Inherently assuming that programming should aspire to the highest level specialization means that you get geeks that know computers and not enough of other things.  They may write programs that are good from a computer science perspective but not from the perspective of the end user whose specific needs are unment.  So I guess you can be added to the list of people that love the code to much and need to get in touch with humanity more.
        Rate this comment: 12345

        ssargent
        01/19/2007
        Posts:11
        Avg Rating:
        3/5
  • C++ and Generality
    'Generality' is something BS takes very seriously in guiding the develpmenet/evolution of C++. This is also the hinderance/barrier in getting across certain aspect of the language. In particular, when people criticise C++, they usually mention something that the language does not do or support. As I said else where, understanding the design goals behind C++ seems to be a pre-requisite in understanding C++ itself. One other fundamental concept behind C++ is the concept of generality and BS talks about this in most of his writtings and interviews. Howevr, the importance of this concept maybe lost for people without a rigorous mathematical background.

    BS seems to be encouraging the follwoing approach when designing/coding application: with a specific well understood problem to solve, you step back and consider the space in which that problem exist. Then design a solution of which the case in point is 'a' solution. While mathematician may easily understand, it maybe a little difficult for lots.  This approach requires training on its own.
    Rate this comment: 12345

    jnfombanu
    02/26/2007
    Posts:1
    Avg Rating:
    4/5

Log In

Forgot your password?     Register »
Advertisement

Videos

Making 3D Maps on the Move
Technology Review November/December 2009

Current Issue

Natural Gas Changes the Energy Map
The United States has vast supplies of this cleaner fossil fuel. But how should we use it?
Featured Content
Sponsored by:
White Papers

Twelve ways to reduce costs with SQL Server 2008
Find out how to reduce costs and get more efficient

Download

Total Economic Impact of SQL Server 2008 Upgrade
Forrester reports on increasing productivity and management capabilities

Download 

Achieving Cost and Resource Savings with UC
How Office Communications Server R2 and Exchange Server can make your business smarter and more efficient

Download 

The Compelling Case for Conferencing
Read how you can improve workload support and find IT efficiencies

Download

How Windows Server 2008 R2 Helps Optimize IT and Save you Money
Read how you can improve workload support and find IT efficiencies

Download

Windows Server 2008 R2 Hyper-V Live Migration
See how Windows Server 2008 R2 and Hyper-V enable virtualization and Live Migration

Download
Advertisement
Subscribe to Technology Review's daily e-mail update. Enter your e-mail address

TECHNOLOGY RESOURCES
Advertisement
MIT Massachusetts Institute of Technology © 2009 Technology Review. All Rights Reserved.