Recently, my beloved Prius finally gave up the ghost (brake pump died, over $5000 and months of repairs), so I decided it was time to replace it with an electric car. Specifically, a 40kWh Nissan Leaf.
And I highly recommend it.
There’s a lot of reasons to like it, not least because its fun to humiliate gas car drivers at stoplights, but because it has a fancy app which is a virtual treasure trove of data.
Continue Reading
There’s a debate going on in the world, a tension between the CS and the SWE majors. As a professional programmer, I will be the first to admit that it is exceedingly rare that I compute the big-O of a function I work on. It’s even rare that I work on a function that’s not O(1). So, one might argue, what is the point of a four year computer science degree?
Continue Reading
So, several years ago I wrote a post talking about decoding the X-Wing vs. TIE fighter briefing file format. Blog posts are a perfect medium for this sort of thing, since they give me a place to take notes, and they give you a place where you can listen to me talk about file formats. Win-win.
Anyway. I find myself in this position again, in my work decoding World of Warships replays.
Continue Reading
X-macros: Like the X-Men, except that nobody likes them.
Here’s why.
If you aren’t familiar with what x-macros are, they’re a way in C and C++ to embed lists of data tuples into a program, while minimizing the amount of boilerplate, at the cost of using the preprocessor. For example - let’s say you have a list of products, each with a unique product code, and you want to be able to convert those codes into nice product names.
Continue Reading
So there’s this variable naming convention called “Hungarian typing”, which defines itself by naming variables according to their type. The classic example is:
int iPotatoCount = 53; const char* sPotatoName = "Russet"; With the upside that where the variable is used, you can clearly see the type:
printf("Number of potatoes is %d\n", iPotatoCount); Which is not super useful for two reasons: One, modern text editors will just directly tell you the type if you hover over the variable, and two, your functions should all be short enough that all of your arguments and local variables should appear on the same screen as whatever code you’re looking at (or same page, if you print out your code).
Continue Reading
So during the Second World War (the less great one), in the Pacific theater, the Americans and the Japanese fought largely over pacific islands (famously places like Okinawa, Guam[1], Palau, etcetera). This was almost entirely for logistical reasons - The US needed to control the area in order to launch bombers and resupply forces in the region, and they provided access to the Japanese homeland in the event that a direct invasion was required.
Continue Reading
So I play this game, World of Warships:
It’s a fun game. You drive around and shoot at boats and such. Highly recommend it (despite the fact that their marketing department is seemingly high on drugs.)
Like many other games, it generates replay files. A small community has sprung up around building programs that parse the replays.
Mine is here. There are many like it, but this one is mine.
Continue Reading
It’s been a couple weeks, so let’s focus up and get down to business. Which, as we all know, means promulgating Rust talking about software engineering.
It was reported by the creator of curl a few weeks ago that half of curl’s vulnerabilities are C mistakes. Notably, this is only talking about security vulnerabilities. (also, fun fact, curl is apparently used by that really far away helicopter, Ingenuity. If Ingenuity is hosting a WiFi AP to serve its camera data, JPL isn’t telling)
Continue Reading
class MyClass: def __init__(self): self._signature = None def get_signature(self): if self._signature is None: self._signature = self.peek_register(SIGNATURE_ADDR) return self._signature We’ve all seen this code before. You have some getter that you want to return a value, but it’s expensive/inconvenient to initialize, so you cache it. You don’t want to do it when you make the class, maybe because not every class ends up needing one, maybe because it’s difficult to initialize in the constructor.
Continue Reading
Okay, so first off, floating point numbers are the worst and you should never use them.
But if you are, they say programmers should be aware of coercion rules. “ints promote to floats”, they say. “And floats promote to doubles.”
You probably had to go to a school and pay money for somebody to put that on a slide so that you could forget it and look it up later. So look at this code:
Continue Reading