Live data from Hacker News

Preparing Yourself for Modern JavaScript Development

codethinked.com

21–30 of 75 posts

Re: Preparing Yourself for Modern JavaScript Development

#21
post #7

This is a nice, gentle introduction, but if you're going to start using modules you might as well go slightly farther and use something like RequireJS ( http://requirejs.org/ ) or Browserify ( https://github.com/substack/node-browserify ).

both RequireJS and Browserify are not good options. Browserify's implementation is awkward, incomplete and pollutes global scopa a lot.

Check out OneJS: http://github.com/azer/onejs

It's the only tool that lets you structure your client-side project as a CommonJS package and produces unobtrusive code mixable with anything in same global scope.

Re: Preparing Yourself for Modern JavaScript Development

#22

Here are a couple book recommendations for those of you looking to improve your JavaScript: "JavaScript: The Good Parts" by Douglas Crockford "JavaScript Patterns" by Stoyan Stefanov

I've been working on following the good parts for my latest project. I've started to cringe any time people talk about the prototype or using "this"

I cringe when people claim to be writing more than the most basic JS and aren't using prototypes.

Re: Preparing Yourself for Modern JavaScript Development

#23

I always find it odd that the same developers who deride PHP look at things like IIFE and think "wow, JS is a cool, modern language!" Thanks for the article though, if I ever need to write some JS this will help keep me a little more sane.

> I always find it odd that the same developers who deride PHP look at things like IIFE and think "wow, JS is a cool, modern language!"

I don't deride PHP (I don't know it), but I see nothing wrong with IIFE. Yes, it could benefit from some syntactic sugar, but otherwise it is just using one of the best features of JavaScript, function support (first-class functions, anonymous functions, etc.).

It makes perfect sense to use a pattern like IIFE in order to encapsulate code, often using closures to allow access in a controlled manner from the outside, etc.

I suppose perhaps you don't like closures and so forth, and that's fine, but many people including me love them.

Re: Preparing Yourself for Modern JavaScript Development

#24

I always find it odd that the same developers who deride PHP look at things like IIFE and think "wow, JS is a cool, modern language!" Thanks for the article though, if I ever need to write some JS this will help keep me a little more sane.

Exactly my thoughts. There really needs to be some healthy competition in client side languages.

Re: Preparing Yourself for Modern JavaScript Development

#25
post #23

I always find it odd that the same developers who deride PHP look at things like IIFE and think "wow, JS is a cool, modern language!" Thanks for the article though, if I ever need to write some JS this will help keep me a little more sane.

> I always find it odd that the same developers who deride PHP look at things like IIFE and think "wow, JS is a cool, modern language!" I don't deride PHP (I don't know it), but I see nothing wrong with IIFE. Yes, it could benefit from some syntactic sugar, but otherwise it is just using one of the best features of JavaScript, function support (first-class functions, anonymous functions, etc.). It makes perfect sense…

IIFEs are cumbersome and non-intuitive. Better languages have block scope or a "let" statement instead.

Re: Preparing Yourself for Modern JavaScript Development

#26
post #7

This is a nice, gentle introduction, but if you're going to start using modules you might as well go slightly farther and use something like RequireJS ( http://requirejs.org/ ) or Browserify ( https://github.com/substack/node-browserify ).

both RequireJS and Browserify are not good options. Browserify's implementation is awkward, incomplete and pollutes global scopa a lot. Check out OneJS: http://github.com/azer/onejs It's the only tool that lets you structure your client-side project as a CommonJS package and produces unobtrusive code mixable with anything in same global scope.

What's specifically wrong with RequireJS? I haven't heard much discussion of it, and you only addressed Browserify in your comment.

Re: Preparing Yourself for Modern JavaScript Development

#27

Earlier quoted context omitted.

both RequireJS and Browserify are not good options. Browserify's implementation is awkward, incomplete and pollutes global scopa a lot. Check out OneJS: http://github.com/azer/onejs It's the only tool that lets you structure your client-side project as a CommonJS package and produces unobtrusive code mixable with anything in same global scope.

What's specifically wrong with RequireJS? I haven't heard much discussion of it, and you only addressed Browserify in your comment.

I've been following the work on RequireJS for two years and think that it's an evil project that sabotages the rise of CommonJS, NodeJS and NPM by leading client-side Javascript coders to follow a non-standard, awkward way of JS development. From the very beginning, it forces coders to cover their code with awkward code and maintain it manually. It's completely insane. I even think that I'm wasting my time by talking about it.

Re: Preparing Yourself for Modern JavaScript Development

#28

I always find it odd that the same developers who deride PHP look at things like IIFE and think "wow, JS is a cool, modern language!" Thanks for the article though, if I ever need to write some JS this will help keep me a little more sane.

Exactly my thoughts. There really needs to be some healthy competition in client side languages.

Oh definitely. Or rather we need a vm designed to write code that can be optimized to run fast (personal dream, allow me to optionally include typing information. I already type my JS, might as well make it run better).

This means that the vm would be lowlevel enough that performance would start to approach that of native code, with complete freedom for the programmer to write the code for it in any language he desired.

The browser would then be able to execute this code instead of the corresponding Javascript file (e.g you compiler outputs two different object codes, one minified javascript for legacy browsers, one modern vm file for modern browsers).

Re: Preparing Yourself for Modern JavaScript Development

#29

great post, thanks. i also highly recommend using popular frameworks and libraries, since lots of them use the tricks mentioned in your article. Another thing that's worth noting is the JSON Object Notation: http://www.hunlock.com/blogs/Mastering_JSON_(_JavaScript_Obj... very readable form of declaration.

"JSON Object Notation" => JavaScript Object Notation Object Notation

Re: Preparing Yourself for Modern JavaScript Development

#30
That was a well-written article that has a pattern that should work well for a lot of people. But I think it can be improved.

One cool fact is that Javascript has first class functions. This means you can bring a lot of development patterns from the functional realm into your web development.

There is a trend of languages moving away from the concept of mutable state. The article does a good job with the first steps (by wrapping everything in its own function scope), but Javascript lets us go further. The article seems like it attempts to shoe-horn the concepts of classes and sub-type polymorphism into a language that has better options.

Post reply on HN