Live data from Hacker News

Modern JavaScript

blog.rebeccamurphey.com

21–30 of 33 posts

Re: Modern JavaScript

#21
I wish Javascript has an easy to use unified library/module system. Something like,

  require "http://ajax.googleapis.com/js/sha1.1.3.1"
In the browser, the browser would download and cache the the library and all its dependencies. For the server side, the server environment would download and cache the library and its dependencies in the same way.

Edit: Ha, a reply was deleted so fast that I didn't have a chance to reply to it. To clarify, Sha1.1.3.1 was meant to be an example of a library, not the SHA digest of a library, though that would be a nice feature. Also "require" should be a feature of the language, not using the html tag so be able to work in the server environment.

Re: Modern JavaScript

#22

Suddenly CoffeeScript makes a lot more sense to me: "the language itself is held hostage by browser vendors, some of whom have shown a strong inclination to not give a fuck about owning up to and fixing their egregious mistakes" So true. The JavaScript we've got now is the assembly language of the client-side. We can't easily change it, but we have to start building better tools on top of it.

A pretty decent part of the CoffeeScript MO is to start implementing things proposed for future versions of JavaScript ... but that we won't be able to use cross-browser for years and years. For example: * Destructuring Assignment. * Splats (Variadic Arguments). * Lexical "this". * Array and Object comprehensions. * Classes (As sugar for prototype wrangling). * String interpolation. ... to name the bigger ones. Many…

This reminds me of Scala X expecting Java 7 discussion. I like the fact that we, as more agile communities (Scala's and Coffeescript's), decided that we should not wait for committees, and we should control the languages we want to use it. And we won't wait 2/3 years. We are doing it now.

Re: Modern JavaScript

#23
post #21

I wish Javascript has an easy to use unified library/module system. Something like, require "http://ajax.googleapis.com/js/sha1.1.3.1" In the browser, the browser would download and cache the the library and all its dependencies. For the server side, the server environment would download and cache the library and its dependencies in the same way. Edit: Ha, a reply was deleted so fast that I didn't have a chance to re…

[deleted]

Re: Modern JavaScript

#24
I understand the desire for structured packages, but even in languages like python that have 'the python way' or what have you, there are still plenty of packages that don't quite fit. This isn't a problem with python, it's a largely philosophical/religious issue that has much to do with the idiom or mindset of the package (or likely the maintainer) at hand. But still, i don't see this as a problem that javascript has to address rather than say, a problem that libraries have to address.

You see this all the time in even jquery packages: are they $.pkg.method(elts) or $(elts).pkgmethod() or is it $(elt).pkgmethod(spec) or .... and so forth. Part of it is a matter of taste even if sometimes it goes against 'the jquery way.' Again, this is so religious that it's often not even worth fussing over.

Blaming browser vendors or our ecma overlords for package standards seems like a bit of a straw dog because javascript isn't a package distribution mechanism, it's a programming language. If you want to build apt/npm for browser js via require.js+jquery or your combination du choix, then by all means, but this isn't a failing of the language just as brew failing to install mutt is not a failing of ruby.

Certainly, there's bound to be some overlap in packages, but this happens everywhere and who cares? underscore+jquery seems like a strange example especially when the two are complementary. If the goal is to have a "lightweight core" with "components that deliver specific, isolated functionality" i mean, aren't we there right now? And for where we're not, as mentioned by other commenters, coffeescript and friends certainly seem to be fighting the good fight.

I'm all for innovation, but i could do without "enterprise javascript" (isn't that was es4 was and, i mean, i'm not exactly losing sleep over that decision). For proof positive that we're already getting the 'roll your own' strategy, check out the modernizr 2 beta (or, the less modest jq-ui).

If the point of modern js is that people are working together and optimizing, then yay!! but if the point of modern js is that we need to abide by some static discipline where each function only accepts a single spec object and conforms to some require.js loading protocol then, umm.. thanks but no thanks.

Re: Modern JavaScript

#25

Suddenly CoffeeScript makes a lot more sense to me: "the language itself is held hostage by browser vendors, some of whom have shown a strong inclination to not give a fuck about owning up to and fixing their egregious mistakes" So true. The JavaScript we've got now is the assembly language of the client-side. We can't easily change it, but we have to start building better tools on top of it.

>So true. The JavaScript we've got now is the assembly language of the client-side. Huh? Javascript is a high-level, dynamic language with very nice metaprogramming capabilites (compared to Ruby: http://fingernailsinoatmeal.com/post/292301859/metaprogrammi... ). Totally bizarre to compare it to assembly.

It's an appropriate comparison. Javascript was designed as a helper language, not what it's become - the level we code guis at. We need something more dynamic than html and less programmatic than javascript.

Re: Modern JavaScript

#26
post #21

I wish Javascript has an easy to use unified library/module system. Something like, require "http://ajax.googleapis.com/js/sha1.1.3.1" In the browser, the browser would download and cache the the library and all its dependencies. For the server side, the server environment would download and cache the library and its dependencies in the same way. Edit: Ha, a reply was deleted so fast that I didn't have a chance to re…

If library writers were to use CommonJS Modules (i.e. just use require() and exports), we'd be most of the way there.

Require.js and AMD still feel like they are not appropriate in all scenarios (e.g., I really don't want or need a "loader" in simple single page applications).

This is my suggestion for a very light weight way of using CommonJS Modules in the browser which is agnostic about how your scripts are loaded.

http://github.com/mckoss/namespace

Re: Modern JavaScript

#27
The core message is good but I think Rebecca's obsession with jQuery just kills here ability to deliver it. jQuery is not a problem. jQuery's popularity is not a problem. Complex applications are the problem. People not knowing how to structure complex applications are the problem.

Let's see the context there: jQuery is wildly popular, but it is the right tool for the job in most cases. Not all web pages jQuery is used on are webapps. Not all webapps are GMail. Yup, jQuery is "DOM, AJAX and effects" library which is great for trivial tasks. A lot of tasks are trivial.

But there is no "jQuery divide", like there was no "Prototype divide" some six years ago. These are just tools that can be misused. Sorry, Rebecca, but if dojo were as popular as jQuery is the JavaScript land would not be any better than it is now. It would be just a different tool misused, that's all.

The second point she is way wrong (again, IMHO) is the API. Don't you ever underestimate the importance of the good API. When you have tools X, Y, Z which more or less do the same with more or less the same performance, API is the main differentiating factor it's the think you write and look at the whole day. jQuery's API is awesome for many reasons. Dojo's is not.

Structuring complex applications is hard, no matter what language you use, it's not some trouble only JavaScript has. True, JavaScript comes with a couple more complications in that regard but these are minor in the context of the problem.

What she is right about it's the lack of good examples going beyond the basics. But I think the reason for that is that we are just on the way to find out what works reasonably well. It will come, I hope.

So my point is: stop talking about jQuery and dojo. Talk about the core of the problem (and any js lib is not the core).

Oh, and I would like to see Rebecca's take on backbone.js.

Re: Modern JavaScript

#28
The problem is that browsers don't deal with libraries. You can implement a module and a script loader system, but in the end of the day you will concatenate most scripts for faster download and initial page rendering.

The big problem is that we still have: IE6, IE7, IE8 and probably IE9 too They are too slow, they will not allow you to write nice modularized code.

Re: Modern JavaScript

#29

The core message is good but I think Rebecca's obsession with jQuery just kills here ability to deliver it. jQuery is not a problem. jQuery's popularity is not a problem. Complex applications are the problem. People not knowing how to structure complex applications are the problem. Let's see the context there: jQuery is wildly popular, but it is the right tool for the job in most cases. Not all web pages jQuery is us…

I appreciate your feedback and understand that previous posts of mine have framed this as a jQuery vs. Dojo debate; I tried particularly hard not to do so in this post, and I think you'd be rather hard-pressed to say that this post was a "jQuery vs. Dojo" diatribe. Yes, it linked to my Berlin slides, but that's simply because a post in response to them is what got this whole post percolating in my head to begin with.

The fact is, though, jQuery and Dojo are the two libraries with which I am quite familiar, and so they are the two libraries I am most able to compare. Having used both, it is easy to see the weaknesses of ... both! I truly believe there is a "jQuery divide" -- there are people who think jQuery is what there is to know of JavaScript, and that it can solve all of their problems; then there are the people who know there is more, either because they have always known or because, like me, they've discovered it through some painful mistakes.

What I am asking for, in this post and in my Berlin talk, is for the people who know there is more to take some responsibility for bringing the others up to speed, to show people what can be done if you leave behind the "get some elements, do something with them" mentality.

None of this is to say that jQuery is not a useful tool, and the right tool in so many situations! I have used it, I have contributed to it, I have taught it, I have recommended it. Its API is seductive and its API is a huge contribution it has made to the JS landscape. The point, though, is that it's just an API -- an API that can be and has been be readily replicated. My experience has been that other libraries' APIs can have their own elegance, once you get used to them. The problem is that the appeal of jQuery's API I think is what can lead people to keep approaching problems in a DOM-centric way long after it makes sense. I do not fault jQuery for this, but I think as a wider JavaScript community we do well to discuss -- and not in an us v. them way! -- other viable approaches that exist.

Finally: Backbone is a viable entry in the field, and I am eager to see more complex examples (to-do list applications fall far short of this) that use it. I haven't used it personally, but I mostly like what I see and have heard good things about it. Unfortunately it had just come out right before my Berlin talk, and while I may have mentioned it in my actual talk, it isn't in the slides. (That said, I do cringe a tad that its examples suggest (http://documentcloud.github.com/backbone/#Model) that a "Sidebar" is a thing that should be a model.)

Re: Modern JavaScript

#30

The core message is good but I think Rebecca's obsession with jQuery just kills here ability to deliver it. jQuery is not a problem. jQuery's popularity is not a problem. Complex applications are the problem. People not knowing how to structure complex applications are the problem. Let's see the context there: jQuery is wildly popular, but it is the right tool for the job in most cases. Not all web pages jQuery is us…

I appreciate your feedback and understand that previous posts of mine have framed this as a jQuery vs. Dojo debate; I tried particularly hard not to do so in this post, and I think you'd be rather hard-pressed to say that this post was a "jQuery vs. Dojo" diatribe. Yes, it linked to my Berlin slides, but that's simply because a post in response to them is what got this whole post percolating in my head to begin with.…

Oops -- that's a very good point about the Model example being a bad one -- I was just trying to use something visible, in order to see the "change" event binding in action. Perhaps we should swap it out for something more model-y.

These days, if you're looking for complex Backbone examples, there's a bounty to choose from:

* http://getflow.com

* http://m.soundcloud.com

* http://basecamphq.com/mobile

* http://getcloudapp.com

* http://www.documentcloud.org/public

Post reply on HN