Want an easy way to keep up on the latest TUX website stories, news, and reviews? Load the RSS feed featured below into the reader of your choice, and get headlines and summaries downloaded automatically. Click here to learn more about RSS.

Programming Options

Ok, why? Because I have had quite a few people who aren't programmers
ask me about learning to program. So, here is my typical answer. In English. I
suppose I can then just let Babblefish (or Babel Fish) translate the
answer to Spanish as the majority of the people asking me recently
don't speak English.

There are really two questions here:

What programming language should I learn?

Where can I get the software I need?

Let me answer the second one first. The answer is almost universally
"it comes with most Linux distributions". This tends to be a shock for
the non-Linux people asking me but it also offers a lot of them the
incentive to give Linux a try.

Ok, on to languages. There is no universal good answer but there are
some good suggestions. My first suggestion is that you learn an
interpreted (or byte compiled) rather than a compiled language.
This decreases the number of steps you have to go through each
time you want to try something.
Call it immediate gratification.
With very fast computers and efficient
interpreters, a compiled language is not likely to be worth the
difficulty involved.

Ok, filled with my opinions, here we go--language by language.
If you want a different opinion, check out
WikiPedia.

BASIC  BASIC, which originally stood for Beginner's
All-purpose Symbolic Instruction Code, was supposed to become that
first language. Unfortunately, the initial language was not very
powerful because of the hardware of 40 years ago. As hardware
capabilities improved, "better" versions of basic appeared.
Unfortunately, they tended to be incompatible.

C  A categoric no. While C is a good language for
writing operating systems, it is not a language for computer
newcomers.

C++  In the professional programming world we can
explain why C++ is better than C but, again, for a first language,
forget it.

Fortran  It might have been the right answer about 40 years
ago. But, today is today.

Java  Java got more hype than a lot of other "new"
languages and is available virutally everywhere. But, while the
standards process was initiated Java was withdrawn from the process
and language specifications remains proprietary property of Sun Microsystems.

JavaScript  I mainly mention this to make sure you
don't confuse it with Java. They are different langauges. JavaScript
is commonly used in client-side web programming--that is, running
within your web browser--to handle dynamic aspects of some web pages.

Pascal  Developed as a language to teach
programming, Pascal had its place. However, it suffered much like
BASIC from everyone having a better version. There is virtually
nothing being developed in Pascal today.

Perl  Please, no way. A lot of stuff can be and has
been done with Perl but it is probably the most confusing interpreted
language ever created for a newcomer. This is because Perl takes the
best of awk, grep, UNIX shell programming and all too many other
things and tosses them together. For the newcomer, you have to learn
how all these different things work and how to put them together.

PHP  For web development, PHP is probably the most
popular language. But, it sees virtually no use in other areas and
suffers from growing pains. That is, the original syntax looked very
much like C but adding modern object oriented features has tended to
add confusion. Unless you need to do web work in PHP, forget it.

Python  Python is, in my opinion, a clean interpreted
language that will not scare away beginners. It is used extensively in
many areas including web development and as a scripting language for
various programs such as Scribus and the GIMP.

Ruby  Probably the cleanest object oriented language
in common use. Much less popular than Python but possibly easier to
learn.

So, what's the bottom line? I recommend going with Python. Python
interpreters are available for virtually every computing platform,
syntax highlighting exists in most editors and it is supported by many
development environments from KDevelop to its own eric and idle. Note
that these two program names should help convince you that Python is
named after a TV show, not a snake.

Eric, idle and pida are three Python-specific development environments. You
should give each a try along with KDevelop. If you really like a
screen full of buttons and windows, eric is probably the tool for you.
If, on the other hand, you would rather
have a separate editor, give kate a try. It offers excellent Python
syntax highlighting and is easy to learn and use.

One other program of interest is pychecker. It is an easy to use
command-line tool (just type pychecker followed by the name of your
python source file) that will spot problems in your program.

Finally, like most programming languages, Python continues to evolve.
Version 2.4 is current with 2.5 to be released soon. I highly
recommend using at least version 2.4 as there have been some
language cleanups recently and version 2.4 defaults to using the newer
forms. This will help you prepare for the future.

Comment viewing options

First things first: forget C and C++ or Pascal or COBOL or anything like that. We're talking here about the first language for Jane/Joe User, who will at most do some simple, quick and dirty programming tasks. I don't think Joe User will code a new operating system or a compiler with this his/her first approach to programming. Joe/Jane User does not want to meddle with strict variable types, nor with pointers, memory allocation and garbage collection. She/He will want something simple and easy to handle, so the best for Joe/Jane User will be interpreted or scripting languages: Ruby, Python, Perl (yes, even Perl), Lua, bash, Basic (yabasic or X11basic or Gambas or...), or tcl. Heck, even Pilot! (remember that one? like Forth and intended for kids?).
My personal favorites are Perl, Lua and Basic. I have not tried Ruby yet, but will do so soon.

These articles always end up with lots of comments. That is because to many a programming language is like a religion.

I'll just plug my favorite beginner's language and leave it at that: Euphoria.

It is a very easy to understand language that has some of the best parts of BASIC and PASCAL and yet is easier to read and write than either one. The license isn't perfect for Open Source purists but it is good enough. There is a pretty strong community following it and a library of example programs and libraries to use.

After browsing around the computer language shootout (a great place to study the intrinsic readability of other people's code), one language seemed to be hanging as fast and light as the compiled gang, and was really easy to read.

Lua's concept of closures invert the idea of scope in a nice way. And making variables into handles for anything was simple and powerful. Coroutines seemed interesting. It crushes floating point work.

There's this interesting duality where Lua seems syntactically the opposite of C in many ways, but they are in fact meaningfully and usefully interrelated (and easily bindable to each other). This made sense as a design decision, because I would probably be programming in one of two ways: rigorously and in the hardware, or quick and dirty. Lua does the second way well, and is designed to connect to languages that do the first way better. Lua was designed to be a helper for other languages and easily connectable (or embeddable) with them, instead of trying to do all their features. Many complicated OO ideas are left out of the language itself, because they are quckly (and adaptably) done in small closures.

It's not perfect. The scariest thing might be the handling of multiple return values. I haven't gotten the reasoning behind the generic iterator phrasing down yet. And the metatable/metamethod thing is a good idea with clunky phrasing.

If you really want to learn an easy to use programming language, Basic comes at first and under Linux Gambas is the best choice for Basic Language Programming.
I've been using Gambas (http://gambas.sf.net) for some time and let me tell you it's an excellent IDE and it's very easy to learn and use.

Although not used much in general programming, there is nothing wrong with Pascal as a first language, as it's in-built inflexability forces you to learn to program in a better way. Also, with FPK (www.fpk.org) you get a full IDE, compiler and language that's fast and produces programs with little pain.

Yes. I like Pascal too. It is logical, pedagogic, and it is easy to read the code you or others have written. Other languages are a mess. In Pascal, you have to use the right data types, and you will have control of what you are doing.
Pascal compiles 9 times faster than C.

And i think Pascal is a good option these days:

For many years there has been limited options for Pascal. You had development tools like Borland Delphi. It cost a lot of money, and it is only for windows.
Now you have the freepascal compiler under GNU-license, and you have a rapid development tools called Lazarus. Everything for free, and for multiple platforms! Lazarus looks like Dephi, and it used to be almost a clone.

While I agree that scripting languages (and I use them a lot) are easy to learn for people with no background in, well programming, I would wish to disagree with you that they are the best to learn how to program. C++ is the best for learners and only takes a few painful hours but once you are up, you are running because the concepts and all have been learned and going on from there is a bit smooth than to the person who learns scripting languages.

Without understanding many of the basic concepts that 'C' forces a student to learn, the programming is reduced to scripting. Scripting is tedious, and mind numbing, whereas programming is challenging and rewarding.

That's the difference between 'C' (and 'C++') and other lesser languages.

I have programmed in C and C++ for years now, and I have taught beginning programming classes in C++. I know what it's like to teach students who don't know anything about C++ or programming in general and have wished for a easier language to work from. C++ suffers from being somewhat too flexible and complex at times. I would vote in favor of C over C++ anyday, but I recommend Python or Ruby even more. Yes, it is still necessary to teach many of the "in's and out's" and every little nuance of how a computer works. But it's better to start them by taking baby steps, and let them work towards to a deeper understanding as they go. So working from a language that at least starts from a level that hides some of the deeper details is a far better way to go then making them start at the bottom.

This way they gain mastery over concepts such as creating an alogrithm, flow control, variables (without worrying about declaring int's, floats, char and how they typecast), templates, function protoypes, header files, and compiler issues.

You say "scripting" is tedious and mind numbing, but I say you don't understand the power of languages such as Python and what you can do with it. It's a powerful and fun language that goes beyond just mere "scripting" (however you define that). I've written some challenging programs with Python. The beauty of Python is that it allows me to focus more on solving my problem instead of fighting extraneous issues to the problem such as wierd compiler errors, memory leaks, and other problems with a lower level languages such as C/C++. Plus, I could quickly test out a function or idea in the interpreter without having to "compile" my whole project for one feature. That's what made it the most fun of all.

In some ways, being able to test out your ideas from the interpreter is the great aide to learning how to program. I wish I had something like that for my students back then.

Now, I'm not knocking either C/C++. I appreciate and understand their power and efficiency, and I enjoy using them for different problem domains.
But for getting your feet wet in general programming, C/C++ is like stepping into a tsunami in some respects.