The work by you, @aemkei et al was the inspiration for this chapter. :-)
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!
It also would have been more honest if it said "Web Spreadsheet in 99 lines using AngularJS and 11,331,980 lines of Code[1] in a modern web browser like Firefox."
Now that's a great write up. I always find when I'm blogging about some technical stuff, I start out strong and then say "ah screw it, here's the code, figure it out yourself". Kudos audreyt for great quality from beginning to end.
Glad you liked it! This is my first serious attempt at "literate programming" style writing; it did take many attempts re-arranging the functions in logical order for the prose to make sense.
To people commenting before reading, this link is more interesting in its discussion of how the demo was implemented than the fact that it is 'only 99 lines'.
Please check out the great write-up and thank you author(s).
Thanks for the amazing write-up. Extremely clear. I learned a lot about Angular and ES6, from this, and I encourage this meticulous write-up style for future projects.
Also, your attitude in dealing with the comments here is extremely commendable.
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.
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.
You're forgetting the many thousands of lines of code that went into writing the web browser it runs in, and even more that went into the underlying operating system.
I think the point being made here is that the OP only had to write 99 lines of original code using a few libraries and tools to get a rather impressive web based spreadsheet. If that's not impressive to you than your standards might be slightly too high.
Hi, thanks for the feedback! Sorry if it comes across as bragging; the line count is kept minimal both to reduce reader's cognitive burden, and make inline commentary feasible.
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.
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.
[+] [-] xem|11 years ago|reply
[+] [-] audreyt|11 years ago|reply
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!
[+] [-] enesunal|11 years ago|reply
[+] [-] polskibus|11 years ago|reply
[+] [-] audreyt|11 years ago|reply
[+] [-] logicallee|11 years ago|reply
It also would have been more honest if it said "Web Spreadsheet in 99 lines using AngularJS and 11,331,980 lines of Code[1] in a modern web browser like Firefox."
[1] https://www.ohloh.net/p/firefox/analyses/latest/languages_su...
[+] [-] waterside81|11 years ago|reply
[+] [-] audreyt|11 years ago|reply
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.
[+] [-] filearts|11 years ago|reply
Please check out the great write-up and thank you author(s).
[+] [-] VeejayRampay|11 years ago|reply
[+] [-] stevep98|11 years ago|reply
Also, your attitude in dealing with the comments here is extremely commendable.
[+] [-] lazyant|11 years ago|reply
[+] [-] doczoidberg|11 years ago|reply
Excel like spreadsheet editing in the browser
[+] [-] chandrew|11 years ago|reply
[+] [-] audreyt|11 years ago|reply
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.
[+] [-] callesgg|11 years ago|reply
Nice work anyway.
[+] [-] audreyt|11 years ago|reply
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!
[+] [-] gren|11 years ago|reply
Anyway, nice bunch of new ES6 features out there
[+] [-] audreyt|11 years ago|reply
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.
[+] [-] genericacct|11 years ago|reply
[+] [-] jorgeleo|11 years ago|reply
Not 99 lines anymore, hence no bragging rights
And # of lines stop being a problem since VAX computers
[+] [-] marknutter|11 years ago|reply
I think the point being made here is that the OP only had to write 99 lines of original code using a few libraries and tools to get a rather impressive web based spreadsheet. If that's not impressive to you than your standards might be slightly too high.
[+] [-] audreyt|11 years ago|reply
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.
[+] [-] joereggan190|11 years ago|reply
[deleted]
[+] [-] joereggan190|11 years ago|reply
[deleted]
[+] [-] joereggan190|11 years ago|reply
[deleted]
[+] [-] restlessmedia|11 years ago|reply