DailyJS

Contracts.coffee, Game Prototyping, Persistence.js

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

libraries html5 mobile games coffeescript

Contracts.coffee, Game Prototyping, Persistence.js

Posted by Alex R. Young on .
Featured

libraries html5 mobile games coffeescript

Contracts.coffee, Game Prototyping, Persistence.js

Posted by Alex R. Young on .

Contracts.coffee

Contracts.coffee (GitHub: disnet / contracts.coffee) by Tim Disney is a new dialect of CoffeeScript that adds contracts.

Contracts let you clearly express how your code behaves, and free you from writing tons of boilerplate, defensive code.

// id is a function that should always be called with a number and return a number
id :: (Num) -> Num
id = (x) -> x

When I first looked at this I thought I was looking at Haskell, and the
author points out the similarity:

It looks a lot like types (in fact the syntax looks a lot like Haskell) but unlike types, contracts are enforced at runtime in pure JavaScript.

The Contracts.coffee site
includes lots of details on how to get started using the dialect. I
don't usually write CoffeeScript, but this twist on the language is
definitely extremely interesting.

TJ Holowaychuk on Game Prototyping

In Game prototyping with JavaScript &
CSS3
,
TJ talks about game prototyping with CSS3, HTML5, and
move.js (GitHub: visionmedia / move.js, License: MIT). TJ discusses how he started writing a game for iOS, moved to Canvas, and
then discovered the performance gains of CSS3 and HTML.

He's posted a
game-prototype to GitHub, and I hope to see more (particularly as he mentions Grim
Fandango in his blog post).

Persistence.js

Jacob Mumm emailed us about his experiences using
persistence.js, an asynchronous ORM mapper by Zef Hemel. In particular, persistence.js
comes with persistence.sync.js, a remote server
synchronisation plugin:

persystence.sync.js is a persistence.js plug-in that adds data synchronization with remote servers. It comes with a client-side component (persistence.sync.js) and a sample server-side component (persistence.sync.server.js) for use with node.js. It should be fairly easy to implement server-components using other languages, any contributions there are welcome.

I'd like to write more on mobile sync in the future, as I've done a lot
of work on native app syncing (mostly Objective-C), and I've also
recently been working with single page client-side apps that sync
against remote APIs. If you're interested in this area, give
persistence.sync.js a look.