4 ms·
Further proof that JavaScript accidentally became the new C++. “Aren’t you surprised that this syntax works?” is not praise for a language design.
by pavlov 1y ago
Further proof that JavaScript accidentally became the new C++.
“Aren’t you surprised that this syntax works?” is not praise for a language design.
- asah 1y agoAgreed!!!! Serious q: but how does this sentiment change with LLMs? They can pickup new syntax pretty fast, then use fewer tokens...
- fph 1y agoI imagine the error messages must be terrible to read, since this hack is based on reusing syntax that was meant for something entirely different.
- Cthulhu_ 1y agoIt sounds like using less tokens (or, less output due to a more compact syntax) is like a micro-optimization; code should be written for readability, not for compactness. That said, there are some really compact programming languages out there if this is what you need to optimize for.
- pavlov 1y agoI’ve heard it said before on HN that this is not true in general because more tokens in familiar patterns helps the model understand what it’s doing (vs. very terse and novel syntax). Otherwise LLMs would excel at writing APL and similar languages, but seems like that’s not the case.
- throwawaymaths 1y agoprobably because there arent enough apl examples to imbue the rare weird apl tokens with sufficient semantic meaning to be useful.
- miningape 1y agoIMO it's more likely to get confused because there are less unique tokens to differentiate between syntax (e.x. pipe when we want bitwise-or or vice-versa)
- rco8786 1y agoIs there a language that can’t be contorted in surprising ways that I’m unaware of?
- IshKebab 1y agoProbably not, but there are definitely languages that don't do automatic type coercion - so at least one fewer contortion available.
- bobbylarrybobby 1y agoLISP — the contortions are expected, not surprises
- kazinator 1y agoNon-Lisp: gratuitous contortions are expected.
- dominicrose 1y agoA language where there's only one way to do things, maybe a very early version of CSS. The things is all languages end up bloated with new features.
- dymk 1y agoI think that depends on the person, the language, and how familiar they are with the language. Someone's "what the fuck" is another's "obviously it can do that".
- cluckindan 1y agoReminder that Perl exists: https://metacpan.org/dist/perlsecret/view/lib/perlsecret.pod#SYNOPSIS https://metacpan.org/dist/perlsecret/view/lib/perlsecret.pod...
- refulgentis 1y agoSwift, IMHO. Grew up on ObjC and the absolutely crazy things you could pull off dynamically at runtime. You can definitely feel they did not want that in Swift. There's operator overriding but idk if I'd count that as contorting in surprising ways shrugs
- cluckindan 1y agoIt is not a surprise that overriding the implementation of an operator’s type coercion works and overrides the behavior of the operator’s type coercion.
- pavlov 1y agoDo you really think that most JavaScript users are aware that “overriding the implementation of an operator’s type coercion” is a language feature? Sure, you can claim that everyone should know this obscure feature when they don’t. But that’s how this language enters C++ territory.
- catapart 1y agoI actually don't think you are wrong, but I'm not backing that up with any actual data. I happened to know it because of how the hyperHTML micro-library works; the author went into great detail about it and a ton of other topics. But my gut would say that the average js dev doesn't know about it. But then... it's useful for creating component frameworks which... most js devs use. Which doesn't mean they know how they work under the hood. But... a lot of devs I've met specifically choose a framework because of how it works under the hood. ... so... I really have no idea how many people know this. I'm still betting it's less than average.
- cluckindan 1y agoWell, Proxy objects do allow you to override the behavior of any property, including Symbol properties. Symbol.iterator is pretty widely used to create custom iterable objects, so I would expect curious devs to have taken a look at what else can be done through the use of Symbol properties.
- overgard 1y agoNo way dude, this does a disservice to the insanity that is C++'s syntax. Wake me up when you have 6 different initialization syntaxes or fun things like 4[array]
- jonny_eh 1y ago> “Aren’t you surprised that this syntax works?” is not praise for a language design. It's a clever hack. This is Hacker News. Let's try to appreciate clever hacks while here.
- ricardobeat 1y agoNothing new. This was 15 years ago: https://github.com/tbtlr/def.js https://github.com/tbtlr/def.js