What programming language should be learned first? And what was your first programming language?
Some articles on the topic
- Introductory Computer Programming Education by Philip Guo. The proposed curriculum is: Python and Unix command line, then Java within the Eclipse IDE, and then C and Scheme.
- Thoughts about the Best Introductory Language by Shlomi Fish. The author advocates teaching Perl as the first language. At the same time, he admits that Perl is hard to learn.
- LOGO. The programming language created for teaching. Procedures and recursion can be learned in a graphical environment (see sample programs). Papert's book includes several success stories, e.g. the history of Logo in Russia.
- Alice is a 3D programming environment for novices. The programming language supports loops, conditions, and some OOP stuff (objects, properties, methods, events). 3D animations and even simple 3D games can be made with Alice. The program is written by dragging properties and selecting methods/arguments from menu. Should be attractive for the kids who dream of creating their own 3D game!
- Ruby – best introductory programming language by Tony Targonski.
- Seven Deadly Sins of Introductory Programming Language Design by Linda McIver and Damian Conway. The paper also contains recommendations for choosing a more "teachable" language.
- Teaching programming to kids. Discussion on Reddit.
- Just Let BASIC Die by Albert Sweigart. The author argues for using Python as a modern introductory language.
Questions
What are the criteria for choosing the first programming language? What language would you use if you wanted to teach programming to your kid? Why? And what was your own first programming language?
Your feedback is welcomed. Please use the comment form below.
Programming is about coping with tediousness and insanity. Therefore, the first computer programming language a person should learn is the following:
http://en.wikipedia.org/wiki/Brainfuck
Just go insane right at the beginning, and get it over with! The interpreter is only 200 bytes!
When they've mastered that, they are ready for:
http://en.wikipedia.org/wiki/Whitespace_%28programming_language%29
To complete their studies in Computer Science, the student should become proficient in:
http://en.wikipedia.org/wiki/Befunge http://en.wikipedia.org/wiki/LOLCODE
Google uses LOLCODE on its mainframes to handle searches relating to cheeseburgers. Microsoft uses Befunge as inspiration for API design. Python and Makefiles use the same technology found in Whitespace to ensure that we don't take invisible characters for granted.
OK… Perhaps I exaggerated the virtues of those languages, and maybe I am mistaken about the role those languages play in the world's biggest software companies.
Actually, in all seriousness, I think C# might be the best contemporary language to learn first. Microsoft Visual C# 2008 Express Edition is free, and is an excellent development environment. The .NET libraries are extensive, uniform in style, and generally well thought out. A person can start the compiler, select the type of program to create (console mode or windowed), and press a single button (after the project selection dialog box is dismissed) to compile and execute the empty program. A person can then type a single line of code (e.g., Console.WriteLine( "Hello, World!" );), and, one click later, see that appear in their console mode program. Or, a person can type g.Clear(Color.Blue); in the Paint() method of their Windows Form, and, one click later, see their windowed program filled with blue. Then they can add g.DrawLine( Pens.White, 0, 0, 100, 100 ); and see a line. (Maybe I got one or two details wrong with those drawing calls, but it really is that simple.) Adding a button to a form is easy, and making that button do something is also easy. But, really, there's plenty of fun to be had with pure console-mode programming. Like many other languages, reading a file in to a variable is a single line of code, like String s = File.ReadAllText("file.txt"); (maybe the function name is not quite right), and reading text in to an array of lines is also easy: String[] s = File.ReadAllLines("file.txt"); (again, maybe that function name is not quite right). Some people LIKE languages that "liberate" people from thinking about types, but I think that's a recipe for future frustration (when people inevitably have to learn the secrets of all the implicit activity of a language to solve mysterious bugs with their programs – e.g., strings being interpreted as integers, integers being interprets as strings, and floats sometimes becoming integers, and data types having both array and associative array properties, etc).
Also, I am no fan of Microsoft, but C# is superior to Java. Java might have generics now, but C# had those since .NET 2.0 (2005). Using C# with platform libraries is trivial, whereas with Java it is a bit of a pain (although maybe in the past few years Java might have made advances in that area). Although novice programmers obviously have no interest in that language feature, such a feature allows other people to provide interfaces to many native libraries the might be very interesting to a novice programmer. For example, maybe a novice programmer thinks it would be fun to write a program to control a robot or get images from a web camera. The ease of providing C# interfaces to external, native libraries means the such C# libraries will be available for the novice C# programmer.
Having said all of that about C#, I do think Java has its merits as a first language, too. But one has to consider the WHOLE programming experience, and Java proves to be annoying in so many ways. Java would be a much more popular and relevant language today if the people who created and updated Java over the past 15 years had given more attention to the programming and end-user experience. The Java SDK and run-time environments should have had a simple version numbering scheme right from the beginning. The stupid CLASSPATH environment variable, and the frequent failure to find classes that are "right in front of its face" (e.g., contained in the same JAR file as the main class), for example, could have been fixed by a more aggressive search for "missing" classes. Forcing a class to be contained in a file having the same name as the class is not so bad, but requiring a directory structure to match a package hierarchy is SOOOOO LAME! Java is also exception crazy, and its fondness for exceptions was imitated by C#. Anyhow, Java could have dominated much harder than it did. Instead, the creators of Java were evidently blind to the extremely annoying and lame aspects of the total experience of using their language. It's the same kind of blindness that allowed the Python developers go ahead with making white space significant, and that allowed Objective-C to exist at all.
P.S.: I wanted to actually answer the posed questions.
Even BASIC on the Commodore 64 satisfies these criteria more than Lisp, Haskell, Ocaml, Python, PHP, and Javascript. LOL
C#, because the language makes it easy to do many interesting things, also enforces strict rules regarding program structure and types. Although *some* programming errors reported by interpreters and compilers are merely syntactical, or are mere artifacts of the arbitrary requirements of the language, I think many errors promote critical thinking about the relationships between concepts. Of course, it would be nice to be able to focus on algorithms, rather than on more mundane details, like data types.
PHP, Python, and even Javascript, offer fun and easy activities with arrays, associative arrays, etc, which aren't so simply expressed in C#, but those languages mush your mind.
I think the oldest version of BASIC might be a really good introduction to programming, but only for a week, just for laughs, before switching to C#. The thing about BASIC, with its line numbers, is that it is really easy to understand.
That is a great first experience.
People proposing Lisp, F#, Haskell, etc, as a good first language, saying that procedural languages are a bad habit – closing the minds of people who indulge in them, making them unable to understand or appreciate more abstract ideas about "execution" and data types – overlook the rewards of actually doing anything evidently cool! I'm sure some nutcase implemented a video game in Lisp or Haskell, but those languages are better suited for making A.I. textbooks look ugly for a decade and for computing things inefficiently. When a language is forced to introduce "syntactic sugar" to enable people to do practical things, and when a language is forced to compromise on its core features (e.g., allowing some mutability) to not be super annoying, and when a language is not easily used for fast, interactive experiences, then I think that language is LAME.
BASIC on the TRS-80 Model III at the local Radio Shack when I was 10 years old. My family was poor, so we couldn't afford to own a personal computer at the time. But the manager at that local Radio Shack store didn't mind that I visited a lot to do programming on the computers they had on display. But in middle school I had access to Apple II computers, which were lots of fun (color drawing functions and speaker tone functions). Then the Commodore 64 computer came out and was only $199. I LOVED THE C64! The games were awesome, and programming graphics and sound on that computer was SO MUCH FUN! Although I already did some assembly language for the Apple II early on in high school, I did much more of that stuff on the C64. I wrote my own floating-point functions in assembly language, and used the numerical integration methods appearing in Feynman's Lectures on Physics to reproduce his planetary motion calculations, and used the C64 sprites to show planets orbiting the Sun. But, wow, the games were awesome. Chopper Command, Bruce Lee, Quasimodo, Forbidden Forest, Montezuma's Revenge, Pogo Joe, Necromancer, Conan the Barbarian, Jumpman, Impossible Mission, etc.
Thank you very much for your opinion! Old good BASIC was a nice introductory language. My first computer was a cheap Russian clone of ZX Spectrum and I spend a lot of time in my school where "real" computers (IBM PCs) were installed. The teacher was so kind that I could write programs in evening, when there was nobody in the computer class.
LOGO may be good for learning programming, because of its intuitive turtle graphics. Here is a nice e-book and an online interpreter. (However, there is no OOP and first-class functions in LOGO; the syntax for variable assignment is terrible, etc.)
Microsoft has Small Basic language, which is (IMHO) worse than 40-years-old LOGO (no function parameters!)
I agree with David Mercer, for novice programmers FORTH is pretty hard to beat. The entire metaphor, if taught properly, rapidly gets a beginner up to speed as to what the machine really is and that is by no means a small feat. I know professional programmers with years of experience that still do not understand the fundamental premise upon which the machine is built, logic gates. FORTH, because of its stack orientation is somewhat similar to the way the CPU works. Also, in a stack based system programmers tend to learn good habits. That, coupled with the extensibility of the language through creating new 'words' tends to make learning and understanding easier for novices.
Years ago I was flabbergasted by a program, written in FORTH, for the Apple II computer, Das Fleeter mouse. It was written by a German in FORTH to simulate a bat flying. It was fast, represented the bat as well as it could for that era. But let me say this again, it was FAST. This was on an 8 bit machine (6502) running at 1 MHz with 32 KB of accessable memory! Yeah, the II could have up to 64KB but because the video memory was mapped stating at 8000H the upper memory was virtually useless without patching your way around it. I dissected the code and was amazed at how you could build this simulation in that language by building up a set of 'words'.
I haven't looked at FORTH in probably going on 3 decades, being a profession programmer I am caught up in the Microsoft world, C#, HTML, VB, java, oop, agil, etc. But I do still remember learning how to do this stuff. Fortunately for me the school I attended taught us logic, how to manipulate the CPU and the basics of machine design. Back then we delt with punch cards and had to load them into an IBM 5250 card reader.
My first program of any significance was a loan amortization program written in Fortran 77 on a mainframe using an acoustically coupled teletype. Now I'm dating myself but I am probably the only one I can get a date with!
But, in all seriousness, learning to program is not the easiest thing for most people and when you heap C++, C#, OOP, understanding the machine, Assembly and a whole bunch of other stuff with questionable application on a poor college student who just entered his or her first year of computer science. It can be and very often is, overwhelming.
An introductory course with something like FORTH or Logo or even VB as the language would be a much 'gentler' way to go about it.
Furthermore if a person is able to use the complete x86 instruction set, he is also able to program nearly every other CPU in assembly because most other CPUs only use only a subset of all the x86 instructions available.
If someone can program decently in assembly, the person won't have any problems using pointers, arrays etc. in any HLL. He will also know how to program fast because he knows how the CPU works. He will also know how to use a debugger, if his complier doesn't work properly or if some apps needs some reversing.
The responses that cite an easy to use development environment that explains syntax errors and catches the various "beginner" programming errors sounds good, but ... Having learned to program using FORTRAN on punch cards, and with limited resources such that I only had about 14 attempts to get an assignment correct, I quickly learned to be meticulous and thorough. I don't see that in the junior programmers today.
IMHO, I think a first language should be one that is available on ALL platforms and has tools available through the public domain. It is a serious career error to become locked into an architecture or operating system. A good software engineer (differentiated from "programmer") will look at the programming language as a carpenter does his tools, as an artist does their brushes and paints.
My choice for "best" first language -- pick the worst (hardest, complicated, etc.) one there is. If you can learn that one and still want more, send me your resume. Otherwise, go get an MBA.
Recommended first language: Erlang because it has lightweight processes and encourages you to write parallel code, it is also concise, clear, and useful for real world tasks. It also has some great virtues that can positively influence the way you write code in other languages: no globals, single assignment of variables, etc.
No beginner should ever be asked to learn a language that does not have parallel processes as part of the language. We will never get away from the dumb calculator approach that most of us were taught if we don't start taking parallel processing, multiprocessing, multitasking, distributed computing, cooperative sequential processes, etc., seriously.
If people start to lose their interests when learning these languages and saying they're too hard. Then they should stop and do something else instead because programming isn't easy. Either they're going to know that soon or soon enough.