workshopper / learnyounode

Learn You The Node.js For Much Win! An intro to Node.js via a set of self-guided workshops.
Other
7.25k stars 1.84k forks source link

ES5 and programming style ? #547

Closed samuelpath closed 5 years ago

samuelpath commented 7 years ago

Hi,

I've started the challenges (I've done the first 3) and I've realized that the examples in the challenges description use old style JavaScript (e.g. with var instead of const). Same thing for the official solutions. Moreover, the solutions use imperative techniques (such as looping over an array with for, and incrementing a counter to calculate a sum) instead of using declarative functional style techniques (such as using map/reduce).

Is this by design? Or has the course simply not been updated?

If the latter, I'm willing to help update the course. If the former, what are the reasons?

Cheers :) Samuel

AnshulMalik commented 7 years ago

I was thinking of the same for a while now, What do you think @martinheidegger ?

martinheidegger commented 7 years ago

I can not remember where I have been asked (and answered) this before 😓 Basically I think it this applies:

Workshoppers should only be expected to support the Node.js LTS and Stable releases that are not older than a year.

As far as I know this means Node.js 4 should still be supported! Following node.green this means we should welcome any PR that updates the example code and code style to use features available in Node.js 4.

samuelpath commented 7 years ago

Thx @AnshulMalik & @martinheidegger for your quick responses.

Alright, so this means that language features like const, let & arrow functions are not allowed, but I think array prototype functions like map, filter & reduce should be fine.

However, in this regard, not all developers prefer the declarative style over the imperative one (with essentially for loops and if/else).

Moreover, I'm afraid that this style could scare away beginners, who came to learn Node in particular, not a particular style of programming (the advantage of the traditional imperative style is that it's very easy to understand for anyone).

What do you think about these concerns?

martinheidegger commented 7 years ago

Actually const, let and arrow functions are all supported in Node 4 (its worth to read node.green in detail).

That being said you are right: Beginners struggle with const, etc. and my approach to this is: just because a feature exists doesn't mean it is good to use it. ES6 language features are of various shape and if there is a new function that can make things easier for everyone it is a no-brainer. For the other features (which are likely in the majority) I would still say: we should use them, Node developers will stumble over them at some point and learnyounode should be educational after all.

We should accept any implementation PR that allows to switch on/off es6, it has no priority for me though.

AnshulMalik commented 7 years ago

Let's start supporting es6 features, master branch will continue supporting es5.

All es6changes will go to es6 branch.

shanmukhateja commented 5 years ago

This issue can be closed as it seems it has been resolved. Feel free to re-open it at a later time if you have something to say on this context.