Live data from Hacker News

Ask HN: JavaScript as a first language?

news.ycombinator.com

1–10 of 15 posts

Ask HN: JavaScript as a first language?

#1
Little background, been working in startups for the last couple of years, mainly in marketing and sales. Recently started my own Magento ecommerce store that's essentially sustaining me passively so i'm looking at spending some time learning to code.

Question is, is there any reason not to pick javascript as a first language? Been hearing alot about Node.js and Meteor, any downsides to picking it over something like ruby?

Would be great to hear your thoughts.

Re: Ask HN: JavaScript as a first language?

#2
Well if someone asks me then I would never ever recommend him to pick javascript as his first language. Actually javascript is a very different language as compared to other languages, its a prototype based language which is not easy to swallow at first, I have seen many experienced developers who have been into web-development for years using either PHP or Rails even .Net but they are really weak when it comes to javascript. I would recommend you to pick up either PHP (which is really easy to understand) or ruby.

let see what others say

Re: Ask HN: JavaScript as a first language?

#3
Not JavaScript – Prototypal inheritance is interesting and powerful. However, overall JavaScript does not afford good programming practices and does not cleanly expose important re-usable programming concepts. Between the good parts of JavaScript, there are nasty surprises.

I think python is a good first language for a few reasons.

1. Overall the syntax is clean, concise, and readable in the sense that the actual code can be close to "sudo" code, or that it is somewhat similar to what what you might encounter in a mathematics class.

2. From Wikipedia:

"Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive standard library."

All of those programming paradigms are important to understand and few languages capture all of them as nicely as python. Also, static typing and memory management are important to understand – yet, mostly distracting while learning a first language. Python removes the distraction.

3. Python's strict white space rules will force you maintain a somewhat consistent code style – something that many new programmers are awful at.

This list is not exhaustive, just some thoughts.

Re: Ask HN: JavaScript as a first language?

#4
JavaScript is not even a good second or third language. Of course it is easy to cut and paste code and hack things. But when it doesn't work right you will go crazy trying to work out why.

To be good with JavaScript you need a rather substantial and solid grasp of CS fundamentals and how they are implemented in languages that are stricter about what they will accept and how.

In JavaScript there are too many situations where it either does something totally unexpected (well actually totally logical, but you need to know some pretty arcane stuff to see it that way) or it just fails silently or less likely with a terse exception.

For a beginning programmer that is very little feedback to help with overcoming the initial roadblock. Sometimes called the "getting helloworld to run problem". Trying to learn JS in a browser context is made even more difficult because you need to grapple with the DOM - it is not easy to grok at the best of times.

If you decide to ignore the advice in this and the other posts and go ahead learning JavaScript as the first language, then I suggest getting a very good introductory book and perhaps using Developer JavaScript Console. The debugger is good in that you can single step code and watch variables as they change. You will probably need to take copious notes to understand what is going on.

To be a competent programmer is more than learning a language, it requires a solid foundation in computer science and software engineering. Whilst these topics can be learnt from a book, most people need guidance from those who have acquired such knowledge. Whether they can be bothered answering newbie's questions is another matter.

Re: Ask HN: JavaScript as a first language?

#5
post #3

Not JavaScript – Prototypal inheritance is interesting and powerful. However, overall JavaScript does not afford good programming practices and does not cleanly expose important re-usable programming concepts. Between the good parts of JavaScript, there are nasty surprises. I think python is a good first language for a few reasons. 1. Overall the syntax is clean, concise, and readable in the sense that the actual cod…

+1 (wish I could have clicked +10) Python is increasingly being used in first programming language courses at many top-level universities and colleges. Learning good code structuring habits has considerable value down the track.

Re: Ask HN: JavaScript as a first language?

#6
Look at "hello world" in Javascript and Python. Then look at "ask user for their name and display "Hello user's name"" in Python and Javascript.

https://wiki.python.org/moin/SimplePrograms

    name = raw_input('What is your name?\n')
    print 'Hi, %s.' % name
http://www.utexas.edu/learn/javascript/example1.html

    var who = window.prompt("What is your name");
    document.write("Hello " + who);

The complication in the Javascript example are the window.prompt and document.write parts which make Javascript harder for beginners to learn.

Re: Ask HN: JavaScript as a first language?

#7
In my experience, the answer to this question largely depends on what your ultimate goals are.

Want to become a competent programmer and do that for a living? The advice in this thread is solid (particularly @CyberFonic's).

If you simply want to hack/glue-up/play around with some side projects, I once heard someone suggest you pick the language your close friends know best and buy them lots of beer.

In my case, I needed a newbie-friendly prototyping tool and JavaScript/Meteor has served me well.

So, give us an idea of your goals, and I'm sure the community here will be able to steer you in the right direction.

Re: Ask HN: JavaScript as a first language?

#8

JavaScript is not even a good second or third language. Of course it is easy to cut and paste code and hack things. But when it doesn't work right you will go crazy trying to work out why. To be good with JavaScript you need a rather substantial and solid grasp of CS fundamentals and how they are implemented in languages that are stricter about what they will accept and how. In JavaScript there are too many situation…

What you're saying is pretty accurate and I agree. But the problems you enumerate are ironically the best parts about learning JavaScript at the same time.

Failing silently - it's nice to have 'incorrect' programs still do stuff when learning. Who wants to spend hours tracking problems they cannot even comprehend? Figuring out the DOM - tricky indeed. But it's at least superficially familiar to everyone. Browsers have great tools to inspect and play around with it. You have to learn so much more of insert other language to output to the DOM (or other graphical environments).

My advice: Learn underscore. Always refer to Mozilla's docs first (avoid w3schools). Learn ins and outs of Chrome DevTools (or the FF equivalent).

If you end up wanting to choose a different language - either go lower-level (Go, Java, Swift, C-family etc) or higher-level (any LISP pretty much).

Re: Ask HN: JavaScript as a first language?

#9
I would recommend . . . I would start with this progression . . . HTML->CSS->Javascript then PHP/MySQL then once you have a handle on creating a simple web app with PHP/MySQL look at either Rails/Ruby or Laravel/PHP . . . it's tough to understand all the magic going on in Rails/Laravel till you've created a basic app from scratch Login/Logout/CRUD etc . . .

Railscasts.com and Laracasts.com are great tools for learning those. But get a decent foundation before moving to a framework . . . then you can add things like Angular on top of your app.

Post reply on HN