11 ms·
Show HN: The JavaScript Way, a book for learning modern JavaScript from scratch
- bpesquet 9y agoHi all, author here. Backstory: I'm a CS engineer/teacher and this book is a side project started in December 2016. You can read a bit more about it here: https://medium.com/@bpesquet/walk-this-javascript-way-e9c45ab5b696 https://medium.com/@bpesquet/walk-this-javascript-way-e9c45a.... The writing process is now completed and I'm actively looking for feedback to make the book better. Any opinion or advice about content, pricing, or that hastily created Leanpub cover would be greatly appreciated. However, please keep in mind that this is a self-published effort still far from being polished and open to improvement. I'd also like this thread to stay focused on the book itself, not on the merits/weaknesses of JavaScript or the usefulness of choosing it as a first programming language. Thanks in advance!
- scarcitykillz 9y agoIt's a great idea and I think the world does need a new book for pure JS. There was a book released about 10 years ago by the guy who wrote jQuery. It started with basic JS and went all the way through to advanced features. It really helped me master JS. Where I think that book is better then yours is that it focuses entirely on JS where as you spend a lot of time talking about http and the web works. Anyone reading your book to learn js will already know that. An updated version for the modern day of the book I mentioned earlier would do very well. I don't mean to sound negative and I applaud your effort and the time you put in to do it and wish you the best of luck!
- mynd 9y agoI assume a book titled "X from scratch" requires no previous knowledge for the intended audience. It's hard to talk about writing apis without knowing the difference between POST and GET
- matthewvincent 9y agoI definitely wouldn't assume that a JS newbie knows the http fundamentals. That definitely wasn't the case for me when I started learning. You can get a lot done on the web without really understanding what you're doing.
- leeoniya 9y agoi wrote this a few days ago: https://www.reddit.com/r/Frontend/comments/6pconk/a_simple_summary_of_the_http_requestresponse/ https://www.reddit.com/r/Frontend/comments/6pconk/a_simple_s...
- scarcitykillz 9y agoMaybe but it makes this book only good for true newbies. There's plenty of tutorials for complete newbs but no good book for people who want to master modern pure JS
- photojosh 9y agoWas that John Resig's 'Pro Javascript Techniques'?
- feiss 9y agoI love it, very nice. Clean, modern, concise. Are there plans for translating it in other languages? I'd love to have time to translate it to spanish, but almost no free time..
- specialist 9y agoNice. Thanks for sharing. Bravo for burrito recipe. I'm convinced I became a programmer in 4th grade. Our creative writing assignment was instructions for making a peanut butter & jelly sandwich. Then our teacher followed our instructions literally. Hilarity ensued. --- I think the Intro's link to the local env setup in the appendix is broken. Anymore, I always check the colophon first, then decide to proceed. I applaud the online option. I'm dubious of the local option. "Install the latest XYZ" will bite you (your students). Especially with JavaScript and nodejs. Mayflies live longer. For future, should tutorials start with Docker images, or scripts, or virtualbox images, or something, to mitigate digital drift? Hoping other commenters will share their ideas, experiences.
- 52-6F-62 9y agoSide note: That teacher's method is great! That's a hell of a way to have kids remember what you taught them.
- andrewstuart2 9y agoFor digital drift: anything content-addressable (e.g. using git and referencing SHAs) is your answer. Continued availability and support, though? If you can answer that question, you should probably quit your current job and use your divination talents in more profitable fields.
- at-fates-hands 9y ago> Our creative writing assignment was instructions for making a peanut butter & jelly sandwich The Harvard CS50 class uses this as an example as well - with mixed results that are hilarious, but relatively obvious once you start thinking about coding and recipes. Here is the video: https://www.youtube.com/watch?v=euFj8D1A1Kw https://www.youtube.com/watch?v=euFj8D1A1Kw
- Cthulhu_ 9y agoRe: nodeJS versions, I'd go with something like "Install NodeJS, this book was written with version x.y.z"; I don't think JS will become backwards incompatible in the near future, so as long as the book doesn't contain experimental or unofficial JS features, it should be fine for the next 5-10 years.
- tmaly 9y agoIt might be too much to ask, but I really liked how the KnockoutJS tutorial was presented http://learn.knockoutjs.com/ http://learn.knockoutjs.com/ You basically live code to learn the basics right in a browser. It would be cool to have something like this for the book
- noir_lord 9y agoThat demo is the reason I picked knockout years ago, never regretted it either, knockout was/is amazing and they understand backwards compatibility and API stability.
- schemathings 9y agoI've seen a few comments here suggesting you spend time explaining how to install toolchain etc or version issues. I agree that having a default VirtualBox VM might be the best way to go so it's a 2 step install and everyone is on the same page regardless of what OS they have. David Swafford at Facebook has been teaching Python to network engineers at NaNog conferences for awhile and does the same .. he hands out a USB stick with everything needed, but I wasn't there so I emailed him and he gave me a dropbox link for everything needed .. e.g. this talk https://www.youtube.com/watch?v=dv328WQlUQg https://www.youtube.com/watch?v=dv328WQlUQg
- z3t4 9y agoI think you have to introduce all the CS stuff more slowly. Did you learn everything you know about programming in less then five minutes ? Then how do you expect a beginner to understand any of it ? Don't get me wrong though. The content is good, but it's too dense. Reading it as a beginner will be painfully slow and boring, like reading the TCP/IP spec. just to make a HTTP request.
- nailer 9y agoThis is a great idea but ES2017 instead of ES2015 would make it even easier for newcomers. This would allow `await` which is a lot easier for newcomers to follow than callbacks or .then(). Also you really want string.includes() ! Node and all current browsers support ES2017 so you don't really lose anything either.
- JustSomeNobody 9y agoI skimmed it and think it looks good for a beginner and really like that it focuses on pure JS. One thing I didn't see (and, again, I admit I skimmed) was how to structure a JS project/application. I know this is targeted at beginners, but even beginners need to see structure. If I missed all this in my skim, please forgive.
- deleted 9y ago[deleted]
- le-mark 9y agoVery, very nice. I briefly went over some chapters and I especially admire the 'no framework' approach you've taken. I believe there's a real need for a book like this, kudos to you for making it happen! What inspired you to create this?
- bpesquet 9y agoThanks for your nice comment. I'm currently writing a blog post about this experience. Expect it soon on https://medium.com/@bpesquet https://medium.com/@bpesquet.
- ryanmarsh 9y agoI just got home from teaching JavaScript to a room full of people who've never written a line of code in their life. This book is missing something critical that most intros to JavaScript overlook: How does the student set up the plumbing and run their code? It's amazing how much of a hump this is for many trying to get started. It also amazes me how oblivious most of us programmers are to it. "Just open Chrome Dev Tools" or "put this in a file and run Node" are really strange computer tasks to someone who has never typed and executed code.
- hugs 9y agoWhich method (Chrome Dev Tools, Node, etc.) did you teach to your students? Any other online resources you recommend?
- ryanmarsh 9y agoBoth. Node and chrome dev tools. Mostly VS Code plus some plugins plus node. Easiest way to give them a working, comprehendable and debuggae stack.
- 0xCMP 9y agoVery true. Or things like "download and install git". Oh wait you're on a mac you need Brew. But you're on windows? You're gonna need X. You're using linux and still don't know? (e.g. Parent installs linux on a computer for their child to learn programming on (e.g. buys them a rpi) ) Lots of "setup" stuff needs to be explained or at least guided through for a from scratch approach, but also needs to be easy to skim and skip if the person learning already knows how to do it.
- yorwba 9y agoSometimes I fantasize about a platform for tutorials on "how to do X using Y if you know Z" where prerequisites would be linked wiki-style, but disambiguated for the learner. If they are on Windows and use cmd.exe as their shell, command-line examples would be adapted to that, while someone using bash on Linux would get fitting examples as well. If they already know how to do a part, they get just a short summary instead of lengthy explanations. Unfortunately, you'd need a lot of content before something like that would take off, and just specifying a few options while otherwise relying on the reader to figure out any differences is simply easier for a writer and still good enough for most learners.
- dotnetkow 9y agoSaw this on Reddit last night, poked around on a few pages. It's great! Love the movie list example on this page: https://github.com/bpesquet/thejsway/blob/master/manuscript/chapter10.md https://github.com/bpesquet/thejsway/blob/master/manuscript/.... Going from "for" loops into map/filter/reduce concepts is an excellent way to teach!
- baalimago 9y agoDidn't know "var" was outdated. Good stuff, thanks!
- scottmf 9y agoYou can technically still use var if you wish, but I'm not sure of any reasons to do so. When switching to let/const, bear in mind the difference in scope: var is function-scoped: (function () { var x = 1; })(); var x === undefined let/const are block-scoped: if (true) { var x = 1; let y = 1; const z = 1; } x === 1 y === undefined z === undefined
- mikekchar 9y agoThe only reason I can think of is if you want hoisting for some reason. For example, if you want to call functions before they are declared. Personally, I don't like that style, but some people do.
- Cthulhu_ 9y agolet / const are both hoisted though, they're just hoisted to the top of the current block scope instead of function scope.
- joshuacc 9y agoSort of, but the effect is very different due to the "temporal dead zone." Attempting to access a variable declared with `let/const` or const before the declaration will throw an error, vs just getting `undefined` for a variable declared with `var`.
- mikekchar 9y agoI'm a bit confused. What does "hoisted" mean in this context if accessing the variable before declaration will throw an error?
- 9y ago
- jchien17 9y agoShould one learn ES2015 before learning ES5? Is there any value or need to learn ES5 if you're not maintaining an old codebase?
- pspeter3 9y agoNot all browsers support ES2015 so knowing ES5 first is helpful.
- EduardoBautista 9y agoExcept on almost any serious project you should be using a transpiler anyways.
- nawtacawp 9y agotranspiler?
- yunyu 9y agoConverts modern JavaScript to ES5
- tannhauser23 9y agoIt converts your ES6 code into Javascript that can run on all browsers. It's how you can get advanced Javascript features before the browsers fully implement them. Look up Babel.
- tasty_freeze 9y agoIt is a portmanteau of translater + compiler
- pspeter3 9y agoAgreed, but I find it helpful to understand the transpiled code. The "clean" ES5 output was a large reason for using TypeScript https://blog.asana.com/2014/11/asana-switching-typescript/ https://blog.asana.com/2014/11/asana-switching-typescript/
- internalfx 9y agoAnother great JS book on github... https://github.com/getify/You-Dont-Know-JS https://github.com/getify/You-Dont-Know-JS
- samuelthomas 9y agoThis is a pretty great one, and one of the books I recommend for anyone who is learning JS. My favorite book to recommend though is Eloquent JavaScript (also free). Just a fantastic, readable, intro to programming and JS. http://eloquentjavascript.net/ http://eloquentjavascript.net/
- draker 9y agoEloquent is good if your have prior programming experience. It starts easy but the 4th chapter goes quickly to a level above what I'd expect a beginner to understand without some exposure to programming or general CS theory. The exercises include a recursive list and recursive deep comparison.
- epmatsw 9y agoI love the async book in that series. Really opened my eyes about Promises.
- scottmf 9y agoLooks great. I love modern JS, and the faster everyone can move on, the better! I didn't see any async/await stuff though, is there a reason for that? I'd imagine it would make some code much easier to follow.
- _pmf_ 9y ago> and the faster everyone can move on, the better! Why? Where does this mindset come from?
- nailer 9y agoDirect style is easier to reason about. Control passes onto the next line consistently, for both async and sync operations. Do you really prefer callbacks or just use them because they were once necessary? Are they so good you'd use them for sync operations too? add(a, b, function(sum){ .... }) Personally: that seems like a waste of time. I'd rather just do: var sum = a + b; Likewise I'd rather do: var response = await superagent.get('https://...')
- scottmf 9y agoWhy would you want to use callbacks? Here's a code example from an npm package I was looking at, vs how I would rewrite it in modern JS: https://gist.github.com/scf4/8157abd755eb9c232e87dcc342b78b4b https://gist.github.com/scf4/8157abd755eb9c232e87dcc342b78b4... Some of it may be preference but a lot of it is objectively simpler to reason about. I don't understand why anyone would choose to make things unnecessarily complex.
- fanpuns 9y agoIf OP wrote using ES2015 then it wouldn't be included, async is defined in 2017
- partycoder 9y agoWhat all these tutorials omit is the tradeoffs JavaScript and node incur in order to be simple and friendly. - In JavaScript: no type annotations, numbers are floating point numbers, garbage collected, no multi-threading in the language spec. There are some ways to workaround these limitations, but they're not a part of the language. - The concurrency model of node, based on libuv event loop. This dictates what node is good for and what is not good for. Short lived tasks = good. Long lived tasks = bad (service degradation + cascading failures bad)
- eksemplar 9y agoIf you ask me all that you need to know about modern JavaScript is that it exists mainly to sell online learning material. But I may be a bitter old man and your resource looks pretty good.
- leke 9y agoI love the tl;dr section. It's basically what I have do when reading books, in order to recall the essential information without having to read the entire chapter again. Well played.
- minademian 9y agothis looks promising. I like how it teaches the concepts using plain Javascript without focusing on a tool or library. Kudos.
- ThomPete 9y agoThis is great! I am fairly familiar with programming having done both AS, Lingo and PHP I understand code when I see it. I am however not a programmer but more a technically oriented product designer and so I don't get to practice as often. I have been trying to get into javascript and while I understand all the fundamentals it's still not something that I feel comfortable doing which is a shame as it's kind of the language of the internet. Skimming through this books it looks like the perfect way for me to spend my next two weeks of vacation so thank you so much. Is there a way to to donate to you? Having made something as comprehensive as this you need to think about how to break it up so that you keep users engaged and so that you cam maximise your revenue. Selling books is mostly a spike and then long slow ramp towards halt so make sure you keep your content alive. If I may come with two suggestions. 1. Make a forum for your readers perhaps in the form of an online reading group so that you have someone to go through the book with. 2. Make a step by step email course where you go through the book and have people turn in assignments perhaps even in forums. 3. Let people hire you as a private teacher perhaps build up . a network of private teachers. (Ok that was three suggestions) These I think would be great ways to monetize.
- bpesquet 9y agoThanks for your nice comment and for these suggestions. You can support my work by buying the ebook version on Leanpub: https://leanpub.com/thejsway https://leanpub.com/thejsway. Monetization is not my #1 priority right now, but that might change later ;)
- noir_lord 9y agoThis is incredible. GF wants to learn to program, she has a strong math/finance background and I think she'd be good at programming but the web can be a bit overwhelming in totality.
- sAbakumoff 9y agoI think that the best book ever about JS for everyone, especially for those starting from scratch is https://github.com/getify/You-Dont-Know-JS https://github.com/getify/You-Dont-Know-JS you simply don't need anything else
- beeandapenguin 9y agoCompletely agree, YDKJS is a great book for learning the language. In my opinion though, it's not the best book for how to practically use JS in the real world. It would be a great supplement for those looking to learn more about language details with the book the OP posted.
- sAbakumoff 9y agoYou can only learn how to practically use the language by...practicing it in the real world. No book can teach you that because the real world is too complex.
- in9 9y agoDisagree.. A book could easily show you some basics for project/directory structure, basic code organization, documentation, simple defaults that can really make life easier for a noob. With that he can get used to it and compare code he has to work, or is reading, with what he has already been taught.
- sAbakumoff 9y agoI think it's undeniable that we spend most of our time by debugging and fixing the existing code structure, bugs, defects and sometimes adding new features. I highly doubt of existence of a book that can teach how to effectively do that. It's a luxury and real pleasure if you are asked to create the project from scratch in a real job.
- oblib 9y agoI went over a few chapters this afternoon and really enjoyed what you've put together. I'll definitely recommend it to friends who ask me about learning to code.
- drngdds 9y agoThis is really good! And I like the dig at 9gag :)