

Show HN: Fully-featured Nil interpreter in less than 1 line of JavaScript - TazeTSchnitzel
http://ajf.me/demos/nil/

======
onion2k
I would debate whether or not this is actually Javascript. For something to be
JS, surely it needs to actually call the JS interpreter when it's run. This
doesn't. So it isn't.

Now, if you could override Function.prototype to just function(){}, then
everything passed in would be ignored and you'd have a proper Nil interpreter
in JS. But you can't[1], because that would be stupid.

[1] Or rather, _I_ can't. I did just spend a few minutes trying.

~~~
shawnz
> Now, if you could override Function.prototype to just function(){}

Function.prototype is already set to an empty function by default (evaluate
Function.prototype() and you get 'undefined'), so I am not sure this has the
consequences you think it does.

When you call a function object, let's say f, Javascript looks for an internal
method on f called [[Call]] and calls it. If one doesn't exist, an error is
thrown. The internal property [[Prototype]] of f is not ever considered,
although you are right that it would be equal to Function.prototype.

EDIT: Despite what I think, executing phpnode's code in my node.js REPL
instantly crashes it, so I guess there is more going on here.

~~~
oso2k
Node.js modifies globals is the issue and does other seriously interesting
things[1].

[1]
[https://groups.google.com/forum/#!topic/nodejs/FuOB3151rPQ](https://groups.google.com/forum/#!topic/nodejs/FuOB3151rPQ)

------
TazeTSchnitzel
Example program ("hello, world" is not traditional in the Nil community):

    
    
      I wandered lonely as a cloud.
    

Outputs:

------
joelennon
It was only a matter of time before someone came up with a parody for the X
lines of JavaScript posts. Nicely done though.

~~~
probably_wrong
There was also a story yesterday titled "Hello World in 1 line of Javascript"
(which I think is now dead).

------
brickcap
Just one suggestion.I think it would improve the usability if you put the run
button below the program source.

Otherwise wonderful work. I think it would be difficult to top this.

~~~
TazeTSchnitzel
I've considered doing JIT compilation to JavaScript and adding IntelliSense,
but that'd require another 0 lines of code and I'm worried it might ruin the
beautiful simplicty of it.

------
bct
If you're going to take cheap shots at RMS at least make them accurate. You
may not agree with his reasons, but they have nothing to do with sin.

~~~
TazeTSchnitzel
True, but he seems to have a moral conviction that proprietary software is
wrong, and hence doesn't like JS much as it is a vector for automatically
download and executing proprietary software. So I was exaggerating, but there
is some truth to my words.

------
RankingMember
Hahaha, well done. I originally expected some word-wrapped 10,000 char thing
on a single line.

------
gprasanth
So this is the All Consuming Void the Compilers warned their creators about?

------
yread
Ha I wanted to shout "plagiarism" because I remember seeing it here already,
but it was you who posted it yesterday:

[https://news.ycombinator.com/item?id=6759980](https://news.ycombinator.com/item?id=6759980)

Still not very classy, is it?

~~~
davidjhamp
But it is interesting that the title change resulted in it making it to the
front page.

------
venticco
Finally! Someone had to do this.

------
basyt
I fully endorse this, these posts were getting a bit ridiculous.

------
singularity2001
it failed without throwing a NilPointer exception, how can we debug it?

------
gishse
False, there is no JS present at all.

(should be an empty file)

~~~
nervousvarun
"no JS present" = "less than 1 line of JavaScript"

No?

~~~
gishse
You've got a point. It was a joke though.

