Fog Creek Software
Discussion Board




Programmers, Languages, and Power

I was just chatting with a colleague, and we made the mistake of comparing Java to C++.

As it happens, I told him I prefer C++ to Java, while he told me he preferred Java to C++. Naturally, we talked that subject to death... as programmers are wont to do.

Paul Graham has said that "The only programmers in a position to see all the differences in power between the various languages are those who understand the most powerful one."

http://paulgraham.com/avg.html

In this case, my colleague is working with C++ every day, so he certainly understands its capabilities.

Perhaps C++ is more powerful than Java (my contention). My colleague's point was that the differences don't matter and aren't necessary for writing good software.

This has me thinking... I've always felt that the best language to use is the one that lets me express the largest vocabulary of programming idioms in the simplest and most direct way. As a matter of fact, I would program in Scheme if I could get away with it.

My colleague's point is that Java expresses the idioms he needs to express in a simple and direct way, and C++ complicates those idioms. I feel that Java makes some of my preferred idioms actually harder to express.

But... Am I wrong?

Quite honestly, is Java (or C#) "good enough"? Has innovation in programming languages reached the point of diminishing returns?

What do you folks think?

--
http://www.braithwaite-lee.com/

Reginald Braithwaite-Lee
Tuesday, April 29, 2003

There are many languages because there are many problems to solve.  I would not use Java for a high speed scientific application requiring many complex algorithms that use a lot of data.  I would not use C++ for making webpage applets.  You fit the language to the problem.  If no language really fits, and you are very talented and motivated, you write your own language.

Barry Sperling
Tuesday, April 29, 2003

  As I see it there are two main arguments, besides the "Java rules" and "real programmers code in C++" crap, to chose a development plataform (lang + APIs).
  There are those that say "the right tool for the right job". One of the problems with this approach is that languages and plataforms are very complex beasts. Although it may be easy to hack a simple utility if a few days or weeks; it takes years to master any plataform.
  The other big argument is"stick to what you know". But this can also be dangerous. Just think if "what you know" is COBOL or FORTRAN?

There is no easy answer...

Not my real name.
Tuesday, April 29, 2003

First, good job on moving above the "my language is better than yours.." that we often see these fall into. 

I believe that Eric Raymond is correct, but for more than the reasons posted in the essay.  It is breadth of experience.  Consider a plumber who arrived at your house with a single wrench.  It may be a good, even great wrench, but how good could he be to only have one?  How much experience can he draw from with only a single point of reference. 

Having the tool is not enough.  I can give you surgical instruments but it does not make you a surgeon. You need to intern, to use the tools to see when to ask for a number 4 or number 8 scalpel, or just use your hands.  Lisp may be the language that makes you appreciate the others.

To your question of are " Java (or C#) "good enough"? Has innovation in programming languages reached the point of diminishing returns?" 

I don't think so.  They are good enough today, but always looking to improve.  I wonder if COBOL has been on the desktop instead of basic would we even have other languages? [But I digress..]

I see us heading in the other direction.  Consider VB,  at one point it was suppose to be an abstraction.  Something that did a bunch of "stuff" in the background so developers (amateur and professional) did not need to deal with the detail.  IDEs are trying to do the same thing.  They will continue to get better, but we will still need more.  More detail, more granularity, more speed, more something.  And then a tool for the job will need to be selected. "Glue" to fit the pieces together or handle the contact to hardware, or who knows.  That glue will be java, C++, perl, python,  or something new. 

More tools, more power.

Mike Gamerland
Tuesday, April 29, 2003

There's another side to this, too:  Which idioms a particular person likes.

Some people love the object-oriented paradigm, and so languages like Smalltalk work well for them.

Others just don't think in an object-oriented way; they think in terms of other idioms, so they'd be better-suited to some other language.

So, IMHO, there is no one "best" language.  Sometimes a particular language is particularly suited to one domain.  Sometimes a problem can be done best and most quickly in a language that the programmers know well even if that language is not ideal for the problem.

Brent P. Newhall
Tuesday, April 29, 2003

I am certainly idio something-or-other (the prefix suits me to a "t").

C++ has always struck me as a powerful language for expressing abstract types in a strong and static typing environment.

A lot of the C++ idioms in my toolbox are ways of hacking the static type system to enforce constraints.

Java, OTOH, does a pretty crappy job of expressing abstract types. Everything is an object, and don't you forget it. A lot like SmallTalk, except when I say "everything is an object," I mean, "everything you design is an object." The language still has all these primitives that don't behave like objects at all.

In Java, all variables are equal, but some are more equal than others.

Now that we have inner types, Java is more like Scheme in that it has lexical scoping, and that has allowed me to use some more of my idioms.

But of course, it trips me up here and there because lexical scoping is implemented for members but not for parameters. Once again all variables are equal, but some are more equal than others :-)

So I guess what I am saying is that I don't like it when I have trouble expressing my favourite idioms in a simple and direct way.

And yes, programming language design and implementation is a hobby of mine :-D

Reginald Braithwaite-Lee
Tuesday, April 29, 2003

In an ideal world, Java would be "good enough".  Almost every issue I have with Java is due to implementation issues (bad garbage collection systems, poor UI performance, etc) more than the idealized design of the language.  C++ certainly has its share of implementation problems, and even some extra design level problems that I don't think Java has, but since it is less of a black-box abstraction, you can plug the leaks yourself with more flexibility than you can with Java.. 

End result.. I prefer C++ over Java because in my experience I've never hit a brickwall with C++ whereas I have with Java.

Brickwall example: JVM leaks memory like crazy making it unsuitable for my application.    Oops, I'm screwed.  Hopefully Sun will patch the JVM, if they don't there's little I can do to work around it.

George McBay
Tuesday, April 29, 2003

1) I think it's hard to evaluate the relative power of C++ and Java.

C++ has some extremely powerful abstractions, mostly involving template metaprogramming.  But every book on the subject includes endless footnotes about working around obscure misfeatures in the C++ standard.  So C++ has lots of deeply powerful features, but they're not especially /composable/ without sweating blood.  The Law of Leaky Abstractions is the law of the land.

Java, on the other hand, is quite clean, and provides tidy versions of many popular abstractions.  But it's hard to rise above the built-in level of abstraction.  (However, Java's simple syntax and byte-code representation allow lots of preprocessors to be written: iContract, Pizza, Java Generics, AspectJ, etc.  Many of these rock.)

For most programmers, I'd have to say that C++ and Java are roughly equal in expressive power.  If you master template metaprogramming in C++, or take advantage of preprocessors for Java, you can eke quite a bit more power out of the basic language.

2) I don't think we've reached a point of diminishing returns in programming language design.  We're not even close.

LISP, ML, Scheme and Haskell all provide gorgeous abstractions.  Programmatic macros, multimethods, functional programming, closures, continuations, generators, monads, mixed static/dynamic typing, pattern-matching dispatch, parameterized modules, automatic type inference, and lazy evaluation all have benefits, and few of them have ever been packaged in a language intended for mainstream developers.  Some of these features are weirdly incompatible (pending further research); others are deeply synergistic.  And that's only counting the features already invented. :-)

And let's not forget the scripting languages.  While Perl, Python and Ruby may not include every theory geek feature in the universe, they provide simple, concise syntax for common idioms.  Sure, they suck at detecting errors at compile-time, but they're pretty darn nice to code in.

With enough design work, I think a mainstream language could include a powerful, pleasant, useable mix of many of the above features.  But the design work for any worthwhile language is non-trivial.

Eric Kidd
Tuesday, April 29, 2003

I wonder why no one has sued the pants off sun or one of its app server vendors (bea) for this?

But you can always use a non sun jvm, for instance on windows IBM's JDK works really well (read quick and stable and does not leak memory) with BEA

Daniel Shchyokin
Tuesday, April 29, 2003

commanderSpock wrote, "As it happens, I told him I prefer C++ to Java, while he told me he preferred Java to C++. Naturally, we talked that subject to death... as programmers are wont to do.....

....Quite honestly, is Java (or C#) "good enough"? Has innovation in programming languages reached the point of diminishing returns?"

What type of work does your colleague do?

Higher level programming languages such as C#, VB, and Java serve a purpose, however, they will never be the appropriate tool for every job. As George McBay mentioned their biggest weakness is that they require the software vendor to add functionality to them. The announcement of the .NET development platform didn't legacy classic Visual Basic --  it was Microsoft's announcement that they will no longer provide updates and patches to this programming language.

While C++ is definitely a more powerful programming language, that doesn't make it is the appropriate choice for all software projects either. Perhaps learning C++ plus at least one high level programming language is still the best path for most developers to follow?

One Programmer's Opinion
Tuesday, April 29, 2003

[While C++ is definitely a more powerful programming language, that doesn't make it is the appropriate choice for all software projects either.]

And to add to that: the cost of development is not limited to the application. Human costs are significant and time saved is money earned. That's the decision the new platforms target, the human cost decision. By abstracting the details of development they hope to increase the developers productivity and his value.

Of course sometimes that's not always the case. Sometimes the needs of the application outweigh the human costs and help one determine what platform to use. For instance, If I needed to write some code for a device driver I doubt I would spend much time contemplating whether to use .Net or Java.

trollbooth
Tuesday, April 29, 2003

[his value]

or her value. Didn't mean to discriminate ;-)

trollbooth
Tuesday, April 29, 2003

I don't think either Java or C++ are good enough.

I have never seen a real world Java project that would not have benefitted from being done in some other language. Often even C++.

However, Java excels in an academic enviroment. While sometimes the case could be made for Smalltalk or something even more esoteric like Eiffel or O'Caml, Java serves very well.

C++ is in every way inferior to Objective C. And often used for reasons that are more ego than technical, as with the perpetual VC++ vs VB debates.

The problem is that the adoption of new programming languages is primarily a marketing exercise.

No academic will ever get their language adopted regardless of its merits.

The only real hope for us programmers is Perl6. Good grassroots support combined with reasonable theoretical underpinnings. But it will be a long time before machines are powerful enough to consider it "general purpose". And there will always be the question whether something that complex can be consider rigourous and safe.

Anonymous Coward
Tuesday, April 29, 2003

Eric:

I love most of the languages you've mentioned and have a great interest in Java preprocessing. I deeply believe that a small and gifted team can accomplish much more with, for example, Ruby or Scheme than they can with Java.  Even for a server application.

However... When I say "returns," I mean as measured in gross programmer productivity. The fact is, it has been a long while since the choice of a programming language was in my own hands.

My question was... is Java "good enough" for our current climate? Are there no competitive pressures forcing organizations to use more powerful programming languages? Or a rethe more powerful programming languages not that much more powerful?

Reginald Braithwaite-Lee
Tuesday, April 29, 2003

"My question was... is Java "good enough" for our current climate?"

No. I want programming where it is easy for one guy (me) to do the work of 10 people. Not a language where it makes it easy for 1000 people to do the work of 100. For server side applications java requires 10x the amount of programming as the equivalent python or perl program would. For desktop applications,  one has to just use whatever works natively or there will be speed and UI issues.

choppy
Tuesday, April 29, 2003

Neither is more powerful than the other. They are both Turing complete languages and can be used to express the same computations and abstractions. Similarly, C is not more powerful than Visual Basic.

Now, if you'd like to talk about which more language is more efficient... that would be an interesting conversation. There are many different types of efficiency (run-time vs. development time, etc.), and every project has different requirements.

Actually, I guess the conversation wouldn't be that interesting - as many have already said, the efficiency argument boils down to selecting the right tool for the job. If you write myExcel in C++ and some C zealot demonstrates that he can increase performance by 15% by sticking to pure C constructs, the important question is "So what?" It may matter, it may not.

Every language has its place.

Dan J
Tuesday, April 29, 2003

I believe that some languages are more powerful in practice than others. As a friend says, "In theory, there is no difference between theory and practice. In practice, there is."

"We know from experience that computer languages differ not so much in what they make possible, but in what they make easy." --Larry Wall

So I'll rephrase my question to eliminate the "any language will do" answer:

Have popular languages like Java made programming easy enough? If not, are the 'more powerful' languages actually making programming easier in practice?

Reginald Braithwaite-Lee
Tuesday, April 29, 2003

IIRC, Grace Hopper invented programming languages because there were just too few people qualified enough to program raw machines.  So here, the driving force behind languages wasn't power, but making it so anyone can do something useful.

If you take languages as UI, then you get Java, which deliberately reduces power so people think in certain "safe" ways.  And it looks like what people are used to (C/C++), just like Windows may be bad, but because it's popular people want their UIs to look like Windows.

Languages as Power may never catch on in the same big way.  Maybe it shouldn't.  In writing a Python program, I had the power to change something small from functional to imperative.  Java would never give me that power, but its S&M also might lead to better median-case code.

Tj
Tuesday, April 29, 2003

My god, I just realized I said absolutely nothing new now that I've slept, hope I don't do that often.

There was a panel with Paul Graham, John Maeda, Jonathan Rees, Guy Steele:
http://www.ai.mit.edu/projects/dynlangs/wizards-panels.html
and I remember someone asked why academia wasn't focussing on new languages, and the panel seemed to consense that it wasn't such a burning CS need anymore.  Perhaps it's now more a market phenomenon, with different kinds of users trying to find out how to supply their needs.

Maybe computers are still too slow to have a truly interesting language interface, and we're in a local maxima.

Tj
Wednesday, April 30, 2003

"Maybe computers are still too slow to have a truly interesting language interface, and we're in a local maxima."

See, now *that* is interesting. I have never used this line of thinking to quantify the capabilities of programming languages, only to test the different aspects of the programs we create with them. I don't know why, because it's obviously very applicable.

I think it's fascinating (albeit a bit discouraging) to think that researchers and developers are just sliding back and forth across the last high point of programming evolution. It is possible that people who have strayed from this point (the status quo) have come ever so close to overcoming a high point of difficulty and finding amazing new advances that change the way we program like never before... but they quit just before doing so, discouraged by difficulty, sliding back towards the status quo. And there is no way to tell because it's not possible for us to evaluate where we are technologically without knowing all the possibilities ahead of time. Isn't that weird?

So, what if Paul Graham is right and functional languages like Lisp really are the way of the future, but we just haven't figured out the best way to apply them yet? Can you imagine if Microsoft started pitching Lisp .NET as a replacement for C#? I, for one, would be leading the mass exodus of developers from the software industry.

Dan J
Wednesday, April 30, 2003

Dan: Why would you be leading the exodus? What's so
scary about Lisp? (And why would it be impossible to go on
developing software in other languages even if Microsoft
said "All move to Lisp, please"?)

Gareth McCaughan
Wednesday, April 30, 2003

Since the people participating in this thread seem to be in to Programming Languages the following web site should be of interest:

http://lambda.weblogs.com/

Dan Shappir
Wednesday, April 30, 2003

Languages are tools.  I could buy the most powerful three-phase bandsaw on the market and it would do me no good if I wanted to, say, tape wallboard.

The "power" of a programming language comes from its ability to elegantly and correctly represent the semantics desired by the developer.  It's meaningless to say that one language is "more powerful" than another without stating the problem domain.  Which is more powerful, SQL or C?  Depends on what you're trying to do.

Eric Lippert
Wednesday, April 30, 2003

Reginald: I think we can design much better languages for small teams of very good hackers, and I think we can design much better languages for enormous groups of mediocre developers.  These may or may not be the same languages.

Here are several language ideas (with a fair bit of overlap):

1) An infix Lisp, with working macros.  Also known as: "Let's redesign Dylan with the benefit of hindsight" or "All the yummy goodness of Lisp, with no more scary parens."

2) An optimizable "scripting" language. Aka: "Python at the speed of C."

3) A language with mixed static/dynamic types that work really well.

4) An accessible, statically-typed programming language designed for C++/Java programmers, with support for type inference, unit analysis (aka "No more lost Mars probes"), parameterized types, etc., and no weird warts in the type system.

5) A language which supports programmatic source->ast->source transforms in the standard library.  This would make round-trip CASE tools and refactoring browsers a cinch to write.

6) Any existing language, but with high-quality iterators and/or built-in support for design-by-contract.

There's about 2 million scripters who'd kill for (2), a fair number of uberhackers who'd love (1+2+3+5) if it didn't scare off their bosses, any number of enterpise developers who'd love the tools they'd get with (5), and plenty of people who'd benefit from (6), even if they don't know it yet.  And (4) would appeal to anybody who's really in love with compile-time checking, or who works in the sciences.

I bet that, in 20 years time, we'll have much better mainstream languages, and everyone will mutter under their breath about the horrible languages we were using in 2003.  Progress takes time.

Eric Kidd
Wednesday, April 30, 2003

The problem with the "use the right tool for the job" idea is that languages are a lot more like toolboxes than like tools.

If your toolbox contains pliers but no wrenches (aka spanners), you'll be capable of using bolts, but you probably won't use them if you can avoid it.

Similarly, if your programming language has function pointers but not lexical closures, you'll be capable of using higher-order functions, but you probably won't use them if you can avoid it.

Rob Mayoff
Thursday, May 01, 2003

"Python at the speed of C" is doable now, for various values of "speed of C".  :)  See:

http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/

It gives you C speed for any operation that involves variables declared with C types.  You have to compile your code, of course, since it's effectively a Python-to-C translator.

Phillip J. Eby
Friday, May 02, 2003

*  Recent Topics

*  Fog Creek Home