
Ask HN: What is with all these 'X in 30/35 lines of Javascript' posts? - sarreph
Just curious, but why is there suddenly a lot of attention on the type of things people can create in 30 lines of Javascript?
======
beagle3
I don't know about JavaScript, but generally short code is impressive: For
most of these things, if you think about doing them "the usual way", you think
about a 10x or 100x (or 1000x) more lines of code. e.g. there used to be a 842
line Java Spreadsheet example in the JDK (maybe it is still there). And then,
someone shows you that it can be done in 35 lines of JavaScript.

As a hacker, it is a case study of (ab)using some JavaScript features on one
hand (yes, _with_ , I'm talking about you), and on the other hand, it is
tractable proof about which part of (say) the 842 lines are useless, and why.

Many people have not experienced lots of functionality in very little code,
and the fact that it is possible is both surprising, and often inspiring.

And JavaScript is familiar, so it gets an audience. If I posted the two (2)
line K2 spreadsheet, that does a lot MORE (e.g. keyboard control) than the 30
line JS one, and needs a 200KB K interpreter, instead of a 20MB browser - then
people will just ignore it with a SEP field.

    
    
        S..t:".[`D;(;);{. y};S[]];S[.;`f]:9$D[]"
        S:D:.+(`$'_ci 97+!26;26 99#,"");`show$`S
    

If you want to know more, head over to
[http://nsl.com/papers/spreadsheet.htm](http://nsl.com/papers/spreadsheet.htm)

------
bjourne
Love them. Much more interesting than the average hn posts.

------
pritambaral
It is obviously an impressive thing. People are always impressed by a computer
language/framework that can do "so much" in "so little".

Combine that with the behaviour of human attention, precisely how one thing
inspires another, and trace it back to the original "spreadsheet in 30 lines"
post, you can see that these type of posts are just recurring manifestations
of executions of the same principle.

By the way, JavaScript, even without the host of browser-side framework, IS a
powerful language. Of course, it stands on the shoulders of giants: JIT,
platform abstraction, type-management, memory management, graphics (browser),
visual toolkit (browser) etc.

------
aaronetz
I really like those, but hanging to X lines of code bothers me sometimes. It
can make the code unreadable - no comments, multiple statements in one line,
obfuscated variable names, etc. I wish there were a better metric that would
still impress people on HN but wouldn't result in unreadable code. How about
the number of statements? Or let's just say "tiny"? Like, "Tiny javascript
raytracer"?

~~~
pritambaral
The original spreadsheet post focussed on keeping it readable and not cheating
for the sake of no. of lines. That spirit seems to have not been carried over
by the followers.

------
talles
Someone started (the excel one?) and people followed along.

Because it's fun.

------
VLM
Well, lets rephrase it, is there anything interesting an outside doesn't know
about javascript interpreters and lines of code?

I could imagine the existence of a JIT compiler engine that caches everything
smaller than 64 lines, or maybe less than 1K compiled. Imagining doesn't make
it so, but it would explain a heck of a lot.

Is there anything other than competitiveness like obfuscated C contests?

~~~
rimo
I was asking myself the same thing, anybody knows about obfuscated JavaScript
contests?

------
dphnx
Maybe it’s been a sufficient amount of time since the last JS1K and the code-
golfers are getting itchy?

Whatever the reason is, I don’t mind so long as the submissions are
interesting and I can browse the source. The ray tracing one that’s #1 at the
moment IS impressive but I had to read the HN comments to find the source
article.

------
gregors
To me their the same exact thing when people drag-n-drop code in visual
studio. oohhh ahhhh everyone says, except it has nothing to do with real world
coding. i.e. it's proof of concept code at best.

------
DanBC
It's fun. Javascript is really easy for people to noodle about with. Some of
them are really impressive. Some of them are just fun.

------
justbaker
The only reason I got hired for my current position is because I released 2
tiny libs of javascript.. 20 lines each.. but clever code.

------
colanderman
Let them be. Otherwise we'd be seeing "look I drew a square using pure CSS"
posts again.

------
alisnic
these are live examples that javascript is not alien technology and that
pretty clever stuff can be done with small effort.

~~~
w0utert
I think that by now, not many people consider JavaScript 'alien technology',
or don't believe you can do clever stuff with it.

I don't mind the 'X in 30 lines of JavaScript' articles at all, they're nice
curiosities. That said, let's not pretend JavaScript is unique in its ability
to do a lot in very few lines of code. I've seen more impressive raytracers
written in just as few lines of C for example, Perl one-liners that draw a
live analog clock on the console, competent Python web services in less than
100 lines of code, etc.

~~~
justbaker
^^^ Of course. I've actually wrote a minimalistic ruby library, then done the
same library in javascript in similar code..just a nice curiosity.

