If you use the shunting yard algorithm or similar for infix binary operators it's trivial to define a table with operator precedence values and use that. You can have a bunch of operators all at the same priority but it is the same complexity really, the algorithm is pretty trivial
The point here is that not all operators should have a concept of precedence. Expressions like "a & b + c >> d" should be invalid, as no human actually understands them unless they spend a lot of careful focus. Instead, such an expression must be written as "((a & b) + c) >> d" explicitly. On the other hand, "a + b + c" and even "a + b * c" are fine, as addition and multiplication (and subtraction and division) are so drilled into everyone in early education.
> Expressions like "a & b + c >> d" should be invalid
When read procedurally (left to right) it is quite okay though, and no parens are needed (but could be added).
The catch is that `1 + 2 * 3` becomes 9 instead of 7 as math eyes expect. I guess there are things to unlearn and unlearning is always hard. But consider the rules other languages have, like C regarding signed and unsigned, and Javascript regarding comparisons, compared to them this is almost trivial.
> When read procedurally (left to right) it is quite okay though,
Except that there are almost no circumstances in which "((a & b) + c) >> d" is a sensible expression. The only reasonable interpretation is "(a & b) + (c >> d)", and even then that plus is suspicious.
In practice, the worst offenders are "a & b >> c" and "a & b << c". The first expression is usually intended to mean "(a & b) >> c" — it's a bitfield extraction; the second one is usually intended to mean "a & (b << c)" — it's clearing of all but one bitfield. As you can see, those semantics are impossible to achieve with << and >> having the same precedence.
> > When read procedurally (left to right) it is quite okay though,
> Except that there are almost no circumstances in which "((a & b) + c) >> d" is a sensible expression.
That doesn't seem like a convincing argument to me. The question is whether or not the rules set you up for scenarios where misunderstandings are likely. Strict left to right does not - for example, given a & b << c it is immediately clear that the desired interpretation is not the actual one while b << c & a will unmistakeably do what you want.
> The question is whether or not the rules set you up for scenarios where misunderstandings are likely.
No, this is a misleading statement of the problem because it tacitly assumes that programmers write arbitrary expressions with almost the same probability, so the rules should accommodate them all, at the same expense. This is patently false, and is a horrible policy for any UI/UX/DevEx/etc. designer. The very existence of linters and static analyzers, hell, even the warnings in the modern compilers about suspicious operator precedence and "this expression doesn't mean what you probably think it does" — all that suggests that some kinds expressions are more probable than others; ergo, those should be accommodated for at the expense of the unlikelier ones. So, the precedence levels and PEMDAS it is, instead of the abstractly-pure, from-the-first-principles, strictly left-to-right order which makes only its inventor, with a very peculiar kind of mind, happy at the expense of most of the actual programmers and users of the language.
honestly speaking, I think that shifts would almost always be better represented with functions, like lsl(a, 4), which solves the shenanigan between arithmetic/logic shift too.
Freaking BCPL had those in 1976, and that language was more primitive than C (it didn't even have any types beyond "machine word, reinterpreted accordingly to the operation applied to it").
Yes but if you read the EULA the two VM limit it does sound like you can't really sell access to VMs:
> except as otherwise provided in writing, signed, or issued by an authorized representative of
Apple, to install, use and run up to two (2) additional copies or instances of the Apple Software,
or any prior macOS or OS X operating system software or subsequent release of the Apple
Software, within virtual operating system environments on each Apple-branded computer you
own or control that is already running the Apple Software, for purposes of: (a) software
development; (b) testing during software development; (c) using macOS Server; or (d) personal,
non-commercial use.
In section 3 they also say that if you're renting access to a Mac you can only run one VM, which sounds kinda like that
> Except as expressly permitted in Section 3, the grant set forth in Section 2B(iii) above does not permit
you to use the virtualized copies or instances of the Apple Software in connection with service bureau,
time-sharing, terminal sharing, relay service or other similar types of services.
I'm puzzled about why people were so vehement at roasting Joe Biden for his clear advanced age, while Trump is blatantly suffering from dementia or some similar mental impairment. His speech is way more rambling and incoherent that anything Joe Biden ever went through, and it doesn't get better when he's in a more familiar setting - quite the opposite, he gets more and more nonsensical whenever is giving an interview to anybody
IMHO the current contracts are a half-baked feature that I suspect will immediately end up in most coding styles as "do not use contracts".
I understand the concept but having a feature that's not consistent among compilers, targets, ... all while doing absolutely nothing to solve the _real_ problems with C++. Like that the build model is still the obsolete TU model of C, while adding multiple compile-time features that inevitably end up causing build times to skyrocket considerably. Or that modules are still DOA after 6 years. Or that the syntax is full of bullshit anti-features that could be at least fixed by having a proper build model (like Rust) and editions (like Rust).
Having yet another feature that only works sometimes with quirky semantics is dumb and I understand why many people feel like it should be shelved to prioritise the features people _really_ care about, like meta
I'd start with the basics: A scanf() replacement would be nice, having a ostream/printf() alternative, but not something for input feels very unfinished.
Basic Unicode support is also still a mess.
Another thing I don't get: Why is uninitialized memory still the default? Why haven't they made the uninitialized state explicit in any of the numerous language updates?
> and is no longer undefined behaviour to act on them
This is only partially true. From the proposal [0]:
> Moreover, a variable that has a well-defined, erroneous initial object representation under this proposal can still lead to undefined behaviour later on:
void f(T&);
void g(bool);
void h() {
T* p; // uninitialized, has erroneous value (e.g. null)
bool b; // uninitialized, erroneous value may not be valid bool
f(*p); // dereferencing has undefined behaviour
g(b); // undefined behaviour if b is invalid
}
Unfortunately C++ is full of very dubious features that I argue may not make much sense or may make sense in a different form that's not how C++ implements them.
Except it still drags unsafe legacy APIs into the future as part of its core library. std::env for example isn't some safe take on how to deal with a system provided program environment in a modern multithreaded language, it is a thin wrapper around an ancient C POSIX API that is not threadsafe and cannot be fixed.
Rust can't magically fix how Unix works. On Windows, the unsafe APIs in std::env are merely unsafe, if you use them carefully you're fine. On Unix, these APIs can cause chaos if you use them in multi-threaded context because Unix never provided any mechanism, even in a modern Linux, to do better.
Rust is doing everything it can here, these APIs are labelled unsafe, and on a system where they can work, they will work. You can see similar in the filesystem code. On Windows, or a modern Linux, you get what you'd like to have, and on somebody's SysV clone where that's not possible it's still not possible from Rust.
Rust has no reason to touch the original Unix API. Take a snapshot of the values at startup and write an API around that, any runtime modification of the Unix environment is suspect anyway and anyone who wants to deal with that rotten mess can jump through half a dozen hoops.
> Rust is doing everything it can here, these APIs are labelled unsafe
Unix gave us C, clearly Rust should have just labeled every C standard library function like malloc and free unsafe and thrown up their hands instead of introducing ownership semantics and all that messy compiler logic around it. After all Rust can't fix how Unix works, so they shouldn't have tried in the first place.
Let me clarify. There is no reason for std::env to be dragged down by UNIX, it could be its own, modern, safe thing with the Unix API living in std::pet_cemetary or some comparably clear namespace for people who have to pass runtime information to a C library through absolutely unsafe ways. Environment variables are usefull, the unix limitations make them less so.
It could be a completely separate "modern, safe thing" which roughly nobody has any use for and which would be confusing since what people want are environment variables and this would instead be its own "modern, safe thing" for some reason.
Mutex<HashMap<String,String>> is probably a reasonable "modern, safe thing" for the handful of people who actually would get value out of this, and the fact it's not labelled "Environment variables" because that's not what it is probably also avoids people who needed the actual environment variables cursing because they were hidden down the back of the sofa.
Why not? Is it the lack of race conditions? The lack of crashes or memory leaks? Is it the fact that you came up with it in five seconds and it is still a million times better than what we have? Or is it the fact that the holy book of Posix spells out how to do it badly in C and because of that we are never allowed to replace it with something better?
That's a feeling I've been also feeling for the last year or so. Turns out the means was what I cared about, and I didn't care about the ends that much. LLMs robbed me of that in a way I couldn't see coming.
I think that we as a society fail to see that the speed we built things was rarely the problem. The real shortage was in the ideas - having them, finding the motivation to act on them, sharing them, and the biggest driver was the desire of showing off, being told you are great and your idea was great.
I am afraid that by removing the ick to fix things, to challenge everything and being rewarded for that, we will end up with less innovation, not more. Why bother? Why do anything if everything is cheap, why start a new project only to be shrugged away as being yet another thing any machine could have done? Why show off when the merits are the machine's?
HN went from being a constant stream of Show HN to AI news after AI news. The most interesting projects AI have enabled are to run old stuff onto other things.
Rehashes of old ideas keep sprouting out of everywhere, keeping new ones at bay. I think we are probably entering a long winter and all that will be left is permutations of what we did before '23
From a technical standpoint, there is an interesting story here about how to know that what you're doing is solid and reliable.
I have to assume the fact this didn't get discovered suggests they weren't investing in trying to break their own crypto. A good takeaway for anyone else who wants to be in this space.
yeah anyone wise migrated away from PHP ages ago. The fact it got lipstick on back with PHP7 doesn't make it a well designed programming language. At least in my experience the vast majority of PHP websites nowadays are old abandoned PHP5 projects, which aren't much worse than just slopping a rewrite in something else
> Run Android apps natively on Apple Silicon Macs. No emulator, no virtual machine, no Linux underneath.
God damnit Dario fix Claude already so that it stops using this sentence structure once and for all. Opus is so annoyingly recognisable that it has started to irk me badly lately
It's also not even correct. The diagram in README says the app is run on "built-in Java runtime" after it is converted, which, as I recall, is a virtual machine.
We're at probably a century and a half, and then I feel like we're quibbling over semantics, but the Coliseum seems like a pretty good example of a manifestation of pop culture.
But this is a digression. Language changes. It always has. What's the big deal? That it's not your generation controlling it this time?
Precisely. Regis Philbin, Paris Hilton, Charles Barkley - they each have a pretty distinctive way of speaking and I have always actually enjoyed hearing each one's way of phrasing things. But it would quickly become hell if each week an additional 1% of the things we read was written exactly how Regis would phrase it.
(I purposely picked people with pretty specific speaking habits because yup, the Claude output is 100% that distinctive).
I don’t get to customize the prompts used by others. I’m sure if I generated a lot of prose with Claude I could convince it to talk differently. It’s all the content others make that is so annoying.
I said several months ago that bots like your coworker, personal assistant, search engine, and customer service are now all the same person. They also write all the blog posts and articles you read and scripts for YouTube videos.
Imagine if everything in the world you read was written by one author - and you didn't particularly like that author's writing style. Or even if you did like the author's style, it began to grate on you simply because there was no reprise from it.
Yes I got that, but afterwards it doesn't explain how until you get all the way down into the diagrams saying that it translates the code one-time. It's once again like no emulators, no virtual machine, no Android, no Linux kernel, no items, Fox only, final destination, whatever
"Run Android apps natively on Apple Silicon Macs. Uses translation instead of emulation."
No, slop generally doesn't get the point across efficiently.
It's hard to parse, it's grating, and in addition to the strange language you have to apply additional skepticism due to gross inaccuracy being more likely than in human-written text.
If you run a readability analysis on slop it scores very poorly. LLMs generally continue to be mediocre with the veneer of quality without context to guide them.
Cliches annoyed people before LLMs. There is a whole microgenre of essay ranting about the proliferation of various annoying cliches, bits of jargon, etc. the proliferation of Claude prose is simply rendering certain turns of phrase into annoying cliches, which people are reacting to in the normal way. Cliches also get the point across but nonetheless lots of people find them grating.
reply