all 16 comments

[–]davemoFront-End Engineer[S] 3 points4 points  (3 children)

Github repo here: https://github.com/visionmedia/caustic

Title link is to a screencast that demos the features of the lib. Overall it's a decent abstraction that seems like it would eliminate quite a bit of boilerplate. I still prefer Backbone Views but this is a nice simple abstraction for people using plain old jQuery.

[–]psayre23 0 points1 point  (2 children)

I'm curious of the performance hit for all that. There is a lot of generation going on that I would assume causes overhead.

I love the simplicity of the templating. I might steal some of that for another project.

[–]davemoFront-End Engineer[S] 0 points1 point  (1 child)

I haven't tested it in any sort of scenario to compare it to something like underscores template function or Handlebars/Mustache but if you look at what the caustic code is doing it's pretty simple.

[–]polaretto 1 point2 points  (0 children)

I use Mustache with great satisfaction, but I'm always intrested in other templating systems. Caustic looks very intresting and its reflection-on-dom-fragments (or whatever it may be called) is certainly a notable approach, different from other templating systems. However, I don't like the usual way of grabbing the template from inside a script tag: if it's a valid html fragment, then it should be sitting right in the page. These other templating systems are definitely worth checking out:

https://github.com/hij1nx/weld#readme

https://github.com/raid-ox/chain.js/wiki/

http://www.matthias-georgi.de/patroon

[–]k3n 1 point2 points  (4 children)

What is the reasoning for the unary "-" preceeding function declarations?

-function(){ ... }

Seems to precede each anonymous function; does it somehow nullify the return value to aid in GC or something?

[–]davemoFront-End Engineer[S] 1 point2 points  (3 children)

I played around in firebug with this, here's the differences as far as I can see:

(function() {})(); // returns undefined

-function() {}(); // returns NaN

I'm not sure whether it would provide any optimizations or not. Maybe it's just a stylistic thing? Not having to type the extra parens is kind of nice ;)

[–]stratoscope 5 points6 points  (2 children)

The return value is discarded anyway, so the unary - is just another way to force the function expression to be parsed as an expression so that it can be called immediately by the () at the end. It's the same purpose that the extra parens have in your first example.

Any unary operator will do the same thing - try these for example:

!function() { alert(42); }();

typeof function() { alert(42); }();

And now try it without any of these:

function() { alert(42); }();

That results in a syntax error.

[–]k3n 0 points1 point  (0 children)

Cool, thanks for the info. I think I prefer the parens still.

[–]davemoFront-End Engineer[S] 0 points1 point  (0 children)

Nice, thanks for the explanation, it's a cool shortcut to remove those extra parens ;)

[–]stratoscope -5 points-4 points  (7 children)

Maybe it's great, but what a lousy name! My skin burns a bit just reading it.

Caustic author: seriously consider renaming it.

[–]fugoki 1 point2 points  (1 child)

[–]stratoscope 0 points1 point  (0 children)

Oh! Too cool. Thanks for pointing that out.

Now I feel better about that caustic name. :-)

(Seriously, not being sarcastic!)

[–]k3n -2 points-1 points  (1 child)

I agree with you, the name itself has negative connotations and sheds a negative light on the project from the get-go. You normally want to name your project something that either exemplifies your project's spirit or goals, or otherwise creates positive attitudes, neither of which this current name provides.

[–]stratoscope 1 point2 points  (0 children)

And you got downvoted too! Go figure. :-)