Live data from Hacker News

A spreadsheet in fewer than 30 lines of JavaScript, no library used

jsfiddle.net

171–180 of 274 posts

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#171
post #168

Earlier quoted context omitted.

Imagine if management had not vetoed non "Java-like" syntax's during javascripts creation. Maybe Brendan Eich could have gotten a decent scheme dialect into the browser instead, people could have learned it (because in hypothetical retrospect, what else were they going to do? Not learn it?), and we would be in a far more pleasant position today...

Not learn it? Certainly an option; keeping the syntax recognisable helped rather than hindered adoption, which was slow enough as it was at the beginning. JS+DOM could have lost to Flash rather than vice versa.

If being "like java" was so important, then why didn't it just straight up lose to "actually java"?

I don't think that JS+DOM beating flash/java has much to do at all with "gee, this looks superficially like java, but is different enough to trip me up in rather weird ways".

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#172
post #33

Earlier quoted context omitted.

Personally I was confused as to how the fellow got around the basics of having to parse tokens until I noticed with (DATA) now that's just genius. I hate writing token parsing.

Using both 'with' and 'eval' on the same line, nice ;) Douglas Crockford said in his excellent talk 'JavaScript: The Good Parts' that he highly recommends js -developers to avoid 'with', as it doesn't work correctly and for 'eval' he has to say 'If you are finding yourself using eval, you really are thinking about things the wrong way'. Source, starts where he is speaking about with and eval: http://youtu.be/hQVTIJBZ…

There aren't a lot of good reasons to use `eval` and `with` in production JavaScript. Two wrongs don't make a right, even when you use them on the same line of code.

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#173
If anyone else is wondering why formula evaluation is not working in Chrome, it is because jsfiddle is violating Chrome's security policy by serving up the javascript from fiddle.jshell.net (not jsfiddle.net).

When this javascript code attempts to access the LocalStorage API, Chrome (rightfully) steps in and says: nope. This may be a new security feature, but is present in Chrome 30.0.1599.114 on Fedora.

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#174
post #137

Earlier quoted context omitted.

A 30 line javascript spreadsheet is similar for me to when I first saw Norvig's 21 line python spelling corrector ( http://norvig.com/spell-correct.html ): this language is more powerful and expressive than I thought. I'm increasingly believing that HTML/CSS/JS in a browser is a viable common runtime. This demo does quite a lot to solidify that belief.

The only things that are powerful and expressive in JavaScript are bastardized beyond recognition versions of ideas from Lisp, Smalltalk and Self. You get those dynamic mechanisms that we know for 50 years now (lambda expressions and runtime method dispatch, oh wow) to be useful but without learning any lessons learned in those 50 years about how to design a coherent language based on those concepts, you just get a h…

So....I wonder...what's your idea of what should be a proper language to have in the browser?

Note: This isn't criticism of your view nor am I taking sides. I am wondering --since you have a strong opinion on this front-- what you think the solution might look like.

I mean, are you looking at the idea of having something like python natively available at the browser?

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#175

I am impressed. Its a neat hack, it actually is a real spreadsheet in 30 lines of code, with references fully working (ie =A3+B4 gives expected output. As does =alert("foo") but then nothing is perfect). I think it says something about the browser as a platform - these thirty lines simply assume an enormous amount that excel and visicalc could not - visicalc had to write their own screen refresh routines. It is usefu…

> What is it now that is the equivalent of writing our own screen handling routines?

Centering something using CSS. :(

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#176
What concerns me about developing browser applications is the idea that there are precious few ways to protect your code. I know we all love open source, but sometimes you want or need just the opposite. Not sure there's a way to truly achieve that with JS (limitations or not).

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#177
post #168

Earlier quoted context omitted.

Not learn it? Certainly an option; keeping the syntax recognisable helped rather than hindered adoption, which was slow enough as it was at the beginning. JS+DOM could have lost to Flash rather than vice versa.

If being "like java" was so important, then why didn't it just straight up lose to "actually java" ? I don't think that JS+DOM beating flash/java has much to do at all with "gee, this looks superficially like java, but is different enough to trip me up in rather weird ways" .

Don't conflate why Flash lost to why Java (in the browser) lost, there are very different reasons. For one thing, Java had failed as a browser plugin long before Flash did (as if we don't still see Flash in the browser...I wonder what our discussion would be if not for Apple?).

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#178

I am impressed. Its a neat hack, it actually is a real spreadsheet in 30 lines of code, with references fully working (ie =A3+B4 gives expected output. As does =alert("foo") but then nothing is perfect). I think it says something about the browser as a platform - these thirty lines simply assume an enormous amount that excel and visicalc could not - visicalc had to write their own screen refresh routines. It is usefu…

A 30 line javascript spreadsheet is similar for me to when I first saw Norvig's 21 line python spelling corrector ( http://norvig.com/spell-correct.html ): this language is more powerful and expressive than I thought. I'm increasingly believing that HTML/CSS/JS in a browser is a viable common runtime. This demo does quite a lot to solidify that belief.

> Norvig's 21 line python spelling corrector

That spell checker is intended to demonstrate a technique but it is far from 21 lines of real code. It you look at the included modules (re and collections) you'll find THOUSANDS of lines of code.

As always "I did x in n lines of " often are really interesting learning tools but real production code isn't (or should not) ever look like these examples. No criticism of Norvig's code, it's interesting and I, too, learned something very interesting the first time I saw it.

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#179

Earlier quoted context omitted.

They would have learned whatever Java/C-derived scripting language that Microsoft came up with instead.

That was likely the fear at the time, but what we actually saw was Javascript became popular because it was useful and there wasn't really anything else like it. It became popular, so Microsoft threw in with it too. In order for that to have not happened, it would have had to be so unpopular that Microsoft would decide it wasn't worth adopting, but still popular enough to get Microsoft on board with the general idea.…

that is a weird and complicated take.

microsoft had visual basic in the browser, working like php works. that was microsoft's vision, which would have been the web if netscape didn't still have significant market share. IE had to implement javascript to be compatible with pages written for netscape.

simple as that. just microsoft's famous "embrace, extend, extinguish" strategy at work.

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#180

I am impressed. Its a neat hack, it actually is a real spreadsheet in 30 lines of code, with references fully working (ie =A3+B4 gives expected output. As does =alert("foo") but then nothing is perfect). I think it says something about the browser as a platform - these thirty lines simply assume an enormous amount that excel and visicalc could not - visicalc had to write their own screen refresh routines. It is usefu…

> What is it now that is the equivalent of writing our own screen handling routines? Centering something using CSS. :(

Just goes to show how much the far left and the far right has influence over our society
Post reply on HN