Live data from Hacker News

A 220b spreadsheet app in HTML/JS

xem.github.io

41–50 of 105 posts

Re: A 220b spreadsheet app in HTML/JS

#41

Super impressive and I love code-golfing but the title is slighlty misleading since the HTML part of the app, the cells, seem not to be included in the 220b. Still great.

I think I see what you're meaning, but this code actually generates all the cells (). You can execute it in a JS console and it'll work fine.

Re: A 220b spreadsheet app in HTML/JS

#42

If, like me, you're trying to figure out how this works, I've expanded it here to make it more readable: https://pastebin.com/1c72BYK1

Hey, thanks! Would you like me to write a commented version of that code? A lot of black magic is still hidden in every line :)

Re: A 220b spreadsheet app in HTML/JS

#43
I'm concerned about the lack of type annotations. What about XSS prevention? Maintainability? An API? How are people supposed to use this code in future projects? Your variable names don't conform to Code Complete. This code smells funny. Haven't you read clean code? And I don't think it's general enough. What if people want to add columns, but preserve formulas? What made you think you shouldn't use React for this? At least Vue, come on.

ah, if only we could all code just what we needed, instead of over-engineering solutions to problems we wished we had

Re: A 220b spreadsheet app in HTML/JS

#45

Yesterday I was blown away by both tetris and snake golfed out to this degree and now this. I feel like this is the modern reincarnation of obfuscated c. Can somebody explain to me how: "a[i]+-~j" is the same as "a[i]+(j+1)" ?

>Can somebody explain to me how: "a[i]+-~j" is the same as "a[i]+(j+1)" ?

-(~j) = Twos complement of the ones complement of j

Twos complement = ones complement + 1

So twos complement of (ones complement of j) = ones complement of (ones complement of j) + 1 = j + 1

Re: A 220b spreadsheet app in HTML/JS

#46
post #33

Earlier quoted context omitted.

yes hack yourself. bravo :) I guess you would have to sanitize when you save and/or load the spreadsheet

> I guess you would have to sanitize when you save and/or load the spreadsheet Sanitizing? No chance. Either you have a dedicated expression parser, or you run it directly throgh eval. There is no reliable middle ground. Decades of security failures of so-called "sanitizers" show this pretty clearly. (Even if you manage to create a perfect sanitizer today, wait a few months, new features are added to the browser, and…

Is there really no middle ground? Sanitizers fail because they try to salvage the clean part, only blacklisting some possible inputs. But what if you turn it around? Only send to eval what fits through a matcher for a very small subset of the language. The matcher can even allow invalid inputs if you know that eval will safely reject them (think unbalanced brackets). That matcher will be much easier and safer to implement than a full parser/interpreter for the same subset.

Re: A 220b spreadsheet app in HTML/JS

#47

I'm concerned about the lack of type annotations. What about XSS prevention? Maintainability? An API? How are people supposed to use this code in future projects? Your variable names don't conform to Code Complete. This code smells funny. Haven't you read clean code? And I don't think it's general enough. What if people want to add columns, but preserve formulas? What made you think you shouldn't use React for this?…

All of the things you mentioned are best practices when building something that you want other people to use in production. The author was trying to build this with the absolute minimum amount of code as an exercise so I don't think any of your comments here apply.

Re: A 220b spreadsheet app in HTML/JS

#49

I'm concerned about the lack of type annotations. What about XSS prevention? Maintainability? An API? How are people supposed to use this code in future projects? Your variable names don't conform to Code Complete. This code smells funny. Haven't you read clean code? And I don't think it's general enough. What if people want to add columns, but preserve formulas? What made you think you shouldn't use React for this?…

This seems to be code golf, which would answer most of these questions I think. Maybe I'm missing some sarcasm in your comment, it's early!

Re: A 220b spreadsheet app in HTML/JS

#50

I'm concerned about the lack of type annotations. What about XSS prevention? Maintainability? An API? How are people supposed to use this code in future projects? Your variable names don't conform to Code Complete. This code smells funny. Haven't you read clean code? And I don't think it's general enough. What if people want to add columns, but preserve formulas? What made you think you shouldn't use React for this?…

ha ha, you're absolutely right on each and every point, but for your information: you can add columns by adding more letters after "ABCD"
Post reply on HN