tgriesser | 11 years ago | on: Show HN: Interactive guide to Tetris in ClojureScript
tgriesser's comments
tgriesser | 11 years ago | on: JSX: XML-like syntax extension to ECMAScript – Draft specification
The great thing about JSX is that it doesn't build markup. It doesn't even need to be used for markup, it can be used for anything. It's frequently associated with markup because it has been used alongside React, but JSX standalone is a simple syntactic transform for XML-ish notation to JavaScript.
This is quite convenient in some cases, as you can elegantly write DSL's, where each of the tag names are JavaScript functions - and writing the equivalent JavaScript would look something closer to a lisp (moving the function name to the right of the paren).
This:
<Database name="business">
<Table name="user">
<Column name="id" type='int' length={10} />
<Column name="first_name" type='string' length={255} />
<Column name="last_name" type='string' length={255} />
<Column name="choice" type='enum' values={['a', 'b', 'c']} />
</Table>
<Table name="account">
<Column name="id" type='int' length={10} />
<Column name="first_name" type='string' length={255} />
<Column name="last_name" type='string' length={255} />
<Column name="choice" type='enum' values={['a', 'b', 'c']} />
</Table>
</Database>
run through the compiler[1] becomes this: Database({name: "business"},
Table({name: "user"},
Column({name: "id", type: "int", length: 10}),
Column({name: "first_name", type: "string", length: 255}),
Column({name: "last_name", type: "string", length: 255}),
Column({name: "choice", type: "enum", values: ['a', 'b', 'c']})
),
Table({name: "account"},
Column({name: "id", type: "int", length: 10}),
Column({name: "first_name", type: "string", length: 255}),
Column({name: "last_name", type: "string", length: 255}),
Column({name: "choice", type: "enum", values: ['a', 'b', 'c']})
)
)
I find the first easier to read / reorganize in blocks, which can be useful in lots of situations... definitely not all situations - but having declarative markup while being able to imagine it executing as the latter, constructing actual JS objects with specific logic built in - rather than needing to "parse" the XML tree and deal with an extra step of execution, etc, etc.tgriesser | 11 years ago | on: Human JavaScript
I'm not sure if there's something different about TS and React but I'd imagine if they have source map support it should work similarly?
tgriesser | 11 years ago | on: Ask HN: Is JavaScript the Good Parts still relevant?
http://www.amazon.com/Effective-JavaScript-Specific-Software...
Outside of books, http://superherojs.com is another good resource to recommend.
tgriesser | 11 years ago | on: Ask HN: Is there a consensus on the way to do JS inheritance?
tgriesser | 12 years ago | on: Managing Node.js Callback Hell with Promises, Generators and Other Approaches
Bluebird is not only so fast that it's almost on par with callbacks[1], but also innovates on the ability to filter on catching different error types[2], support for generators[3], context binding[4] among other things.
[1]: https://github.com/petkaantonov/bluebird/blob/master/benchma...
[2]: https://github.com/petkaantonov/bluebird/blob/master/API.md#...
[3]: https://github.com/petkaantonov/bluebird/blob/master/API.md#...
[4]: https://github.com/petkaantonov/bluebird/blob/master/API.md#...
tgriesser | 12 years ago | on: Ghost Blogging Software ported to PHP
tgriesser | 12 years ago | on: Knex and Bookshelf – ORM for JavaScript
In terms of maturity, Bookshelf & Knex are still definitely young and a work in progress, but fairly mature in the sense that they are both heavily inspired (and in Knex's case, mostly copied) from the excellent Laravel PHP framework's query builder and ORM. Bookshelf also adapts different conventions I found useful from Backbone.js' Models, Collections, and Events - I'm also aiming to eventually make the libraries usable outside of Node (webSQL or otherwise).
I've been looking to take the best from other languages' data interfaces and try to adapt them into a few great packages for javascript, as opposed to completely re-inventing the wheel.
Some of the differentiating features include eager-loading and nested eager-loading relations, the ability to constrain those relations[1], polymorphic relations, a distinct separation between the ORM and the query builder layer, and until recently transactions (which from what I've heard, sequelize has begun to add to the library).
Some things that Bookshelf doesn't have out of the box are explicit typecasting (hooks exist to handle this if you need, but most times the db takes care of this for you) or validations (IMO out of scope for Bookshelf/Knex, but something I'll have incorporated in my next database package), and static finder methods `User.find(1)`, `User.findOrCreate({...})` - easily added but these will also come in the next package in progress.
Bookshelf aims to be a simple Data-Mapper, rather than a full out Rails ActiveRecord style ORM... This is something that will be a different project entirely which I'm actively working on building out. Sitting atop of Bookshelf, it will include scopes, validators, callbacks, helper methods, etc.
[1]: https://github.com/tgriesser/bookshelf/issues/69#issuecommen...
tgriesser | 12 years ago | on: Create-error.js – A simple helper for subclassed errors in Javascript
The aim of this helper is to create a custom object which has the same functionality as a traditional Error object.
tgriesser | 12 years ago | on: Ghost Launches to The Public
So in theory putting in the correct connection config should allow you to use Postgres.
tgriesser | 12 years ago | on: Promises/A+
The source should be fairly annotated and is structured similar to Backbone.js, so it might be useful to take a look through and see where/how those functions are being used.
tgriesser | 13 years ago | on: Bookshelf.js: An ORM for Node.js with transactions, eager loading, promises
It also has support for handling database transactions, which seemed to be missing in any other libraries I had looked at, and also doesn't force you into a particular way of doing other things like validations or typecasting (though it does provide hooks/events for handling both).
The ORM is also just a single ~900 line file that takes a lot of inspiration from Backbone as being a library you can easily read through and understand, and focus on the important parts of database interaction, rather than trying to provide the kitchen sink.
tgriesser | 13 years ago | on: Bookshelf.js: An ORM for Node.js with transactions, eager loading, promises
It's definitely something I'll begin to look into a bit, possibly splitting up the Backbone components into a separate library specifically for Bookshelf, similar to lodash's custom build process. If you have any ideas for a good way to go about this, feel free to open a ticket.
tgriesser | 13 years ago | on: Bookshelf.js: An ORM for Node.js with transactions, eager loading, promises
I owe a lot of thanks to Taylor for writing Eloquent, he has been really helpful with any questions I've had in putting this together.
tgriesser | 13 years ago | on: Bookshelf.js: An ORM for Node.js with transactions, eager loading, promises
tgriesser | 13 years ago | on: Ask HN: How do you deal with the NodeJS Pyramid of Doom?
tgriesser | 13 years ago | on: Backbone.js 0.9.9 Released
This doesn't account for any child-views, or views that don't use .remove(), so you'll need to make sure those are taken care of when a view is destroyed. But in most cases, the garbage collection issues that have been seen relating to views & events are taken care of.
tgriesser | 13 years ago | on: Ask HN: Resources for advanced JS?
tgriesser | 13 years ago | on: Advice On & Instruction in The Use of Ember.js
[1]: https://github.com/documentcloud/backbone/commit/3ae1af6df1b...
tgriesser | 13 years ago | on: Ask HN: What tech problems would you glady pay $25 a month for a SAAS solution?