HNHacker News
TopNewBestAskShowJobs

caspper69

729 karma · joined July 29, 2018

submissionscomments
caspper69··on Liskov Substitution: The real meaning of inheritance
Respectfully, I think you're throwing the baby out with the bathwater.

I read your story, and I can certainly empathize.

But just because someone has made a tangled web using inheritance doesn't mean inheritance itself is to blame. Show me someone doing something stupid with inheritance and I can demonstrate the same stupidity with composition.

I mean, base classes should not be operating on derived class objects outside of the base class interface, like ever. That's just poorly architected code no matter which way you slice it. But just like Dijkstra railing against goto, there is a time and a place for (measured, intelligent & appropriate) use.

Even the Linux kernel uses subclassing extensively. Sometimes Struct B really is a Struct A, just with some extra bits. You shouldn't have to duplicate code or nest structures to attain those ergonomics.

Anything can lead to a rube-goldberg mess if not handled with some common sense.

caspper69··on Liskov Substitution: The real meaning of inheritance
Just because you see OO languages starting to favor composition over inheritance does not mean inheritance has no place, and indeed, interfaces as a form of composition have existed in many bog-standard OO languages for decades.

Your example dosn't compute, at least in most languages, because derived objects would not have the same shape as one another, only the shape of the base class. I.e. functions expecting a User object would of course accept either an Employee or a Student (both subclasses of a User), but functions expecting a Student object or an Employee object would not accept the other object type just because they share a base class. Indeed, that's the whole point. And as another poster mentioned, you are introducing a burden by now having no way to determine whether a User is an Employee or a Student without having to pass additional information.

Listen, I'll be the first to admit that the oo paradigm went overboard with inheritance and object classification to the n-th degree by inventing ridiculous object hierarchies etc, but inheritance (even multiple inheritance) has a place- not just when reasoning about and organizing code, but for programmer ergonomics. And with the trend for composition to disallow data members (like traits in Rust), it can seriously limit the expressiveness of code.

Sometimes inheritance is better, and if used properly, there's nothing wrong with that. The alternative is that you wind up implementing the same 5-10 interfaces repeatedly for every different object you create.

It should never be all or nothing. Inheritance has its place. Composition has its place.

And if you squint just right they're two sides of the same coin. "Is A" vs "Can Do" or "Has".

caspper69··on Understanding Memory Management, Part 1: C
I initially read your username as boehm, and I was like wow, ok, this is a guy who knows his memory. :)

What situations would an arena allocator prove problematic or non-optimal, aside from the many allocations/deallocations scenario?

This is an area I'm very interested in, so any info would be appreciated.

caspper69··on What Every Hacker Should Know About TLB Invalidation [pdf]
I don't mean to be a pedant, so someone please correct me if I'm wrong, but I don't think TLB mishandling would result in arbitrary memory access (I suppose in the strictest sense arbitrary can just mean random, but generally I have understood it to imply that the address can be attacker controlled, which a stale TLB wouldn't allow).

Unless you're like Microsoft (from your link) and accidentally leave the page tables writable from userspace for 2 months. But that's not really a TLB error, that's just L-O-L, wow!

caspper69··on What Every Hacker Should Know About TLB Invalidation [pdf]
I only know x86/64, but I assume most page table caching would be somewhat similar.

Basically, if you don't handle the TLB properly, the CPU will not know that page mappings and/or page permissions have changed. So if you had a page mapped RW, and then changed the mapping to a RO page (such as setting up COW), but failed to flush the TLB (or at least call INVLPG to flush the entry), the CPU might use those stale permissions and grant write access on that page when it shouldn't. The same could happen for changing a region of the VA space to use a different physical page, where the next bit of code would hit the old page (and who knows what state it might be in or what it could be being used for).

The TLB is not super-complicated, but it has some quirks (it's been so long since I've done anything with it, the PCID handling rules were new to me; didn't even support it back when).

caspper69··on Understanding Memory Management, Part 1: C
I agree with you 100%. I think arenas are a much lighter burden for the programmer to reason about than lifetimes & access patterns.

But arenas can have one big drawback, and that is if you do a lot of allocations and deallocations, especially in long-running routines, you can essentially leak memory, because arenas are not usually freed until they are going out of scope. This can vary depending on the language and the implementation, though.

My thought to counteract that though is you could offer a ref-counted arena just for this scenario, but I'm not sure what exactly that would look like (automatic once refs hit 0? offer a purge() function like a GC?). I haven't wrapped my head around the ergonomics yet.

caspper69··on Understanding Memory Management, Part 1: C
Nothing is going to tell you where to put your free() calls to guarantee memory safety (otherwise Rust wouldn't exist).

There are tools that will tell you they're missing, however. Read up on Valgrind and ASAN.

In C, non-global variables go out of scope when the function they are created in ends. So if you malloc() in a fn, free() at the end.

If you're doing everything with globals in a short-running program, let the OS do it if that suits you (makes me feel dirty).

This whole problem doesn't get crazy until your program gets more complicated. Once you have a lot of pointers among objects with different lifetimes. or you decide to add some concurrency (or parallelism), or when you have a lot of cooks in the kitchen.

In the applications you say you are writing, just ask yourself if you're going to use a variable again. If not, and it is using dynamically-allocated memory, free() it.

Don't psych yourself out, it's just C.

And yes, there are ref-counting libraries for C. But I wouldn't want to write my program twice, once to use the ref-counting library in debug mode and another to use malloc/free in release mode. That sounds exhausting for all but the most trivial programs.

caspper69··on What I Learned Failing to Finish a Game in 2024
100% this.

I have done work in embedded game dev off and on for about 20 years, and I could have done so much more had I had even one ounce of artistic ability.

And (other than hobbyist or OSS), it's very hard to use canned artwork. Everything just needs to be unique for a commercial offering.

But in all fairness, I don't think many of the artists I worked with could code. Just seems to be opposite skillsets (beyond just the creativity).

caspper69··on Data evolution with set-theoretic types
They wouldn't also happen to throw out memory safety guarantees one level up by using a ton of array indexing, would they?
caspper69··on Apple will soon receive 'made in America' chips from TSMC's Arizona fab
Right, and at least Microsoft has a large sales organization.

But Google and Meta?

caspper69··on Apple will soon receive 'made in America' chips from TSMC's Arizona fab
These companies hire all of these exemplary graduates and pay them so well because (1) they are flush with cash because businesses are essentially held hostage to adtech; and (2) so that they won't go out into the world and build systems that make them irrelevant, as smart people are wont to do from time to time. Someone on your payroll doesn't have the time nor the inclination to knock you from your pedestal.

Why else would Google need 182,000 employees? Or how about Facebook with 67,000? Microsoft clocks in at a whopping 228,000, and Apple at 161,000.

These are staggering numbers of employees. So many, in fact, that it would be an exercise in futility to try and manage so many for the number of products they offer, especially Google and Meta.

It's cheaper to make busywork than risk the cash cow.

caspper69··on Allstate used GasBuddy and other apps to track driving behavior: lawsuit
This may not be true of all such apps, but I open mine and it subdivides trips by every stop (including stop signs and lights). Then when you don't do it for 3-4 days, you have 50 trips you need to click through.

My time was worth more than the savings they offered. In fact, it was insulting.

I should not have to spend 3 hours per month categorizing my trips for their data mining expedition for a $30 discount (especially not one that evaporated at the next renewal, because I wasn't safe enough). That app was rigged.

caspper69··on Company of One: Why Staying Small Is the Next Big Thing for Business
Honestly, as I've gotten older, I just don't have a lot of respect for companies that are simply chasing growth for the sake of growth and monetization just for the sake of monetization. I don't think people realize when enough is actually enough.

I think one of the worst things a company can do is go public (outside of industries and niches that simply require large players). It just seems to ruin the quality of a company's products, services & culture.

I know we can't all live in Mayberry, and that people don't really pay for quality, but when your sole objective boils down to pleasing Wall St. quarter after quarter, something gets lost in the process.

Being a part of something that you take pride in used to mean something. Craftsmen and inventors weren't necessarily looking for a seven figure exit (or more), or to become billionaires. They wanted to make the lives of their customers better.

I think we all suffer in different ways because of this growth-at-all-costs mentality, from the top all the way down.

caspper69··on Why is my CPU usage always 100%?
Funny thing about all of this is that it's just such oppressive overkill.

Most GUI toolkits can do layout / graphics / fonts in a much simpler (and sane) way. "Reactive" layout is not a new concept.

HTML/CSS/JS is not an efficient or clean way to do layout in an application. It only exists to shoehorn UI layout into a rich text DOCUMENT format.

Can you imagine if Microsoft or Apple had insisted that GUI application layout be handled the way we do it today back in the 80s and 90s? Straight up C was easier to grok that this garbage we have today. The industry as a whole should be ashamed. It's not easier, it doesn't make things look better, and it wastes billions in developer time and user time, not to mention slowly making the oceans boil.

Every time I have to use a web-based application (which is most of the time nowadays), it infuriates me. The latency is atrocious. The UIs are slow. There's mysterious errors at least once or twice daily. WTF are we doing? When a Windows 95 application ran faster and was more responsive and more reliable than something written 30 years later, we have a serious problem.

Here's some advice: stop throwing your web code into Electron, and start using a cross-platform GUI toolkit. Use local files and/or sqlite databases for storage, and then sync to the cloud in the background. Voila, non-shit applications that stop wasting everybody's effing time.

If your only tool is a hammer, something, something, nails...

caspper69··on C++26: A Placeholder with No Name
I think you're right.

As soon as you start writing big(ger) software in Rust, its lacking ergonomics really become apparent.

.as_mut().unwrap().unwrap().as_mut().do_stuff() gets really old after a while.

And I am not convinced that borrow checking is the panacea that it's made out to be. Region-based memory management can accomplish the same safety goals (provided there's a sane concurrency model), without forcing people into manually opting into boxing and/or reference counting on a per-reference basis.

Throw into that the pain of manual lifetime management (it's not always elided, and when it needs to change, it's painful), I honestly believe it's far more reasonable to ask programmers to throw shit into two or three arenas and then go hog-wild with references than it is to expect them to deal with the tediousness of the way Rust does things.

We are just cargo-culters (no pun intended).

caspper69··on Test if a number is even
gcc does it even when it's not optimizing
caspper69··on Robotics 101 at UMich: Applied numerical linear algebra as intro linear algebra
I honestly don't think the problem is the textbook.

I have Stewart (both the standard version and Early Transcendentals), and I also have a book from 1967 by Tom Apostol (the 2 volume set that covers single & multivariable calculus, linear algebra, a subtle introduction to differential equations and some probability as well).

My gut feeling is that I just don't know the correct way to study math in general. I have no problem doing the work. But it feels more like mechanical or algorithmic solving than it does like true understanding. There is a difference. I can't deconstruct a problem and think in the abstract to come up with a different method to solve it.

And there always seem to be some fundamental truth that I'm always missing. A part of a proof here or an axiom there that seems obvious to other people who study these subjects that I just don't "see".

It's incredibly frustrating, because deep down I know I have the aptitude for this stuff. I guess that most subjects have always been easy for me. I could ace exams without cracking the book (or just skimming).

Math is not like that. You need to read. And then re-read. And then do. And then do some more. And then go back and re-read again to see what you missed. And there's a lot of things that are between the lines, and if you're not following it, those things fall by the wayside.

I just need to learn how to learn math. I need to learn how to deconstruct notation and proofs to truly understand them. And there's no shortcut. It's grind and grind until it all becomes clear. That sort of thing is just difficult for me.

caspper69··on Robotics 101 at UMich: Applied numerical linear algebra as intro linear algebra
Thank you for posting that info. I'd hate for the guy to want the applied computer-centric linear algebra only to find himself neck deep in a super rigorous course that might go deeper that he intended! Oof.

I should have posted the Math 257 description too. It also has lectures online as well as a synchronous Zoom component:

Introductory course incorporating linear algebra concepts with computational tools, with real world applications to science, engineering and data science. Topics include linear equations, matrix operations, vector spaces, linear transformations, eigenvalues, eigenvectors, inner products and norms, orthogonality, linear regression, equilibrium, linear dynamical systems and the singular value decomposition.

caspper69··on Robotics 101 at UMich: Applied numerical linear algebra as intro linear algebra
One day, God willing, lol.
caspper69··on Robotics 101 at UMich: Applied numerical linear algebra as intro linear algebra
Thank you. I appreciate the feedback and the pointers.
caspper69··on Robotics 101 at UMich: Applied numerical linear algebra as intro linear algebra
Such is life. We all have regrets, and being sloppy and indifferent with math in my youth is a big one for me. If I had done it then, I wouldn't have to try so hard now.
caspper69··on Robotics 101 at UMich: Applied numerical linear algebra as intro linear algebra
I can't personally vouch for the program as I have not attended, but the University of Illinois offers quite a few mathematics courses online geared toward high school students, distance learners, and those preparing for grad school.

It is self-paced, so may not be what you're looking for, and it is expensive ($1250 if you have a BS already), but I seriously considered going this route before deciding to save big $$ and attend the local community college (which was actually a decent decision).

Program link: https://netmath.illinois.edu/

They offer 2 linear algebra courses, Math 257, which is Linear Algebra with Computer Applications (likely the "easy" applied version) and Math 416, Abstract Linear Algebra. Some of these Netmath courses do not have online lectures, but the Abstract LA course has video lectures from 2016.

From their site: "Math 416 is a rigorous, abstract treatment of linear algebra. Topics to be covered include vector spaces, linear transformations, eigenvalues and eigenvectors, diagonalizability, and inner product spaces. The course concludes with a brief introduction to the theory of canonical forms for matrices and linear transformations."

When I was investigating what to do in order to solidify my math credentials (still a work in progress), I knew UofI was a good school, and figured credit in one of their courses (online or not) would not be a terrible investment. At a bare minimum it wouldn't be belittled or untrusted like other online certificates might.

Plus the credit should transfer anywhere, if that's important.

caspper69··on Robotics 101 at UMich: Applied numerical linear algebra as intro linear algebra
This would have helped me get an actual CS degree 25 years ago instead of CS-lite (networking & server admin).

It's not that I can't do calculus, I took it in high school, and then again in my first go-round in CS. It's that I hate calculus. Not the subject itself, just the grinding away at problem sets.

I did a refresher in pre-calc, calc I, calc II & discrete mathematics during COVID at the local community college (was planning to finish the few credits I need for an actual CS BS) & I started calc III twice (but dropped both times). I even got a 4.0 on my first calc III exam (and this was an in-person class, so no online shenanigans).

I just have some kind of weird aversion to 3 dimensional calculus. I have convinced myself that I'm simply not smart enough to actually do the work. I understand it, I just get clammy with it.

Truth be told, maths are my kryptonite. Despite working with numbers all day every day for 30+ years, and writing a lot of software over the years (and not just CRUD, but games of all things), I am absolutely ashamed that I just can't seem to grok math with any rigor.

I have all the Stewart textbooks on my shelf, many textbooks from libgen (ones I've seen recommended on HN from people who went to much better universities than I attended), and I even work through problems a few hours per week. I just can't seem to make that leap from a guy who's "good with numbers" (from a layperson's perspective) to a guy who's good at math.

Maybe I need to break open one of my physics textbooks and actually use the calculus in an applied context and that will break whatever mental barrier I have (I've even watched all of the 3 blue 1 brown videos, countless youtube lectures, etc).

caspper69··on BareMetal OS
While the ISAs are (mostly) standardized, the broader hardware support is a mishmash.

ACPI is available, but not widely supported.

Some hardware uses DeviceTree.

Other hardware just expects you to know what devices are connected and how to interact with them.

caspper69··on Show HN: Banan-OS, an Unix-like operating system written from scratch
So here's the kicker.

Microsoft, having the resources it does, was able to design and implement a stable driver ABI. In fact, they also have a stable userspace ABI. Both have evolved, but that's not the point.

Linux conversely (whether by design or by limitation) does not have stable ABIs (although userspace compatibility isn't terrible). Even though you can build kernel drivers as modules (and then load/unload), those modules are unique to each specific kernel build.

Remember those guys didn't write the compiler & linker toolchains they were using like Microsoft was able to do.

I will be honest, I understand why Linus & Co. have decided to keep it this way, because it encourages hardware manufacturers to submit either their drivers or their specifications to the upstream kernel, which promotes software freedom. It is a noble goal and has served them well.

BUT - thieir decision has caused me no small amount of consternation over the years as a system administrator. Once you use Linux for something that is not "server software" (be it auth, file sharing, web, etc.), you are generally using it to drive some piece of hardware (CNCs, industrial tools, cough phone systems cough). Vendors, especially those that deal in low-volume / high-margin products, do not want to release their source code. They're allergic to the idea even. So I have gotten stuck in outdated kernel hell on several occasions because the kernel devs have decided to change internal interfaces in a point-point release that my driver software relied upon.

I so wish that Linux would move to a stable driver ABI. It would make administration & upgrades so much easier, especially on the embedded side.

But I also know that it'll never happen.

FWIW, the "no stable kernel ABI" is unique to Linux, although no one really does this like Microsoft (i.e. the BSDs can break between releases, but I do believe NetBSD is superior to FreeBSD in this respect).

caspper69··on Show HN: Banan-OS, an Unix-like operating system written from scratch
Not really. I don't see how Linux being popular & strong today had any bearing on people's willingness to contribute 33 years ago.

Writing an operating system is challenging. Not as challenging as a compiler, but certainly more work (so much hardware, so many specifications ugh).

In 91-92, people were clamoring for a free, unencumbered 386 Unix. Enter Linux.

Every successful (non-commercial) OS undertaking needs and has a hook.

Redox? Rust (enough said).

Serenity? Live coding and mental health (no knock there).

And on the flip side, look at ReactOS. Languishing. Painfully slow 15+ years in development, and people would still rather pay Microsoft or roll the dice running applications under Wine. It's hook just isn't strong enough.

Again, not to knock this guy, because just the fact that he wrote his own AML interpreter is super impressive to me (I've floundered around in those same ACPI specs for far, far (far, far) too many sleepless nights), and never put out 1 line of AML code. So mad props.

But there's just no hook. C++? Passe. No microkernel / hypervisor / <insert_feature_here>? No capability model?

It'll be tough. But I know that OS'ing is a labor of love, even if not a single other person cares. Cheers.

caspper69··on Show HN: Banan-OS, an Unix-like operating system written from scratch
There was a need for linux, and that's why it took off. The Unix wars, the provenance of the 4.3 BSD code, the cred of running a Unix (or Unix-alike).

Not to trash this guy's project, but there's no similar perfect storm going on right now.

caspper69··on Gordon Letwin OS/2 Usenet post (1995)
It wasn't just memory requirements that hurt OS/2. I'd argue one of the biggest hurdles was IBM couldn't stop being IBM for even one second to do any reflection on the realities in the PC market. They still thought they were going to have a renaissance with 386 PS/2 systems for goodness sakes.

And man were they expensive. $195 for OS/2 2.0. That's about $434 in 2024 dollars, and the PS/2 systems that ran it best started north of $2k if memory serves. No one outside of corporate and the biggest enthusiasts were shelling out that kind of money for "a better DOS than DOS" (cough Desqview cough) or "a better Windows (3.1) than Windows (3.1)" (irrelevant and not that impressiive imho).

Love them or hate them, Microsoft has always been good at hitting the 75th percentile, aka "good enough" and "cheap enough". They proved (conclusively) that customers will put up with a mountain of shit if you cost half of what your competitors do. Plus they knew how to make ISVs a lot of money too. IBM just couldn't get it's head out of it's ass, I mean the 1960s.

And for the record, I salivated over OS/2. I scored a beta of 2.0 when I was 14 off of a BBS associate. I had an IBM laser printer, IBM typewriters, an original IBM PC. I thought back then that IBM meant quality (and to be fair, it did).

But they didn't get it and Microsoft did. Windows 95 had pizzaz and hype, the CD had Weezer's Buddy Holly video (video!). They were working to get games running right under 95. They were courting all of the biggest application vendors. They were doing shit. IBM? Too busy being IBM.

caspper69··on Steam drops Windows 7 and 8 support with the latest client
Time flies when you're having fun I guess.

Windows 10 released on July 29, 2015 or almost 9.5 years ago.

While I'm sure there are people gaming with Steam on 7/8/8.1, I doubt it's very many (Valve's own statistics I'm sure would support this).

I would also point out that Steam on Linux only officially supports the latest LTS release of Ubuntu, which means they support old versions of Windows far longer. Of course, Ubuntu is free, and the kernel hasn't introduced any draconian hardware restrictions, but I think Valve has done a good job with their Windows support.

caspper69··on Running DOS Apps on Windows from 1.0 to 95 (2020)
PC Magazine (and others I'm sure) used to regularly do "showdowns" with DOS multitasking environments and upcoming GUIs.

There was a time when none of this stuff was settled and a lot of folks threw their hat into the ring.

I used to love the writeups as a bbs operator, lol!

← PreviousPage 7 of 12Next →