Ask HN: What programming language should I teach my little brother?
My brother is 13 and asked me to teach him "how to code". I really don't know what programming language would be the best to start at this age.
First I thought of C because it will also teach him how the Linux he runs was made. But… I hate C. I personnally learned programming with OCaml and Pascal. I still love OCaml (pattern matching FTW), but it didn't really teach me anything about Unix…
I'm looking for a language that would be easy to learn, with a beautiful syntax, and that would gently introduce a 13 year old to the amazing world of Unix/Linux.
Any ideas?
118 comments
[ 3.8 ms ] story [ 106 ms ] threadI can't recommend enough getting him a "Basic Stamp" kit. Seeing how software can control hardware is magical. Then work him up into "Arduino" world in C.
"Hey, see if you can make those 8 LEDs do like the KITT car!"
I thought BASIC is very good to teach basic programming concept such as Loops, line-by-line execution, etc. Really, for a beginner, one must have that kind of mindset.
2) Numbering lines for programs is nonsensical.
3) Gotos are bad practice.
4) Most programs consist of more than 1 file.
5) Hello world is just as easy in any other (more useful) language.
Can't think of any more off the head right now, time to eat.
Didn't we all start with basic, even if just for a little bit?
Other than that, bare-metal programming on microcontrollers has the advantage that the boy can get a mental picture of the entire machine in his head; not so easy with an SDK of hundreds of megabytes for a modern high-level language.
It's the most human-readable language out there. I personally think that it's a lot easier to get started with the basic concepts of programming like while loops, if statements, etc. It is a lot easier to do those things when you don't have to think about including random libraries and putting everything in specifically named functions (ie. main() or static-something-or-another in JAVA) and what-not.
It's the fastest way to get started.
JavaScript would allow your brother to share his creations with friends and learning the amazing (and at times frustrating world) world of the web.
After Python, you could also try teaching him Scala.
Avoid languages like C++ or Java because there is so much to learn before you can produce a simple Hello World. There is no reason to learn OOP to do a simple task.
I think JavaScript would be a reasonable second language. He should learn programming firs before having to deal with browsers, the DOM model, and OOP.
Here's how to get a kid hooked on programming:
Who really cares if a child isn't using "good programming practices"? When I started writing code, it was downright shameful.But in time, my internal desire to advance my art led me to nuking my globals and having some kind of naming standard. Eventually I fell in love with elegant languages.
Give the kid a fire. Let him decide if he wants to improve himself over time.
When I started, I just wanted to make games. Not learn Greek. Kids just don't care about Python or Ruby's elegance.
Good Javascript programming requires coding differently than you would in Python and C, you have to understand and use strange but cool features like closures and prototypal objects.
In some ways I almost think javascript in a browser is enough, you have firebug and its shell, and you can immediately show hacking around etc..
Of course, there are some who the mathematical pleasure is really what they are after, in which case I would think haskell - and it has the bonus of a very simple syntax that really doesn't look like a "programming language" - at least what most people think.
I'm a stubborn bastard, only reason I kept going.
Also, it's easier to explain to someone if you have an interpreter going and they can see the results.
There is a lot of explanation for any language, but with javascript there is a compiler/runtime on every computer.
Ruby or Python is good for a start, because it's easy to debug and you can do simple, cool things with them pretty quickly. Then introduce him to Lisp or Scheme, and finally OCaml or Haskell so he's exposed to good static typing. Save C for later (by the time he's ready for it, he'll be picking languages rather than asking you for advice).
I personally thought VB6 did a good job of letting you build something quickly in its day, in spite of its other faults.
These days though, I would recommend teaching him Python or Ruby.
Python seems to be the teaching language of choice these days, and it lets you do useful stuff without getting in the way. It's certainly not the only language to learn, but I'm inclined to say it should be the first.
Seriously, can we just nuke this argument?
And the kids were alright back then, and they are alright now. Applesoft BASIC makes PHP 5 look like Haskell (we're talking about a language with nothing but global scope, here), but the generation that built the Web grew up using it and it didn't hurt anyone. The smart kids just moved on to better things as they became aware of them.
Teach the kid something fun. For a thirteen year old, that's very likely to be Javascript, Actionscript (i.e. Flash), or PHP, though I certainly might give Shoes or Hackety Hack a try, or maybe this Scratch thing: http://scratch.mit.edu. Try several of these and see if any of them stick. But don't get hung up on the details. The guy is thirteen. There will be plenty of time for him to learn how ugly, fragile, insecure, opaque, and unmaintainable his code is. Try to let him have some fun and get hooked before he's forced to learn the truth. He won't sit still for it, otherwise.
Every language that has been around for a while has its own culture and traditions. The culture of PHP is a better reason to avoid it than the language itself. I spent a lot of time un-learning habits I picked up from languages like PHP and BASIC. I suspect I would know a lot more now if I had started with Smalltalk[0] and not had to waste as much time un-learning bad habits.
[0] Python wasn't around then
It's easier to code and deply GUI app in VB (and .NET environment).
For a beginner to start coding web-app in Python would be like a non-geek trying out Linux with just command-line.
Apologies for a (related) tangent but I'm in a very similar situation (except that my little brother is 31). He has more artistic inclinations but in the past he's demonstrated an aptitude for mathematics and is generally good at problem solving. I've been teaching him some basic set theory and number theory in preparation for some actually programming.
My first thought is to teach him one high level language like Lisp followed by a low level language like C. On the other hand, JavaScript (+ HTML) has some of the best of both of those worlds with the added benefit of affording immediate gratification. Any thoughts?
*Admittedly, my bro is a bit more motivated by financial considerations but I do think he will come to appreciate the beauty of programming if it is presented the right way.
For a 13-year-old who has probably not been exposed to much mathematical rigor at school, I would not recommend Haskell, though. Haskell makes it hard to write a program that, as ugly and unmaintainable as it may be, somehow mostly works (e.g. you have to plan ahead which parts of the program may perform I/O).
Therefore, I'd go with an imperative language and reserve Haskell for the day when he asks "is that all there is?".
C is mandatory, every programmer knows C, it teaches you about memory management, syscalls… it teaches you how you computer works. Once he gets it, he can start having some fun with the sexiness of Lisp, and he will make less mistake because he knows what's happening behind the scenes. Plus… it's really hard to learn C when you already know Lisp exists. I mean… first you ride a bike, and then a motorcycle.
For my brother, I don't think Haskell is such a good idea. Sure, it's a great language, but maybe too mathematical for his age (he just learned the Thales theorem…).
Good luck with whatever you decide though, he's fortunate to have a brother that's taking the job seriously :)
Monads can be motivated as a generalization of a lot of stuff that follows similar rules (the Monad laws). E.g. Lists, Haskell's Maybe (representing success/failure), sequential computation.
This is exactly the problem.
Also, there are arguments that Lisp is better than everything else. Especially when the goal is to learn something (rather than get a product out the door, which makes it more important to have existing libraries, and to be able to hire people who know the language).
I don't know which one is better for a 13 year old, just pick the one you know better.
My biggest recommendation, though, is that once the kid has any sort of "foundational" programming language under his belt, you write a Scheme interpreter together, in that language, and then show him that the interpreter you just wrote can run Scheme files that already exist (possibly ones you pre-prepared.) That's the best way, I've found, to burn into someone's head that there's no one-true-language, and to get their mind started experimenting with "what if the language was different in way X? Could I code that?" trains of thought.
The most important part in teaching a 13 year old programming is to let him have fun and a give him a sense of achievement. The rest will come.
http://hacketyhack.net/reality/
And Ruby has a number of other benefits:
* Easy web frameworks if he wants to get into that (Rails, Merb, Sinatra, Camping, etc)
* Definitely fulfills the "beautiful syntax" part
* shoes for really easy GUI apps (that are portable, so he can show it off to his lame windows-using friends)
* Built-in powerful regexps for that pattern matching you expressed love for
* It's generally something that you'll run from command line, helping with the learning about Linux part
* Lots of cool libraries out there
* Object-Oriented, which at least for me was a very easy thing for me to grasp (especially compared to functional, which I'm currently trying to learn)
* Awesome
Also, I'd choose a language I like and that I'm familiar with. I think OCaml would definitely be a good start. Strongly typed and strict, lots of possibilities for abstraction, it's all pretty cool. Or teach him (and yourself) Haskell using RWH or something.
If you go for an imperative language then Ruby or Python would probably be a good idea. Those languages are really a lot like English and have a lot of momentum. If you go for Ruby, take a look at http://hackety.org/, I think it's awesome for young programmers.
I'd push him toward PHP.
The goal isn't to make him a great programmer with an amazing language. The goal is to get him doing fun stuff fast, so that he sticks around.
When things are fun, kids stick around.
I'm guessing that many readers here got hooked on a language, not because it was a functional language, but because you could accomplish things quickly.
Introduce him to PHP and work with him on coming up with a very specific project he wants to hammer out. Then you can sit down and walk him through the various phases of putting it together.
Btw, why do you hate C ?
I prefer languages that offers a certain abstraction, languages that allow me to concentrate on the algorithmic part of the program, the core of the application.
then js+jquery with firebug console as repl
Give the Why's Poignant Guide and you can't go wrong. Plus he'll love the cartoons, even if he doesn't get the strangely subtle adult humor.
At 13, he may be too old for it, but Logo was one of my first languages back in elementary school, and I remember being very excited that I could write my own galaxian clone in just a day or so.
Otherwise, I would stay away from JavaScript and Ruby (I like them, but they are hard for beginners) and stick with Python.
(I took a class in which we used NetLogo to run agent-based economics simulations. Lots of fun, although the LISPer in you will start to hate it after a while.)
Heck, there are plenty of situations where exactly this happened, and the programming language was COBOL or Assembly!
Project sprouts (http://www.projectsprouts.com) makes it easy to get started in ActionScript and is also a good introduction to writing support scripts in Ruby.
perl: practicality + fanatically helpful community, and it's in unix's dna javascript: nice skill, something you can make money in if you're good, immediate gratification on web pages haskell (or lisp): get some theory in there. i'd vote haskell because of the community