Hacker News new | comments | show | ask | jobs | submit login
How Batman.js can Help you Build Apps (shopify.com)
85 points by joshuacc 1861 days ago | hide | past | web | 35 comments | favorite

Before anyone gets too upset: both Batman.js and the code examples are written in Coffeescript. If you wish, you may write Batman apps in js, since Batman compiles to native js.

Calling it Batman.coffee just didn't sound as cool.

It would be very unpleasant to write a Batman app in js since it's dependent on CoffeeScript's "extends" capability (which can be recreated in js, but would be unpleasant as most frameworks handle this sort of thing for you). Of course this can be fixed if they decide to provide a Batman.extend() method.

Looks very nice! I'm certainly excited to try this out on mobile, as it sounds pretty perfect for that. I'd rather wait for pushState support as I dislike hangbangs. Looking at the source, it would likely be easy to create alternate storage adapters, which is something I'm interested in.

Extends is compiled into JS. You can add it to Batman:

    var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
      for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
      function ctor() { this.constructor = child; }
      ctor.prototype = parent.prototype;
      child.prototype = new ctor;
      child.__super__ = parent.prototype;
      return child;
    Batman.extends = __extends

well, you can use jQuery.extend(whateverBatman, *methods) if you want to extend it. (i don't do much JS, but I know just enough to write really bad code)

While similarly named, these functions actually do quite different things.

jQuery.extend is a function which copies references to properties out of later objects into the first argument.

CoffeeScript's extends is a language keyword which creates inheritance relationships in CoffeeScript's built in object model. (Which is similar but not identical to the object model in Backbone.js.)

No, jQuery.extend copies properties. It is not the same as CoffeeScript's extend, which uses prototypal inheritance as well as copying static properties.

No matter how good it gets. I'm going to have a really hard time seriously recommending my team go with batman.js for our next project.

My team's core language is named after a surrealist British comedy troupe ;-)


I think that language would've had difficulty if it was called montypython :).

Batman.js, unfortunately, only evokes one image.

So you're saying it needs a half-man-half-bat logo to make sure it can evoke more than one image? :-P

I think it needs a man-wielding-a-bludgeon logo.

named after or name inspired by?


I think many here are thankful they're not working wherever it is you work.

In a former life, I helped out on the SproutCore project. It's good to see things like Batman.js taking up the challenge of a tightly-integrated MVC framework.

(I'm still bummed SproutCore didn't take off, but there's little I can do to change things now.)

If you're wary of having to troll annotated CoffeeScript source to discover some features and figure things out, then hold off a bit. Batman was open-sourced just a month ago. Docs are not there yet.

But I'm very happy with it. It makes some mundane things pretty delightful. Some of the best parts of it, IMO, are a powerful view tier and terse template style. A super easy macro for creating routes and reverse routes. A promising Filter type, that Github indicates is being improved.

Also, you don't need to use NPM to install it. If you're looking to just use it on the client side (I'm using it w/ Python and PHP), just clone the repo.

So is there a good grid comparing batman.js with backbone and knockout.js?

It appears to me (in my 1 minute look at the site) that it's a server-side framework. backbone and knockout are client-side

EDIT: I think what I just said is incorrect since the article makes a backbone comparison

Yeah, it's a client side framework. Though it seems like they're going to be rolling out a server as well -- though I'm sure it will not be required. That is, you'll be able to use Batman with any server you want.

I think it's cool that you will be able to use the same language - CoffeeScript - and even the same objects on both client and server side.

But the server side stuff is optional. At the moment you can persist to HTML5 localStorage or REST.

I have a difficult time finding things that differentiate Batman.js from Knockout.js

edit - Further research shows RESTful persistence is the highlight difference and Batman.js is a bit cleaner.

Templates in Batman (eg, your HTML files) are a lot cleaner.

Batman is a great choice if you're using CoffeeScript.

On the other hand, Knockout has way better docs. Batman will get there eventually. But right now it's still pretty rough going.

I've been using batman for a bit now, really loving it.

Looking forward to the event system rewrite that they're working on now to close out some open issues.

The templating in knockout is getting a lot cleaner with 1.3 which is in beta. There are now if, with and foreach bindings that use the inner HTML as the template instead of having to write the template as a separate script block.

Knockout is also probably being included in ASP.NET MVC 4 - it's in the beta - which should help it gain traction especially amongst beleaguered Silverlight developers thanks to it's familiar MVVM / data binding structure.

Also Batman has Rails style generators that create a familiar directory structure and a built in server. They're both really neat.

Cool stuff.I'm keen on creating apps though I'm only a novice in programming but that doesn't prevent me from making complex and profitable apps.I'm using snappii.com and consider this service to be the most flexible concerning design opportunities among its competitors.

How is calling it "batman.js" not a trademark violation?

1) It is not a confusingly similar service or product


2) I doubt DC Comics cares

1) It is confusing. Batman is neither a common word nor name. Without reading about it you could easily mistake it for a product of the DC comics web team.

2) I'm sure they care about their trademark being devalued through unauthorized uses.

The real defense batman.js has is that the library is named after a turkish provence: https://secure.wikimedia.org/wikipedia/en/wiki/Batman_Provin...

Trademarks have no application outside of trade. If they're not selling batman.js or seeking to confuse buyers of Batman merchandise, there is no trademark violation. Especially considering this is a web development framework, which isn't even remotely related to Batman media.

Well we both know it's a very large grey area. But while I agree that the combination of the words bat and man alone could in someway be construed as non associated with the comic star, using code examples like:

batWatch = Batman currentCrimeReport: Batman address: Batman number: "123" street: "Easy St" city: "Gotham"

- and -

jokerSimulator.get("why so serious") #=> "WHY SO SERIOUS, HA HA HA!"

kind of destroys the ambiguity.

Don't get me wrong, I think the technology behind batman.js is interesting and useful. I just think it's rather unfortunate that they chose a name with such strong pre-conceptions and that is so childish.

It doesn't matter if it's associated with the comic star, it only matters if it's in the same area as the trademark.

you say childish, I say fun. why so serious? ;)

There are so many [yourlibrary]js.org microframeworks out there, and their feature sets are mostly equivalent, and largely unnecessary for small projects, that it ultimately becomes impossible to get behind any of them.

Perhaps, instead of asking yourself how this could help you with something you already do competently, you might try asking yourself “What does this make possible that was previously painful?”

batman -> coffeescript -> javascript. I don't get it.

Too many layers of abstraction.

I'm having serious trouble with even jQuery (with IE7,8 for example) on some of the stuff I'm working on, particularly on older machines.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact