Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

A friend of mine seeks to learn Javascript programming but he never programmed before. I've found Python as a quite nice language that takes most unneeded "strangeness" out of learning programming while remaining useful. Personally my first language was Pascal and while experimented a little with C++, C, Java, C#, Php and Javascript, I then found Python and this is actually what I most of the time use for years. I find Python a good language to introduce most programming concepts in a way where you can focus on the concept and not on the language. Actually imho Python has only 1 big gotcha, the significant whitespace, while other languages often feature more that is unnecessary when introducing today's programming itself (like overhead, pointers, implicit conversions, operator overloading, etc.). I've also heard that many instructors use this language to introduce programming concepts, and I tend to agree with this choice.

As Javascript has it's own strenghts and weaknesses as an programming-introductory language, I wondered whether it's worth considering using Python instead for learning programming and then learn Javascript, when you already understand many programming concepts.

I'm not used to teaching, so I would ask ones who are, what pros and cons would teaching Python first have over teaching Javascript right away, for a newcomer to programming?

share|improve this question

closed as off-topic by gnat, Bart van Ingen Schenau, Kilian Foth, GlenH7, Robert Harvey Dec 5 '13 at 18:50

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "Questions seeking career or education advice are off topic on Programmers. They are only meaningful to the asker and do not generate lasting value for the broader programming community. Furthermore, in most cases, any answer is going to be a subjective opinion that may not take into account all the nuances of a (your) particular circumstance." – gnat, Robert Harvey
  • "Questions about what language, technology, or project one should take up next are off topic on Programmers, as they can only attract subjective opinions for answers. There are too many individual factors behind the question to create answers that will have lasting value. You may be able to get help in The Whiteboard, our chat room." – Bart van Ingen Schenau, Kilian Foth, GlenH7
If this question can be reworded to fit the rules in the help center, please edit the question.

www.codeacademy.com makes learning introductory javascript very easy. With the new learning materials out there, I'd say that both javascript and python are amongst the easiest languages to get started with. –  Racheet Jun 13 '13 at 10:33
Why does your friend want to learn javascript? If it's for the DOM, then there's no other way. –  Florian Margaine Jun 13 '13 at 11:51
@FlorianMargaine his main interest is clearly design (with css + html5), but he wants to have an overview of web development in order to be effective in that. (As Lego' said it, 'cool webpages', and webpages as art. He has good technical affinity.) –  naxa Jun 13 '13 at 21:47
Python has several features that make it a particularly good choice among scripting languages as a first computer programming language. –  Paulo Scardine Dec 5 '13 at 4:35

4 Answers 4

Given a few days to learn the syntax, a good programmer should be able to code in any language.

Putting aside my personal preference for Python, there are a few key factors that will influence your friends first language.

  1. If you are the teacher, teach a language you know - If your friend knows no programming, they need some one who knows what they are doing. If you are teaching the basic - loops, ifs variable assignment - these can all be taught in any language. So if you know Python, consider just teaching them Python...
  2. Don't teach them to be an X developer - My favourite language is Python, but I'm not a Python developer, I'm just a developer. I can code Python, C, Javascript (and reluctantly do so in Java). Teach your friend that although they want to learn Javascript, what they really want to do is learn programming. So reinforce the fact that regardless of the language they learn in step 1, they are really learning Javascript (and C and Java and Haskell, etc...)
  3. Teach a language that will be helpful - Your friend wants to learn Javascript, but what they really want to learn is how to make 'cool web pages'. Like you, I like Python, but maybe thats not the ideal language, as Python won't be helpful for "dynamic webpages". Maybe consider Coffeescript as an alternative, and make sure you are teaching a language that is useful. The last thing you want is your friend getting scared off because they couldn't do hat they wanted straight away. However, if they get that they need learn the basics first push for Python.
share|improve this answer
hmm it take more than learning the syntax to code properly in a language though –  jk. Jun 13 '13 at 11:53
Really good point, more managers should see programming as such. The only point I am not totally with you is using a meta-programming language as a learning base (CoffeeScript) –  JF Dion Jun 13 '13 at 14:58
While the post is nice overall, the first sentence is so out of whack with reality I had to downvote. For someone who was exposed only to e.g. C grasping the ideas behind Python or Javascript is a mental strain, and ideas behind Lisp or Erlang or Haskell is a serious work, not a few days' exercise. And conversely, someone who only dealt with Python or JS needs time and effort to get the idea of static checking and strong typing of e.g. Java, let alone Scala. See, the question is about beginners, not well-rounded experts. I wish that first statement did not mar your otherwise good answer. –  9000 Dec 5 '13 at 6:32
@9000 You can write code that works in any language without fully comprehending the depth of it. But you can't fully comprehend a dynamically typed language without understanding the concept of types in general. Transitioning to C from JS is a lot easier than transitioning to Java or C#, IMO. JS and C don't try to protect you from yourself. –  Erik Reppen Dec 5 '13 at 8:11
@ErikReppen: definitely, you don't need the whole depth, but usually it's basic things that are done differently (in programs more complex than "hello world"). For instance, JS (or Go) makes you create a lot of small, locally defined and sometimes deeply nested functions, very unlike C. In JS, a hash lookup and a member access are essentially the same thing, and everything is malleable. You need to wrap your head around these new concepts before you can be productive and understand others' code. –  9000 Dec 5 '13 at 12:38

I came from Pascal, C background and then went for JavaScript and only then to Python.

Whitespace is like a religion and I hated it in Python for around 2 days. After that I felt it's good as it is so it's not a major point.

I would recommend Python as JavaScript has it's quirks and can make a beginner a little confused:

  • Incompatible browsers
  • DOM
  • Forgiving syntax
  • Hacks everywhere
  • Can be launched through console via node which for a beginner adds just more complexity imho.

I would say - stick to Python as you can build great things with it and you can find a lot of courses online as well as books guiding you through data structures and algorithms with it which is a breaking point for a beginner to understand inner workings of software.

share|improve this answer
+1 for the list of potential confusers! –  naxa Jun 13 '13 at 11:26
@naxa thanks, These are the first ones that pop in my head. JS development should not be confused. It's harder than it looks and on the other side you must be familiar with HTML and CSS if you want to output something –  lukas.pukenis Jun 13 '13 at 11:29
right html/css knowledge is an aspect too! Made me think about: Personally I yet to find a good workflow for debugging js, ajax and php together. Things like your list or this kind of debugging difficulty may be separated from the inherent difficulty of learning programming first. –  naxa Jun 13 '13 at 11:38

IMO Python is a perfect learning language (though the first versions were smaller so better...). One can learn the basics pretty fast, and it's even good to use for many purposes in development.

As it has strong support for functional style it's indeed good for demonstration of concepts too.

JS can be learnt as on top of it without problems. I second your idea.

share|improve this answer
I agree with this; Python is a good choice here not because of any similarity to Javascript, but because it's a good "learning language". You'll have to get used to Javascript's unique aspects no matter which language you go with first. It's also best if you can find an IDE that will give you immediate feedback for syntax errors. Theoretically, even Notepad++ would do this for you pretty well. –  Katana314 Jun 13 '13 at 13:27

I learned JS first and know it considerably better but I like both. Both languages have a lot of things in common that IMO, are great for learning.

Both JS and Python are good for learning because:

  • Readily accessible console environments that are easy to execute and get output from code in. IMO, it is so much easier for a new dev to learn the basics by just trying stuff out to see what happens without having to compile or install some ridiculous IDE, etc...

  • Both communities are heavy-hitters in cross-platform code with JS devs coming from a legacy of IE shenanigans and other cross-browser issues (primarily with the DOM API) and Python devs tending to write things that work great in every OS. It is a value every coding culture should respect. If you're not writing C/C++ or assembly, there is no reason for your app to only work okay on one platform with the vast majority of modern languages IMO. My biggest beef with Rails as a framework, the JVM, or .NET in its very design, is that I can't run any of them on every popular system flawlessly almost every time. I've come to expect this of popular JS and Python solutions and the world would be a better place if every new dev expected this of everything.

  • Both have dynamic type systems. Dynamic types hurt more when you do it wrong. They help you smash through all kinds of needless complexity with less code when you do it right. And by right/wrong, I mean stuff that helps/hinders you in any language paradigm. Stuff like not letting 20 different things put their hands on the same set of data. Static types have design-tradeoff advantages (IMO, performance primarily) but I think dynamic introduces you to the consequences of crap-code a lot faster than static + gigantor IDE does.

  • Both are strong "glue language" options, although I suspect Python trumps JS on this front. Regardless, either will likely expose you to a lot of different coding paradigms. JS wins on that front for all the server-side stuff you'll look at eventually if you're curious enough.

I would recommend JS for several reasons:

  • The DOM API. Yes, it's butt ugly, but it's also highly accessible and it's right there, ready to access and tinker with, at any time on any modern computer. Separation of concerns? Loose coupling? A lot of client-side web devs learn these things by instinct before they even have the labels to apply. More important is all the stupid int0rn3tz pranks you can play on friends and relatives with no harm that can't be undone with a page refresh. Consoles are great but having such easy access to GUI behavior in a ubiquitous environment (browsers) is awesome.

  • Proper first-class functions. The benefits of being able to pass functions around like candy, take advantage of closures, etc... are pretty big when you know how to leverage them. I don't know what the state of Lambdas vs JS first-class funcs when compared to Python 3 is yet but JS certainly had Python beat on that front when compared to version 2 and functional programming is a topic worthy of investigation in any language where it's possible.

  • The web never relents - You don't get to stop learning. This is true of any programming career but it changes faster on the web than in any other programming paradigm. I did no web UI for a year and was amazed at how many little new things I was a little behind the curve on.

  • You want your own coding paradigm - JS is like sculpey basically. Once you know enough about it you can really implement solutions to problems in damn near any fashion you want if you're not overly bothered by semis, var decs, and curly-brackets.

  • I can't lay claim to empircal evidence her but based on experience I'm pretty sure most JS devs are more comfortable with Python than Python devs are with JS typically. Better to start with JS friends, IMO and : P at the snootier elements in the Python crowd.

Good reasons to pick Python:

  • Desktop OS Stuff - Node's great but I doubt we have the coverage that Python devs do on that front. You better believe we're catching up fast, but they had a good decade plus of a head start to write desktop OS stuff and they've been kicking ass at it.

  • You're not at all okay with ambiguity - JS and I think UI devs perhaps in general are a lot more comfortable with the idea of there being 20 different ways to do the same thing and it being hard to say which one is best in every single given circumstance. This does not at all align with the whole "Pythonic" thing. IMO, there's good and bad things about both philosophies but few Python devs would indulge in such ambiguity : ) I think it has a lot to do with JS being a language of primarily UI developers who had to handle 5-20 different interpretations of their own code for every little thing they did for JS's first 15 years of heavy use or so. To be fair, Python devs at the median level probably arrive at an efficient solution faster than your typical JS dev at a similar level.

  • Much stronger peer review - Once you know a fair bit about what you're doing in web UI you will see that the vast majority of jQuery plug-ins and DOM-related libraries in general are complete and utter crap. There's plenty of crap in Python too, I'm sure, but you're not going to run into really nasty junk if you go browsing around on the official Python site for modules to use. Whereas in JS, the matter of what is actually "official" requires some elaboration. You can be bad at Python and still shop for mostly good stuff. This is less true of JS and I'm very sad to report that DynamicDrive still exists (I just checked).

Best Reason to Learn Both Eventually:

  • Very different syntaxes - I would recommend learning any language that works for you. But after a year or so, take a few to stop and learn another language that looks nothing like the one you're used to. JS and Python have enough differences that you'll learn to appreciate the peculiarities and strengths/weaknesses/tradeoffs of each a lot more by knowing both but you'll have a lot of ideas about how to go about learning that aren't likely to trip you up moving from one to the other. It became much easier for me to learn other languages after getting pretty good at implementing stuff with JS and then learning some Python. Now I'm entry to jr-level comfortable at Java, C#, and a little Rails and PHP as well but I really want to master C and then C++ so I can finally figure out why those guys hate each other so much.
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.