What (Programming) Languages?
This big unanswered question.
This is a common question on the Internet - what programming language should I learn? Unfortunately, it doesn't have a common answer. If you were asked what human language should I learn, you probably wouldn't give an immediate answer, because a lot depends on the person asking the question. Do they already know another language? Do they know their native language very well? What do they want to learn a language for - interest or work?
It's the same problem for computer languages, though there are some advantages; computer languages are easier to learn than human languages, there are fewer of them (if we exclude older or unpopular languages, and some academic languages), and they usually share a great deal of commonality. On the other hand, while the grammar is usually relatively simple, the vocabularies can be daunting - and you'll need both to become proficient.
So I'll begin to answer the question with a set of questions. What do you need to learn a programming language for? Do you already know one or more programming languages? Are you learning for interest or work? Do you have a specific idea that you want to implement? Are you going to write platform specific applications, multi-platform applications, or web applications? How much time will you dedicate to studying?
If you're thinking why are there so many programming languages, or why isn't there just one programming language, well, they're good questions. Again, it's like asking why are there so many human languages. The most important reasons, for human languages, are cultural and geographic. If you're interested, there is a map, prepared by Dr. C. George Boeree of the Shippensburg University, of
Language families. In the specific case of programming languages, the discussion is a little different. Programming languages are designed, or invented, either because they want to resolve a specific problem (C, JavaScript or PHP, for example), improve on previous languages (C#, C++, Perl, Python or Ruby, for example), as an academic work (Smalltalk or Lisp, for example), or by companies or committees to produce a dominating or standardised technology (Ada, C# or Java, for example). You can find definitions for these and other programming languages in the
Wikipedia.
Now, let's take a very brief look at some programming languages. We'll start with a
definition of programming language. Spend a few minutes on this article, you'll find good definitions of syntax, types, and libraries. After that, take a look at a
definition of scripting language. This introduces you to other concepts, such as interpreters and compilers. Both articles mention about twenty programming languages, so which one is best?
There is no simple answer to this question. To expand on Paul Graham's
painting analogy, it's like asking which is the best painting material. Oils, water colour, acrylics, ink or crayon? It depends on what you are trying to do, and that's why I have to ask so many questions.
I hope it is becoming clear that no single programming language will always be the best solution for all problems. In other words, if you want to take up programming seriously, to resolve a variety of problems, then you will need to learn several programming languages well.
The two Wikipedia articles nicely divide programming languages into pairs; interpreted or compiled, statically or dynamically typed, weakly or strongly typed, procedural or object oriented, etc. We can also add a further division; platform specific or web applications. By platform specific application I mean a program which runs on your computer, and by web application I mean a program which (mostly) runs on someone else's computer – a server.
In reality, these divisions are becoming more blurred, some interpreted languages can be compiled, others can be both procedural and object oriented, but at least this gives us a starting point.
To Begin, the Start Bit
If you don't have any prior programming experience, you'll want to start with the basics; creating data and changing those data values via code. You'll need all the help you can get - and you should expect frustrations - so that means finding a good tutorial or book, with lots of examples which you can try out, and modify yourself. It can be a trilling experience, even getting the classic “Hello World” program to work can be rewarding.
If you're only interested in programming, that is to say you're looking for a new hobby rather than trying to find a new job, (though the one can lead to the other), then I suggest you try out one of the online interactive script interpreters, together with an introductory tutorial. This means that you won't have to install anything on your computer, you'll just use your browser and your Internet connection. This is definitely not the way you'd want to develop your first serious program of course, but it provides a fast, cheap, and simple means of getting to grips with programming.
If you're already a programmer, but are curious about a few languages that you haven't explored yet, and just want to dabble a little, then take the time to take a step back. Try to pretend that you don't know how to program, and don't make too many assumptions. You won't need to learn the basics again – after all, there can't be so many ways to define state and alter it, but try to feel how the language approaches the problem. I have found that the greatest handicap to the experienced programmer is that that very experience can polute the broadmindedness that beginners have by virtue of their ignorance. Yes, of course you can do things better in your favourite language – because you know what to do, it's second nature. But can this new language offer new and interesting ways to do the same things in even better ways? Allow for your natural bias, and give the new language a little extra space for manoeuvre. Then decide if it is worth adding to your toolbox.
If you're wondering how I chose the programming languages in this section, well, glad you asked. I took into consideration: popularity, general usefulness, quality of tutorials, and that I found an online interactive interpreter. Since the first three factors are difficult to quantify, only the last factor really had any weight in the decision.
Online JavaScript
JavaScript is very popular, since it was introduced by Netscape as the programming language for web pages, and has never to date, been usurped from this throne. In other words, if you ever get to build web applications, you'll need to know JavaScript. But it doesn't stop there. In slightly different incarnations it is also available in the Microsoft Windows scripting engine as
JScript, and on the Microsoft .Net platform as
JScript.Net. That means you could do ASP web pages and ASP.Net web pages in JavaScript too.
From an open source viewpoint, there are several
JavaScript engines (
SpiderMonkey, written in C, or
Rhino written in Java, for example) which can be embedded in a platform application, with due care and attention, of course. It also forms a central pillar in the Firefox browser, together with XML, to create
XUL, the GUI framework, which is probably why Firefox has so many extensions.
Mono, the open source .Net platform also provides a
JScript compiler. Of couse, it's also the J bit in
AJAX, Asynchronous JavaScript and XML, which allows code in a web page to communicate back to the server without refreshing the whole page.
From a commercial viewpoint, you can use
JScript in Microsoft ASP pages, as well as Jscript.Net in Microsoft ASP.Net pages. You can even use JScript in Microsoft's
Windows Script Host to build your batch files.
Finally, JavaScript is not Java. They do share the same first four letters though, probably just to confuse us all. Further, it is a powerful, if misunderstood language, as
Douglas Crockford points out. If you noticed his book recommendation, you'll find that you can read an
earlier second edition online, before you decide to fork out on the latest dead tree version.
The W3Schools
tutorial gives a good overview for all levels of students. There are example pages where you can try out the code for yourself. It is orientated towards the JavaScript you'll find in your browser, rather than the other flavours I pointed out above.
One of the better sources of clean JavaScript (there are, unfortunately, plenty of sources that do not fall into this category) is Peter Paul Koch's
QuirksMode web site.
In conclusion, if you develop web applications, you'll need to learn JavaScript. If you want to make a Firefox extension, you'll need to learn JavaScript. If you want to build a multiplatform application using
XULRunner, which is the application framework for Firefox and Thunderbird, then you'll need to learn it. Or if you're thinking of building an offline web application with
Google Gears, then you'll need to learn it. Otherwise, of course, you won't.
An
online Javascript interpreter is available from MochiKit. If you want to try out some JavaScript in your browser,
this article, by Dan Simard will get you started.
Online Perl
Perl, invented by Larry Wall, is still the script language
du jour of Unix based systems. It is also justly famous for its regular expression handling, which every other programming language has had to follow. It has also became fondly known as the duct tape of the Internet, and is one of the P's, together with Python and PHP in the acronym LAMP, the other three being Linux, Apache, and MySQL, which together define the
de facto web application environment for open source projects.
As a mature programming language, you will find a staggering supply of libraries known as modules, available from
CPAN. During this maturation, it became object oriented, and added libraries for handling both web applications and platform application GUIs.
As way of warning, I'd better let you know that I don't do much Perl programming – though I do read quite a lot of the stuff, and make smallish modifications. That said, there is a wealth of books on Perl, one of which is freely available, “
Picking Up Perl”, by Bradley M. Kuhn.
The online Perl interpreter can be found at
http://feather.perl6.nl:8080/cgi-bin/runpugs. But do check out the
online help as well. Keep your examples fairly simple, and don't forget to type before you exit the page. I found that you can only achieve very simple results, possibly because I didn't know how to use it properly, and possibly because it's at an early development stage. Don't give up on Perl even if you give up on the online interpreter, you can easily download Perl onto your computer, see below.
In conclusion, Perl is a fine text analyser, with a large and thriving community. It is facing stiff competition from newcomers, such as Python and Ruby. My suggestion, for what it's worth, is that you learn Perl well enough to be able to read other people's work, and use Python or Ruby for new work – but do take into consideration the extensive Perl library, which cannot easily be matched by newer languages.
Perl has also been used in some of the most heavily trafficked sites on the web, such as
SlashDot, whose open source code is freely available from
SlashCode. The
Catalyst framework also seems to be enjoying increasing popularity in the web application arena.
Finally, Perl solves the multi-platform application framework problem by offering wrapper libraries to the major multi-platform GUI frameworks;
Tk,
QT,
GTK+ and
wxWidgets. This is also true of many other scripting languages. The 'look and feel' of the GUI is then strictly related to one of these underlying frameworks, which don't quite correspond to native applications. This may or may not be acceptable to the final user.
Online Python
Python, invented by Guido van Rossum, is designed to be syntactically simple and readable. Like Perl, it also began life as Unix glue, and has similarly evolved into a powerful language for both platform and web application development. Interestingly, it has also been targeted as alternative languages both for the Java Virtual Machine, and the .Net Common Language Runtime. More about this later. It is also one of the P's, together with Perl and PHP in the acronym LAMP, the other three being Linux, Apache, and MySQL, which together define the
de facto web application environment for open source projects. Also, there is a wide range of books on Python, several of which are freely available including “
A Byte of Python”, by Swaroop C. H., and “
Dive into Python”, by Mark Pilgrim.
The online Python interpreter can be found at
http://www.datamech.com/devan/trypython/trypython.py, and works very nicely for simple, single line statements. Once you get to the point of wanting to declare and call functions, then you've probably reached the limit where it is better to download the Python interpreter onto your computer.
In conclusion, Python's most distinctive feature is the cleanliness and readability of its code, especially for those with C like language knowledge (C, C++, C#, Java, etc). It enjoys an active community, and has an extensive suite of libraries, called packages. In the web application arena, two frameworks are currently enjoying popularity,
TurboGears and
Django. It has also been used to build highly regarded servers, such as
Zope and
Twisted.
Finally, as with Perl, Python solves the multi-platform application framework problem by offering wrapper libraries to the major multi-platform GUI frameworks;
Tk,
QT,
GTK+ and
wxWidgets. This is also true of many other scripting languages. The 'look and feel' of the GUI is then strictly related to one of these underlying frameworks, which don't quite correspond to native applications. This may or may not be acceptable to the final user.
There are also tools available to convert a Python platform application into standalone executables;
py2app for the Macintosh, and
py2exe for Windows. Python modules or libraries can be supplied via a packing mechanism called
PythonEggs.
Online Ruby
Ruby, invented by Yukihiro Matsumoto, like Python, is also designed to be syntactically simple and readable. It is, according to its inventor, designed to be “more powerful than Perl, and more object oriented than Python”. Though not yet in the top ten list of popular programming languages (see later), it is currently enjoying a rapid rise in popularity, probably due to the introduction of the
Ruby on Rails web application framework.
Its guiding philosophy is based on the “principle of least surprise”, so that most of the time things work the way you would expect them to. Though the language doesn't begin with a P, it still fits happily into the LAMP acronym, the other three being Linux, Apache, and MySQL, which together define the
de facto web application environment for Open Source projects. Also, there are many books on Ruby, several of which are freely available including an early edition of “
Programming Ruby – The Pragmatic Programmer's Guide”, by David Thomas and Andrew Hunt (also known as the Pickaxe book), and the curiously styled “
Why's (Poignant) Guide To Ruby”.
The online Ruby interpreter can be found at
http://tryruby.hobix.com/, and seems to have been the catalyst for all the other online interpreters – which is in itself an interesting point. You can use the online interpreter to build simple expressions, or even create classes. The only downside I could find is that you can't paste code snippets into it.
In conclusion, Ruby's most distinctive features are the cleanliness and readability of its code, especially for those with C like language knowledge (C, C++, C#, Java, etc), and its total dedication to object oriented design and philosophy. It enjoys an active and uncommonly polite community, and has an extensive suite of libraries (
http://rubyforge.org/), and a packaging mechanism called
RubyGems. Ruby also has a much closer interfacing mechanism to the C language than the other scripting languages discussed.
To Continue, the Middle Bit
Now that you've dipped your feet in the water, you'll probably be prepared to download some software, because from here on you'll require a text editor and interpreter or compiler. Actually, they're the minimum requirement, but please don't let that stop you from exploring the virtues of version control systems like
Subversion, or the language's built in documentation system, or an external documentation system if it doesn't have one, like
Doxygen, or
unit testing harnesses. Maybe not straight away, but certainly as a next step. True, you probably won't have to worry about things like that until you need them, but in my experience, when you need them, you need them desperately.
To help with the language choice decision process, you can always keep your eye on the TIOBE Programming Community Index, which will keep you informed both to how popular your current programming languages are, and which new kids are appearing on the block – though some of them can, in fact, be quite old.
C
One of the languages that almost always shows up in the pedigree of the languages that we've briefly looked at so far is
C. Not only that, but according to the TPCI above, it is also still one of the most popular, not bad for a language in its late thirties. That should give you food for thought, and indeed many of the languages discussed here rely on C libraries for some of their power, frequently using a binding tool called
SWIG. That means that you can almost always add other mature C libraries into your preferred programming languages yourself, once you learn the basics. Many of the interpreted languages discussed here use C to build the interpreters themselves.
C is a “nuts and bolts”
procedural programming language, and can almost always produce the fastest compiled code. It powers the kernel of most modern operating systems, and is still one of the commonest programming languages in the industrial and home automation fields. Many of the operating systems in embedded devices, such as mobile telephones are written in C.
If you're interested in programming to the metal, then C is a definite must. Otherwise I'd suggest you don't spend too much time on it. It has little of the luxuries of modern languages, such as automatic memory allocation and removal (garbage collection), objects, or exception handling. It is rarely used to develop user interfaces, even though it is used to develop user interface frameworks.
There is plenty of source code available for those who intend studying this omnipresent language, and there is also a wealth of compilers and tutorials. The
GNU Compiler Collection (originally the GNU C Compiler) has one of the most modern and complete C compilers, will run on almost anything, and will compile code for almost anything. A comprehensive overview of the C language is given in “
The C Book” by Banahan, Brady and Doran, as does “
C Programming” by Steve Holmes. There is also an interesting article entitled “
Everything you need to know about pointers in C” by Peter Hosey, which tackles probably the most difficult hurdle to programmers new to this language.
Even if you are not going to pursue the C language any further, there is an interesting article “
The Development of the C Language”, written by one of the language's inventors,
Dennis M. Ritchie, which gives an overview of the history of this language.
C++
C++, invented by
Bjarne Stroustrup is a major advancement on the C language. Although not all current features were available in the early versions, C++ is today considered one of the most powerful and efficient programming languages. Features include easier memory management (but not garbage collection),
object oriented and
generic programming, operator overloading, and exception handling.
Of course, any programming language with this much power will also be more complex. Much as C before it, C++ has an even richer syntax, allows even more complex and potentially dangerous operations, and can be the source of greater frustration for new programmers.
Several major applications still use C++, such as
OpenOffice.org. This may of course be due partially to their age, however, even for newer projects, it would be very difficult to find another programming language which matches the speed and efficiency of C++.
Personally, I wouldn't recommend C++ as a first language for the fledgling programmer. On the other hand, I do consider it to be a major bonus on a professional programmer's curriculum vitae. So if you're considering programming as a livelihood, you will want to come back to this masterful language, once you've cut your teeth on some of the other languages I have outlined here. You may find that starting with C, and then moving on to C++ helps relieve the indigestion.
For those of you who are willing to take the plunge, the
GNU Compiler Collection (originally the GNU C Compiler) is one of the most modern and portable compilers for C++, and there are several books available, including “C++ In Action”, by Bartosz Milewski, which is also
available online.
The
Boost C++ libraries website provides a wealth of well written source code.
Java
Java was invented by James Gosling. As one of the newer programming languages, it gained enormous popularity in a very brief period of time. Most of that popularity came about because it also coincided with the popularity explosion of the Internet. Personally, it is still one of my favourite programming languages, since it got almost everything right. It introduced many of us to a programming language with
documentation comments, built in
security,
threading,
garbage collection, and that holiest of grails, portability via the
Java Virtual Machine, or JVM for short.
One of the things they didn't get right, and which has been the cause of its unpopularity in the Linux world, is that they didn't make the entire tool set open source until late in 2006. Most of the other things that they didn't get right have been corrected in later versions, probably thanks to competition from C#, see below.
Today, Java is firmly entrenched in web application development. Despite several attempts, it has not found much appeal for platform specific applications, mostly due to unappealing user interfaces. The large (and ever growing) size of the Java Virtual Machine doesn't help either.
It is very easy to get started using Java, there are software development kits, with support libraries, also provided in source code form, and open source Integrated Development Environments. Your first choice will be either the
Standard Edition, mostly for creating client side applications and libraries, or the
Enterprise Edition, which is more orientated towards web application development. There is also a third choice, the
Micro Edition, which is aimed at small hand held devices, such as mobile telephones, ironically the original target market for Java.
If you're just starting in Java, then opt for the Standard Edition, changing over to the other editions will only cost you the time to download the development kits later. Sun also provides an extensive
tutorial in almost all aspects of Java programming. The tutorials can be downloaded for offline browsing.
You can start off with a simple text editor, and the supplied compiler, however, you will eventually want to make use of one of the two excellent Integrated Development Environments (IDE) available; one is
NetBeans sponsored by Sun, and the other is
Eclipse sponsored by IBM. Both are open source projects, and almost entirely written in Java. Both of these IDEs also provide development environments for numerous other languages.
Finally, in a continuing progression from its humble beginnings, the Java Virtual Machine has also become host to a series of other programing languages, as outlined in the
Scripting Development website. Apart from incorporating the Rhino JavaScript engine into the current Java Runtime Environment, you will also find good implementations of
Python and
Ruby, to mention just two.
C#
Java's great success in the web application arena, driven both by Sun and IBM, helped spur a major overhaul of programming languages within Microsoft, culminating in the
.Net framework.
While they had the advantage of being able to study, emulate, and improve on five years of Java expansion, the resulting framework is a radical change from the past. The previous Microsoft language heavyweights,
Visual Basic and
VBScript, had to be given second place, in favour of
C#.
Visual Basic.Net is the heir to the Visual Basic throne, but the syntax has been so heavily and necessarily modified to ensure compatibility with the .Net framework, that many Visual Basic programmers are abandoning it.
Though similar in form to Java and the JVM, C# and the
Common Language Runtime (CLR) also introduce additional concepts such as
autoboxing,
delegates, and
partial classes, and allows for operator overloading, to name but a few.
While Java was originally intended as a single omnipotent programming language running on multiple platforms (“Write once, run anywhere”), the .Net framework was designed to be a platform for multiple languages which would run on Microsoft Windows. The fierce competition between Java and C# has clearly raised the bar in the expressiveness of these programming languages, at the expense of simplicity. The Wikipedia gives a well balanced
comparison of Java and C#.
As with Java, C# has gained a strong position in web application development, together with the
ASP.NET framework. Since the .Net framework is also supplied in the latest versions of Microsoft Windows, there is a more widespread use of C# to produce platform applications. The open source
Mono project is also developing a .Net framework for Windows, Linux and Mac OS X. Although this is always trailing behind the current version of the Microsoft implementation, it is standards compliant, and sufficiently complete to be a viable alternative.
To begin programing in C#, you can
download the .Net framework, and Visual Studio Express, the integrated development environment (IDE). Alternatively, in the open source arena, there is
Mono, and the
SharpDevelop IDE. Microsoft provides extensive C# documentation, and
tutorials, though these are unfortunately only available online.
The .Net framework also provides an engine, the
Dynamic Language Runtime (DLR), for scripting languages, including
Python and
Ruby.
PHP
PHP, which originally stood for Personal Home Page, but now is PHP: Hypertext Preprocessor, is a classic example of an open source project created by a programmer (Rasmus Lerdorf) to “scratch an itch” - he wanted something to be able to collect traffic data for his personal website. Since then, PHP has developed into an object oriented programming language, has a
bytecode compiler, and enjoys phenomenal popularity in the web application arena.
It is one of the P's, together with Perl and Python in the acronym LAMP, the other three being Linux, Apache, and MySQL, which together define the de facto web application environment for open source projects.
Several mature and popular open source projects are based on PHP, including
Joomla!,
Drupal,
WordPress and
MediaWiki.
You can start using PHP by going to the
official PHP website, and downloading the necessary software. This site also provides a
tutorial for the PHP language, and downloadable
documentation for offline reading.
The
Eclipse Integrated Development Environment provides the
PDT (PHP Development Tools) project which provides a framework for PHP development.
Perl Revisited
I gave a brief overview of the Perl online interpreter above. If you've decided that you want to explore the language further or you have some Perl scripts that you need to execute, you'll need to download and install the Perl interpreter onto your computer. Perl is usually already installed on most flavours of Linux, but you may want to check that you have the latest stable version.
The
official website gives pointers to all things Perl, as does the
O'Reilly sponsored site. The
Comprehensive Perl Archive Network (CPAN) is the main repository for Perl modules, and the
interpreters for numerous operating systems, with a
special section dedicated to Windows.
There are plenty of Perl Integrated Development Environments
available, though most Perl programmers seem happy with plain text editors.
The
Eclipse Integrated Development Environment can host the
EPIC (Perl IDE) project which provides a framework for Perl development.
Python Revisited
The
official Python website provides information on all things Python, including the latest stable release of the
Python interpreter for various operating systems. Python is usually already installed on most flavours of Linux, but you may want to check that you have the latest stable version.
Web application development is supported by a number of frameworks, two of which seem to be enjoying the highest popularity ratings;
Django and
TurboGears.
The Python distribution comes with its own Integrated Development Environment, called
IDLE. There are also
plenty of others to choose from.
The
Eclipse Integrated Development Environment can host the
PyDev (Python IDE) project which provides a framework for Python development.
Ruby Revisited
The
official website is the best place to start for information about Ruby. The Ruby interpreter is available for
download for most operating systems. Ruby may already be installed if you are using some flavour of Linux, or the latest Mac OS X, but you may want to check that you have the latest stable version.
The Ruby installation comes with its own IDE, called FreeRide. The
NetBeans IDE provides a
Ruby development pack, similarly the
Eclipse IDE hosts the
RDT (Ruby Development Tools) project.
Of course, web application development is supported by the
Ruby on Rails framework, which probably introduced more programmers to the Ruby language than anything else.
To Summarise, the End Bit
This very long article is really only the tip of the iceberg.
Such a short question, and such a long answer – assuming that this gave you an answer, of course. But let's be optimistic. You've probably noticed that I have introduced you to the top 10 programming languages in the TIOBE list – well more or less. Of course, I missed quite a few out, but don't let that stop you from investigating them for yourself. If you want to sample an enormous range of programming languages, all producing the same output, see the curious
99 Bottles of Beer website. I also suggest that you take a look at some of
Joel Spolsky's thought provoking articles.
Finally, since a little knowledge is a dangerous thing, Peter Norvig's
article may help keep reality in check.