Engineering is very reliant on mathematics and as real world as it gets.
HN user
mabster
Ok fair enough. I don't write performance stuff in Java so I haven't even needed to look at this stuff to be honest. Most of the intrinsics I would want are there, except for any memory related stuff. I'm still not sure how structs are laid out in memory but I guess there's something for that too. My favourite thing in C++ is just loading a big binary blob and being able to point directly into it.
The only thing that was different was that we had a number of platform-specific intrinsics to really shake fast code out. E.g. shuffles on x86 on older SSE editions were terrible and we would have custom x86 code for shuffles or let memory out differently.
The only thing we use from C++ stdlib is unique_ptr. For everything else we had our own much more tailored, much faster, stuff. We had something like 10 different array containers for example.
Yeah what you described with templates is what we are doing re speculative optimisation. We have tuned versions for different workloads. We would inspect before we decide which one to run (only if that wasn't slower then just having one implementation, which was often the case because of instruction cache).
Something to be aware of is that on consoles mmapping a page to be executable was forbidden. So no JIT. And you aim for your slowest target so PC just follows that.
I'm a Java developer now, amongst other languages. The advantage of Java is that it takes A LOT less time to develop something, so there is the whole bang for buck for sure. I have had a few problems where I would love shared direct memory access and some atomics (because it would be a lot easier). But for the most part developing in Java is a lot quicker.
I don't think game developers are more conservative than any other developers. We do have large C++ codebases and so it's hard to change.
All modern engines have a few scripting languages tacked on too.
Something like Lua usually is the sweet spot: most of the people developing scripts are not developers. We even had a Java interpreter for scripting once, but it lost favor for this reason.
There were exceptions, but I found that developers generally preferred C# over Java anyway. Our assets pipelines are generally in C# already.
Any speculative optimisation we were doing by hand. There is the whole deferring allocations / moving allocations, both of which we were already doing (e.g. copying every frame).
A lot of our C++ code is intrinsics (including memory primitives like _mm_stream_ps and barriers) and you HAVE to have good control over how memory is laid out (e.g. knowing that data is split between cache lines so that you you don't get contention). Lots of spin locks too. I just don't see how you can do this kind of low level work in Java.
Low level CPU-related optimisation is absolutely still a thing. The GPU is always filled to the brim trying to get as much quality out of a graphics frame so a lot gets offloaded to the CPU. When I was doing this I was doing a lot of low-level CPU optimisation. GPU optimisation was usually more about transform process topology but there was plenty of low-level work to do there too.
Games are both high throughput AND low-latency and C++ is still king there
I did notice that difference too. But previous "credit card size" projects have all been several mm (as in couldn't fit a wallet designed for credit cards). So 1 mm is... pretty sweet!
I went to the page expecting to rant about how it's not actually credit card size because of the thickness and was for once pleasantly surprised! Kudos to the author! It looks great!
That's pretty close to "be like Keanu Reeves"!
It's always the kitchen for me across food places (in Australia). Ending up with pickles when I removed them. Ending up with coke zero instead of coke. But the worst is ending up with anything mock meat!
It's been mixed moving to normal code: I haven't had to low-level optimise for ages now (man I miss that). But performance in the O() sense has been the same.
Game engine development is very much about processing of data. The pipeline is long and the tree is wide. Being able to reason about complicated data processing topologies mapped very easily across.
I haven't watched his videos on his language for ages, but this was a big thing he wanted in his language: being able to swap between array-of-structs and struct-of-array quickly and easily.
Unless LA stood for Latin America haha.
I guessed American when it was compared to Hockey, Baseball and Basketball.
In Melbourne, Australia, Football is again another sport (but it not being called Footy gives it a way).
I flew Scoot airlines recently and my 13” MacBook Air was too big to have on my lap even though the seat in front was not reclined.
There's also something about those seats where you get back pain when you try to sleep with your own seat reclined.
Memories shattered. Yeah, you're right and I would have watched interlaced broadcast content.
I saw interlaced NTSC video in the digital days where the combing was much more obvious and always assumed it was only an NTSC thing!
I'm guessing you're talking about interlacing?
I've never really experienced it because I've always watched PAL which doesn't have that.
But I would have thought it would be perceived as flashing at 60 Hz with a darker image?
You nailed it - that's my criticism :)
I've worked with a lot of code like this (particularly C libraries and litanies of return codes), and it's fine... But I prefer something like Java-style exceptions. And with Java lambdas or Kotlin the trend is unfortunately away from checked exceptions these days...
I too am interested in your other reasons!
I'm the opposite - I really like checked exceptions in Java because it's very easy to see how developers are handling errors and they also form part of the function signature.
Most functions will just pass on exceptions verbatim so it's better than error return values because with them the entire codebase has to be littered with error handling, compared to fewer try catch blocks.
setjmp, etc. are like unchecked exceptions, so I'm also not a fan, but I use this occasionally in C anyway.
I just pictured someone getting a message to check which model was right from an ancestor 20 giga generations ago!
Or the timeline just doesn't have capacity for experimentation so the expectations are clear right from the start!
In context most of the major optimisation work was on the engine. The game code can be and usually is slow but we do try to tame things in an O() sense.
I worked licensed titles for a while and that area the quality of a title and whether it sells were largely uncorrelated haha!
I've written this kind of function so many times it's not funny. I usually want something that is fed from an iterator, removes duplicates, and yields values as soon as possible.
We had similar thoughts about "premature optimisation" in the games industry. That is it's better to have prematurely optimised things than finding "everything is slow". But I guess in that context there are many many "inner-most loops" to optimise.
I can't remember the details because we coded the SPU in C, but the PS3 SPUs had odd and even cycles with different access properties too.
I worked with a developer that copied and pasted A LOT and would keep his fingers on the old copy and paste buttons (Ctrl-Ins, etc.). I've even seen him copy and paste single letters. He's one of the most productive developers I've ever worked with.
In my setup I use Colemak DH mod which loses the Vim arrows but I added a modifier where the 'a' key (left pinky on home row) when held down switches the right home row to arrow keys. Hasn't been an issue.
We purposefully didn't use shared_ptr and hence weak_ptr. With these, it is all too easy to construct the "bad" version which has the stub reference count and pointer stored far away in memory from the object itself requiring a double dereference to access the object which is bad for cache performance. Instead we derived off a shareable class that has the reference count to make sure it is close in memory.
We were happy to use unique_ptr, however.
Was also gonna jump in with the old way of doing circle boundaries, which can be done all integer: https://en.m.wikipedia.org/wiki/Midpoint_circle_algorithm
For my day job I'm either "Getting things done" or Zettelkasten anyway because it's more about retrieval than memory.
But for languages, SRS is great.
And I'm also glad I memorised a whole bunch of math formulas way back. E.g. Boolean algebra I keep using an identity that I couldn't find on identity sheets by web search.
Totally expected the "desirable difficulties". For SRS to work effectively it has to "be yours" and that only works effectively if you're building your own cards.
With Duolingo it kind of encourage small bursts rather than the hour (minimum) per day you need with Anki for better or worse.
Nice write up!
I've got a soroban but never got around to learning it. Definitely should pick that up again.
When I was at Uni (electrical engineering) I noticed that the Chinese students would reach for their calculator way less than western students and assumed that was because of the abacus.
Side note: they tried to shape a control theory subject (everyone was getting 100%) by disallowing calculators in tests. It was rough having to do things like long division for the first time in decades. Still everyone got 100% haha.