Ask HN: What's the most important piece of code you've written?

105 points by jessehorne ↗ 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 ] thread
My first professional job was doing a little bit of work for the Human Genome Project. I've never done anything else nearly as worthwhile.
I wrote an entire e-commerce inventory SaaS platform singlehandledly (frontend, backend, database, cache, nginx, blah blah blah) that had 100 users and about $30k/mo revenue.

Then 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.

Sad story! Did you get any sort of shares/equity?
I think legally he knew he had to give me something as a parting gift to cover his ass (he was really smart. He once sued a company by spending a ton of $400-$500/hr lawyers just to get them to change their name because it was too close to his on another product line he had going) so when he fired me, he told me I could keep the iMac he had let me order when I was an employee.

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...

You're not alone on this. Similar story to yours. Every component of our system was developed by me, right down to the the business model as far as what users do day-by-day. I didn't speak up from the start about ownership, and once the product was profitable I was kicked out.

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.

If it makes you feel any better, in the job market it made me realize my worth. I started making $40k/yr when I was 19 (because the investor/entrepreneur knew I'd do all of the work, had no other options, and would be hungry). At the end, I think he got me up to $120k/yr (no 401k, no a lot of stuff lol) but then deducted my pay because I argued back with him that I didn't want to do sales calls once.

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.

Wanna write a competing software solution?

If they didn't have an IP contract, I'm interested :D

I would be interested in something like this as well. ;)
'This small company was created by three developers who found a joint calling: getting fucked by previous experiences in startups' - YCombinator 2020?
I responded to muffins comment. I want to get in touch with you guys. I'd love to see where this goes.
Do you have marketing/advertising skills or do you think I'm over-exaggerating how hard it is to gain marketshare?

I think we need a blend of developer related skills and non-developer related skills to be successful.

I don't know how comment response notifications work on HackerNews but... I just responded to the thread above. Let me know your thoughts.
The hard part in my eyes is the marketing/advertising. Getting a landing page built, on-boarding customers (every customer wanted custom development to fit their business), getting well written app store listings written, getting support + documentation written for the customer. Videos, images, graphics, blog articles. We'd be up against startups who get $15m+ in funding and have a 7 year head start.

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.

If the two of you manage to pull this off, please update us. I would love to see a story of people meeting in the HN comments and go off and build something. I'm sure it has happened on here, but I never hear about it!
Let's connect. Could you shoot me an email real quick? j.horne2796 AT gmail. :)
(comment deleted)
you are not alone. i got layed off from project that i have worked for 2years from scratch. it's quite successful now. i learned my lesson now.
I guess when I was 12 and had a Commodore 64 in my bedroom. I stayed up late and got up early to learn basic, put sprites on the screen, debug and otherwise get caught up in whatever I wanted to create that day.

I’d like to say thank you to my father for buying it and keeping the chocolate milk and powdered doughnuts flowing.

Oh man, this brings up so many good memories :)
For me too. Having that Commodore set me up for my future.
I currently work for a company that is focused in increasing online privacy. Everything I write now supports this effort. I've never felt better about a job.

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.

It really depends on what you mean by important? Some of my most important code saves a company millions of dollars a year... It's not at all important to me, but it does it's job and it is important to someone.

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.

You might want to redefine "freedom" for yourself. I personally struggle with this too, but I find it useful to remember; I can still go down the street, buy something to eat, then go to town and see all that's around.
> I can still go down the street, buy something to eat, then go to town and see all that's around.

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).

(comment deleted)
I agree an animal in a zoo can do all those things, but an animal in the wild (usually a good example of being free) can do them, too, and to a much greater degree. I do not quite understand how the comparison works better for a caged animal as opposed to a free one. Draw a big enough fence, and everyone's always been in a cage?

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?

Not off the mark at all, at least as far as I see it. I'm probably more free than a person 500 years ago could ever imagine... I'm also more caged than they could know too.

Times change, as do perspectives. Sorry I can't be more helpful.

true freedom is terrifying, we like to bind ourselves to things, be it our relationships, hobbies or goals.
Why is selling investment advise better then gearing your own investments?
It's hard to understand why if you're able to consistently do 100% yoy you'd even bother or waste any time selling investments products.
Well, this is important to me, but it isn't exactly a scientific breakthrough or as worthwhile as what others might say, but several years ago at the utility I'm currently working for, we have this stupid method of adding users to a HMI...by manually typing in their user ID, their name and some default password into the user credential file onto the HMI (this is also a crappy HMI software, so the text document isn't even hashed) and then emailing said password to the users.

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.

Probably this UI: https://www.facebook.com/live/create

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.

That seems like a very impactful project. Hundreds of thousands of people (millions?) have used Live videos on FB. Not many engineers can say they've made an impact like that. Congrats!
For me, it's been codes that have been for internal use. One ran a room full of production machines. Another has been in use for a decade, and is the main utility for manufacturing a complex apparatus that requires a lot of adjustment and testing steps.

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.

It's not really coding, but I helped with troubleshooting and analysis when Obamacare first rolled out.

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%.

Oh wow. I remember that. Cool to hear of your involvement.
wrote an entire CRM platform for a niche which is still my business today. revenue is at ~200,000 $ per month, profit margin is >60%.

Tech stack: MySQL, Java EE, JQuery, Bootstrap and the like. No big frameworks. All hosted on Google Cloud.

Stories like this are incredible. If you ever want to go into detail with this story in an article or something, I'd love to read it.
Thank you, I don't enjoy writing anything else than code or short texts/comments though.
I probably couldn't afford to pay you to change your mind but I could volunteer some time on a project or something in exchange for you answering a few questions that I could turn into an article about your success, perhaps? Win win?
Thank you for your offer. No offense, but that would be of no use for me. I learned that external outsourcing of development tasks is not effective at all if you want to focus on delivering quality that customers really love.

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.

(comment deleted)
I'd also be very curious to know more about this.
(comment deleted)
I did the same for an area related to mental health. Generates about $5k a month, so nowhere near your level, but it pays for the kids to go to one of the best school in the Santa Clara Valley. So for me, it’s the most important code I have ever written. Second most important is code that does some video and audio stuff that runs on about a literal billion devices.
The most important code I ever wrote was probably the control system for a submersible robot we developed in grad school. It was important not so much from a money standpoint, but because a whole group of graduate students got their Masters' and Doctoral degrees using it, it was sort of my bequest to humanity. And boy was it a hack...

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.

Improvise. Adapt. Overcome.

Thanks for sharing that nugget!

I'm an IT/SysAdmin type guy so I don't really code beyond web stuff at a hobbyist level, though I did do CompSci at uni way back when. However when I followed my partner overseas for a few years, the only job I had while away was working in a computational research group at a university.

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.

In 1987 I wrote about 150 lines of 68000 assembler that applied a low-pass filter to every sound heard by the towed-array sonar system on the Los Angeles class fast-attack submarines. I was an intern (co-op) and nobody even looked at my code. But it fixed the problem that had been plaguing the ANN-BQQ-5D system, preventing it from going into trials and 'management' just shipped it once the tests started passing.

Compared to other things (including some of the ID3 tag processing code that's still in Windows today, and OLEView) this seems pretty important.

For what it's worth to you, I still remember the first time I watched Windows detect that a folder was full of MP3s and enumerate artist/album data alongside the other typical file attributes, and feeling that it showed a big step in its development. It felt like something close to magic for Explorer to be able to do that.
A ringbox mailbox multi-threaded implementation.

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.

Machine vision applications to inspect inkjet printheads during manufacturing. You've probably used a cartridge my apps inspected.
Nothing.
Same. I don't think anything I've written is really important in the grand scheme of things. Important enough that someone will pay me to do it, yes. But not important, really.
My most 'important' thing was probably a novelty passcode for phones. The important part was the timing of getting it done, as I was low on funds and this allowed me to continue on the path I was onto (still to this day) instead of 'retreating' back home.
(comment deleted)
The most important code I ever wrote was as a phd student. No one uses that code, but they use the concepts behind it every single day.

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.

AUFS or something?
UnionFS came out of the my advisor's first phd students new lab (stoneybrook). Aufs itself was inspired by that. My inspiration came from saying we should combine this semantic with linux package management semantics (as can be seen clearly from the papers where I give a summary of it).

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.

> The Q was how does one manage large numbers of heterogeneous 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

I wouldn't take credit for James E. Casey's work.
(comment deleted)
Adventures in Game Development is the perfect example of the risks of giving assholes your money for crowdfunded projects.

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).

The first Flash game that I released [1].

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

Like others, it depends upon what you mean by important.

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.

I’d have to say the headless server infra/features for Windows server 2003. The previous dev quit saying it was impossible, but as a new engineer I didn’t know any better.
I wrote a data collection and messaging framework for devices with a few MBs of memory, that had to stay powered-on and connected to a TCP socket server for about a year before they were going to be accessible again for maintenance etc. A bug in the code that could require a reset of the device could cost the company a big client. I couldn't find any ready-made solution that would satisfy all of the requirements. So I wrote, tested, documented and deployed it in a month almost single handedly. Two and a half years later, that code is still serving them.
The most important code I “wrote” was merged with code from my wife and produced a tiny human executable.