A demonstration that inheritance is a good technique. Which it is not. It hurts locality of behaviour, and that's bad because it increases the rate of mistakes. There have been studies about this.
10,104 karma · joined July 1, 2009
https://monocypher.org
https://elligator.org
A demonstration that inheritance is a good technique. Which it is not. It hurts locality of behaviour, and that's bad because it increases the rate of mistakes. There have been studies about this.
There's just one problem: code should not deal with a model of the world. It should deal with a model of the data.
A chair is a chair you'd say? Well it depends. Is it a background texture you'd never get close enough to notice it's flat? Is it a static mesh that never moves, and could be considered part of the ground itself? Is it something you can grab and displace? Can it be swung like club, or thrown like a rock, and do damage if it hit you or an NPC?
Depending on what you want to do with that chair, the data describing it will be very different. And if you have any performance constraint that data will likely be put in very different structures or systems, from landscapes to two-handed weapons. The very concept of "chair" at this point is mostly moot.
> Inheritance is taught because most real OOP codebases use it extensively and it works OK.
Avoiding inheritance would have worked better in most such codebases. I have seen things…
> If you don't understand inheritance you can't understand the standard libraries of most OO languages, most UI toolkits etc.
Any item behind "etc"? Because so far those two are the only example of inheritance being kind of mandatory. And I'm not even sure about standard libraries, the C++ STL is very light on inheritance, and I see very little of it in Python (at least as a user). I guess Java makes heavy use of it.
What are its appropriate uses? The more I program the fewer I see.
That, my friend, is modular programming. It is not specific to hardware, and not at all exclusive to OOP. In fact, C can do it just as easily as C++:
typedef struct {
// Private stuff, do not rely on it
int bar;
float baz;
} foo_ctx;
int foo_init (foo_ctx *ctx);
void foo_cleanup (foo_ctx *ctx);
int foo_frobnicate(foo_ctx *ctx, int frobnicator);
And if you don't like putting private data in the header file, we can have a pointer to implementation and hide it even better than idiomatic C++ (I don't like this much, because this requires allocations the above avoids): struct foo_ctx; // forward declare
typedef struct foo_ctx foo_ctx;
foo_ctx *foo_new ();
void foo_delete (foo_ctx *ctx);
int foo_frobnicate(foo_ctx *ctx, int frobnicator);
Some would say I'm just emulating OOP in C. Except I'm not. There's no class in there, just a data structure with opaque data in it, and functions that operate on it.---
I find it especially tiring when people use classes to do modular programming, call it "OOP", and assume it doesn't exist elsewhere, or was an OOP invention. OOP coopted modules, and put light syntax sugar to call it its own.
And I can already hear you scream that I'm "emulating OOP in C", though what I'm actually doing is emulating modular programming in C. And if we insisted on making it look like C++, there are indeed 2 missing ingredients.
The first one would be overloading on the type of the first argument. With that we would no longer care about name clashing, and could write the module like this:
typedef struct { int bar; float baz; } foo;
int init (foo *this);
void cleanup (foo *this);
int frobnicate(foo *this, int frobnicator);
The second missing ingredient would be syntax sugar so `f(x, y)` could be written `x.f(y)` instead. That way the calling code could really feel OOP, even though it's little more than a thin layer of syntax sugar.I have even done it myself. Wrote a scripting language for a client who wanted OOP. Instead I gave them function overloading and universal call syntax, and they didn't notice a thing.
---
When you think about what OOP really is, there's not much. There's the idea of instantiation, where instead of using global variables you define a data structure and instantiate it under one local name. OOP made this popular, though I'm not sure it's not another cooptation. Any language that have user defined types can do that.
Then there's inheritance, which is mostly a mistake (in my experience inheritance is best avoided unless absolutely necessary — and it is almost never necessary).
And finally there's subtyping, which is nearly interchangeable with closures. It's a bit more powerful, but it is also a bit more cumbersome, and the added power is rarely needed in my experience.
---
Anyway, when one repeats the above often enough, there comes a time where one had enough, and just write a quick dismissal. When it comes don't to it the conclusion is fairly simple:
OOP ain't so hot.
Though that’s not surprising from neo-liberal government who thinks pretty much everything should be privatised. They are after all quite explicitly about favouring the rich, and cutting off mass access to those bits of culture is but a small part of their plan to maintain and expand inequality.
So I prefer to shorten the definition to "A prime of the form 2ⁿ-1". It’s bloody useful that n has to be prime though: makes searching that much faster.
sizeof(uint32_t) == 1It would be nice if we stopped stigmatising play. Growing up doesn't mean we stop playing. Acting grown-up might mean stop playing, but it's just that — an act, and a likely childish one. Real adults don't give up on what brings them joy.
https://loup-vaillant.fr/articles/source-of-readability#avoi...
Do we have studies that test this hypothesis? Did people actually fail to replace the old thing by the new, or did it turn out okay?
That's very different from letting life happen and stop working on it without really having decided it.
How much faster, though? RISC-V decode is not crazy like x86, you only need to look at the first byte to know how long the instruction is (the first two bits if you limit yourself to 16 and 32-bit instructions, 5 bits if you support 48-bits instructions, 6 bits if you support 64-bits instructions). Which means, the serial part of the decoder is very very small.
The bigger complain about variable length instruction is potentially misaligned instructions, which does not play well with cache lines (a single instruction may start in a cache line and end at the next, making hardware a bit more hairy).
And there’s an advantage to compressed instructions even on big cores: less pressure on the instruction cache, and correspondingly fewer cache misses.
Thus, it’s not clear to me that fixed size instructions is the obvious way to go for big cores.
In my experience, the best way to make code flexible and extensible is to make it simple. No hooks, no architecture, no pattern, just the smallest thing that does the job. And failing that, the most modular.
That way, when unforeseen requirements do come your way you can just modify your code. The simpler it is, the easier it will be. And it works for any future requirement, not just the ones you had the experience or luck to foresee.
The flip side though is that simplicity is not straightforward. One does not simply "spit out some [simple] code". Simple code requires time and effort. I would like to be able to just say "forget about extensibility, just make it simple", but it wouldn’t convey the difficulty of making things simple.
Only if those abstractions are any good. In actual practice, many are fairly bad, and some are so terrible they not only fail to fulfill their stated goals, they are downright counterproductive.
And most importantly, this only works up to a point.
> Yes, the machine and systems underneath the abstractions are far more complex, and so if you set out to try to completely fit all of them in your brain, it would be much more difficult than fitting the entirety of the Commodore 64 in your brain, but that greater complexity exists precisely to free the higher layers of abstraction from concerns about things like memory management and clock speeds and so on.
A couple things here. First, the internals of a CPU (to name but this one) has become much more complex than before, but we are extremely well shielded from it through its ISA (instruction set architecture). Some micro-architectural details leak through (most notably the cache hierarchy), but overall, the complexity exposed to programmers is orders of magnitudes lower than the actual complexity of the hardware. It's still much more complex than the programming manual of a commodore 64, but it is not as unmanageable as one might think.
Second, the reason for that extra complexity is not to free our minds from mundane concerns, but to make software run faster. A good example is SIMD: one does not simply auto-vectorise, so to take advantage of those and make your software faster, there's no escaping assembly (or compiler intrinsics).
Third, a lot of the actual hardware complexity we do have to suffer, is magnified by non-technical concerns such as the lack of a fucking manual. Instead we have drivers for the most popular OSes. Those drivers are a band-aid over the absence of standard hardware interfaces and proper manuals. Personally, I'm very tempted to regulate this as follows: hardware companies are forbidden to ship software. That way they'd be forced to make it usable, and properly document it. (That's the intent anyway, I'm not clear on the actual effects.)
> I think a world in which we abandoned C Machines and the paradigm where everything is opaque black box binaries that we control from a higher level shell but have no insight into, and instead iterated on what the Lisp Machines at the MIT AI Lab or D-Machines at Xerox PARC were doing, would be far better, and would allow us to achieve similar levels of ease and productivity with fewer levels of abstraction.
I used to believe in this idea that current machines are optimised for C compilers and such. Initially we could say they were. RISC came about explicitly with the idea of running compiled programs faster, though possibly at the expense of hand-written assembly (because one would need more instructions).
Over time it has become more complicated though. The prime example would again be SIMD. Clearly that's not optimised for C. And cryptographic instructions, and carry-less multiplications (to work in binary fields)… all kinds of specific instructions that make stuff much faster, if you're willing to not use C for a moment.
Then there are fundamental limitations such as the speed of light. That's the real reason between cache hierarchies that favour arrays over trees and pointer chasing, not the desire to optimise specifically for low(ish)-level procedural languages.
Also, you will note that we have developed techniques to implement things like Lisp and Haskell on stock hardware fairly efficiently. It is not clear how much faster a reduction machine would be on specialised hardware, compared to a regular CPU. I suspect not close enough to the speed of a C-like language on current hardware to justify producing it.
1. Scroll down to the bottom of the home page:
2. Under the "Team" subsection of the footer, click "Org Repositories".
3. Now we’re on GitHub, click on the first pinned repository: "pulsar".
4. Scroll down, *now* there’s a screenshot.
If I didn’t know it was on GitHub, I would never have gone through step (2). Those screenshots are decidedly not easy to find.I chose mockery instead.
See, it looked like the authors of this tool weren’t entirely innocent. The whole website oozes the need for recognition, it’s pretty with a well crafted sales speech… and the first comment I see here mentions a segfault on install. On install. Which suggests the quality of the product probably doesn’t match the nice cover it is given.
That’s wrong. https://www.youtube.com/watch?v=k8gIJOy0c2g
That: the simplest solutions look obvious once you see them, but they’re rarely, if ever, obvious from the outset. Simply put, the simplest solutions are rarely the most obvious. You have too actively look for them, and that takes time and effort.
One corollary is that people who take the time to design the simplest solutions that end up making life easier for everyone else, tend to look much less productive than the tactical tornados that masquerade as a heroes. Worse, when the boss looks at their code it’s much simpler and much easier than everyone else. Clearly they took the easy route and chose the easiest things to work on.
And what do you think happens to low performers who chose the easiest work? They can leave, one way or another. But they can also give in and expedite more, more complex code.
Simplicity isn’t just hard. It’s a hard sell.
I would argue there should, no exception. Not even WWII. While keeping in mind that the responsibility was so gigantic to begin with, that even diffusing it might end up putting most participants in jail, some of them for a long time.
To sum this up, they were putting the redaction work, but someone else failed to, and at that point it was too late.
Note that "I will come to your soil if and only if you make such and such promise" is not deciding how their justice system should work. It just means that if they don't get the promise, they will not come to their soil. Likewise, we could point out that Sweden has no right to force someone out of their jurisdiction to turn themselves in.
> What I don't remember was any reasoning on why he thought it more likely that he'd be extradited from Sweden to the US rather than from the UK, who are particularly close?
Sweden has a history of extradition, the treaties aren't the same… and though at the time Assange wasn't formally charged by the US, if I recall correctly he did have (founded) suspicions that a grand jury was put on his case. At the time, his chances of being extradited from Sweden rather than the UK were higher.
> you've drunk the koolaid and are in full defense mode
Someone has gone full attack, and I suspect this is not just about "striking a balance".