Live data from Hacker News

A 220b spreadsheet app in HTML/JS

xem.github.io

91–100 of 105 posts

Re: A 220b spreadsheet app in HTML/JS

#91
post #87

I hate to say that, but I just seem to have broken it. Here's how: I put 0.1 in A1, 0.2 in A2 and =A1+A2 in B1. Now B1 displays "=A1+A2" instead of the result.

Looks like any decimal place breaks it. Whole numbers only. But hey, whaddaya want for 220 bytes?!?

Weirdly enough, it works if the first number is an integer even if the second isn't.

Re: A 220b spreadsheet app in HTML/JS

#94
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…

Blacklisting (checking that the input doesn’t contain any of a fixed set of known troublemakers) is asking for trouble, but whitelisting (checking that the input doesn’t contain anything but a fixed set of known safe constructs) should be fine.

If your whitelist allows a wide range of constructs, it isn’t much easier to check that an input is in the allowed set than to write an evaluator that is limited to that set, so it may not be much of an advantage to have a more powerful ”eval” lying around.

Re: A 220b spreadsheet app in HTML/JS

#95
post #81
post #77

Earlier quoted context omitted.

Well, this spreadsheet as it is now isn't very much useful. In fact it is annoying at best. Only programmers will find it amusing and precisely because of how small the code is. No one is actually going to use it ever.

good thing we made it just for fun, then

I wasn't criticizing your work, but the commenter above, which sounded like it would be great if all software was like that.

Re: A 220b spreadsheet app in HTML/JS

#96
post #80
post #53

If we're using ES2015, why not save a byte? (o=b=>{for(j in a)for(i in a)y=a[i]+-~j,b?document.write([[" "][i]]+` `):eval(y+(".value"+o[y]).replace(/[A-Z]\d/g," +$&.value"))})(a="ABCD")

of course! Thanks, I'm adding this enhancement on github!

Here's another char off:

    (o=b=>{for(j in a)for(i in a)y=a[i]+j,b?document.write(``):eval(y+(".value"+o[y]).replace(/[A-Z]\d/g," +$&.value"))})(a="_ABCD")

Re: A 220b spreadsheet app in HTML/JS

#97

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?…

[deleted]

Re: A 220b spreadsheet app in HTML/JS

#98
post #68
post #66

Earlier quoted context omitted.

XSS prevention, maintainability, code reuse, good variable names, good-smelling code, readability, and using popular libraries are not "over-engineering". They are 95% of what makes someone a good employee instead of a shitty one. With modern languages and tooling, you can have the benefits of most of these things at little-to-no additional cost. If any of these require something complicated and "over-engineered", I'…

No. Rule one is making code that works correctly and quickly, in a short about of time. This is 100% of the job. If you think that "maintainability" and "readability" and "popular" libraries, and "code reuse" and "good variable names" and code that "smells good" to you, help someone do that, then great: That's an argument we can have just by pointing to anyone who gets rule one without those things. However. There's…

> There's another kind of person - and there's a lot of them - who thinks those things are important by themselves, and that putting those things ahead of what I think are rule one is ever acceptable.

I think you totally understood my humor. Thanks!

I saw a good blog in 2011 about how it is a waste of time to overbuild things since mostly you are only ever going to use that code for the specific purpose you are writing it, and you'll likely never need to generalize and you'll probably chuck it out anyway and start from scratch.

Obviously there are a bunch of caveats to that and it's not always true that's the case but I think it's a very useful counterpoint to the profession's current best-practice obsession. If you keep it in mind, alongside all the best practices, and you make a choice about approach in any given situation based on appropriateness, rather than just robotically applying best practices or giving into that common Engineer's temptation to overbuild, this counterpoint can help you build quickly just what's needed, which is effective, exactly like you said.

Re: A 220b spreadsheet app in HTML/JS

#99
post #80

Earlier quoted context omitted.

of course! Thanks, I'm adding this enhancement on github!

Here's another char off: (o=b=>{for(j in a)for(i in a)y=a[i]+j,b?document.write(` `):eval(y+(".value"+o[y]).replace(/[A-Z]\d/g," +$&.value"))})(a="_ABCD")

awesome! (oh noes, it gets rid of the +-~j trick! :D)

Re: A 220b spreadsheet app in HTML/JS

#100
post #99

Earlier quoted context omitted.

Here's another char off: (o=b=>{for(j in a)for(i in a)y=a[i]+j,b?document.write(` `):eval(y+(".value"+o[y]).replace(/[A-Z]\d/g," +$&.value"))})(a="_ABCD")

awesome! (oh noes, it gets rid of the +-~j trick! :D)

https://github.com/xem/sheet/pull/7 :D
Post reply on HN