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?…
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.
A 220b spreadsheet app in HTML/JS
81–90 of 105 posts
Re: A 220b spreadsheet app in HTML/JS
#82Earlier quoted context omitted.
I'm more concerned with the use of the symbol `b` to denote bytes instead of `B` :)
Yeah. A 220 bit spreadsheet would be impressive. Particularly the achievement of the source length not being a whole number of bytes.
Re: A 220b spreadsheet app in HTML/JS
#83Re: A 220b spreadsheet app in HTML/JS
#84Earlier quoted context omitted.
Hilariously Chrome offers to pass the c code through Google Translate (with predictably useless results)
Language detection works on language trigrams, and are trained on human language. I bet punctuation is stripped during preprocessing. So it's not surprising that code will have false positives.
Re: A 220b spreadsheet app in HTML/JS
#85Hello World, I'm xem, author of this mini app, but standing on the shoulders of giants: it's inspired by http://aem1k.com/sheet/ which was inspired by http://jsfiddle.net/ondras/hYfN3/ Cheers to all the JS codegolf team who teached me this noble art and continue to learn new tricks everyday with me! You can find a list of all our mini apps here: https://gist.github.com/xem/206db44adbdd09bac424
Cheers
Re: A 220b spreadsheet app in HTML/JS
#86This is awesome, are you planning to add more features like complex functions that are minimally sized?
Re: A 220b spreadsheet app in HTML/JS
#87I 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.
Re: A 220b spreadsheet app in HTML/JS
#88Earlier quoted context omitted.
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 impl…
> Only send to eval what fits through a matcher for a very small subset of the language That's exactly what I meant by "dedicated expression parser". (Not sure why you name it "matcher", though. Please be aware that a regex-based matcher will almost certainly fail for that task. You usually want a grammar, i.e. parser, which is more powerful, and shorter, and easier to read and to verify.) EDIT: To those who downvote…
If you relax the rules, as the gp said, you can get away with something like a regex to do the job. While regex's are bad at context free grammars [0], if you forgo balancing brackets etc. a regex will do just fine.
All that said, with the crazy things JS lets you do [1] a recogniser for a relaxed language is likely to still let potentially dangerous code though.
[0] Yes, with most regex engines you can parse CFGs, but it's not nice, and at that point you _do_ want a grammar based parser
Re: A 220b spreadsheet app in HTML/JS
#89Judging by some of the comments one can regularly find on HN about the size of apps, this may be considered a pinnacle internet technology to be standardized mainstream Tongue in cheek aside, very creative code. Thank you for sharing
Re: A 220b spreadsheet app in HTML/JS
#90Earlier quoted context omitted.
> Only send to eval what fits through a matcher for a very small subset of the language That's exactly what I meant by "dedicated expression parser". (Not sure why you name it "matcher", though. Please be aware that a regex-based matcher will almost certainly fail for that task. You usually want a grammar, i.e. parser, which is more powerful, and shorter, and easier to read and to verify.) EDIT: To those who downvote…
There is a difference between a recogniser, which answers the question "does this belong to the language", and a parser, which outputs a data structure. All you need here is a recogniser, and then pass the string through to eval which will do it's own parsing. Recognisers are smaller than parsers. If you relax the rules, as the gp said, you can get away with something like a regex to do the job. While regex's are bad…