News for hackers. Stuff that matters.
Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by beagle3 on Tuesday November 19, 2013 @08:09AM (#6760887)
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
Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by bjourne on Tuesday November 19, 2013 @07:19AM (#6760627)
Love them. Much more interesting than the average hn posts.
Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by pritambaral on Tuesday November 19, 2013 @06:58AM (#6760551)
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.

Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by aaronetz on Tuesday November 19, 2013 @07:23AM (#6760640)
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"?
Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by pritambaral on Tuesday November 19, 2013 @07:29AM (#6760660)
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.
Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by talles on Tuesday November 19, 2013 @07:45AM (#6760745)
Someone started (the excel one?) and people followed along.

Because it's fun.

Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by VLM on Tuesday November 19, 2013 @07:52AM (#6760786)
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?

Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by rimo on Tuesday November 19, 2013 @08:02AM (#6760840)
I was asking myself the same thing, anybody knows about obfuscated JavaScript contests?
Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by dphnx on Tuesday November 19, 2013 @07:00AM (#6760563)
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.

Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by gregors on Tuesday November 19, 2013 @09:20AM (#6761267)
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.
Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by DanBC on Tuesday November 19, 2013 @05:36PM (#6765006)
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.
Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by justbaker on Tuesday November 19, 2013 @12:08PM (#6762551)
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.
Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by colanderman on Tuesday November 19, 2013 @08:09AM (#6760885)
Let them be. Otherwise we'd be seeing "look I drew a square using pure CSS" posts again.
Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by alisnic on Tuesday November 19, 2013 @06:54AM (#6760540)
these are live examples that javascript is not alien technology and that pretty clever stuff can be done with small effort.
Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by quchen on Tuesday November 19, 2013 @06:59AM (#6760556)
I sincerely doubt the "small effort" part.
Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by w0utert on Tuesday November 19, 2013 @07:10AM (#6760594)
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.

Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by justbaker on Tuesday November 19, 2013 @12:19PM (#6762644)
^^^ Of course. I've actually wrote a minimalistic ruby library, then done the same library in javascript in similar code..just a nice curiosity.
Re:Ask HN: What is with all these 'X in 30/35 lines of Javas... by INTPenis on Tuesday November 19, 2013 @07:23AM (#6760639)
Yes and I also view them as PoC to get rid of Adobe Flash eventually down the line.