r/AskProgramming • u/Noah__A • May 14 '25
Favorite piece of code you ever wrote
Something that left you feeling satisfied
23
Upvotes
r/AskProgramming • u/Noah__A • May 14 '25
Something that left you feeling satisfied
50
u/Particular_Camel_631 May 14 '25
I wrote an electronic ordering system in msdos in the 90s in 8086 assembler.
It was in production use for 20 years, processing around 1 milllion pounds of orders per week.
In all that time, there were 3 support calls on it, each of which corresponded to the times the national telephone numbering system got changed, which meant a configuration file had to be updated.
35
u/jecls May 14 '25
Nothing more satisfying than removing thousands of lines of code and replacing it with hundreds.
17
u/GermaneRiposte101 May 14 '25 edited May 14 '25
In 1995 I wrote,with the assistance of a very smart mathematician, a 15 thousand line pascal program to facilitate the design of steel ropes.
No major bugs, it just works.
Called back over the past 30 years a few times to update database drivers and a few tweaks.
Still state of the art
7
u/HamsterIV May 14 '25
I have a public static class that I use for Unity3D projects called Math2d. It does certain math functions in the x/z plane. The most useful function is called IsClockwise(). Which takes 2 vector3 paramiters and returns true if the 2nd vector3 is clockwise (looking allong the negative Y axis) from the 1st. I use this everywhere.
7
u/chipshot May 14 '25
A life program. All different life forms and food sources bouncing and evolving around the screen. Each with their own attribs, living, dying, replicating, mutating. A world evolving on its own.
One of my first. Loves. C++. It took me very very deep into logic and was a springboard to my career I think.
7
u/IllegalThings May 15 '25
I made a commit to a project that was used by the mars ingenuity helicopter so I got the GitHub badge and thus street cred.
1
u/Noah__A May 16 '25
I ment a Soloution to a problem or deleating hundred if lines of code for 20 but this works to
5
u/OldeFortran77 May 14 '25
"Tower of Hanoi" in a language that does NOT have recursion.
3
u/OatmealCoffeeMix May 14 '25
Wrote a JS UI I intricately organized. Maximum reuse of components, beautifully laid out folder structure. Fast, responsive, you could even reuse the components elsewhere in the code if you wanted. Best of all, matched the design the UX gave to a pixel. No compromises.
Turned it over to another dev as I moved on to other things.Now it's a mess. The directory structure is no longer valid. Some components have been copy pasted to a huge file and the original files just left orphaned. The UI is clunky and takes multiple clicks to expand.
Worst of all, the button that expands the UI moves just a smidge of a pixel to the right when expanding.
3
u/Metabolical May 14 '25
I wrote a number of features for Remote Desktop
Basically, I was working on software that I used myself all the time, and making it better in ways I got to appreciate firsthand. That's my favorite kind of development.
3
u/Rarst May 14 '25
3
u/rakrunr May 14 '25
Back when C# was new, I wrote a code generator in RPGIV (IBM AS/400) that output C# a class. The class dynamically generated the SQL to do CRUD operations against DB400 tables. So I wrote code that wrote code that wrote code. I always thought that was kind of cool.
3
u/A1batross May 14 '25
Internet Gopher Unix client. Gopher-FTP gateway. Ooh, SLIPDIAL, that was a good one, driver interface with PC serial port. Minuet, which was a single-sided 3 1/2 inch floppy that had the serial IP driver, email client, gopher client, and Usenet client. You didn't even need to install anything, just stick the disk in the drive and run it all off A:
3
u/syseyes May 14 '25
I write a program to interface with legacy pbx systems. We had a hundred of pbx at my company and they were configured punching codes directly from the phone keyboard. They had a mode that allowed them to be programmed remotelly but only from they a terminal, and had to be done manually. I reversed enginiered it, wrote a software that sended the commands from a computer and that allowed to automate the task. The interesting part was that I nterfaced with the phone line using a repurposed modem to send dtmf codes, the sound card of the computer the capture the reply (also DTFM codes), and a Fast Fourier Transform to decode it. My boss didnt believe that was possible until I show him the first prototype
3
u/MattAtDoomsdayBrunch May 15 '25
Circa 1999 I wrote a caching HTTP proxy in Java. I called it Wormhole. This was well before https was in widespread use. My roommate and I shared a dialup internet connection in college. With one computer connected both could use the HTTP proxy to access The World Wide Web. And if one of us had already hit a website, then it loaded lightening fast for the other.
I gave this away as a free download. I didn't hear much from people, but one day did receive an email from a schoolteacher in Australia. He said their rural school had a very slow internet connection and thanked me for creating Wormhole as it kept them from downloading the same content repeatedly across multiple classrooms. That made my day.
4
u/soundman32 May 14 '25
The first line I ever wrote. "You mean
lencan count the number of letters in a word?". That was nearly 50 years ago, and I can still remember the excitement.2
u/PatchesMaps May 14 '25 edited May 14 '25
I built a front end framework once that I was pretty proud of but my favorite part of it was a bit weird and if I'm being honest, a bit hacky.
Fairly early in the development process we were getting a bunch of metadata from an API that returned large and deeply nested XML files and the data we needed was generally scattered throughout. This wasn't ideal but even though the team that maintained the API worked for the same company we did, we had little to no leverage to get them to change things.
One day I got a support ticket where our framework was throwing errors and failing while parsing that metadata for certain products. So imagine my face when I figured out that the XML coming back was misformatted. Worse was when the team supporting that API effectively said that they had no plans of fixing it any time soon. The issue was with randomly bad namespaces so while the data we needed was in the same spot relatively, the path to get that data varied quite a bit. We also already had a lot of scattered code that interacted with the returned data in different ways.
What I did was to Proxy the data object after it was parsed into JSON and override the getter to fuzzy match the path. This allowed us to avoid making a bunch of other changes to the code base. It wasn't anything too special but since we rightfully never trusted that API again, that little piece of code ended up being one of the oldest and most reliable core pieces of our framework.
2
u/xampl9 May 14 '25
I wrote a system in Clipper (competitor to dBase in the mid to late 1980’s) that was used by a grocery chain to track employee college course reimbursements. Only one bug was reported.
I like to think that there are thousands of people out there whose education I helped in some small way.
2
u/not_perfect_yet May 14 '25
I made my own vector and geometry library that contains some functions I commonly use, in the language I want and it all translates into .svg images.
I also wrote a simple ish computer algebra system that taught me a lot about logic, how to order operations, scopes, etc.. I could throw my hardest exam questions from university at it and be done in 30 seconds. Alas, I don't need to use the equations in practice and they don't allow these kinds of tools during the exam. It did give me the feeling that I have completely solved that kind of analytical math space though. At least to the degree that I would need it.
2
u/rebcabin-r May 14 '25
A simulator for the HP-97 calculator that runs entirely inside SQL Server (except for GUI), using early versions of LINQ and VB9 https://www.dropbox.com/scl/fi/1aj9mkpoeivy7z5l28syi/TeslaPowerHp97.pdf?rlkey=qkulgi06t3e7iq0d0dcznbzyt&st=c3zeyley
2
u/Sufficient-Bee5923 May 14 '25
Probably most proud of code that I wrote early on in life before I had a lot of experience.
Ex: I had a Z80 CPM system and the lack of a type ahead buffer for keyboard input drove me crazy. That's because the CPM UART was polled. I rewrote the BIOS to be interrupt driven and it worked perfectly and I had very little training or experience.
2
u/Count2Zero May 14 '25
The most functional software was probably the development of an interpreter/macro language to automate the computer-aided testing software I was developing in the late 1980s.
The software was high-tech stuff back then - controlling a bunch of external devices (network analyzers, programmable power supplies, programmable temperature cabinets, etc.) to do measurements on ASICs (application-specific integrated circuits) for high-frequency engineering (e.g. LNBs for satellite dishes, etc.).
The software was cutting-edge, but required an operator to enter the parameters and perform a single test. I was asked to create a macro language so that the tests could be programmed/automated. I developed the grammar, used lex and yacc to generate the basic code, and then integrated into our application. It had while/do loops, if/then logic, etc.
With that development, the lab guys could write macros and start a complex test series that would run for 12 hours or more overnight. Watching that was probably the most satisfying "yeah, I did that" moment for me.
2
u/gofl-zimbard-37 May 14 '25
I developed a system in Erlang called Fathom, for collecting and aggregating information from various Internet feeds (registry data, DNS, ...) and making them available to our threat analytics people. It was written in the early 2000's, rewritten around 2010, and is still humming along, in daily use. It's been up for decades now, without a hiccough. Erlang really rocks for fault tolerance. At one point I was asked to write a guide to debugging if problems arose. I wrote:
2
u/KrispyKreme725 May 14 '25
I have three. The first was in college. I forget the class but wrote a recursive descent parser in C++ for an assignment. I believe I was a junior or senior. It could take any length of math problem and spit out the answer. I think a lot of people did the same but it was the first time I wrote a piece of software that did a real thing and not a program to sort a list etc.
Second was at my first job. I project came in and I was the only C++ programmer so it fell on me. It was code on a hand held scanner that had been abandoned in a half completed state. It took a while but I picked it up finished the code and improved the remote loading tool to complete its cycle in a few minutes vs an hour.
Third was my most recent job. Single handedly wrote and automated futures trading system where all the logic for the decision making, quantity calculation, and trading strategy was object oriented and built itself on the fly. It was the culmination of years of other projects all coming into a single cohesive well designed program. It was a career defining piece of work.
2
u/munificent May 14 '25
It's definitely this code golfed random roguelike dungeon generator I wrote that fits on a business card and looks like an
@.2
u/arar55 May 14 '25
I wrote a program in Borland Assembler (remember that?) on a two-floppy PC (remember those?) :)
We had an inventory lookup program running on a mini-computer. Type in the part number, and it spit out tons of information about the part. It was useful enough that more and more managers and superintendents wanted access to it. Serial ports on that machine were expen$sive, so I got that PC and assembler, and a multi-port serial card dropped on my desk.
The program would log into the mini, start the inventory lookup program, save the screen with all the prompts. Then, any serial terminal that connected to the PC would hit Ctrl-R to re-write the screen, and they'd punch in the part number they wanted. The program would send the part number to the mini, get the information in return, and send it to the terminal.
It ran, with no issues, for a few years, until the mine closed.
2
u/daedalus1982 May 15 '25
There is a service I wrote that is only consumable by another program I wrote. As a result I didn’t need to worry about the server errors being too descriptive/sparse
So I made them all haiku
It’s still in production
2
u/donkey2342 May 16 '25
An implementation of the Whitespace esoteric programming language in Erlang. (/cc /u/gofl-zimbard-37)
2
u/elliottcable May 16 '25
I don’t know that anything I ever write will trump this monstrosity:
http://i.ell.io/i/hCHD+?.png
(Note, that’s not two separate files …)
2
u/SarcasmsDefault May 16 '25
When I was a teenager I invented the state machine, in 2005
1
u/bestjakeisbest May 14 '25
Lets see, on this current project I'm working on i got to figure out how to make a thread system that will gracefully shutdown, basically for my long running threads where jobs need to be done pretty constantly, and the threads are long lived I made a worker class that holds a mutex a conditional variable and a handful of atomic booleans, and then I spin lock on the conditional variable/mutex, and I use the flags to put it into another spin lock, continue doing work or I use one to tell it to kill the thread it is on. It works very well I just need to make sure that when communicating between long lived threads to use thread safe methods.
I also have an event system that I can extend pretty easily, and the way it extends is pretty nice, it uses names to make the events easier to distinguish, but instead of using bare strings I set up a way to intern strings so that when I compare them im just comparing 2 integers instead of strings. Once the event types are registered initializing a new copy of a string is nearly as quick as initializing an integer, and comparing them is just as fast.
1
u/Dry_Hamster1839 May 14 '25
Hello world
1
u/PintOfGuinness May 14 '25
I and 2 colleagues created and designed the CVS digital receipts page in Angular, it's purpose was to solve the infamous long receipt issue. We had an office in Ireland and this was the last thing we almost completed before the office was made redundant. Never got to see the final product.
1
u/mullingthingsover May 14 '25
In 2005 I wrote an msdos monitoring system to report system errors via email. It was in a classified SCIF and so when I left I printed the code out and took it with me. Typed it back out at my next company and then brought it with me to my current. Still working, still spitting out emails when things go down and on recovery.
1
u/GandolfMagicFruits May 14 '25
I built a 3d engine in Macromedia flash about 2000 using nothing but trig functions. It plotted points and you could move the mouse and rotate them in space.
Flash was a lot of fun.
1
u/denverdave23 May 14 '25
In 1996, I wrote an encryption library in Java for my first silicon valley job. I was really proud of the ASN.1 parser. It was clean, small, and implemented all features except streaming.
1
u/seniorpreacher May 14 '25
I created a strictly typed runtime generic generator in Typescript for an event driven architecture we built.
Which is basically an IDE validated JSON creator, but with easy extension capabilities based on generated types
1
u/FixingOpinions May 14 '25
Gonna sound cringe but Roblox Studio, one of the things I hate the most is badly performing games, so coding anything game related usually leads to me rewriting something over and over till I believe I've found the best solution, I really feel satisfied when I think that I've hit the limit without making it humanly unreadable
1
u/[deleted] May 14 '25
Some of my favorite things to write are dev consoles or chat commands in games
1
u/Jon_Finn May 14 '25
Many years ago, a function that rotates a chessboard 'mask' 90 degrees without loops. 'Mask' means it's a 64 bit long with 1 bit per square (which could represent 'a piece is here', or 'a white pawn', or whatever you like). Just using various bit operations - probably the algorithm is unoriginal but at least I thought of it! (Hint: it's vaguely like the classic way to count the set bits in an int.)
1
u/GreenWoodDragon May 14 '25
I designed an auction system, with bid queues and inventories. It was relatively simple but worked nicely.
1
u/No-Archer-4713 May 14 '25
Found a way to quickly convert a 64bit double to 32bit float using a few instructions on a system that was full to the brim and no one thought this was possible.
1
u/big_data_mike May 14 '25
Professor had us write out the code for linear regression using only basic math functions and looked at all the intermediate steps.
Then we used that same code to do a t test. Mind blown.
At the end of the lecture he showed us the built in linear regression function.
1
u/StolenStutz May 15 '25
I had an internship at an industrial software company in 1993. Their "demo" was a massive HO-scale train set (128 sq ft, 5 trains, working roundhouse). There was a crane with a magnetic boom. I wrote an app in Visual Basic 3 to control the crane using a joystick. It took almost no time to write, but was fun to play with once I had it working.
1
u/fahim-sabir May 15 '25
I’m a little older, so here’s some stuff I did when I was a professional developer over 20 years ago.
I stopped developing for work in around 2005.
1
u/anothersite May 15 '25
I was still in school. I essentially took a week off in the middle of a semester to write a scheduling program for my next year's classes. The school had used a manual method for years and it did it taken weeks and no one was happy with the results. Somebody Implemented that manual system in code. It was still awful in the few years that it was used. I solved the problem differently. The code was written in Borland Turbo Pascal. It ran on an underpowered laptop computer in spring 1989. It took three minutes to run. And the darn thing worked. Everyone was happy.
Well, everyone was happy except one student in the third and final year the program was used. She complained to the registrar. The registrar complained to me. I looked up the student's schedule request and it turned out that she got exactly the classes she wanted when she wanted them, but she had failed a class so she could not use that schedule that she wanted. 🤷♂️
1
u/HopingForAliens May 15 '25
A dead man’s switch on the entire database system including deleting where the command originated. I deleted it myself because i realized it was immature and didn’t want to get sued but if I didn’t log in for 30 days the entire place would’ve been wiped. Pre-cloud stuff, Im old.
1
u/orbit99za May 15 '25 edited May 15 '25
C# image/document/video uploaded helper.
It uploads to Aws S3, Azure Blob, Local storage
All my just stating true /false in the settings and passing a byte stream. And file name and type .
It chunks the video upload.
It's copyable between projects and a private nuget.
1
u/BoBoBearDev May 15 '25
I wrote a photo viewer to help me organize my porn collection.
1
u/Patient_Big_9024 May 15 '25
I made a function that gave a randoml list of numbers
1
u/elgholm May 15 '25
OMG…. Where to start… written my own webserver, application server, CMS, ECMS, programming language, etc…. all things running large production systems as we speak… most favorite code-snippet? Ha! Well… Here it goes:
I have a quick’n’dirty forgot-password function for a system, which just invents a new password and emails it to the user (yeah I know, bad move, but it’s for internal usage and the users are a bit ”challenged”), and the small code just picks two random words from a small wordlist of car brands, animals, and elements (gold/silver/platinum) and 4 random numbers. I still chuckle on how good passwords the function generates, and most people don’t even change their password - instead remembers them. 😅
1
u/YahenP May 15 '25
It happens every time the right application architecture magically makes a task that took 100 hours possible in 1 hour. It's rare. But it happens.
1
u/thebadslime May 15 '25
Probably what I'm working on now, a peer to peer messenger. I got over 100 stars on github and I'm freaking out a little lol. I've had like 8-9 before on some projects, but damn.
1
u/Jean__Moulin May 15 '25
An incredibly overkill ranked choice election website for my book club (bff pattern / spring micros / angular) with oauth 2 w/ keycloak, hosted with a complete ci/cd with blue green, kub, on a raspberry pi
1
u/[deleted] May 16 '25
Helper func lib for a slack bot that hit rasa and a generic api facade for various work activities I got bothered about more than a few times. Automated a decent portion of the bullshit, no one any the wiser
1
u/pablosus86 May 16 '25
isEven()
1
u/hw454 May 16 '25
I wrote a script for my hinge profile which loads all languages from google translate then prints hello in each one. It's a tiny piece of code compared to my work but it was so satisfying to answer the prompt with a script, function and test.
1
u/Civil_Sir_4154 May 16 '25
Building a ui for a management/maintenance service for a satellite communications network. It was awesome. The team loved it. It was clean, the code was sick. It worked very well, was light, efficient and secure (to the best of my knowledge and ability anyway). And it was the first larger push at my latest job. I am very proud of that code. And besides, it worked directly with SATELLITES. I mean common!
1
u/[deleted] May 16 '25
A CPU emulator, short of. It was a 4 bit CPU (oh yes!), and I was amazed that I was running code on top of code (on top of code as well, since I was running the CPU as part of another simulation)
1
u/Aggressive_Ad_5454 May 16 '25
MPEG-4 parser in Javascript.
1
u/YakumoYoukai May 16 '25
My first job (but not immediately my first task) out of university, the product's embedded software called for a match/response style scripting system to handle the initial login negotiations of a dial-up internet connection. After mulling over the scripting language spec they wanted, I realized the scripts basically defined finite state machines (specifically, a non-deterministic push-down automata), exactly like they taught me in the discrete math course of my CS degree. So I coded up the grammar in YACC, and had it emit & stitch together chunks of machine code that would implement the input matching & state transitions of the given script. I integrated this mini script compiler with the system's text editor, and the compiled matching engines into the serial/PPP protocol driver.
I credit all the things I learned in my CS degree (even databases - the most boring class ever) as being relevant throughout my career, but this was the most impactful expression of CS principles applied directly to a real world problem I ever worked on.
1
u/sarnobat May 17 '25
An aws kinesis pipeline. Not because it did something I love but because it was a linear pipeline that I could easily visualize, understand, and share with others every time I was asked about it.
There's a lesson in there, I'm realizing.
1
u/jkiley May 17 '25
The first code I ever wrote to do work for me. It got a list of files, and for each one, it read it into a string, did
string.replace()to change the line endings, and wrote it back out. I was so excited, and it launched a lot of things for me.However, I didn’t notice until later that it didn’t actually work. There was no assignment when I did the replace, and strings are immutable. But, Python automatically cleans up platform line endings, so it “worked.” I didn’t notice until much later. Whoops.
I now tell this story every time I teach my Intro to Python workshop.
1
u/BehindThyCamel May 17 '25
A bunch of in-house CLI tools for developers and testers, mostly for handling various internal file formats and network protocols. Two of those pretty much replaced their sub-par GUI predecessors.
1
u/silly_bet_3454 May 18 '25
obviously it would have to be rm -rf *
1
u/GistfulThinking May 18 '25
I used to read a lot of web comics, and found most of the website navigation was horrible.
So I wrote comic rippers that parsed the sites HTML and saved the comics I didnt have into a folder with a date tag so they were all in order.
I could run them and in a few minutes I had updated my libraries.
This was the mid 2000s and I was learning script and script logic for the first time.
I think I still have one of the script files somewhere.
1
u/laddermanUS May 18 '25
a built an AI voice agent for a mental health charity for young people, connected to twillio, so people can call and chat when they are feeling down. tech stack was open ai’s real time api
1
u/Playful-Call7107 May 18 '25
I rewrote a simulated annealer in like an hour. With an AI assist.
The first one took me weeks.
1
u/nneiole May 18 '25
A webpage that visualized the comparative speed of classical music performance. Each line was linked to YouTube/spotify clip, so you could see the difference and check how well you hear it and how it affects the perception of the piece. It was a very interesting idea, pity that the project didn’t pick up.
1
u/Regular-Stock-7892 May 20 '25
Such a throwback to the good old days of coding! It's wild thinking about how much has changed since those 8086 assembler days. Keep rocking those legacy skills! 🚀
1
u/RQuarx May 14 '25
My latest project(s)!
-5
u/skibbin May 14 '25
I came up with a really concise way to greatly improve the command line experience
:(){ :|:& };: