476 karma · joined August 26, 2009
Here is the version — by popular demand — that only uses DOM methods and does not use Angular, still clocking at 99 lines:
https://audreyt.github.io/500lines/spreadsheet/as-without-an...
I have joined some short statements, but each line is still at most 99 characters.
Source code is at: https://github.com/audreyt/500lines/tree/master/spreadsheet/...
It was an interesting exercise — thanks for suggesting it!
In my previous writeups such as http://g0v.asia/tw/ , I've followed SPJ's "writing a paper" guidelines ( HN: https://news.ycombinator.com/item?id=6989806 ) — almost to the letter — which was immensely helpful as well.
In a couple year's time, Web Components, Shadow DOM, and Object.observe may very well make application of this size not requiring AngularJS anymore, just like the "no tool at all" document.querySelector replaced jQuery.
I'd be happy to revise the chapter once a suitable polyfill exists for today's browsers — pull requests welcome, too!
Technically, Web Worker is not a library, and Traceur is used to translate ES6 to ES5 while browser support catches on, so AngularJS is the only library used.
The non-Traceur ES5 version at https://github.com/audreyt/500lines/tree/master/spreadsheet/... has exactly the same line count, but with more idiomatic workarounds that's less clear to students new to web development (the audience of this book).
It is possible to replace AngularJS (the only external library) with regular blur/focus/change handler as @xem shows — without affecting the line counts — but the separation of concerns between view, logic and worker would be less clear.
EtherCalc is mostly in maintenance mode at this moment, and the "99 lines" engine described here is an attempt to simplify its core logic both for educational and refactoring purposes.
Back when it appeared on HN, the first thing I entered was =(function(){for(;;){}})() — which predictably froze the browser.
Trying to find a sufficiently-robust way around this restriction ended up shaping the Web Worker based structure. So, thanks for the inspiration & golfing!
The version at https://github.com/audreyt/500lines/tree/master/spreadsheet/... has exactly the same line count, but with more idiomatic workarounds that's less clear to students new to web development (the audience of this book).
It is possible to replace AngularJS (the only external library) with regular blur/focus/change handler as @xem shows — without affecting the line counts — but the separation of concerns between view, logic and worker would be less clear.
It's like Kanso/CouchApp for CouchDB, and has support for the functional/object-oriented/new-fangled LiveScript language on top of the v8 engine.
Still working on the homoiconicity part, though!
We can also refactor Social Scripts into Social Programs through sharing Codes of Conduct to build maintainable communities.
EtherCalc was, is, and will remain a F/OSS infrastructure project, not a business enterprise.
A dictionary — being text-based, with very few animations, and no background soundtracks — avoided most of mobile-platform-specific issues.
(lo, as in a lota; lambic, as with an Iamb.)
Compare, say, people who self-identify as "German-American" instead of simply "American".
http://www.haskellforall.com/2013/09/perfect-streaming-using...
The pipes ecosystem ( http://www.haskell.org/haskellwiki/Pipes ) is working well to offer {effects, streaming, composability} without the resource leak issues introduced by lazy IO.
LiveScript: I'd rather be writing Perl-flavored Ruby, with a Haskell syntax. ( http://livescript.org/ )
A simple tiebreak function — such as lexicographic sorting on keys — means when the user requests "next page" via another range request, the same-scored second value will predictably show up on the beginning of next page, which is how users will expect in the real world.
Hope this helps!
If computation is local to each of many long-running threads, and the two-way messages being passed around is small enough (so the serialization overhead is negligible), then threads do perform better on multi-core machines than alternative models.
EtherCalc.org is one such use case: http://aosabook.org/en/posa/from-socialcalc-to-ethercalc.htm...
We're using it happily in production, and it's proved to be quite stable, and there's quite a few users — certainly more than the average amount of emails I get from other projects. :-)
It's true that I haven't heard from the earliest adopters (like Uber.com), but it might be a sign of its maturity rather than abandonment.
The last commit was 2 month ago, and only to repair compatibility with the then-just-released V8 version. It will likely require another commit for Node 0.12.0 — pull requests welcome!
Edit: Just released v0.4.8 to npm with references to the http://aosabook.org/en/posa/from-socialcalc-to-ethercalc.htm... writeup.
PgREST was originally designed for a large, in-production Postgres app (i.e. Socialtext), so we can get all the model, validation, view & trigger code in one place, getting the benefits of CouchApps while maintaining the underlying data layer.
For new projects, the main difference is likely familiarity with the toolchain (npm+Pg vs Kanso+CouchDB).
For authorization (authz) it's IMHO a bit better to handle it in the DB level, similar with Firebase's ACL lists.
The main difference is that back-end models, validation rules, triggers and views are coded in DB level via stored procedures written in Node.js-compatible modules, so it's enforced for both SQL- and HTTP-speaking clients.
As you pointed out, this is simply an instant JSON-over-REST API server on top of existing Pg databases, and is not intended to replace the need for traditional frameworks with server-side templating.
Firebase++ for an extremely well-thought-out API, though!