r/javascript • • Jul 26 '17

The JavaScript Way, a new book for learning modern JS from scratch

https://github.com/bpesquet/thejsway
401 Upvotes

36 comments sorted by

3

u/Amos47 Jul 26 '17

I'm curious why you think starting at the front end, and doing a small piece on node later is the right way to go?

I've been instructing new people to build some basic node APIs then build an index page, then do some JS on that as the buildup to a full web app.

8

u/bpesquet Jul 27 '17

This is definitely another valid approach.

I considered it but went back to the conventional route for a number of reasons, among which:

  • Dealing with Node upfront (installation, asynchronicity, modules, etc) might be overwhelming for a complete beginner.

  • It's not easy to handle user input in Node.

  • Many people are drawn to JS for front-end dev and won't touch Node until some time.

Out of curiosity, did your students had any prior programming experience ?

1

u/Amos47 Jul 27 '17

I do typically have them run through some JS stuff on CodeAcademy or plunker or something like that to get the feel for it before the setup process.

I just try and avoid introducing the DOM and things like that until they have some experience writing logic.

I also try and introduce CRUD before front end JS, since you mostly need that concept to unlock front-end potential, but that depends on the student's experience if I do ajax style SPA or just a straight html web server.

6

u/jax024 Jul 27 '17

I agree. Strictly speaking, node is the best way to learn JS. Front end is more memorization then learning to get a feel for the language. Honestly the comnination of node and react made me learn the language, and best practices.

1

u/compacct27 Jul 27 '17

did you start from no programming knowledge and dive into node and then react? I'm teaching a few people and am taking them through important HTML/CSS concepts first

1

u/jax024 Jul 27 '17

No I started with an HTML/CSS background.

10

u/On3iRo Jul 26 '17

This looks pretty good. I will definitely recommend this to js beginners. Thanks for sharing.

8

u/dangerzone2 Jul 26 '17

This looks looks like a great intro! However, I really wish these intro docs would also implement namespaces. Otherwise you're just cluttering the global namespace and asking for trouble if jumping in or creating a larger'ish project.

2

u/XVsw5AFz Jul 27 '17

I'd be careful with that. We're currently in the middle of upgrading a very large application that used a homegrown namespacing system. It was using an older grunt based simple concat/minification build pipeline where everything had to be put in the right order etc. Taking this system and moving it to webpack and import/require statements has been beyond tedious. It's probably best today not to worry about namespacing at all and use import and export. Then use Babel and something like webpack to stitch the final output together for the browser.

1

u/sjwking Jul 27 '17

This. Since there is a standard, follow it because of future compatibility issues.

1

u/dangerzone2 Jul 27 '17

Thats a great idea as well! I'll definitely have to consider that approach for the next project.

1

u/cyr1s Jul 27 '17

Any resources you can recommend that do?

2

u/[deleted] Jul 27 '17

Look into the module pattern. https://stackoverflow.com/questions/881515/how-do-i-declare-a-namespace-in-javascript Skip over to Divyanshu Rawat's answer, I think it's a great explanation.

4

u/asdf7890 Jul 27 '17

Skip over to Divyanshu Rawat's answer

You can link directly to answers using the share link at the bottom of them, https://stackoverflow.com/a/41962097 in this case.

If you are logged in the link generated will include your user ID. If that is a problem for you then open the page in an incognito/private/similar window and use the share links from there.

1

u/[deleted] Jul 27 '17

Thanks for the hint!

1

u/XVsw5AFz Jul 27 '17

I'd be careful with that. We're currently in the middle of upgrading a very large application that used a homegrown namespacing system. It was using an older grunt based simple concat/minification build pipeline where everything had to be put in the right order etc. Taking this system and moving it to webpack and import/require statements has been beyond tedious. It's probably best today not to worry about namespacing at all and use import and export. Then use Babel and something like webpack to stitch the final output together for the browser.

1

u/XVsw5AFz Jul 27 '17

I'd be careful with that. We're currently in the middle of upgrading a very large application that used a homegrown namespacing system. It was using an older grunt based simple concat/minification build pipeline where everything had to be put in the right order etc. Taking this system and moving it to webpack and import/require statements has been beyond tedious. It's probably best today not to worry about namespacing at all and use import and export. Then use Babel and something like webpack to stitch the final output together for the browser.

1

u/XVsw5AFz Jul 27 '17

I'd be careful with that. We're currently in the middle of upgrading a very large application that used a homegrown namespacing system. It was using an older grunt based simple concat/minification build pipeline where everything had to be put in the right order etc. Taking this system and moving it to webpack and import/require statements has been beyond tedious. It's probably best today not to worry about namespacing at all and use import and export. Then use Babel and something like webpack to stitch the final output together for the browser.

1

u/XVsw5AFz Jul 27 '17

I'd be careful with that. We're currently in the middle of upgrading a very large application that used a homegrown namespacing system. It was using an older grunt based simple concat/minification build pipeline where everything had to be put in the right order etc. Taking this system and moving it to webpack and import/require statements has been beyond tedious. It's probably best today not to worry about namespacing at all and use import and export. Then use Babel and something like webpack to stitch the final output together for the browser.

1

u/XVsw5AFz Jul 27 '17

I'd be careful with that. We're currently in the middle of upgrading a very large application that used a homegrown namespacing system. It was using an older grunt based simple concat/minification build pipeline where everything had to be put in the right order etc. Taking this system and moving it to webpack and import/require statements has been beyond tedious. It's probably best today not to worry about namespacing at all and use import and export. Then use Babel and something like webpack to stitch the final output together for the browser.

1

u/XVsw5AFz Jul 27 '17

I'd be careful with that. We're currently in the middle of upgrading a very large application that used a homegrown namespacing system. It was using an older grunt based simple concat/minification build pipeline where everything had to be put in the right order etc. Taking this system and moving it to webpack and import/require statements has been beyond tedious. It's probably best today not to worry about namespacing at all and use import and export. Then use Babel and something like webpack to stitch the final output together for the browser.

1

u/XVsw5AFz Jul 27 '17

I'd be careful with that. We're currently in the middle of upgrading a very large application that used a homegrown namespacing system. It was using an older grunt based simple concat/minification build pipeline where everything had to be put in the right order etc. Taking this system and moving it to webpack and import/require statements has been beyond tedious. It's probably best today not to worry about namespacing at all and use import and export. Then use Babel and something like webpack to stitch the final output together for the browser.

1

u/XVsw5AFz Jul 27 '17

I'd be careful with that. We're currently in the middle of upgrading a very large application that used a homegrown namespacing system. It was using an older grunt based simple concat/minification build pipeline where everything had to be put in the right order etc. Taking this system and moving it to webpack and import/require statements has been beyond tedious. It's probably best today not to worry about namespacing at all and use import and export. Then use Babel and something like webpack to stitch the final output together for the browser.

1

u/XVsw5AFz Jul 27 '17

I'd be careful with that. We're currently in the middle of upgrading a very large application that used a homegrown namespacing system. It was using an older grunt based simple concat/minification build pipeline where everything had to be put in the right order etc. Taking this system and moving it to webpack and import/require statements has been beyond tedious. It's probably best today not to worry about namespacing at all and use import and export. Then use Babel and something like webpack to stitch the final output together for the browser.

1

u/XVsw5AFz Jul 27 '17

I'd be careful with that. We're currently in the middle of upgrading a very large application that used a homegrown namespacing system. It was using an older grunt based simple concat/minification build pipeline where everything had to be put in the right order etc. Taking this system and moving it to webpack and import/require statements has been beyond tedious. It's probably best today not to worry about namespacing at all and use import and export. Then use Babel and something like webpack to stitch the final output together for the browser.

1

u/XVsw5AFz Jul 27 '17

I'd be careful with that. We're currently in the middle of upgrading a very large application that used a homegrown namespacing system. It was using an older grunt based simple concat/minification build pipeline where everything had to be put in the right order etc. Taking this system and moving it to webpack and import/require statements has been beyond tedious. It's probably best today not to worry about namespacing at all and use import and export. Then use Babel and something like webpack to stitch the final output together for the browser.

1

u/XVsw5AFz Jul 27 '17

I'd be careful with that. We're currently in the middle of upgrading a very large application that used a homegrown namespacing system. It was using an older grunt based simple concat/minification build pipeline where everything had to be put in the right order etc. Taking this system and moving it to webpack and import/require statements has been beyond tedious. It's probably best today not to worry about namespacing at all and use import and export. Then use Babel and something like webpack to stitch the final output together for the browser.

1

u/XVsw5AFz Jul 27 '17

I'd be careful with that. We're currently in the middle of upgrading a very large application that used a homegrown namespacing system. It was using an older grunt based simple concat/minification build pipeline where everything had to be put in the right order etc. Taking this system and moving it to webpack and import/require statements has been beyond tedious. It's probably best today not to worry about namespacing at all and use import and export. Then use Babel and something like webpack to stitch the final output together for the browser.

1

u/XVsw5AFz Jul 27 '17

I'd be careful with that. We're currently in the middle of upgrading a very large application that used a homegrown namespacing system. It was using an older grunt based simple concat/minification build pipeline where everything had to be put in the right order etc. Taking this system and moving it to webpack and import/require statements has been beyond tedious. It's probably best today not to worry about namespacing at all and use import and export. Then use Babel and something like webpack to stitch the final output together for the browser.

1

u/XVsw5AFz Jul 27 '17

I'd be careful with that. We're currently in the middle of upgrading a very large application that used a homegrown namespacing system. It was using an older grunt based simple concat/minification build pipeline where everything had to be put in the right order etc. Taking this system and moving it to webpack and import/require statements has been beyond tedious. It's probably best today not to worry about namespacing at all and use import and export. Then use Babel and something like webpack to stitch the final output together for the browser.

1

u/XVsw5AFz Jul 27 '17

I'd be careful with that. We're currently in the middle of upgrading a very large application that used a homegrown namespacing system. It was using an older grunt based simple concat/minification build pipeline where everything had to be put in the right order etc. Taking this system and moving it to webpack and import/require statements has been beyond tedious. It's probably best today not to worry about namespacing at all and use import and export. Then use Babel and something like webpack to stitch the final output together for the browser.

6

u/spraaak Jul 26 '17

This will be my new resource to recommend to people when they ask for where to start with JS

8

u/jiblet84 Jul 26 '17

What a great resource, thank you for sharing!

1

u/[deleted] Jul 27 '17

What is the difference between eloquentjavascript and this one?

2

u/bpesquet Jul 27 '17

Author here, so obviously biased, but anyway:

  • Eloquent JavaScript goes deeper about some topics, but it's not the easiest book to follow along.

  • The JS Way is designed to be more beginner-friendly and uses the latest language features. EJ uses an older syntax.

Both books are free to read online, so you can make your own opinion :)

1

u/[deleted] Jul 28 '17

Thanks. Will try.

1

u/thepeka Aug 07 '17 edited Aug 07 '17

Edit: I'm a jerk

1

u/bpesquet Aug 07 '17

Thanks for this pretty brutal feedback.

Your 'functional' examples show terrible anti-patterns like initializing an array, using a for look, and pushing to the array under a condition. Functionally this is an Array#find transform. And this poor advice is given continually throughout (specifically, loops everywhere).

Did you read this chapter entirely? It shows how to refactor these initial examples in a functional way, using map(), filter(), reduce() and function composition.

That coupled with the early and heavy push to the very limited class kw is enough that I won't be reading the rest. JavaScript is a prototypal language and you are doing your readers a huge disservice by glossing over what the sugar of class is actually doing (which is saw where there, but very much so glossed over.. not to mention the lack of using the factory pattern which is a hugely helpful real-world tool in JS). And inheritance for a game? ECS.

In the OO chapter, I explain that JavaScript OO is prototypical and that class is just syntactic sugar over it. "Class is useless" is your opinion, not a fact. I made some choices for this beginner-oriented book, if you don't like them, don't read the book. Or better yet, try writing yours and see how easy it is.

2

u/thepeka Aug 07 '17

yep, you're right. I apologize for my pre-coffee, mobile-only, hungover, poorly crafted analysis.

I have actual criticisms but this is overall a pretty good reference and I won't nit pick it.

2

u/bpesquet Aug 07 '17 edited Aug 08 '17

Nevermind, my reply was a bit brutal too.

And I'm interested in your post-coffee criticisms :)

6

u/[deleted] Jul 27 '17

Better worse or 'before' eloquent javascript?

3

u/vluong Jul 26 '17

This is great. Love the way it is written.

2

u/ThyGuardian Jul 26 '17

Was wanting somewhere to start! Thank you!

2

u/rfargetton Jul 27 '17

I actually followed this guy's course on openclassrooms.fr, which was really similar to this. It is a fun and simple intro to JS. Definitely recommend it πŸ‘

2

u/Darren1337 Aug 11 '17

I bought your book. Can't wait to get stuck into it, looks great :)

1

u/jegcel Jul 27 '17

Excellent resource. I'm both reading it, and recommending it to everyone who wants to start a career in web development. I especially like the tl:dr sections since they are not simplistic, but provide an effective summary of each concept. Thanks for sharing.

1

u/_CastleBravo_ Jul 27 '17

Damn, nothing but positive feedback. Thanks for sharing OP.

1

u/harverychina Jul 27 '17

θ°’θ°’εˆ†δΊ«πŸ‘

1

u/wr0ng1 Jul 27 '17

Bought with extras. Thanks!

1

u/thxbra Jul 27 '17

I've added this to my curriculum of you don't know JS, udemy courses, freebootcamp & the modern js tutorial. In my short time studying this topic I've learned that immersion and active practice is key alongside my readings. This will be a perfect addition. Thank you very much.