Hi,
First of all this thread is not meant to be another closure library
vs. x or y troll, I'd just like to have your opinion :)
I got started with closure library and templates and find that is has
quite a steep learning curve: the library is huge, and not often very
well documented, however grabbing the source and poking around helps
understanding the internals.
Also, having experience with strong typed languages (Java,
ActionScript3) helps me understand the concepts and I find closure's
concepts very useful in the JavaScript development workflow,
However, I still am not using closure in big projects, mostly because
I don't feel ready yet ... that said, in the current project I am
working on, I can start feeling the lack of 'closure' in our app.
I also recently started having a look at Dart, and I find it also
fills the gap when it comes to type checking and bringing oop concepts
to JS
I was wondering if it was worth starting to use closure in my big
project or if I just switch to Dart once it's stable enough...? What
would you do, and what does the closure team think about Dart?
Also, if you have good resources concerning MVC with closure, or
examples/tutorials of single page apps, I'd be delighted (I have had a
look at the Releif framework, but I'd like to understand the internals
before starting using it, I also started checking goog.history and
goog.events packages so I'm starting to get an idea of how this works)
That said, we're not naive. There are many well-designed languages
that are not successful, and many poorly-designed languages that are
widely used. So I think that Closure team doesn't want to jinx Dart by
passing judgment on it one way or the other.
If you're looking for a way to "practice" Closure (or Dart), I think
the best way is to use it to write tests. That's how Closure got wide
adoption within Google. The Closure test runner was much better than
everything else at the time. And if you find out that you don't like
one framework, it's a lot easier to rewrite tests in a different
framework than it is to rewrite the core of your app.
Nick
This comment is slightly misleading in context.
Just to clarify, the warnings that Bjorn is referring to are not type
warnings. They're almost all private/protected warnings (i.e.,
@private). While almost all users care about type warnings, very few
users have historically cared about the access control warnings, and
most teams just turn them off (which the compiler api lets you do
easily).
Nick
heh. I thought it was a good demonstration of the trade-offs between
Dash, where the ideas are baked into the language, and Closure, where
according to freedictionary, they are synonyms
http://freedictionary.org/?Query=dart
i also sometimes call it "Scoot" or "Flash".
I don't love the type system. I immensely prefer static typing over
truthiness and other silliness in dynamically typed languages, but the
Closure Compiler warnings lead to 99% jsdoc comment fixes. It hardly
ever finds anything that would actually break in runtime, fixing
warning feels like unnecessary busy work. We have quite a bit of type
casting jsdoc comments in our code that is like this.doSomething_ (/**
@type {Object} */ someVar);. These warnings are probably correct given
the explicit notation, but pedantically so, and if I removed the
litany of extra jsdoc notation inside the code our app would not
break. A linter that requires === for equality evaluation is much
simpler, requires less work and actually finds problems.
In addition, while we work hard to have zero warnings for our own code
from the compiler, and in fact our build fails if Closure Compiler
reports any of our own making, we have still have warnings from the
Closure Library itself. So not even the authors of the Closure Library
take it seriously. Otherwise we could use the Compiler's error out on
warning instead of some hack that monkey patches the Closure Library
build tools so we can check the stdout and stderr output against
expected warnings.
I think you really have to ask yourself: would you really have so few type-related errors if the compiler/library hadn't forced you to specify them so precisely? Perhaps the reason why you don't feel the compiler is catching many is because it has helped you write better code that is less susceptible to such errors the first time around :)