Stack based languages and the APL tradition all follow this pattern, which I agree can be more terse and nice too. I've also been experimenting with right-associative calls which does the same thing but in reverse. For a data pipeline you're more likely to transform from A->B, so I think the post-fix syntax makes sense.
But you can also define a "thread" operator easily for doing subsequent function calls. ala `threaded x { f; g; h }`
When you're calling a function, you're putting some things into the function... You have to get the things first before you can put them in...
Why didn't it evolve like that in the first place? Is it a byproduct of mathematical notation? If so, I wonder why mathematical notation evolved that way in the first place...
Forth (or Postscript by the way) works exactly like that, but writing the function first also makes sense in functional programming, specifically when you care about currying functions: writing "f(g(h(x)))" (or "f g h x" or whetever) makes more sense, since you are not supposed to put all expected arguments at once.
Did you even have an RPN-based calculator at school?
As to more serious programming languages, Erlang, F#, Haskell have forms of a "pipe" operator, roughly
[1 2 3] |> sum |> print
For it to work properly, functions should be either functions of one argument, or support currying.
But the original algebra functions, as introduced by Leibniz in 17th century, were, of course, pure functions, more like properties than procedures. So cos(x), aka cos x, is just a formalized shorthand for "cosine of x", so it preserved the order of words typical for Germanic and Romance languages. Maybe if functions were introduced by the Japanese, we would have the reverse order, kind of x の cos.
The function reference is actually evaluated first so your preferred order is actually backwards! Consider this:
foo.bar(x)
The `foo.bar` field has to be retrieved before the function can be called. It does not evaluate `x` first. That is observable with JS proxies, or you can test with code like this:
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.
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.
I believe this is the regular syntax for a set of characters (between "[" and "]"), but the caret symbol ("^") is negation when used inside the set. Therefore, it is simply the negation of an empty set of characters.
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.
Doesn’t feel LLM-y to me. If it is LLM-generated, the LLM must have been explicitly instructed to ignore sentence capitalization and invent a persona (‘i chose...’).
I'm not pro-AI (at least not the way the SOTA model companies operate) but I'm tired of seeing "written by AI" on every single thing on HN.
I get "wRiTteN bY aI!" comments on my open source projects when, in fact, I didn't use AI at all. I've considered sharing some of my recent reverse engineering work on HN but am confident that it would devolve into "it must have been written by AI" bs.
Is it important to know if something was created with AI? Yes. But spewing "written by AI!" without reading/evaluating something yourself is just as lazy.
The new generation of engineers will never know a world where all software was written by humans. As someone who spent 22 years writing assembly and low-level C/C++, I think that's a shame. But that is the new reality.
> The new generation of engineers will never know a world where all software was written by humans.
You never knew this world either.
> As someone who… [humble-brag followed by depressingly fake empathetic message]
Please. Get off the high horse. “As someone who…” is just “trust me bro” coupled with ego-stroking nonsense. It is not an argument and gives you absolutely zero authority over what you are talking about.
> We stopped when we got a clean compile on the following syntax:
‘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 haven't seen it in many many years, but at the time it struck my giggle button every time.
Bareword found where operator expected (Missing operator before "Ak"?) at -e line 1, near "&}Ak" Bad name after Ak' at -e line 1.
But you can also define a "thread" operator easily for doing subsequent function calls. ala `threaded x { f; g; h }`
since the order in which things happen is "h first, then g, then f"
When you're calling a function, you're putting some things into the function... You have to get the things first before you can put them in...
Why didn't it evolve like that in the first place? Is it a byproduct of mathematical notation? If so, I wonder why mathematical notation evolved that way in the first place...
It did, just in Arabic.
As to more serious programming languages, Erlang, F#, Haskell have forms of a "pipe" operator, roughly
For it to work properly, functions should be either functions of one argument, or support currying.But the original algebra functions, as introduced by Leibniz in 17th century, were, of course, pure functions, more like properties than procedures. So cos(x), aka cos x, is just a formalized shorthand for "cosine of x", so it preserved the order of words typical for Germanic and Romance languages. Maybe if functions were introduced by the Japanese, we would have the reverse order, kind of x の cos.
It's more natural to write
That will also serves as a litmus test to check how many of my coworkers are reading the code they push.
“Back in my days…”
“No true Scotsman…”
“I remember when…”
“Kids these days…”
Gotta love this self-aggrandising humble-brag nonsensical stuff.
aka "Chrome implemented this and wanted everyone else to do so as well"
Regardless, I don't think it's correct on this one.
I get "wRiTteN bY aI!" comments on my open source projects when, in fact, I didn't use AI at all. I've considered sharing some of my recent reverse engineering work on HN but am confident that it would devolve into "it must have been written by AI" bs.
Is it important to know if something was created with AI? Yes. But spewing "written by AI!" without reading/evaluating something yourself is just as lazy.
The new generation of engineers will never know a world where all software was written by humans. As someone who spent 22 years writing assembly and low-level C/C++, I think that's a shame. But that is the new reality.
You never knew this world either.
> As someone who… [humble-brag followed by depressingly fake empathetic message]
Please. Get off the high horse. “As someone who…” is just “trust me bro” coupled with ego-stroking nonsense. It is not an argument and gives you absolutely zero authority over what you are talking about.