Hacker News new | ask | show | jobs
by RyanDScott 5661 days ago
Reasons you might consider using Closure instead of something like jQuery, plain-old-js:

1. Your javascript file is getting huge and you want to break things out into manageable pieces.

2. You find yourself needing namespaces that are easy to implement.

3. You want to learn how to build structured javascript (Closure is great at encouraging well documented, "object-oriented" coding)

4. You've got too many js files (2+) and you want to only have one in production for faster page loading (use closure compiler)

5. You're building an application with a team of developers; closure helps create modular, well documented code

6. You want to build a snappy, client-side heavy application

Before I ever used Closure, I used javascript more like frosting on a cake. Javascript can be frosting, but it can also do some amazing things. My biggest complaint with javascript in the past has been it's unwieldy nature in medium to large projects. I stuck to using javascript/jQuery to decorate html pages and had the page generation, business logic, templating, etc., on the server side (Python). Then I wrote a medium sized application in closure, and it worked, and it's maintainable, and it didn't require a lot of server side code, and it was fast.

I couldn't be happier.

My only complaint is it seems Closure development doesn't have the velocity that other projects like GWT have. Google, it seems, is putting it's money more on GWT than something like closure; or so it seems based on the amount of announcements for GWT, the quality of the tools and libraries being produced, the number of updates to closure compared to GWT. While GWT is a powerful tool, it's more complex (thanks to Java), harder to setup, harder to get started. In some ways I wish they would take the tools and frameworks they have for GWT and build them for Closure.