6 ms·
Ask HN: What's a good programming language to start with?
Well, I'm reading Dive into Python 3, and it's a little filled with jargon (thank goodness for the ease of google). I know a little VB6, but I think it's time to put on my big-boy pants and learn a real, or 'real-er' programming language. Any suggestions?
- blackmac 17y agoI would suggest to learn C. It might sound a little bit strange, but when you consider it, it's probably one of the best things you could do. Most of the modern languages you will need are somewhat based on C. That is especially true for compiled languages, but most script languages take their fair share of C too. You will learn about pointers, which is important in ANY language, binary trees and stacks are good to know about too.
- dkersten 17y agoI disagree. While I think C is a valuable language to learn and I agree with your reasons for learning it, I do not think it should be someones FIRST language. It would make a great second, though. Why? Because C (and C++) has a lot of confusing cruft that a beginner just doesn't need to know about. The noise in the language is too high and too much work is involved in achieving relatively simple things. A higher level language also has quicker returns, which definitely helps keep someone whos just starting out motivated. Most high level languages have better tools to learn with too, like an interactive read-eval-print-loop. I would recommend Python. Not Python 3, but Python 2.6 - better library support. I recommend Python because it takes very little to get working and it comes with everything a beginner would need bundled. When you're learning, you don;t need direct hardware access, you don't need direct OS interfacing, you don't need high performance (and probably wouldn't get it anyway until you learn how to write good, fast C). You DO need to get things done quickly (its hard to learn, otherwise) and you DO need an environment that doesn't require much background knowledge to work in. In Python, a simple program is simple. Theres no need to learn about "main" (and therefore functions), about includes, printf format specifiers and so on - just to write a hello world. As your skill increases, you can gradually add more language features: conditional statements, loops, I/O, functions, data structures, classes, functional programming tools, libraries, metaprogramming. You dont have to deal with manual memory management and you'll get more meaningful error messages than "segfault". You learn a lot about PRGOGRAMMING (rather than having to deal with the low level complexities of C) which can then be applied to almost any language. If you outgrow Python (and I don't think you ever would, I know people who write some amazing stuff in Python, including HIGH PERFORMANCE CODE) you can learn C. I'd recommend it as a second language. Everything you've learned from Python will be applicable in C too. At this stage you should be well versed and pointers should come a lot more easily. You can also use Python and C together - its not even that hard. You could easily replace Python with Ruby in the above, if you prefer. Python and Ruby are pretty much equal players. If you don't mind going a less mainstream, I'd suggest learning Factor: a fast, powerful, very dynamic, native compiled concatenative language. It has pretty much all of lisps powerful features, with some ideas taken from Forth, Smalltalk and others, has an active community and very clean codebase. (The library code is some of the highest quality code ive seen) being stack based, it may take some effort to get into the mindset though.
- timwiseman 17y agoAll excellent points. But remember the original questioner already knew some python and some VB. C is probably an excellent choice for him, though personally I use Python for the vast majority of my code. Of course, my work has morphed to be more system and database administration than programming lately so I may be biased by that.
- Goladus 17y agoThe poster's first language is technically VB6. If you can make the effort, you can learn programming with C. You need good learning materials (which are available), you need to work hard, and you need to focus on learning C rather than trying to cram C into an otherwise generic introduction to programming.
- intellectronica 17y agoI can't imagine how learning C as a first language will be of much value, other than it will be so hard and confusing and slow it will make other options later on seem light and easy. C is a fine language for when you need to do very low-level work, but it lacks most of the abstractions that make modern programming languages so easy to learn and work with. I must say (not for the sake of picking a fight, but because this is the answer to a real person's question) that I think this is not good advice. If you get into programming, sooner or later you might want to learn C, but for now it will only make the experience frustrating for you.
- bluetech 17y agoI learned C as my first language, and there was nothing "confusing" about it. I find C to be quite direct - here's a variable, there's a loop, a function, a struct. Even pointers are straightforward one you know about memory and addresses, and you will need to understand them (conceptually) sooner or later anyway. In fact, the abstractions you mention are what might be confusing for the beginner: Classes, objects, inheritance, polymorphism, iterators, high-order functions, closures, monads, generators, etc. all require as much book- and code-staring as either void or function pointers do for the first time. I do however agree with you that C is harder and much less useful to learn than a "batteries-included", modern language like Python or Ruby as a first language.
- dkersten 17y agoA lot of people learned C as a first language and a lot of these people suggest others to do the same. "It worked for me" syndrome. However, that does NOT make it a _good_ first language. Sure, it can be good enough, but I'd argue that you'd get MORE out of learning a language like Python. Python is, IMHO, a great beginner language because it has all the abstractions, but (unlike Java) does not FORCE you to use them until you're ready to do so. It eases you into the complex concepts. It also shields you from buffer overruns and manual memory management. It gives much more useful errors when things crash and finally, an interactive shell is the best thing ever when learning. You already know that though, since you agreed ;-)
- nico 17y agoThe introductory programming course's language of choice at my university was C. I have mixed feelings about learning C as a first language. I remember the people who go it right from the start benefited the most and got a good base for the rest of their programming learning/experience. But the people who had trouble grasping some concepts of C, got stuck with that and later ended up hating either C or programming altogether. (Disclaimer: this was a class full of all kinds of engineering students, not just CS). Anyway, I think C could be an excellent second language to learn. Starting with something having a similar syntaxis like Javascript could be a good choice and pretty helpful in the future too. Plus, you won't need an IDE, a compiler, setting up a server or a database, only a browser.
- pclark 17y agoRuby
- csbartus 17y agoDefinitely ... it is the latest worth-noting language hitting mainstream today. The most simplistic, user-friendly and well suited for all your tasks.
- Jim_Neath 17y agoAgreed.
- pjonesdotca 17y agoI second that. The value of having a completely object oriented language descended from Smalltalk yet with the meta-programming capabilities (a la Scheme/LISP/Clojure) will allow you to take on more complicated ideas on a smooth path as your skill increases.
- troels 17y agoI like Ruby, but I don't think it's the best beginner language. Too little guidance and too much inconsistency.
- CraigBuchek 17y agoI'd suggest either Ruby or Python. Both have a pretty simple syntax, and are very self-consistent. In other words, there aren't too many rules to remember, and there aren't a lot of exceptions to the rules. I'd say that Ruby is a bit better as far as consistency is concerned, especially in that everything is an object. I think Ruby probably has more advanced topics (especially meta-programming). I'm not sure if that's good or bad for a beginner. It's good in that you can keep learning and use the language for a long time. But it's bad that you won't understand everything for a while. That said, I was able to take advantage of the meta-programming that other people supplied (Ruby on Rails) just fine without understanding it at first. Now that I understand it, I find Ruby to be a very powerful language, while still quite simple to use. To me, it has the perfect balance of simplicity/elegance and power.
- ErrantX 17y agoI'd actually suggest giving Python 2.6 a shot. It's not significantly different BUT in some aspects I think it is a little easier to learn.Incidentally I find the Activestate Programming Network (ASPN: http://aspn.activestate.com/ASPN/Python http://aspn.activestate.com/ASPN/Python) a really useful resource for python learning - especially the cookbook. PHP might be good to learn (so long as you avoid the bad habits it invokes) if you interested in web programming. I know others might scoff a little at that suggestion: but the online documentation is stellar and you can pick up the basics in a few weeks. C is also hellishly useful because it will teach you some core concepts. In fact I would poke around in C anyway whatever you choose - just for "background".
- dkersten 17y agoI would choose Python and Django over PHP, just because its very VERY easy to fall into the "bad habits" trap with PHP. C makes an excellent (and important) SECOND language, but a pretty terrible first, IMHO.
- jokull 17y agoStarting with Django is a bit like learning to snowboard. No pleasure just pain for the first days. Once you get the hang it's bliss.
- ErrantX 17y agoI might bear that in mind andf give it another shot. I much prefer PHP for the area's Django seems to be useful for simply because it was painful to get into!
- jokull 17y agoIt doesn't really feel like you're getting anywhere the first couple of days because there are so many things to get right and learn about. Hang in there, check out the Django book and read tutorials that teach you cool stuff (balance between taking small steps and seeing cool stuff to look forward to). If you're feeling adventurous check out virtualenv right away (Python not Django specific)
- gdp 17y agoIt really depends on your objective. If you want to be able to go out and score yourself a coding job and earn money quickly, any one of PHP, Ruby or Java would be ideal. If you want to become a good enough programmer that it becomes pretty much irrelevant which language you are asked to code in, I would recommend starting with something like Scheme, perhaps with the aid of either: http://en.wikipedia.org/wiki/How_to_Design_Programs http://en.wikipedia.org/wiki/How_to_Design_Programs or http://en.wikipedia.org/wiki/Structure_and_Interpretation_of_Computer_Programs http://en.wikipedia.org/wiki/Structure_and_Interpretation_of...
- intellectronica 17y agoYou're probably better off starting with Python 2.6. Python 3 is not seeing wide use yet, and the Python community is still revolving around Python 2.6, so that's what you'll be able to get lots of help with. IIRC Dive into Python is written for people who already have experience in programming, so it might be a bit hard if you don't, but there quite a few books about learning how to program with Python. You can use many languages to learn, but I'm pretty sure Python is indeed the best choice for a first language.
- dejv 17y agoIt depends on what you want to accomplish, if you want build some real stuff like web apps then I will take Ruby or Python for start. If you want to take this route for taste of programming I will take a Haskell, it is much more easier to start with it if you do not have much experience with imperative paradigm.
- jamongkad 17y agoIf I were to start over again I would have started with Scheme as a good first programming language.
- nopassrecover 17y agoReally? Or is this just because you have learned all the necessary concepts to understand Scheme and why it is an attractive language.
- apgwoz 17y agoThere are many reasons to learn Scheme first: 1. Virtually no syntax, which is often problematic to first time programmers of C-style languages: "You mean I have to have this curly brace here, and this semicolon there?" 2. Only one choice for looping, recursion. Recursion is a fundamental concept in computer science and programming, yet many people do not grasp it. Scheme learning materials will teach you how to write recursive programs the right way. Plus, recursion is a very elegant, and easy to understand way to express many algorithms such as those used in sorting, a common exercise when learning programming. 3. Higher order functions - This makes it easy to teach abstraction. Build small components that do general things (i.e. fold, map, filter). This sort of thing applies to OOP down the road, as well as to every other paradigm. Break things into small units that do one or two things and that's it. 4. Unbounded numeric tower, which means you don't have to focus on things like, "ints can only express up to 2^32 if they are unsigned," which in many courses has to be taught (prematurely, I'd say) to explain why I can't compile or run a program that multiplies the largest numbers I can type. Something the curious will surely try first.
- nopassrecover 17y agoYeah they are all good, but the syntax while more concise is actually more difficult to map to a non programming mindset. Objects in their very naive form area pretty straightforward concept to get (Oh a Car is a type of Vehicle). Iteration is more natural than recursion (I prefer recursion, it's elegant, but it's not how people think to start with). And most users won't run into the boundaries of variables when beginning learning either. The one thing I will give credit is that the syntax is less voodoo, but I still think the ideas of assignment and a mental model of state combined with the imperative "Do this" approach is easier for non-programmers to understand.
- SwellJoe 17y agoPython, Ruby, JavaScript and Perl are all fantastic learning languages. They have good books (Perl probably wins on this count and JavaScript probably loses), good communities (again Perl is awesome with PerlMonks.org, but all of them have good communities), lots of interesting features that will bend your brain in pleasant ways (all are dynamic multi-paradigm languages allowing OO, functional, and imperative programming techniques), while automatically handling all of the stupid tedious stuff that C and Java and C++ and Objective C impose on you, and they are useful real world languages that people use to build real software every day. For sheer ubiquity, JavaScript can't be beat. In five years, I suspect we will all be writing a lot more JavaScript, no matter whether we are frontend web developers or not. But, for now, the backend is still better written in one of the other languages I've mentioned (or PHP). gdp mentioned HTDP and SICP. He's right, though you have to phrase your question differently...because the language of those books is not a language most real world programmers would suggest you learn. And yet, if you want to be a good programmer, there are probably no better resources. The books and lectures are available for free from various (legal) sources, and provide a really solid foundation on which to build your programming skills. I strongly suspect spending 3-6 months on these two resources and learning Scheme would accelerate your development in any other language enough to repay the upfront cost within a year or two. Becoming a programmer is a multi-year investment, so that's a really good deal, even if it looks like the long way around.
- jacquesm 17y agoI suggest you get an 8 bitter, or an atmel or a pic chip and learn how to program on that, as close to the hardware as possible. So, yes, that means assembly. This will give you invaluable insight in how a computer works on the inside, then work your way 'up' from there. That's much easier than to have this feeling that there is this 'magic carpet' that is holding you up in the air but you have no idea how it works. Almost every high level language will make a lot more sense if you come from the basement up.
- plinkplonk 17y ago" but I suggest you get an 8 bitter, or an atmel or a pic chip and learn how to program on that, as close to the hardware as possible. So, yes, that means assembly." This is a great idea! If for some reason you don't want to work with actual hardware, I reccomend this book(http://www1.idc.ac.il/tecs/ http://www1.idc.ac.il/tecs/) . Dr Schocken uses Java to build a variety of emulators all the way from flip flops to a small computer you can write Tetris for, using a compiler you build. A google tech talk based on the book is here http://video.google.com/videoplay?docid=7654043762021156507 http://video.google.com/videoplay?docid=7654043762021156507 "Almost every high level language will make a lot more sense if you come from the basement up." Exactly right.
- joechung 17y agoPython is a real programming language. Keep at it! If you want to learn an advanced programming language, try Haskell, ML (F#), or Lisp (Scheme). C is a good programming language to learn. It can be quite unpleasant to debug C programs though.
- troels 17y ago> It can be quite unpleasant to debug C programs though. Yes, but if you can do that, you can debug anything. Literally - Most high level languages are implemented in C, so debugging them eventually means debugging C code.
- nopassrecover 17y agoYou should go with C#. It uses the classical imperative syntax which lets you learn a whole lot of other languages and is similar abstractly to VB6. It's also got a lot of nicer features that will help you patch towards higher level languages eventually, but it sounds like that is a little too soon for you.
- nudded 17y agoIf you want to wrap your head around OOP and Java, Bluej (bluej.org) is really usefull. It's used in my university (in the first half of the year, then we moved on to netbeans fcourse) to teach us the begins of OOP.
- Goladus 17y agoMy suggestion is to find some problems that you need to solve before picking the language to use. If you already know so Visual Basic, the languages I'd consider learning first, depending on my situation, would be: Javascript C Python Scheme Or maybe: Erlang Haskell OCaml Mythryl I have very little familiarity with the second set, I only recommend them because they have features that are much different from the first set, and if you are interested in a more functional approach it might be helpful to approach it less intellectual baggage from the imperative languages. Also, I only recommend learning C first if you plan to do a serious, thorough study of the language and need it for a low-level project. Get C, A Reference Manual by Harbison and Steele, read the whole thing, and tackle a significant project with that knowledge. You can make progress with a half-assed approach to learning Python. If you try that with C it will be very painful.
- parse_tree 17y agoIt definitely wouldn't be for everyone, but learning assembler first is something to consider (you'd have to enjoy it of course). There's a great, great free book on this, it'll walk you through code and you'll really get a grip on how the computer works: http://download.savannah.gnu.org/releases-noredirect/pgubook/ProgrammingGroundUp-1-0-booksize.pdf http://download.savannah.gnu.org/releases-noredirect/pgubook... I started out trying Scheme, Java, Ruby, etc. and was constantly in a state of confusion. I could never just go with it because I'd always want to understand the implementation of the commands before using them. Ruby was particularly bad - I had no clue how a language or computer worked and was constantly overwhelmed with all of the different options for doing something. Programming in assembler you get a small set of commands that won't take long to memorize, and you'll have to build up from there. It's not as hard core as people make it out to be - when I was really into it, I could produce output in at a similar rate to C. Once you get a little assembler under your belt, you could begin mixing it with C, and you'll get a rock solid grip on C strings, callback functions, pointers, etc. that so many people have trouble with. EDIT to add: Also, using GDB (the Gnu DeBugger) with Emacs text editor is excellent for learning assembler - must use it!
- bbsabelli 17y agoStart with Visual Studio (VS) and program in either vb.net, or preferably c#.net. VS helps a lot while you're learning, and you can choose to program for either windows or the web. Add the MVC framework and you get a fairly decent web development environment where you can then look into JQuery and maybe even SQL. Once you're happy there, a move to Python, PHP, Ruby or Java will be relatively easy. You don't need to know a language like C unless you plan to work with the elders.
- wlievens 17y agoScheme, the SICP way.
- cpr 17y agoWhy not try Squeak? It's a modern Smalltalk with a complete graphical interface, and learning it well will thoroughly warp your mind into the 100% object-oriented approach to computing. (A very useful warp. ;-) It's freely available and runs on all major operating systems. http://www.squeak.org/ http://www.squeak.org/ And then if you get Peter Seibel's "Practical Common Lisp" book and learn Lisp, you'll be completely ruined for any "blub" language like Java or C++. But you'll be light-years ahead of the crowd...
- cpr 17y agoOh, and I should add that you'll be well-prepared for Ruby or Python, if you go this route.
- ogdoad 17y agoIndeed Scheme (and SICP) would be a good choice; at least I wish I knew that back when I started out with C -- can be done, but don't do it. Besides Scheme, Clojure (which is also a LISP) provides the added benefit of having full interoperability with the JVM; I'm currently giving it a try, and it does seem worth the time and effort, quite the humane choice I'd say for a first language. VB6 of course does not count.
- cullenking 17y agoThere are a couple considerations. First, you want a language that is not too intimidating or difficult to start with, or you may fall off the bandwagon. Many programmers broke their ground on languages which allowed them to quickly get something tangible (a reward), like BASIC. Some people don't need this, and can jump straight into a language like C and love it, however only you will know if this suits your personality. The other consideration is to pick a language that has some sort of structure and encourages a good understanding of underlying concepts. Working with C for example, really forces you to know and understand how a computer works. Something like Ruby (my favourite) allows you to easily ignore these inner workings. This has a speed and ease of development advantage, but could be detrimental to your core understanding of CS. I personally love programming with Ruby, however from personal experience I can say the large amount of different programming styles which Ruby can encompass can cause you to write some really odd and sloppy code while you are learning. Additionally, there are an infinite amount of crappy examples of Ruby code, and relatively small amounts of good code. My recommendation if you go the route of Ruby is to ignore many of the articles/blog posts on beginning Ruby (they are drumming up ad traffic), and dig around in the source code. Additionally, you can writ Ruby in a multitude of styles. Flexibility is always good, however, it can lead to some real serious slop. My first year or two of writing programs that were more than simple scripts were with Ruby, and they are some awkward and sloppy programs. However, the pleasure of producing those programs was probably greater than if I had tried to struggle through with something like C. I am lately leaning towards suggesting javascript or actionscript for a first learners language. First off, both have an awesome ability to quickly get you something tangible. They have a really good layout system (mxml or html/css), and you can easily share your creations with others. Both can can be written in a C style, or can be very object oriented. Neither require crazy development environments.
- joeld42 17y agoIf your goal is to get things done in the real world, Python is a great first choice. Learn C/C++ next. Don't listen to these scheme/functional wackos. It's great -- and once you've been programming for a few years you should definitely learn it, it will improve your programming and allow you to think more elegantly about problems. But starting with scheme is like tying sandbags to your ankles and then training for the hurdles -- in theory you'll be able to jump like superman when you take the sandbags off in a few years, but realistically it's just going to make a challenging task even harder. Just my 2c, of course. I started with BASIC, then 6502ASM, them Pascal, then C/C++, then a bit of APL and lisp variants, then Python (which was like a dream), then some more scheme, and now I pretty much stick to Python/C++, with a bit of Javascript on the side.