Ask HN: What's the most important piece of code you've written?
My answer is as follows... The most important piece of code I've written was a rudimentary 2d tile engine in QB64 for an RPG I never finished. It's memorable and important to me because of what writing it did for my confidence as a developer. At the time, writing a tile engine "from scratch", in my mind, would make me a "professional".
I had been following a Game Development YouTube series called "Adventures In Game Development". I wanted to be a game developer! It was my dream! I was a novice developer when I took on that challenge. After a few articles and discussions with some people in various IRC channels, I began.
A few hours later, I saw a map appear that I had hardcoded which contained 0's, 1's. When I saw the square patch of grass with water in the middle (my clever map design), I thought I could accomplish anything. It was one of those moments that changed my life.
I'm not kidding when I say I had wanted to write a tile engine for a year, at least, before I was actually able to do it. I was probably around 14 years old, at the time.
I hope you enjoyed reading my answer to this question and I look forward to reading yours!
EDIT
I found the link to one of the articles I read when writing the tile engine.
http://www.petesqbsite.com/sections/tutorials/tutorials/rpg_tut2.txt
EDIT 2
Another important piece of code I've written was the prototype for this game.
http://hdfgame.com/
I helped with the commercial version a bit but it was awesome to see my prototype turn into the first commercial game that I helped release. The prototype was simple but it had the basic functionality that Hexapod Defense Force has.
115 comments
[ 5.6 ms ] story [ 193 ms ] threadThen I got kicked out by the owner high and dry after I refused to take sales calls and support calls on top of my developing responsibilities. :)
Software is still running today. It's probably at $50k/mo.
I never looked into my rights because I knew he was worth $50m and I was worth $5 and he'd win no matter what.
I still drive past his new Ferrari sometimes and wonder about what could have been if I just kept my mouth shut and agreed to be his whipping post bitch...
I'm still recovering from the burnout, now broke and unmotivated to move forward. Hundreds of users still spend their 9-5 hours looking at a user interface and performing their job that I'll never be credited for.
From there, it helped me negotiate higher salaries because I could say and prove "I can build entire web platforms front to back and maintain them (and architect/deploy them) in production". I don't make $350k/yr Netflix/Google money but... I do pretty well for my age/skill set/years of experience I think.
I'd say the startup helped me go from junior to mid to senior level engineer quickly, and gave me the confidence in interviews to demand and know my (reasonable) worth.
Let me know if you ever want to vent. I'd love to listen and console.
If they didn't have an IP contract, I'm interested :D
I think we need a blend of developer related skills and non-developer related skills to be successful.
I think the market space is beaten down. At first, we were going to do a free beta. That attracted nobody. Then $29/mo. Well, will you look at that? It's not profitable undercutting everybody because of something we didn't think of: support. Ok, let's try $99/mo. Well, that kind of works, but people are coming and going way too quickly. What finally worked is to do $99/mo per user, with a minimum of 3 users. All other companies in this space pretty much charge a $750-$3k onboarding fee because they have realized what a time suck you'll be.
I have proved I can build pretty much any SaaS platform (which I'm sure 100k people here could do). In my opinion, it isn't the technology part that is hard (CRUD API endpoints are trivial to say the least). The super hard part technology wise is good user interface. Naming technical things easy terms (your item in inventory... is it an item or a kit/bundle? ok... how many channels do you sell it on? ok, well, you have 3 listings that are linked to your kit/item. Try getting that concept across)
Plus, after people choose a system, they invest a ton of time into it (their entire business lives and dies on it. Sync inventory + pricing for Amazon/Jet/Walmart/Shopify. Purchase orders. QuickBooks exports, yada yada). Not a lot of people signing up left and right, and if they were, they really probably weren't worth the headache (anybody can make a "mom and pop" e-commerce shop, but if you have no business/orders, all you have to do to fill an 8 hour day is take out your aggressions on the person on the other end of the phone supporting your failing business inventory software wise)
I'm down to write whatever, but we need marketing + advertising + everything else I just described.
I’d like to say thank you to my father for buying it and keeping the chocolate milk and powdered doughnuts flowing.
Second to that would be the games I wrote on my TI back in high school (90s) when I should have been learning trig. That and some late night script kiddie exploits got me on the path to a career in tech.
The most important code to me is a difficult question... I look at code as solutions to problem. What's most important to me, is the code that made me realize none of us are free (weird as that sounds). I can track anyone on the web from their discussions (provided enough comments, i.e. 1000+ words):
https://twitter.com/AustinGWalters/status/104189476543920128...
Expanding on this system I built an investment framework part of which is incorporated in (https://projectpiglet.com). It has helped me make 100% yoy returns since 2013 (including >200% last year, even with the downturn):
https://twitter.com/AustinGWalters/status/107014266501716787...
It's the basis for my startup, but perhaps more importantly, made me realize we have no freedom. I can do this with no funds, in my house, with a computer. I track a couple million people in real-time (public data only)... I wrote a blog post about my introspection:
https://austingwalters.com/the-last-free-generation/
In a sense, it's open my eyes to the dystopia we are building and it's changed my outlook dramatically.
So can any animal in a zoo...
Freedom of self-determination is what I think most people define as "freedom". If I redefine freedom, I'd argue I should use a different word, as it wont convey the same meaning to others. When our world is manipulated around us to control what we know and to extent what we think, we are in a cage (at least most of "us" are).
Agreed that our world is manipulated around us, but I think the manipulations are much less influential than (a) the difference in society between now vs 500 years ago (and vs where we will be in 100 years) and (b) what we choose to believe and want for ourselves by thinking critically. Still, I do wonder sometimes about the things we choose to believe vs what society convinces us to believe.
How far off the mark am I?
Times change, as do perspectives. Sorry I can't be more helpful.
Anyways, what I did was write a VBA code that
1) Allowed me to take the user ID of the people that needed to be added into said HMI, then get their first name and last name from outlook using an outlook api and automatically adds these users into the credential files.
2) Send the email to the same list of users after I update the file onto the HMI (the HMIs themselves in an air gap network).
Why is this important? Because it got some of my other coworkers to trust that I can find bullshit problems and solve them (this isn't the only bullshit problem I have to do over the years), thus gaining their trust and overtime, got a promotion.
I didn't do it alone of course (probably a dozen people have worked on the UI, and hundreds on the backend), but it was my main project for around 9 months. Lots of videos that people care a lot about go through there.
So each time one of these programs goes through its mainloop, a little bit of money comes into the kitty. ;-)
Possibly a coincidence, but these are also the programs that I was the most disciplined about writing so that they have been in production for years with extremely small and manageable lists of known bugs.
There was quite a fire-- the front-end would crash, lines were endless, etc. The government quickly formed a Tiger Team, with contributors from various companies.
I didn't care for the way the legislation was formed, but I am proud of my involvement. I gave it 100%.
Tech stack: MySQL, Java EE, JQuery, Bootstrap and the like. No big frameworks. All hosted on Google Cloud.
Another point is that my market is really not obvious at all and I want to have competitors as late as possible. Currently there are none I know of. Only competitors who solve parts of it which existed before me anyway.
I had decided to use a new single board computer on the robot that used a compact PCI bus, which at the time was a brand-new standard. It was very expensive - $25,000 - which was a whole lot of money for a university lab, but the computer had specs that we just couldn't beat with other existing single-board computers at that time.
There were no available compact PCI motor controller boards, so we had to use a motor controller board that was built for a different bus standard, and then convert from the Compact PCI system to the other board using a bridge chip. The particular motor controller board we chose was based on an 8-bit motor controller IC, the LM629. This particular chip uses memory-mapped 8-bit registers, and in order to communicate with it you have to write and read the registers in a very specific order. If you do anything in the wrong order, or you try to write to a read-only register, or vice-versa, the chip generates an error.
I was a decent low—level C programmer at that time, and was able to crank out the code in two days. But it didn't work. Whenever we tried to communicate with the chip, it threw an error. I went over the code with a fine-toothed comb, and I was absolutely certain it was all correct. I had no idea what was wrong. I was looking pretty bad to my advisor; I was the C stud, and I couldn't even write this simple device driver. And worse, I had recommended that we use this particular computer system, which cost $25,000, far more expensive than any other SBC we had ever bought, and now I couldn't make the thing work.
Finally, after banging my head against it for a week and making no progress, we threw up our hands and asked the motor controller board vendor if we could bring our system to their facility and get their help debugging it.
We arrived at the vendor and set up. Their programmer checked my code, and he couldn't find anything wrong with it either. After two days the owner took pity on us and asked his best engineer, a digital logic expert, to help us. He carted in a $20,000 digital logic analyzer and hooked it up and had me run my code. What he discovered was that when I had issued an eight-bit read, the chip saw a 16-bit read, which it wasn't expecting, so it threw an error, because the high-order byte was getting read from a write-only register. But the code was clearly issuing an 8-bit read. So where was the 16-bit read coming from?
It turned out the bridge chip had a bug. When it saw an incoming 8-bit read request on one bus, it translated it into a 16-bit read on the other, then threw away the most significant byte. We called the manufacturer, and were told "that's known, documented behavior - it's clearly spelled out in the manual." And when we checked, sure enough, it was - it was mentioned on page 48 in the third footnote, in 8-point type.
The solution we eventually came up with was to cut all of the address bus lines on the motor controller board and shift them to the right by one, and then take the least significant bit line and connect it to most significant line on the address bus. That way, access requests to any odd 16-bit memory address would map into unmapped register space so the LM629 wouldn't see them. Then I rewrote the code to only use even memory addresses. Worked like a charm. But I still feel sorry for the grad students who had that robot after I graduated. There was no way they ever figured out what I had done. Or why.
Thanks for sharing that nugget!
I was brought on to provide a nice looking web UI for an online system that scientists could use to submit jobs to a server running molecular dynamics simulations. After finishing the job queue and interfaces though, I had plenty of time to spare. So the boss asked me to try and run some necessary manipulations on the uploaded PDB (protein data bank) files, before they would be sent to run in the simulation.
It's still the only time I have ever actually used direct material from my undergrad degree at work - using Dijkstra's algorithm and standard deviation to discover protein structural features, then manipulating them. It was also the only time I ever used the Python I spent just one semester learning a decade before. With all those libraries, I can understand why it was the language of choice my boss' field.
I made a log of the jobs as well, and in the 5 year since then, over 10,000 jobs have been submitted, helping scientists from dozens of countries all over the world. It's also the only code I've written since my uni days which isn't just typical web app type stuff. It's just this pokey little online service but I'm really proud of it, and I hope I've contributed to humanity's progress in some tiny way.
Compared to other things (including some of the ID3 tag processing code that's still in Windows today, and OLEView) this seems pretty important.
Whilst I'm sort of proud of the 'word at a time', always contiguous and zero copy aspects of it... the important bit is the metadata.
All the optimization was really to allow me to record metadata around...
* When was a message posted?
* When did it start to be handled?
* When was it finished being handled?
* What was the correlation ID? (ie. the ultimate causal source of the events chain)
...and then extract this data into a sqlite DB and either query that directly or to create message sequence diagrams with the mscgen tool.
Why is this important?
Because I have lost count of the really hard, gnarly real time bugs I have solved using this tool.
The Q was how does one manage large numbers of heterogeneous containers (VM sprawl was already considered a problem, but we said if containers took over the sprawl would be worse). At the time the primary container mechanism was Solaris Zones and people uses ZFS clone functionality to create per zone container file systems. However, this only really helps if your containers are homogeneous. I built a system that created container file systems out of composable layers. One would define template file systems as a collection of layers that are stored in local and remote layer repositories and these layers would be instantly unioned together on demand when one provisioned new containers. We also demonstrated that since heterogeneous containers are now easy to manage, we can not just use containers as lower overhead but similarly long lived VM replacements, but also enable them to be used ephemerally, opening up many new use cases.
You probably know of this by a different name today.
I took unionfs and modified to be more dynamic. i.e. for persistent containers, enable layers to be marked unlink and replaced with different layers (they would remain part of the union for data operations, but would be invisible to file system name oriented operations, ex: lookup()/readdir()). Idea for this was to enable a container to upgrade itself if the template it was based on was upgraded. I wasn't thinking what became the cattle/pet metaphor, was focused on creating a system that would work equally well for persistent and ephemeral containers.
my god this man invented UPS
> At the time the primary container mechanism was Solaris Zones and people uses ZFS clone functionality to create per zone container file systems.
oh wait nevermind he invented docker
The guy that runs it spent years bragging about doing drugs and drinking to all hours of the night with nothing to show for it and then shits on his backers for asking about the progress of the project (none).
I had been programming for about 6 years but had never finished anything of substance. The game took about 6 weeks of working on it between classes (and with the help of a friend with the polish and graphics). It went on to be played millions of times and made several thousand of dollars in ad revenue. Even 10 years and a PhD later, this is one of my biggest accomplishments.
It was one of those moments that makes me feel like now I can actually do this (this feeling seems to repeat every few years...).
[1] http://www.mindjolt.com/stay-up.html
In grad school I helped another PhD student by writing control software for a device used to assess the locality and severity of brain lesions. I got a tee shirt for doing that work.