5 ms·
I appreciate the effort that went into this, and it's certainly important to have a good clear reference on JS. Unfortunately, I can't support the effort to aim
by ivraatiems 10y ago
I appreciate the effort that went into this, and it's certainly important to have a good clear reference on JS. Unfortunately, I can't support the effort to aim this at beginners, because I think JS is an extremely poor choice of language for first-time developers. It's poorly designed, with too many side effects and edge cases and confusing behaviors to be a good choice for a first language. It will bog down first-time learners with weird minutiae, and it will do that because it is a poorly/hastily built language that is being used in ways it was never intended for. I realize JS is ubiquitous and easy to access (since all browsers have it), but that doesn't make it the right choice. It's just too broken.
- nickthemagicman 10y agoThis is great. Also wanted to toss out its asynchronous nature is not great for beginners either in my opinion.
- nevon 10y agoWhy not? What language makes dealing with asynchronous problems easier for a beginner? const getTweets = (username) => return fetch(`https://api.twitter.com/${username}`) getTweets('nevon').then(console.log).catch(console.error) Really isn't that bad, although you have to know promises. With regular callbacks, I guess you have to know that functions can be passed as arguments, but you'll have to learn that quite soon regardless. const getTweets = (username, callback) => { const req = new XMLHttpRequest() req.onload = function () { return request.status === 200 ? callback(undefined, JSON.parse(this.responseBody)) : callback(Error(request.statusText)) } req.onerror = callback req.open('get', `https://api.twitter.com/${username}`, true) req.send() } getTweets('nevon', (err, tweets) => { if (err) { console.error(err) } else { console.log(tweets) } }) Most of the confusing crap in there is because of XMLHttpRequest, not asynchronicity. With async functions, which I personally am not a huge fan of, you can get synchronous looking code if you believe that's more beginner friendly: async function getTweets (username) => { const response = await fetch(url) return response.json() } getTweets('nevon').then(console.log).catch(console.error)
- ivraatiems 10y agoI don't think "is this behavior synchronous or asynchronous" is where we should start when teaching new developers, period.
- nickthemagicman 10y agoLol, asynchronous is harder to reason about than synchronous. Plus just about anything goes in the browser. You can put anything anywhere and alot of things are global by default! And as a noob you have enough on your plate learning OOP and REST. I'm glad I started with Ruby and Java and got really good at OOP and clean compartmentalized code before jumping into the madness that is browser land. Just my opinion.
- nickthemagicman 10y agoPassing functions and lambdas and closures is not what newbies are learning...That's like saying: "building bridges isn't hard, you just have to learn kinematics and materials science...But you have to learn that anyway.."
- PrakashBhatta 10y agoWhich language do you suggest for beginners?
- ivraatiems 10y agoI'd suggest something relatively standardized and regimented. Python, C#/Java, even a Lisp variant like Scheme are all decent choices. But of all the languages not to pick, I'd content that JavaScript is one of the very worst. (PHP and anything Visual Basic are honorable mentions.)
- dflock 10y agoAccessibility beats out all other concerns; why is JavaScript so popular and ubiquitous? It doesn't really matter if you like it or not - especially from a 'purity' point of view. 80% of everything is crap. The weird edge cases in JavaScript are easily avoided when teaching a subset of es2016 to new programmers. The basics: variables, loops, functions, etc... are all fine. It's got pretty good functional programming support, too, for beginners.
- ivraatiems 10y agoIn terms of "should one be able to use it," no, it doesn't matter whether I like it or not. A developer who works on the web needs to know JS. That doesn't mean newbie who doesn't know what they want or anything much about development needs to know it, and certainly not that they need to start with it. It's not a "purity" point of view, it's an "ease of use for the purpose" point of view. JavaScript does weird things that stymie experienced devs - a newbie hitting them will be completely lost. What's worse, as I said, is that it does these things because it's poorly designed/its design doesn't adequately cover all the edge cases it should, so newbies will learn the wrong information about why things do or don't happen. The edge cases are not easily avoided because you don't know what a beginner will or won't try to do when working on their own. That means that not only might they do an okay thing in most languages that doesn't work in JS, but that they may also do something BAD that DOES work in JS, because JS is weird. For instance, the way JS handles variable hoisting and scoping is bonkers compared to most other languages - not stuff you can avoid while learning to program, and making it easy to learn the wrong practice as a result. "80% of everything is crap" is a good thing to know when doing development work, but it isn't helpful when learning. The goal of learning in this context is mastery of the basics of development; 80% won't be good enough.
- dflock 10y ago> you don't know what a beginner will or won't try to do when working on their own This is true regardless of which language you use to start with. Computing in general is so ridiculously over-complex and constructed entirely of layered kludges, that beginners are going to trip and fall into lots of these crevasses no matter what, unfortunately. The first lesson advantage of being able to start the coding immediately (everyone has a browser) is not to be dismissed. If you try to do this in Python - otherwise an excellent choice - you will spend the first ~day of the course installing Python and explaining about command lines, editors and the REPL. This seems trivial to us, but it's a huge hurdle for many first time programmers. The JS version of this is "go to this URL, then right click and select Inspect. Start typing in the console."
- bpesquet 10y agohttp://www.stanforddaily.com/2017/02/28/cs-department-updates-introductory-courses/ http://www.stanforddaily.com/2017/02/28/cs-department-update... https://medium.freecodecamp.com/what-programming-language-should-i-learn-first-%CA%87d%C4%B1%C9%B9%C9%94s%C9%90%CA%8C%C9%90%C9%BE-%C9%B9%C7%9D%CA%8Dsu%C9%90-19a33b0a467d#.diy17rcg3 https://medium.freecodecamp.com/what-programming-language-sh... http://prog21.dadgum.com/203.html http://prog21.dadgum.com/203.html To each his own, I guess :)