What programming language should I start with?
Oh no! a non-programmer on the hacker news! But I figure you guys know?
I want to learn programming, maybe not to be a full-fledged hacker, but to be able to understand the concepts and be able to talk about this stuff more with programmers so I can work in tech?
I hear python and ruby are good to learn on, but what would you guys do or are there any good books you'd read?
116 comments
[ 3.2 ms ] story [ 191 ms ] threadOnly in one small segment of the industry (the one that hangs out here). Python jobs in almost every other area are more common. And, of course, Perl is still more popular than both. And PHP and Java and C# dwarf all of the interesting languages.
I'm not saying they're dumb because they're using Ruby. I'm saying they're dumb for hiring based on one language on the resume. I'd hire a great Python/Perl/Java/Lisp programmer to work on a Ruby app before I'd hire a mediocre Ruby programmer. In my own experience, I've seen a great Java developer become an amazing Python developer in the span of a couple of weeks...while a mediocre Python developer could remain a mediocre Python developer for the rest of his days, even though he may have years of Python experience. Being a good developer knows no language boundary (within reason), and the same is true of mediocrity.
When I saw the Auctomatic guys at demo day, they were talking about how easily a Ruby guy they'd just brought on board picked up Smalltalk (obviously the Ruby to Smalltalk gap is smaller than most languages, but the point still stands). Hire good developers, not good X developers, where X is the trendy language of the moment. The language(s) will take care of themselves.
It seriously takes minutes to pick up ruby. In any good team, any decent developer would be productive by the afternoon.
And honestly, who hasn't really looked and noodled with ruby, even if their day job has nothing to do with it (its probably the sign of a decent programmer really isn't it).
I don't think it matters that much what you start with unless you have something in particular in mind you want to do, in which case, no matter what it is, choose Perl :)
Just fine: Ruby. good, but less simple and elegant than Python.
Good if you want to deeply understand the principles of being a programmer but don't care about being very practical at the start: Lisp (yes, Lisp can be practical, but it's trouble for a newbie)
Avoid: Perl, PHP, BASIC variants. These cause brain damage.
SICP uses Scheme (a Lisp dialect) and falls under the "deeply understand but not practical at the start" category.
Many perl mongers, myself among them, would disagree. But maybe the brain damage has set in and I can't judge properly. But, really, you're showing serious ignorance placing Perl in the same sentence as PHP and BASIC. Perl is on the power continuum somewhere just shy of Lisp, and along-side Ruby (possibly even above it; Perl 6 will place it squarely above any other mainstream language on that continuum). Not liking the syntax is no excuse for misleading newbies into thinking Perl is in the same class as PHP.
Anyway, many a developer learned programming with Perl. Some even turned out good.
The real double edged sword for PHP is that it made it very easy to do web programming. The good side of that is that it let a lot of people write web stuff who otherwise might not have been able to. The bad side of that is that a lot of those people write really bad code that is no fun to clean up.
I hear this "easy" term applied to PHP by many people, but when I look at the language itself, I don't see it. PHP is easy for me because I did C for 12 years, but I look at the comp.lang.php newsgroup and see newbies tripping over all sorts of things.
With PHP, it was and is very easy to get started. I wrote about it here some:
http://www.welton.it/articles/scalable_systems.html
There's a tradition of building simple CRUD apps in PHP - a handful of database tables, and a PHP file for each URL that acts as a thin glue layer between raw SQL and HTML presentation. These are some of the easiest Web apps to understand - which is not to say that they are actually easy - and they are a good place to start.
By contrast, learning something like Rails requires a big up-front investment. There are objects. There's a database and an ORM. There's an MVC framework. There's an abstract mapping between URLs and the methods of your controller objects. All of this makes great sense once you can see the big picture, but to a brand-new programmer PHP must look a lot less intimidating.
Down that path lies madness. I've seen the newbie-focused tutorials for PHP, and it explains a lot of the garbage that passes for software in the PHP world. It is entirely possible to write good software in PHP (I'm reasonably impressed by the Dokuwiki and Flyspray code, for example), but you have to learn the language at least twice to get to that point. You learn it as a newbie, and learn horrible practices from the vast collection of misguided "help" in the Internet. You produce lots of code with those horrible practices...like no DB abstraction, inappropriate or no use of objects and encapsulation, and "gradually mix PHP into your HTML" design. And then you realize you've built an unmaintainable mess and start rewriting it with all of the better practices that have since been bolted on to PHP.
Of course, despite all of that I still recommend PHP for a large classes of application because it is pervasive, hard to make pathologically slow (whereas Ruby and Python can be made pathologically slow even by really good developers--see Plone for an example), and has a pretty large selection of libraries (some are so bad as to be counter-productive, but many are good). But as a newbie language it's rather toxic.
But, yeah, PHP is a scary language. In addition to what you've already mentioned, PHP's core "array" datatype appears to have been designed by a committee of drunken camels.
(OK, I know of one stealth mode startup that's going to make it even easier, but that's beside the point.)
You can also try Lisp, but I don't have much experience with it. Lots of video lectures here: http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lec...
The argument is that there are things you can do in certain languages that you can't do with others. This is important because you're taught to think in the capabilities of the language, meaning you won't even know what you're missing in a less powerful language.
If you want to understand how the computer works, Assembly.
Not that it really matters (this is pure religion after all) but the sheer numbers of Java programmers suggest the exact opposite.
Subscribe to lots of blogs from each community. (Many of them have planet aggregators like "Planet Python" and "Planet Ruby".) Also visit local user groups, wherever your are.
Read/visit them for a while -- say a month or two. Whichever community makes you go, "wow, that's cool" -- join that community and learn the language. You can also interact with those communities via Google Groups.
Lots of people will say -- "that's easy" or "this is elegant" or "that language sucks". Feel free to ignore them.
Mainly, concentrate on learning the technology and not a programming language. Programming languages are just tools for a specific job. By technology I mean, web programming, server/client, application, embedded, etc. Each industry has it's own language and you have to know the technology to speak their language.
Best Option: Figure out what program you want to write and then find out which language you should write it in.
Objective-C and Cocoa are going to be your best bet for learning application programming, but you have to have a Mac. Otherwise, learn Java. It's somewhat simpler than C/C++ because of memory issues.
Microsoft stuff is not an option as it will teach you very very bad things.
If you want to be really hard-core, learn C++ and Assembly ( x86 architecture ). But to be even half-way decent at those will take a lot of time and a lot of reading on how to do it right.
Conclusion: Buy a Mac and learn Cocoa :)
That book doesn't teach you to program. It is a survey of 'best practices' that may help someone who already has some proficiency.
If you want to get stuff done quickly, learn Python or Ruby.
I only recommend learning C first if you have handy: an excellent instructor or an excellent book-- preferably both. I might also recommend C if you already know a lot about how computers work architecturally but don't know much about languages.
With python and ruby, just go to www.python.org or www.ruby-lang.org. Several good resources have been mentioned for Scheme. In those cases, you'll get familiar with the basic idea of telling the computer what to do, as well as fundamentals like expressions and abstractions. Going the SICP+Scheme route will introduce you to recursion and high-order functions fairly quickly, while Ruby and Python have all sorts of practical libraries. Interpreters for Javascript are more readily available than C compilers, though at the moment I can't recommend an ideal place to go learn about it. JS is everywhere though.
I love C, and think that an undergraduate Computer Science curriculum should require learning it early on. But for someone who wants to learn to hack on their own, C is probably not the best choice.
Would you rather start programming on the surface (not knowing what is happening underneath) or would you rather start by learning the hard stuff underneath? I, personally, would rather know what is happening underneath. Is there an argument for learning the more surface stuff first? Maybe I'm off nuts and have a slanted view because I learned Java, Scheme and then C.
C is a valuable language for a large class of problems. But don't learn it unless you want to be a real serious systems-level software engineer. If you just want to write software for the web (even large-scale apps), don't waste months on the intricacies of pointer arithmetic and memory management.
That said, I learned C, and it didn't hurt me any. But I doubt it really helped much either.
And, as the learner makes progress, he can start to go deep into the functional side of the language.
It seems to be a nice fit for the case, indeed. Python would be my second best.
Implementations and libraries are a drawback. I think the best way to learn a language is to build something interesting using it, and the only thing that's easy to build with Javascript these days is the client-side part of a website. Doing that also requires CSS and HTML, which the OP should probably learn a bit about, but it might be distracting to do that while he's trying to learn the fundamentals of programming. Trying to learn Emacs at the same time I was learning Lisp was distracting for me. I don't think browser incompatibilities are a reason to shun JS; unless you're building something for a website used by the general public, just target Firefox. Use Firebug to learn what's going on with your code and track down problems. Once you know what you're doing, it's more tedious than difficult to get it working on other browsers.
If you already know how to make web pages, or really want to learn, JS is probably a good choice. If not, it probably isn't. It's probably best to can figure out what sort of project you'd like to build, and then learn a language well-suited to building it.
It's possible to use Javascript for other purposes, but it's not yet easy. In a couple years, that might change - Steve Yegge seems to think it's the "next big language".
For a first language, look at Python/Ruby and choose what you're most comfortable with.
On the other side, using only Javascript with a stand-alone interpreter would be a nice.
I would go for Logo.
[edit: a couple of spelling mistake]
I was also introduced to OO (of sorts) through JS... I perhaps wouldn't recommend this so much, it was incredibly confusing for me at first. I didn't have any real grounding in OO principles before I started though, so perhaps that would have helped.
I happened to listen to a talk Marc Andreessen did called , "2005: A Web Odyssey" <http://osc.gigavox.com/shows/detail994.html>; where Andreessen talks about commodity hardware and how it effects programming language choice.
"... programming has moved from being machine dependent and complicated to become a dynamic and easy-to-learn process ..."
Andreessen talks about how languages are moving up the ladder from machine languages to "high level, dynamic languages" by looking at increasingly comoditised, powerful hardware. He notes that Java should now be thought of as a system language. JS in browsers was created in '95 to bridge the gap b/w HTML & Java. Java was deemed too complicated for HTML users. The original idea was JS to be server side. But it never took off due to lack of effort by Netscape to create an Open source version and the tool problems.
"PHP is to 2005 what Java is to 1995"
A lot of the talk he talks about how "PHP is to 2005 what Java is to 1995" The talk was done in 2005. So for Andressen PHP or PHP like languages (Ruby, Python etc) are what he suggests. But right near the end of the talk he talks about Sajax and JPSpan where server side PHP (python,perl) transparently talks to higher level JS code in the browser.
You can find more about Sajax and JPSpan following:
- Sajax http://www.modernmethod.com/sajax
- JPSpan http://sourceforge.net/projects/jpspan
I think most people starting out with Javascript would learn how to do stuff in a browser but not how to "program".
If I knew them well enough to choose one, my pick would be whatever makes it easiest to write simple programs. Building confidence is the most important thing, not conceptual elegance. I wrote most of my first programs in old fashioned Basic. It was a kludge of a language, but it was good for writing the dumb little programs I started with. The worry that people will form bad habits from using ugly languages is overblown.
The development environment is easy to find, obviously...any browser and any plain text editor. But user interaction is hard, and gets all mixed up with nasty DOM and browser incompatibilities in short order. You also have to have additional tools (like Firebug) to get anything resembling useful errors from JavaScript.
A good modern learning language probably ought to have an interactive shell. Ruby, Python, Scheme, and Smalltalk are probably all good choices. JavaScript can have an interactive shell in the form of FireBug...but again, it's scary when you get to doing anything that interacts with the user and very few tutorials of JavaScript cover interacting with JavaScript interactively. Having the knobs do something immediately when you twiddle them is almost certain to speed up the learning process. The human mind is pretty good at abstract reasoning: "flipping this light switch causes the light to come on over there". But the more you separate things out temporally and the more variables involved the less they stick: "flipping this light switch starts a timer, which depending on the current state of the light, will cause it to turn on or off in three minutes".
Merely being a non-compiled language is still a slower iterative process than direct interaction (which is the primary disqualifying point against Perl as a learning language in my opinion...corrected in Perl 6, of course, but that's still a few months out). The shorter the "try, debug, try again" cycle is the faster one picks things up, I think. I found Ruby very fast to learn, to some degree, for that reason. Python was almost as discoverable, though I found it less intuitive, where "intuitive" is probably defined as "kinda like what I'm used to". PLT Scheme was a pretty cool learning experience, but it became less interesting as soon as I wanted to build something useful with it--so few libraries (of course, as a Perl user, I feel that way about every language other than Perl...CPAN spoils you for all other languages when it comes to "just get it working" prototyping).
That said, I think in the end JavaScript is going to be the world's most popular language for almost everything, including web applications. I happen to agree with Yegge in that regard. But it's still somewhat less friendly to learners than the other languages I mentioned.
Anyway, if Rhino (or some other standalone JavaScript engine) becomes popular I'd reckon that in a year there will be some good tutorials for interactive JavaScript, and it'll become a great choice for learning programming. I happen to think JavaScript is a very pretty language. A few confusing quirks (Function vs. function vs. = {}(); modules, for example), but overall it offers some great functionality in a pretty simple syntax and low keyword manner.
For people who aren't as confident in their math, I would recommend Python, as other have mentioned. It's thoroughly friendly to newcomers, there's tons of good documentation (the free tutorial written by Guido is incredible), the libraries are among the best available, and, like Scheme, it's easy to start by biting off a manageable chunk and then gradually learning more details as you go.
Functional JS rocks. And the fact that you can examine other peoples' programs with FireBug is huge.
The first question to ask is, "What would I enjoy creating? A website? A video game?"
Based on that answer, you then choose the best tool for the job. Depending on the answer, you may only have one choice.
I'm in the middle of a four-month vacation, but progress is pathetic. Lisp in a box and Practical Common Lisp aren't helping me stay on task. The look like they're made for guys who are learning their sixth programming language.
If you're looking to learn Lisp, try to find something ostensibly beginner-friendly.
The Structure and Interpretation of Computer Programs is a great book for learning the fundamentals of programming. It happens to use Scheme, a dialect of Lisp. If you want an academic introduction to programming, it's one of the best. I haven't found anything as good that takes a more pragmatic "let's build something useful/fun and learn to program in the process" approach, but I bet someone else here has.
Test out that understanding. I bet you know more than you think you know. The purpose of a book like PCL is to be a reference. Scan it properly and go back to it when you need to find something. Intially it will take sometime, then your brain will learn and you won't be looking up so often.
To learning lisp I recommend: http://www.cse.buffalo.edu/pub/WWW/faculty/shapiro/Commonlis...
Notes: YOU HAVE TO DO ALL EXERCISES. Just reading the book teaches you very little.
After this, you can go and read On Lisp (the Uber-Programmer Lisp book) and understand it perfectly in the first read.
In C, if you're wrong, chances are your program either won't compile or it'll give you a nice segfault or bus error.
In something like Javascript, you can easily be "wrong" every time because you don't understand an aspect of the language, and still have your program "work" 9 times out of 10.
If your logic is wrong then yes, it doesn't make a difference what language you're using, but that's not what I was talking about.
Then, once you've got your feet wet, learn another one. I feel like I never understood one language until I could compare it to another.
Python and Ruby are great for hammering out functionality and learning. Common Lisp/Scheme are great for widening your perception of how problems can be solved. I don't want to say much about C because I'm not proficient with it, but it definitely gives you a closer feeling to how your computer runs your code even if it obfuscates the problem a little. Learn Haskell/OCaml when you're feeling lucky. They will break your brain and then rebuild it in crazy, inventive new ways.
As for mind expanding, I like Scheme - as taught by MIT in the SICP series (you can watch the videos on google video). It would be interesting to see that taught to someone new to programming (sorry to make an experiment of you !). Someone tried to teach this stuff (kind of) to me once in miranda (didn't work to well as a first programming language).
As for practical messy stuff, then look into Java (for basic static strong typing and endless tools) and Perl if you must, the basics of C to wrap your head around pointers may help - I learned that around the same time as motorola assembler (much nicer then intel) and it helped form a mental model of 'on the metal' computation which I found helpful.
Another angle: Haskell seems to be popular for functional programming (as it is pure) - many people think functional's time has come, and there are some useful videos introducing it here: http://sequence.complete.org/hwn/20070807
Stick to things where you can get all the tools you need for free on the platform you use (and they are easy to get running).
As for mind expanding, I like scheme - as taught by MIT in the SICP series (you can watch the videos on google video). It would be interesting to see that taught to someone new to programming (sorry to make an experiment of you !).
As for practical messy stuff, then look into Java (for basic static strong typing and endless tools), Perl if you must.
Another angle: Haskell seems to be popular for functional programming (as it is pure) - many people think functional's time has come, and there are some useful videos introducing it here: http://sequence.complete.org/hwn/20070807
Stick to things where you can get all the tools you need for free on the platform you use (and they are easy to get running).
Also, many "tricky" Haskell concepts (algebraic data types, lexical closures, first-class functions, programming without state) are actually quite logical if you've never been exposed to the C/Java way of programming.
Miranda was the first language I ever learnt. I am the only person who I know who learned a strict functional language from the get go. And yes, it scared and confused the heck out of me :( I am not sure if it helps, but at least I (only now) have a appreciation for the mathematical side of functions/functional programming (has taken me 10 years to get here though).
http://docs.python.org/dev/
http://www.scala-lang.org/
My recommendation: Get the book "How to Design Programs". You can check it out at www.htdp.org first.
http://www.multicians.org/thvv/boyd.html
...but I think it's more suitable when kids are younger. If you're old enough, you probably want to get web pages up and running faster than you could with bare wires.
Even if it's for you, you may want to check out The Little Schemer first. It's an easy, wonderful and enjoyable way to get introduced into programming. Don't spoil it by looking elsewhere first. :)
[Edit: How to Design Programs (HtDP) is probably a good one to try after The Little Schemer. That one too is best if you read it as a beginner, because it tends to hold your hand a lot, and you'll have less patience for that when you consider yourself more expert.
These three books are a strong reason to consider Scheme.]
Given your current motivation, I think you'd be better off figuring out what kind of languages the programmers you'll be interacting with use, so you don't learn something that is too different.
If you don't know those programmers yet, do you know anyone that could mentor you, or at least anyone who you could bug with questions often enough? If so, ask them about what language they'd be most comfortable helping you with. Having someone to rescue you when you get stuck will probably help you more than any qualities of the languages themselves.
Failing all of the above, and if you can't get over the notation of Scheme, you can't go very wrong with Python. It's a piece of cake to get started with, it has a great joy to WTF ratio, it looks less alien than the Lisps for most programmers, and it's a very practical and powerful language for the future.
Today, I would probably recommend JavaScript with the browser DOM.
Lisp is so much easier for them, that I think that your statements do not take into account familiarity and most people are just being too used to a particular syntax.
SICP is a hard book to read, however. There are much easier books to learn Lisp.