As a programmer though, it certainly annoys me!
8,399 karma · joined September 4, 2016
As a programmer though, it certainly annoys me!
This is a hell of a thing to commit and pass code review in 2021 on a project like GitLab. I understand that the staff member was fixing a security issue and was probably not thinking deeply about the ramifications, but even so. How many "Falsehoods programmers believe about names" articles do we need?
However, if you use a CAS loop (like this code does) to update some value (i.e. a while loop that repeatedly tries to execute a compare-and-swap), that loop will only fail to make progress if some other thread DID make progress. This means that such an algorithm is in fact lock-free: if thread X didn’t progress, it is necessarily because some other thread did. In addition, a scheduler preempting a thread at any point will not stop other threads making progress.
Whether an algorithm is lock free or not is not a matter of opinion, it is a mathematical statement. The fact that it annoys you is… weird.
I wonder what this means. The efficient assembly probably has fewer instructions that use vector instruction and floating point calculations more, while the "idiomatic" Swift probably has just a larger number of instructions that aren't doing heavy calculation. Does that imply then that the high performance cores does much deeper pipelining, but the the number floating point units or whatever is probably pretty similar across both types?
I don’t know, I think that it’s perfectly reasonable even from an engineering/computer science perspective to say that they are literally the same thing, just viewed from two different perspectives.
After all, what is an object? It’s some code, with bundled data. What is a closure? It’s some code… with some bundled data. I think it’s fair to say that this is a “is it a vase or two faces?” situation. You’re looking at the same image, just seeing it from different perspectives.
These icons are far older than unicode, and in fact is not in unicode at the moment. There's a proposal to add them, but I don't believe it's passed yet. The standardized icons themselves date from the 1970s, though non-standard laundry symbols are much older than that.
Design use of icons over text has nothing to do with Unicode, it's a natural part of human expression. Icons are everywhere, from traffic signs to laundry symbols to buttons on computers to ramblings signs. I think your reading of the typographical history here is simply wrong, neither Apple nor Unicode is responsible for the "iconiziation" of communication. We've always used icons for communication, and we always will.
If your issue is with Emoji, then you should make that case instead. Personally, i think it's great that if I send an emoji from an iPhone to an Android phone (or from/to essentially any device), you get a consistent symbol, instead of being locked in to whatever your manufacturer was using (the fact that this kind of lock-in was occurring was the original motivation for adding emoji to Unicode).
Btw, laundry symbols are a perfect demonstration for another wonderful feature of using icons: they're cross language. You can put one tag on a piece of clothing and sell it anywhere in the world. Not everyone speaks English.
Han unification, on the other hand, is a disaster for Unicode. The fact that Unicode can't comfortably mix Chinese and Japanese language characters is a disaster for an encoding like Unicode that's supposed to cover the whole world.
If you wanna be annoying about this, just imagine he's implementing `strnstr` instead of `strstr`.
Floating point numbers have a dedicated sign bit that specifies the sign, which means that you can flip the sign of any floating point number and get a float with a different bit pattern (and opposite sign). That means that you get necessarily get both +0.0 and -0.0, and they have different internal representation in bits.
This is one of the major advantages of two's complement notation for representing integers: it doesn't have a dedicated sign bit in the same way, so you only get one representation for 0. You can still check the sign by looking at the top bit, but if you flip it for the number 0, you don't get -0 (which doesn't really exist), you get -128 (for 8 bit signed integers).
[1]: https://en.wikipedia.org/wiki/Double-precision_floating-poin...
I have no idea how the postgres C API looks, but the SQLite API has different functions for binding different kinds of data types to prepared statements, like `sqlite3_bind_int` for ints, `sqlite3_bind_blob` for binary blobs, `sqlite3_bind_text` for strings, and so forth. So SQLite "knows" the source type you're binding.
Yep, totally! I'm a firm believer in the power of walking to increase thoughts, but whenever I read about studies like this a big red beeping alarm goes of in my brain that goes "replication crisis! replication crisis!"
sqlite3_bind_int(stmt, 3, 45);
to bind the value 45 to the third item in whatever INSERT/UPDATE statement you’re doing. But that was actually wrong: the third item is supposed to be a string, you meant to bind the int to item 4.A strictly typed database would error out here, a dynamically typed one will just assign the int to the string column, potentially corrupting data.
This is exactly equivalent to messing up types for variables in a dynamically typed language, all pros and cons of typechecking apply equally for SQL. The fact that the host language C is statically typed is irrelevant.
Also: if icc is going to go with LLVM as a backend, then what is the point of using icc at all? Why not just use clang?
That site is indeed very neat! It just uses Google Benchmark in the background, but it's excellent for these kinds of discussions (and lovely to have it link directly to godbolt if you want). It's a shame that it doesn't give you the actual latency numbers like regular Google Benchmark, but I suppose that is to be expected when you're running in server VMs, those numbers aren't necessarily meaningful.
Doing a function call in C/C++ is not expensive. I wish people would stop saying this, it's just not true, it's one of the most annoying myths in programming. A C function call is on the order of a tiny number of nanoseconds. Here's a benchmark to compare [1]. It's an infinitesimal amount, and it is absolutely swamped by something like a cache miss. If you eliminate one cache miss but add 50 function calls, that's probably a net benefit.
The only sense in which function calls in C are "expensive" is during compilation: if a compiler can inline a function call, it can potentially do tons of new optimizations that it couldn't do before, and that can yield a huge improvment in performance. But the function call ITSELF is almost never the problem.
cp $FILENAME $TARGET
Write this: cp "$FILENAME" "$TARGET"
It's a bit annoying, but it's not that bad, and certainly not unmaintainable.> The Elixir approach to shared mutable state is wrapping it in a process. In this case, I needed a counter and the easiest way to implement it is to use an Agent which is a kind of process designed to handle simple state. In this case, the get_and_update function allows me to return the counter and increment it as an atomic operation.
This is literally just an atomic counter. It’s a single CPU instruction that is guaranteed to be safe. I don’t care how lightweight a BEAM process is, it’s not faster than updating an atomic counter. Doing it this way is also absurdly more complicated than using, say, a std::atomic in C++ (or the equivalent type in other languages).
Again, I think Elixir is cool, but if you want to show off how cool it is, maybe don’t use an example that is incredibly much slower and more complicated than it should be. It’s not a great look for Elixir.
“..is the character based on me actually innocent?
Turns out, she asked the killer to help her get rid of her roommate. She didn’t mean for him to kill her, but her request indirectly led to the murder. How do you think that impacts my reputation? I continue to be accused of “knowing something I’m not revealing,” of “having been involved somehow, even if I didn’t plunge the knife.” So Tom McCarthy’s fictionalized version of me is just the tabloid conspiracy guilter version of me.”
It’s clear that the filmmakers have no legal obligation to Knox (and she acknowledges as much in the article), but I think it is equally clear that they have a moral obligation to not slander her using a thinly veiled fictional character.
It’s a shame too, because the real “Amanda Knox saga” would make for a much more interesting movie: what is it like to have your roomate murdered, your life destroyed, and your identity robbed from you by the global tabloid press? That’s the real Amanda Knox story.
The fact that you have to "lure" the compiler into making the hot loop branchless is a little bit weird: you'd think there would be a compiler intrinsic or something which was like `cond_val(condition, val1, val2)` which worked something like `condition ? val1 : val2` but was guaranteed (or close to it) to be free of branches. Shaders have something like that with the `step()` function, seems like a useful thing for this kind of high-performance code.
I mean, obviously you could always write this yourself with inline assembly (or using SSE2 intrinsics or whatever), but that would only work on some platforms and might mess with compiler optimizations, so that seems less optimal.