Hacker News new | past | comments | ask | show | jobs | submit login
Eloquent JavaScript, Second Edition (eloquentjavascript.net)
371 points by fyskij on Sept 11, 2013 | hide | past | favorite | 103 comments



In terms of credentials, just wanted to point out that Marijn is also the author of CodeMirror,[1] which is a wonderful in-browser code editor used by Light Table, Bitbucket, and lots of others.[2]

[1] http://codemirror.net/

[2] http://codemirror.net/doc/realworld.html


And before that, the author of the best postgres library on the planet: Postmodern.

http://marijnhaverbeke.nl/postmodern/


Also, he created Tern[1], a code analysis engine for Javascript, which provides smart code completion, Function argument hints, and other features

This tool is crowdfunded at indiegogo[2]

[1]http://ternjs.net/

[2]http://www.indiegogo.com/projects/tern-intelligent-javascrip...



Doesn't Chrome DevTools use Code Mirror?


Not sure about Chrome, but here's the bug for adding it to Webkit:

https://bugs.webkit.org/show_bug.cgi?id=92769

It's marked as RESOLVED FIXED, but I honestly can't tell from the comments if it was ever actually merged in.

There's also an initiative to begin using it in Firefox's built-in dev tools, still in-progress:

https://bugzilla.mozilla.org/show_bug.cgi?id=816756

(By the way, the difference in readability between the old and new Bugzilla is startling. Good job, Bugzilla team.)


It looks like it made it into WebKit on an experimental basis: http://trac.webkit.org/changeset/125201. This was over a year ago, though; don't know about its current status.


Yes. Both Chrome DevTools and Safari's Inspector (separate projects these days) both use CodeMirror as their editor.


I just came here to say thank you. I tried dozens of methods to learn how to program (I'm a marketer) and all of them start with "ok just type this and see what happens." I love the approach of breaking everything down to the essentials and helping me understand the fundamentals. I don't have much cash, but I'll contribute what I can.


Hey, I am a marketer too and wanted to share my experience with you. I am learning programming simultaneously, on and off at the following resources: http://teamtreehouse.com http://codeschool.com http://edx.org (MIT and Harvard Introduction to computer science) http://udacity.com (several courses, starting from intro)

Combining various sources and styles with general documentation reading and stackoverflow answers really helped me.



"Consider the final product to be your perk."

That's how crowd-funding needs to be done, in my opinion. I don't care about little knick knacks - I want my monetary support to actually better the product, not be spent on useless items.


I want to start learning Javascript (total beginner with few months experience with PHP), can you guys recommend me some good books suggestions as to what frameworks I should get in to?


Elequent Javascript is a fantastic book and one that'll give you a great start in programming for the web. I've also had luck with Envato's Javascript Fundamentals Course[1]. Richard Bovell also put together a course for learning Javascript[2]. These, of course, are not frameworks, which isn't what you want right now anyway.

1. https://tutsplus.com/course/javascript-fundamentals/ 2. http://javascriptissexy.com/how-to-learn-javascript-properly...


Personally I'd suggest you learn the basics before looking at frameworks. Frameworks will muddy the water and you won't be able to tell why/where magic is happening.


I only want to echo what others are saying: avoid frameworks in the beginning. Frameworks will only confuse you. Learn basic programming concepts using the core language only. Eloquent JavaScript is a great book to use.


Yeah I second aidos sentiments. Stay away from frameworks especially jQuery. Check out the first version of this book and CodeAcademy's js course.


jQuery is more of a library than a framework, and I don't see anything wrong with starting with it, since most of what it hides is the warts of the DOM API, not core Javascript concepts. I think the other replies were worried more about Knockout/Angular/Backbone that do a lot more hidden magic and can make it very unclear what's part of the language and what's part of the framework.


The reason to avoid jQuery while learning is that it teaches you to use javascript lazily as an afterthought to get a DOM element to do what you want quickly. It doesn't encourage you to learn a single thing about javascript.


jQuery is essentially a better DOM API than the native API. Hence it focuses on DOM manipulations, which, despite all we've learned about other important pieces of client-side webapps, is still an important piece itself.

jQuery won't help you much with architecture, but then again, neither will your text editor, and it's about as guilty as your text editor or the native DOM API of helping you learn JS or use it effectively.


I don't know about that! People were writing terrible JavaScript to perform DOM-manipulation magic long before jQuery came around.

I think it has more to do with how people see JavaScript, i.e., whether JavaScript is a general purposes programming language or just a tool to make cool things happen on web pages, than it does what framework they do or don't use.


jQuery does hide core Javascript concepts. For example, the for loop in jQuery it is totally abstracted out into $.each.


This is an example of one of many functional abstractions that jQuery (carefully) adds to Javascript.

There are great functional examples in Eloquent Javascript, that show you how to go from low-level loops to high-level abstractions. That's EJ's triumph: it guides you through the mental leap you have to make to go from for loops, to useful enumerations like maps and folds and the like.


That's more so a core programming concept than a js concept.


I see programming as a means to an end. For me, that end is creating interactive websites. For this reason, I found Eloquent JavaScript to be very boring. Most of the book talks about using the language to solve contrived, silly problems like keeping track of your aunt's cats. It got interesting only towards the end, when it started explaining how JavaScript can be used to actually DO things in the browser.

I would recommend Codecademy instead. I like it a lot because the courses consist of short parts where it first describes what you are going to do and why, and then makes you do it. You then see the fruits of your efforts on the mini-browser immediately. For me that was huge, because it is much easier to put the stuff you learn into context when you are seeing the results right away.

Eloquent JavaScript would be great if you want to get down to the knitty-gritty details of the language. But I would argue that not everyone needs that level of detail at the beginning.

edit: not sure why I'm being downvoted...


Derek Sivers great guide to learning Javascript: http://sivers.org/learn-js


To those who've read both, I wonder how [the first edition of] Eloquent JavaScript compares with JavaScript: The Good Parts.


JavaScript: The Good Parts has passages like this:

  The new function object is given a prototype property
  whose value is an object containing a constructor property
  whose value is the new function object.
... whereas Eloquent Javascript is written in English.

[Edit: To be fair, Douglas Crockford does write in the preface that the book is dense and may require multiple readings. He means it.]


I'm the author of Eloquent JS, so I'm far from unbiased, but the main difference in my mind is that The Good Parts is very spartan and extremely prescriptive in what you should do and, especially, what you should never do, whereas Eloquent JS tries to actually be attractive to read and have a much more open and enthusiastic mindset towards what programming is.


Thanks!


I wouldn't try to learn JS from The Good Parts. It is more of a guide to how to write solid JS after you've learned the basics of how it works.

Eloquent JavaScript on the other hand, is a great book to actually learn from.


My favorite quote from the Good Parts: "if you want to find out more about the bad parts and how to use them badly, simply consult any other JavaScript book"


(That quote is a great illustration of Crockfords insufferable arrogance.)


To be honest. I've seen way, way worse. He is very, very, VEERY arrogant - if you don't put space before and after an operation sign, you are an idiot. But the man earned it, somewhat.

I've seen people that are that arrogant and have delusions of grandeur. They are the poison, really.


To be fair when TGP was first published most of the books on the market were garbage.


They are not really comparable, Crockford's book is for programmers who want to use JavaScript and do it 'The Right Way' TM. Eloquent JavaScript reads much more like a story that happens to teach basic programming concepts, which happen to use JavaScript. It could be read both by an experienced developer and a someone who wants to dive in with no programming experience. The Good Parts would be useless to a beginner.


For someone who has rarely if ever programmed (or just done basic HTML/CSS) I recommend Eloquent JavaScript. For experienced programmers or someone who has been hacking JS on their own for a while, but wants to improve, I recommend The Good Parts.

You can learn a lot from both, but they are aimed at different audiences, IMO.


I felt Eloquent JavaScript was more approachable than The Good Parts for someone coming up to speed....


The bugs in the background are fun to watch. They actually eat each other from time to time. Though it does seem to require some CPU power and got my fans to spin up a bit.


If you watch really closely, they even 'mate' and lay eggs.

And yes, it's a huge cpu hog. But it will pause when you unfocus/hide the page.


I imagine it's an extension of the 'terrarium' example which is used to demonstrate OOP in javascript in the first edition of this book....

[edit - yes - it says this at the bottom of the page!]


It completely trashes Firefox here, not exactly a compelling argument for a site like this.


You're right. Seems some recent change in FF upped their requestAnimationFrame fire rate, or I made some change since I last tested it that causes the slowdown. In any case, try to refresh, should be smoother now (I've added a mechanism that reduces the framerate when the animation is eating up too much processing time).


I can barely scroll with the animation turned off, on a 2.8GHz CPU (it only returns to normal when reloading the page with js disabled). It's times like this when I really appreciate NoScript, but the pledge link only appears with js enabled. The fancy background could be hurting you in the pocket.


Odd. Is your screen huge? Your machine slow?

Anyway, I've made it so that the bitmaps are hidden when the animation is disabled, since they are the most likely candidate for making scrolling slow.


That works, clicking "animation" restores Firefox back to normal. What's weird though, is that the usual slow script warning doesn't work here. That shouldn't happen and might be a regression. And no to both, although it's probably slower than yours. Even with 170x140 and the main div removed (responsive design view), it won't animate.


The slow script warning, as far as I understand it, only fires when the script runs uninterrupted for a certain time. This was a case of animation frames taking up more time than their framerate, and thus firing end-to-end, killing the responsiveness of the browser itself.


What kind of machines do you use? I use a 2010 MacBook Pro and have no issues. Chrome beta.


Try Firefox, my box is newer.


I have no problem on Firefox, it's very smooth, but does draw a little bit of CPU power.


I really liked this book the first time around and I'm glad to see it's (possibly) getting a second edition.

But I had to remove the background to finish the page, it really creeped me out.


Hah, okay. That wasn't the intention at all. Why did it creep you out? Do you have a particular problem with little crawly animals?


Nothing like a phobia or anything, but it did give me a feeling that there were bugs all over my screen.

It's a cool animation though and a nice reference to the first book, personally I'd probably add a small toggle for the bugs.


Good idea. Done.


The moving background is constantly distracting me from the main content :( And btw I dind't notice the "animation" button on the top right until I came here to read the comments.


This will be a very interesting experiment. We're certainly keen to release the second edition of Eloquent JavaScript and excited to see Marijn hard at work.

Who knows. Perhaps this will become some sort of interesting blended model for other authors.

-- Bill Pollock, No Starch Press


FYI, from the [Hacker News Guidelines](http://ycombinator.com/newsguidelines.html):

Please don't sign comments, especially with your url. They're already signed with your username. If other users want to learn more about you, they can click on it to see your profile.


Thanks for the heads up. I wasn't aware of that. I'll be sure to strip that information from future comments.


Hey, No Starch Press guy... what is up with your book covers? I have a print copy of Land of Lisp and the texture of the cover material is repugnant. It feels like the phlegm of Cthulhu hardened and pressed into book form. I have actually considered cutting the covers off just so I don't have to touch them.


Interesting. We actually love the texture and so does our author :) That's called a scuff-free matte finish. It's actually a plastic, overall gloss laminate with a matte finish on top. I personally hate glossy covers because I hate fingerprints. Cut the cover off if you like but matte is our preference.


FWIW Land of Lisp feels incredible to me.


Try adding some starch.


Is it worth reading the first edition or should I wait until this is finished? I'm quite experienced in JS but glancing the first edition it seems like it explain some abstract things I still can't wrap my head around in a good way.


The first edition is still the best resource on learning JavaScript I have ever used. Definitely worth reading / using it (it is highly interactive, and so much more than 'a book').


I purchased the print version (haven't gone through it yet, like most books I buy, they tend to sit on the shelf for a while) ... is there a benefit to doing the interactive version instead/in addition?


I'd say get stuck in.

I'm pretty new to js and I'm only part way through as of now but the built in console when reading it online really helps solidify the experience for me.


"they will help with professional editing (which is sorely needed when a non-native speaker like me tries to write an English book"

Wow, I had absolutely no idea that Marijn wasn't a native speaker. I've always considered Eloquent Javascript one of the best written technical books I've read.


I do have to say that I think perks for donations would be better than nothing, even if it's as simple as drop-shipping a copy of the book to each person who pre-buys it (or something)...

something like donate $25, get one of the first copies of the books.

Or even have it be a digital version, or something...


Everybody gets a digital version—as in, I'll be distributing ebook formats from the website as soon as the book is finished.

Sending a book costs about $10 for the book, $2-5 for shipping, and days of my time to orchestrate. It'd decimate more than half of a $25 donation. I do see the appeal of perks, but I think the trade-off is unattractive in this case.


Couldn't hard copies be outsourced to No Starch if a set amount was donated? I'd much rather buy a book - and would make a higher/set donation.


Well, you're free to make a small donation now and order the book from Amazon (for ~$20, I expect) in a few months. I know it's not psychologically the same thing, but the end result is similar.


We always do 40% off pre-pub offers that includes the print book and DRM free ebook versions (pdf, epub, and mobi). Just give us your email (nostarch.com) and we'll send those to you. Maybe we should launch that offer now.

-- Bill at nostarch dot com


I need help with refactoring this funding code :-)

donateButton.onclick=perk;

function perk(){ book.getPageByNumber(getRandomPage())=insertWittyHaverbekeProgrammingPearls(); book.getPageByNumber(getRandomPage())=insertAutographOnRandomPage(); book.getPageByNumber(getRandomPage())=insertNoStarchPrintEbookPromo(); }

function getRandomPage(){ pageNumber=Math.random()*book.length; return pageNumber; };


Not to mention the amount of paper, energy to print and distribute. I know some people to like to thumb through physical books, and I'm sounding like a tree hugger, but small differences from everyone can make big impacts.


I like the layout of the book. For a self publish book how did you get the layout and typesetting to look that good?


I'd like to think that we helped just a little bit :)


We are you referring to when you say 'we', if I might ask?


He means that the paper version isn't self-published, but published by a professional publisher, No Starch Press (which is his company).


Yes. Sorry for the confusion. I need more coffee.

Bill


Are there any plans for a chapter on the new major stuff in ECMAScript 6? I believe the target date for the finalization of the spec is still around December? Which is not that far away... time to start shopping for xmas gifts :S


ECMAScript 6 is out of scope for now, since even when the spec is released, it'll take a while for it to become practical to actually program in.


On the client side, sure. But a lot of the Harmony features are already present in node 0.11.x unstable. So perhaps the node.js chapter could include bits about it.


That's a good point. I'll spend some time learning about ES6 features and their SpiderMonkey/V8 support status.


I absolutely loved the first edition, and I will be chipping in. Great work Marijn.


I bought the first edition six months ago and thought it was still quite useful.

I look forward to the new version, especially for onboarding experienced devs that don't have all the nuances of Javascript mastered.


I've just donated 20 euros to this =).

Hopefully he'll reach his target.


"from Kashmir to Louisiana to Minas Gerais"

Minas Gerais is the Brazilian state that I live, what a coincidence. I wonder if the author choose randomly...


Nope. I visited there once (some of my father's cousins emigrated to Brazil 40 years ago) and did recently receive an email from a reader in Belo Horizonte.


I grew up in Louisiana, and also wondered what the connection there was. It's not a state you see mentioned often (in a positive light, anyway).


I exchanged a few emails with an underfunded high school teacher in Louisiana who was using the book to teach his students programming. Hence the reference.


Javascript isn't the best language to "learn to program". Syntax wise it's decent, but for at least us web developers, we shouldn't preach that to newly interested folk. You see how bad websites are today, and it's mostly due to abusing JavaScript. When people learn something they want to use it, and if they know JavaScript better then a good back end server lang, they create...a mess. Stop abusing my CPU!


You don't like what people build in it? That's a pretty silly anti-javascript argument.


No. That would be a silly anti-anything argument.

Javascript uses client-side resources for execution. Build a crappy app (and they will because their learning), and it will freeze my browser/their browser. Other reasons why JavaScript sucks for learning programming:

- You won't know you messed up until you execute your code - It's slow. - Debugging JavaScript code blows. And most tutorials don't even show users how to do that. - - ESPECIALLY IF YOU USE JQUERY - Too many to list.


This complaint is outdated. The dev tools that come built in with browsers are pretty damn good these days. They provide a Javascript console and debugger, as well as a DOM inspector and a request inspector. So it's actually really easy now to figure out what's going on with your JS code. There are unit test frameworks for JS now too. Bad JS is still bad, but it's much easier to write good JS now than it used to be.


Javascript is definitely one of the best languages to "learn to program."

This is because it's so easy to get something up and running - you don't need to figure out how to set up a development environment or how to compile something. You can focus on learning how to program.

Yes, there is some really bad Javascript out there, but that's why we need this book.


Cool thanks for this. Is there something similar to this for python 2.7?


That's a lot of money to ask. Chuck Palahniuk's Fight Club got bought for $6000. Just sayin'.


If you're going to compare the monetary goals of this campaign to other books, it would probably make more sense to use other programming books as the basis of your comparison.

However, I think this is beside the point anyway for two reasons. First, as the author here is running the campaign himself, it's entirely within his power to set the rules. If one of the tasks isn't raising as much as he expected, he can decide to lower the price. He could also rework the task definition to fit better given the amount raised.

Secondly, I have seen both the first edition of this book, and the companion interactive website, recommended time and time again, here and elsewhere. I would not be surprised if many (if not all) of these goals are hit.

edit: wording fixes


I wasn't comparing a famous novel to a programming book, obviously. It was to remark the (apparently) high price of the book.


Compared to what? The initial price for the rights to a much rejected fiction book by a then totally unknown author?


Yes, and programmers in India work for $300/month, so you should probably lower your salary to that, right?


And was then sold for profit. This book is being released for free once the funds have been raised.


This website is in the top 5 list of the worst website designs I have ever seen.




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

Search: