Hacker News new | past | comments | ask | show | jobs | submit login
A Haml-inspired mini-language for jQuery: Jabs (github.com/collin)
43 points by collint on Nov 30, 2009 | hide | past | favorite | 9 comments



I've yet to find a considerable value-add in Haml. With Sass the value is pretty clear -- CSS can benefit from having variables and functions to make scripts more reusable and easier to manage. As a Python user I'm a lover of significant whitespace, but with the ability to have my text editor auto-complete tags it isn't worth it to learn a new DSL just to save on some brackets.

With Jabs it's even harder for me to see the value; I'm required to learn a new syntax in order to remove some braces and add implied variables. The $ selector for instance removes all of four characters, two of which could be added automatically, if that's your thing. jQuery itself is already a rather terse library and with Jabs I'm adding yet another layer of abstraction and the need for compilation to writing JS.

The code is also harder to parse (for me) as a result of all the implicit variables. I suppose that isn't of much concern if you're just using it to write your own JS and nobody ever has to look at it, though. The ability (and probably frequent need) to mix JS and Jabs only creates a larger mess, I would imagine.


Its not just saving on brackets; you get a few other benefits like not worrying about closing or improperly nesting tags. It also slightly changes your mindset from, "I'm just cranking out markup," to, "I'm building out a DOM tree," which turns out to be great thing for Javascript development.

ERB/"classic" markup still have their place though. HAML is a real pain if you need to crank out a web page that's heavy with content. I use both ERB and HAML in most of my Rails projects; HAML for the more "application/javascript"-heavy parts of my apps and ERB for the content-heavy pages.

At a glance, I don't see the value in jabs. While it might make code more compact, it doesn't seem to be as clear to worth with as HAML & SaSS. Trading clarity for compactness is a trade-off I reject.


Yeah, these sorts of things aren't for everybody.

I love my editor too, and for me it makes writing html and jquery code bearable.

One thing I like about HAML is it really changes the way I think about my markup while writing it and while I'm reading it. This is very much my thing :)

One thing I like about Jabs is the stylistic constraint it imposes. There is a very uniform way to write behaviors in Jabl. I find that when I write straight jQuery I sometimes draw outside those lines. Jabs keeps me in check.

I also think it's important for something like Jabs to stay strictly in the realm of Dom manipulations and event callbacks. As far as I can tell it has no place managing the business logic of your javascript applications.


And ruby's manifest destiny continues

Your current language is too ugly or verbose? There's a ruby DSL for that


I've found that smaller, more expressive DSL's drastically improve productivity over time. HAML, SaSS, and Compass have saved me an insane amount of time. I'll keep using these types DSL's for as long as they keep making me more productive.


Normally when I think of a ruby DSL, I think of a DSL embedded in a Ruby program (a DSL that is legal ruby syntax). In this case a jabs DSL file is not legal Ruby or javascript, but is turned into valid javascript by a Ruby program.

It is possible that the culture of Ruby does leads to Rubyists writing things like this.


I just recorded a screencast showing a quick example coding session for Jabs http://www.youtube.com/watch?v=JdnXJ6bj_qs


Added a second video, showing a more advanced example with drag and drop.

oops: http://www.youtube.com/watch?v=NntBOWEaAlU


Nice work!




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

Search: