So, after sleeping on yesterday’s post, I had some scattered thoughts which I will add here.
Making everything an expression is a bit unweildy, so maybe the update_mystruct module could be written as:
module update_mystruct( clock clk, bit rst, my_struct counter, ) -> ( my_struct counter_out, ); if rst { counter_out[T].is_upcounter = 0; counter_out[T].counter = 0; } else { counter_out[T].is_upcounter = if counter[T] == 100 { 0 } else if counter[T].
Continue Reading
Time. It’s an amazing song by Hans Zimmer. It’s an inexorable passage. It’s many things to many people.
Today, we’ll talk about the second one. And how’s it’s portrayed in programming languages.
In most programming languages, time is implicit, and subsequent instructions are “later” in time. Of course, compiler optimizations and hardware reordering can change when instructions actually execute, but from the perspective of the language it proceeds linearly. For example, in this C code:
Continue Reading
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