Live data from Hacker News

JavaScript: The Right Way

jstherightway.org

31–40 of 136 posts

Re: JavaScript: The Right Way

#31
post #24

Having recently started getting into Javascript, I have to say it is the most confusing ecosystem ever. Learning the basics of the language is easy enough, but as soon as you start trying to create a non-trivial application, bam, you're hit with information overload - X framework, Y library. It's different from Python, Ruby et all because at least with them, there are good consistent popular choices that you can rely…

If in doubt, just use Javascript without anything. Maybe add jQuery. All those frameworks may be nice, but as soon as the tools get a distraction, I think it is useful to step back. And JS doesn't really need anything to be useful.

Plain javascript is nice, but if you're talking about getting a single bit of code to work in N many browsers, the "frameworks" start becoming less optional.

Re: JavaScript: The Right Way

#33

Having recently started getting into Javascript, I have to say it is the most confusing ecosystem ever. Learning the basics of the language is easy enough, but as soon as you start trying to create a non-trivial application, bam, you're hit with information overload - X framework, Y library. It's different from Python, Ruby et all because at least with them, there are good consistent popular choices that you can rely…

Basically it boils down to what you want to do.

If you know you’re replacing many parts of your page with data you have to load, use a framework like angular, backbone, ember, …

If you visualize data, use d3.

If you need to animate some UI elements but don’t need much else, use jQuery.

Else use plain JS, maybe with some shortcuts like function $(sel) { return document.querySelector(sel) }. maybe with underscore.js if your love funtional programming.

In any case, strive to write idiomatic code. d3, jQuery, and many else e.g. have their own variant of $, select, querySelector, … – decide on one framework and use its way to write code.

Any you’ll want to find a way to compartimentalize code. https://github.com/mbostock/smash is good, and http://browserify.org/

Re: JavaScript: The Right Way

#34
post #15

Besides the questionable choice of framework. Does this guide make sense? What would you remove or add?

A mention of JS debuggers like theseus might be good.

Would be cool to automatically change the URL to the anchor as I scroll.

Re: JavaScript: The Right Way

#35

Having recently started getting into Javascript, I have to say it is the most confusing ecosystem ever. Learning the basics of the language is easy enough, but as soon as you start trying to create a non-trivial application, bam, you're hit with information overload - X framework, Y library. It's different from Python, Ruby et all because at least with them, there are good consistent popular choices that you can rely…

> It's different from Python, Ruby et all because at least with them, there are good consistent popular choices that you can rely on.

In the browser yes , i would say there is no consensus as to what lib to use. Some hate jQuery others like it,but the kind of projects people do are very different on the client.

I'm not going to use the same framework for a game or a LOB app or an interactive "flash like" experience, and some framework will use a paradigm I may or may not like.

Also on the client frameworks and libs are totally monolitic because JS doesnt have a proper module system. Python and Ruby dont have this issue. So JS lib are always re-inventing the wheel.

Despite what people say , client side , there is not "one true way" to do stuffs( like using AngularJS for everything).

I personally use jQuery and Ractive because they are fast and easy to use. On bigger projects I use browserify to build my own stack instead of a monolitic framework.

Re: JavaScript: The Right Way

#37
post #24

Earlier quoted context omitted.

If in doubt, just use Javascript without anything. Maybe add jQuery. All those frameworks may be nice, but as soon as the tools get a distraction, I think it is useful to step back. And JS doesn't really need anything to be useful.

Plain javascript is nice, but if you're talking about getting a single bit of code to work in N many browsers, the "frameworks" start becoming less optional.

Actually the frameworks don't help in that regard. They are meant for organizing your code, they don't offer any special compatibility.

jQuery does that.

Re: JavaScript: The Right Way

#39
post #37

Earlier quoted context omitted.

Plain javascript is nice, but if you're talking about getting a single bit of code to work in N many browsers, the "frameworks" start becoming less optional.

Actually the frameworks don't help in that regard. They are meant for organizing your code, they don't offer any special compatibility. jQuery does that.

Well let's define some terms here then. In the sense that I was speaking about, I was using "framework" as a synonym for "library". Not an entirely unprecedented usage.

Underscore gives you array extras in every browser, even ones that don't have array extras.

Mustache because let's face it, javascript doesn't have any nice way of doing templating or string formatting or anything. not without resorting to doing things that might not work in every browser.

and backbone because, while some of the newer browsers and newer versions of ecmascript provide facilities for monitoring and reacting to changes, and doing data binding like things natively, not all browsers do.

now I'll admit that backbone is not as new and shiny as say, that om/react/clojure stack making the rounds on hacker news, it's been around for a few years and it's still here. So that's something.

Re: JavaScript: The Right Way

#40
post #22

"JavaScript has strong object-oriented programming capabilities" What would be an example of a language with weaker OOP capabilities? PS: "The bad parts" section did not fit the page?

    > What would be an example of a language with weaker OOP capabilities?
Something without the concept of objects built in? C?
Post reply on HN