Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
An Open Source Book That Teaches JavaScript (github.com/sumn2u)
178 points by iamsuman on April 11, 2023 | hide | past | favorite | 35 comments


Does anyone else get frustrated when they see, in blogs, articles, or books, introductions such as this:

> Computers are common in today's world, as they are able to perform a wide variety of tasks quickly and accurately. They are used in many different industries, such as business, healthcare, education, and entertainment, and have become an essential part of daily life for many people. Besides this, they are also used to perform complex scientific and mathematical calculations, to store and process large amounts of data, and to communicate with people around the world.

Anyone who would open this book must already know all this. Is there anyone who does not know that computers are everywhere? Does any prospective reader of a book on programming feel that computers are not essential? Does anyone doubt that complex scientific and mathematical calculations are made on computers? Who is this paragraph for? Who has taught us not to proceed straight to business?


"In the beginning there were computers. Many have argued that this was a bad idea but here we are. If you want to program a computer, ..."


May I steal that line?

I find introductions to books too boring, whether Maths, Programming or just about anything. I hope to document my Programming learning progress and document it in a small book. And I totally wish to steal that line.


It sounds similar to another quote.

“In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move.”

Hitchikers guide to the galaxy


Go for it. As another commenter mentioned, it’s a riff on Hitchhiker’s Guide


The book has to start somehow. Would it be better if it featured cartoon foxes? Chunky bacon?


Much better! I miss _why.


You have a point. But I think as a layman I would have appreciated a little more about what kind of reader the book is appropriate for. And possibly have that appear within the first three paragraphs of the intro. I like how this book does give you an idea of how you should expect to work through the examples though.


the point is that it should start without pointing out obvious banalities.


A thousand times yes!


You can say a writer is writing for someone. When I read an intro like this in a book, that’s says to me the writer is targeting a community of go getters who might otherwise be driving for Uber.

But when I read this in a blog, I’m really turned off. Now I think the writer has no friends, doesn’t know how to make friends.

If this was a book about mechanical engineering, I’d say fine. What I know about ME I can stick in my eye and still see good.

If I find this picking up yet another book on a programming that I’m trying to brush up on… grr I’d have to read it non-linearly.


It has the same lecturing tone as typical ChatGPT output.


That was exactly what I thought when I read that. Before ChatGPT, I would've thought of typical SEO spam.


Another excellent and also OpenSource book, which I used a couple of years ago to refresh my knowledge about modern JavaScript is Eloquent JavaScript by Marijn Haverbeke. Highly recommended. https://eloquentjavascript.net/


I came here to recommend the very same. The interactive code examples are also very good for students.


Just took a quick look, this is actually interesting and worth reading even after passing the beginner stage


I credit that book to me going from no college degree to principal developer.


Super.

A book offers structure to get going. 'By example' is great too. As is 'read the manual'. [Good to have all, I like books.]

Getting a structure filled out takes a fair bit of effort. That hurdle's overcome. On Github, its easy to fork / contribute - the tools are right there along with a creative commons (or, Apache in this case) license.

Structure, content, license and tools are all there.


> JavaScript is an interpreted language. While running Javascript an interpreter interprets each line and runs it. The modern browser uses Just In Time (JIT) technology for compilation, which compiles JavaScript into executable bytecode.

This in the intro can't be of much use. Sure, it's an introductory book, but this isn't a correct simplification. Is JavaScript run by an interpreter or a compiler now? The quote can't decide; and the final stage of JavaScript JITs tends to be machine code too. I know there's often both (with interpreter for cold code, compiler for hot code); but given the level of the rest of the intro, throwing terms like "interpreted", "just in time", "compilation" and "bytecode" which haven't been defined would only lead to confusion, nor are they too relevant.


Has anyone here successfully learned any programming languages with the help of ChatGPT?

I feel like we might be entering a new era of education with these LLMs, who will patiently tutor you and answer your every question (not perfectly yet, but we're getting there).


The problem is still that you have no idea what is true and what is made up. Especially as a learner. On my last attempt it gave me a disguised infinity loop that ate up all the ram and frooze the computer.

I believe AI will be amazing for traditional language learning with voice recognition but it really needs to improve to be useful in other areas where facts actually matter. Maybe it can be solved by toning it down so it's less convincing and stop making up things. If that's at all possible.


I asked mine to code a game and I got an infinity stone in the mail, the yellow one. Weird.


Unfortunately LLMs, even the best one I'm aware that exists (GPT-4), aren't reliable.


Commenting on the last exercise, "loops" on https://javascript.sumankunwar.com.np/

The average functional programmer writes this - and not a for loop :

    ````
    const fizzbuzz = (n)=>(n%15==0)?"FizzBuzz":(n%5==0)?"Buzz":(n%3==0)?"Fizz":n;
    Array(101).fill(0).map((_,i)=>fizzbuzz(i)) 
    ````


   Array(101).fill(0).map((_,i)=> [...])
It's astonishing to me that even with all the niceties added to ES7+, JS still needs to resort to a hack like this for a simple range generator. At least give iterators support for forEach(), reduce(), and map(), so we can use `Array(100).keys()` without having to wrap it with the spread operator.

Also, can't help but snark that apparently the "average" FP is so preoccupied with showing off their one-liners that they fail the problem requirements (should be `Array(100).fill(0).forEach((_,i)=>console.log(fizzbuzz(i+1)))`).


A little bit better: Array.from({ length: 100 }, () => ...)


Indeed, much cleaner to do `Array.from({length: 100}, (_,i) => fizzbuzz(i));`


While we're cleaning it up:

   fizzbuzz = i => (i % 3 ? "" : "Fizz") + (i % 5 ? "" : "Buzz") || i
   Array.from({length: 100}, (_,i) => console.log(fizzbuzz(i+1)))


Actual developers just use lodash.

Honestly, I don't understand the complaint, a lean stdlib isn't a shortcoming.


...It absolutely is a shortcoming. Python is the second-most popular language out there, despite its awful performance, largely because of its comprehensive stdlib. (First is JS, because web).

And I don't understand how you can't see the irony of praising a "lean" stdlib immediately after saying every "actual" developer has to add the bloat of importing lodash.


Again, a lean stdlib is a feature, not a bug.

You can have theoretical disagreements with this, but you didn't invent the most popular programming in the world.

As for Python, not interested, it's mostly a "performance doesn't matter, being able to do this without expertise, time or even necessarily intellect does" niche.

JS has been slow to roll in core functionality, but is has made great strides by being highly conservative, not generating the kind of bloat that PHP has.


>you didn't invent the most popular programming in the world.

This is such a weird ad hominin (especially from a two-week-old account).

Regardless, the absolute, overwhelming popularity of jquery pre-ES6 goes to show that practically every developer was of the opinion that JS's weak stdlib was a bug, and the community did their best to patch it. ES7+ is leagues better for it, but it still has room for improvement.



I don't think that was the intention of the exercise.


We used to have stackoverflow docs for it and it was great




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: