HN Companion◀︎ back | HN Companion home | new | best | ask | show | jobs
Yet another way to invoke functions without parentheses (blog.ikaes.de)
95 points by aragonite 2 days ago | 23 comments


This reminds me of "Creators admit Unix, C hoax" (e.g. https://www.gnu.org/fun/jokes/unix-hoax.html)

> We stopped when we got a clean compile on the following syntax:

    for(;P("\n"),R--;P("|"))for(e=C;e--;P("_"+(*u++/8)%2))P("| "+(*u/4)%2);

How Perl was created:

‘Larry, throw the cat at the keyboard!’

MEEEOW!

‘What did it type?’

‘&}Ak'>v=4%Qe}9;’

‘OK, so let’s make this a syntax for hello world.’



I love this. This is a fun hack, but the article also hearkens back to pre-LLM days when people were still interested in _code_.

I wonder if there was a period in the 90s where the chess community was more interested in talking about IBM’s stock price than in actually playing chess.

I'm definitely gonna use that for April 1st though, just adding this as instruction in Claude.md

That will also serves as a litmus test to check how many of my coworkers are reading the code they push.


Programmers are still interested in code

Weekend hobby!

Now there is Monday again, no more coding, back to babysitting agents.

Not gonna work on Firefox, since according to the doc, Error.prepareStackTrace is an optional API and only implemented by V8.

> optional API and only implemented by V8

aka "Chrome implemented this and wanted everyone else to do so as well"


Off topic: This website looks like a ransom note

Maybe it is, just requires a different parser

  Object.prototype.message='alert\x281337\x29';Array.prototype.toString=Error.prototype.toString;Error.prepareStackTrace = Function;const x = new Error;x.valueOf=x.stack;+x;
Well, that's a mouthful! So many years and JavaScript still can do the most amazing, weird, awesome, scary, obscure, and sexy things in the world of coding.

The prototype thing is quite unique among mainstream languages. It is kind of simple in principle and works well for what it intends to do, but god it causes so much confusion and is frequently a source of CVEs. valueOf combined with implicit conversion is a nightmare for production code.

Yesterday I was re-using some shaders I had written a long time ago, and here's what I used to do multiline strings before the glorious backtick arrived on the scene...

    (function () {/*
      my awesome shader code
    */}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1]
... I can't call it sexy, but I also can't deny I felt a mixture of fear and arousal when I saw that.

TIL about [^], never seen that before. Apparently, it works like a dot but it also matches newlines.

Pretty interesting that you can carry comments over.

    (x=>/*this is a comment*/1) + 1
    "x=>/*this is a comment*/11"
I wonder if anything cool can be done with it today. It's probably useless.

JavaScript is so cursed.

If I were to write a book on programming in JS, it would be a black cover with the JS Holy Trinity equality diagram in red, to emphasize its Satanic nature.

What's the purpose of the +x at the end?

The unary plus implicitly converts an expression to a number, which calls `valueOf` for non-primitive values.

I think to implicitly trigger the valueOf function.