Saturday, September 02, 2006

What makes a good programming language?

Have you (if you are a computer software geek) ever wondered why some programming languages suck? I mean, for example, you have languages like C and C++ that are extremely powerful for system-level programming, languages like Pascal that are easy to learn, languages like ML that make things like writing a compiler a matter of a few hundred lines of code, and yet, there exist half-dead languages like Ada, that no one uses? Why do languages suck? Or, more importantly, what makes a good programming language?
Well, here are my criteria:
1. A good language is designed for the designer to code in.
i.e. The language has not been designed for 'them' - who ever they are. So, this automatically puts languages like Ada (which was designed by a committee (a defence committee, no less)), C#, (which was designed with one single motive) and Java, (which was designed for those poor object-oriented programmers who couldn't figure out multiple inheritance) in the trash can. Languages like C, PERL, Pascal, Fortran, C++, on the other hand, shine in this category. Note, I'm ignoring Python because I haven't programmed enough with it.
2. A good language tries to do as much as possible at compile time
Good languages try to find as many defects at compile-time as possible. They are usually statically typed, and enforce type-safety in varying degrees.
3. A good language is never created with corporate interests in mind
I don't need to expand on this.
4. A good language does not underestimate the programmer
Why doesn't Java have multiple inheritance, or enums? Because, ostensibly, they "confuse" users. Well, Einstein's theory of relativity is confusing. So, should we ban it!?
5. A good language respects the programmer's application domain
My favourite recent peev is the way C# handles structs. Now, user-defined structs cannot have default constructors. So, the compiler will provide one, initializing all members to zero. Normally, this is OK, except if the zero-state is an invalid state for your application domain. Let's say it is - then what do you do? A famous book on .NET framework design suggests that you make it valid! So, the language will not serve your purpose, you'll serve the language!
6. Beyond these, a good language gives you good expressive power, excellent libraries and run-time support, and great documentation.
Well, obviously.
I know this post is incomplete, and there are many other criteria for a good language. If you feel strongly about any, post it below :)

2 comments:

Ananda said...

In recent times I see that portability has also been influencing factor for a good language. Well I have a good programming language "gmabzaar", but this only works on Unix based system does not really help.
I would say, C++ growth was also to do with Microsoft supporting C++ in their Visual Studio (or why would a geek think of programming in MS)

Recently I have been using TCL/Perl and their portability has just amazed me.

I think nowadays, developers are also keen on getting their programs done quicker (and less buggy..)

Gops said...

True...portability has been one of the biggest factors for Java's popularity.
However, I'll disagree that C++'s growth was due to MS - MS adopted C++ very nicely, by making development libraries in C++ - and that boosted MS's popularity as a dev platform too! One of the cool things about the MS platform is how quick you can be productive (something you referred to) - as opposed to Unix.