A novel approach to web programming
100% Javascript
Declarative programming
Strong typing, smart editor
In Hammock, a class is simply a JSON document that has a schema (a "fields" property).
A class is always an instance of another class. The root class, which defines the basic types and structure of a class schema, is an instance of itself.
{ "fields": { "name": { "type": "string", "required": true }, "fields": { "type": "object", "required": true, "value_fields": { "type": { "type": "select", "required": true, "options": ["string", "select", "boolean", "object", "array", "number", "function", "markup", "date"] }, "required": { "type": "boolean" /* default: false */ }, "options": { "type": "array" }, "fields": { "type": "object" }, "value_fields": { "type": "object" }, "ref": { "type": "select", "ref": "class" }, "ref_field": { "type": "string" /* default: "name" */ } } } } }
{ "name": "react-meta-class", "fields": { "render": { "type": "function", "required": true }, "getInitialState": { "type": "function" }, "componentDidMount": { "type": "function" } } }This is a class definition for any React.js class. (we called it a meta-class because instances of this class are React classes -- both Hammock and React use the term "class", but they're not really the same thing).
So if we define a class, with the following schema...
{ name: "post-class", fields: { title: { type: "string", required: true }, category: { type: "select", options: ["main", "business", "tech"] }, state: { type: "select", options: ["draft", "published", "archived"], default: "draft" } } }
The editor offers auto-complete support:
Just keep pressing Tab, autocomplete helps you fill in the document. Easy!
When using the Hammock Web Shell to develop a project, both your code and data is stored in JSON documents in a database (using PouchDB and CouchDB).
Similar to other languages, modules can be used to:
Hammock.createModule({ name: "hello-world", title: "Hello World!", world: "earth", render: function () { return <div>Hello {this.world}!</div>; } });...yes, that looks exactly like a React class, that's the point. But a module can also do a lot more.
A more complex example:
(this part is under construction)