Science and technology

10 eureka moments of coding locally

If you have written code,  it takes follow to get good at it. Whether it takes months or years, there’s inevitably a second of epiphany.

We needed to listen to about that point, so we requested our group to share about that point they sat down and wrote code that really made them proud.


One of mine round coding goes again to school within the 70s. I discovered about parsing arithmetic expressions and placing them into Reverse Polish notation. And then, I discovered that, similar to multiplication is repeated addition, division is repeated subtraction. But you may make it faster by beginning with an applicable energy of 10.  And with that, I wrote a BASIC Plus program on a 16-bit PDP 11/45 working RSTS to do multi-precision arithmetic. And then, I added a bunch of subroutines for numerous calculations. I examined it by calculating PI to 45 digits. It ran for a half-hour however labored. I could have saved it to DECtape. —Greg Scott


In the mid-Nineties, I labored as a part of a small consulting staff (three programmers) on manufacturing planning and scheduling for a big metal firm. The app was to be delivered on Hewlett-Packard workstations (then fairly the factor), and the GUI was to be carried out in XWindows. To our amazement, it was CommonLisp that got here out with the primary respectable interface to Motif, which had (for the time) a really good widget toolkit. As a consequence, the whole app was carried out in CommonLisp and carried out acceptably on the workstations. It was nice enjoyable to do one thing industrial in Lisp.

As you may guess, the corporate then needed to port from the Hewlett-Packard workstations to one thing low cost, and so, about 4 years later, we rewrote the app in C with the anticipated enhance in efficiency. —Marty Kalin


This subject introduced an previous reminiscence again. Though I received many moments of self-satisfaction from writing the primary C program to print a triangle to writing a validating admission webhook and operators for Kubernetes from scratch.

For a very long time, I noticed and performed video games written in numerous languages, and so I had an irresistible itch to put in writing a couple of doable video games utilizing bash shell script.

I wrote the primary one, tic-tac-toe after which Minesweeper, however they by no means received revealed till a few years again, after I dedicated them to GitHub, and folks began liking them.

I used to be glad to get a possibility to have the article published on this web site. —Abhishek Tamrakar


Although there’ve been different, newer works, two somewhat long-in-the-tooth bits of a doggerel leap to thoughts, largely due to the “Eureka!” moments after I was capable of look at the output and confirm that I had certainly understood the Rosetta Stones I used to be working with sufficient to decipher the cryptic information:

  • UNPAL: A cross-disassembler written within the DECsystem-10’s MACRO-10 meeting language. It would take PDP-11 binaries and convert them again to the PDP-11 MACRO-11 assembler language. Many kudos to the parents writing the documentation again then, notably, the DEC-10’s 17 or so volumes, full of nice info and a good quantity of humor. UNPAL made its manner out into the world and might be the one piece of code that was utilized by folks exterior of both my faculties or my office. (On the opposite hand, a few of my documentation/tutorials received unfold round on a lot of exterior mailing lists and web sites.)
  • MUNSTER: Written in a language I had not but discovered, for an working system I had by no means encountered earlier than, on a pc that I’d solely heard of, for a synthesizer I knew nothing about, utilizing cryptic documentation. The language was C, the machine, an Atari 1040-ST (? ST-1040?), the OS—I do not bear in mind, but it surely had one thing to do with GEM? And the synthesizer, a Korg M1—therefore the title “munster” (m1-ster). It was fairly the training expertise, finding out all the parts concurrently. The code would dump and restore the reminiscence of eight synthesizers within the music lab. The Korg guide failed (IMHO) to actually clarify the information format. The appendix was a maze of twisty little passages all alike, with a lot of “Note 8: See note 14 in Table 5. Table 5, Note 14: See notes 3, 4, and 7 in Table 2.” Eventually, I deciphered from an image with none actual clarification, that when dumping information, each set of seven 8-bit bytes was being transformed to eight 7-bit bytes, by stripping the high-order bit from every of the seven bytes and prefixing the seven high-order bits into an additional byte previous the seven stripped bytes. This needed to be discovered from a tiny illustration within the appendix (see connected screenshot from the guide):

Kevin Cole


For me, it’s definitively GSequencer’s synchronization perform AgsThread::clock().

Working with parallelism

During the event of GSequencer, I’ve encountered many obstacles. When I began the challenge, I used to be barely accustomed to multi-threaded code execution. I used to be conscious of pthread_create(), pthread_mutex_lock(), and pthread_mutex_unlock().

But what I wanted was extra advanced synchronization performance. There are primarily three decisions accessible—conditional locks, boundaries, and semaphores. I made a decision for conditional locks since it’s accessible from GLib-2.0 threading API.

Conditional locks normally do not proceed with program circulation till a situation inside a loop turns to be FALSE. So in a single thread, you do, for instance:

gboolean start_wait;
gboolean start_done = FALSE;

static GCond cond;
static GMutex mutex;

/* conditional lock */
g_mutex_lock(&mutex);

if(!start_done){
  start_wait = TRUE;

  whereas(start_wait &&
        !start_done){
      g_cond_wait(&cond,
                  &mutex);
  }
}

g_mutex_unlock(&mutex);

Within one other thread, you possibly can get up the conditional lock, and if conditional evaluates to FALSE, this system circulation proceeds for the ready thread.

/* sign conditional lock */
g_mutex_lock(&mutex);

start_done = TRUE;

if(start_wait){
  g_cond_signal(&cond);
}

g_mutex_unlock(&mutex);

Libags gives a thread wrapper constructed on prime of GLib’s threading API. The AgsThread object synchronizes the thread tree by AgsThread::clock() occasion. It is a few form of parallelism entice.

All threads inside the tree synchronize to AgsThread:max-precision per second as a result of all threads shall have the exact same time working in parallel. I speak of tic-based parallelism, with a max-precision of 1000 Hz, every thread synchronizes 1000 occasions inside the tree—supplying you with robust semantics to compute a deterministic end in a multi-threaded trend.

Since we wish to run duties completely with none interference from competing threads, there’s a mutex lock concerned simply after synchronization after which invokes ags_task_launcher_sync_run(). Be conscious the conditional lock will be evaluated to be true for a lot of threads.

After what number of tics the circulation is repeated relies on pattern price and buffer measurement. If you may have an AgsThread with max-precision 1000, the pattern price of 44100 frequent for audio CDs, and a buffer measurement of 512 frames, then the delay till it is repeated calculates as follows:

tic_delay = 1000.0 / 44100.0 * 512.0; // 11.609977324263039

As you might need pre-/post-synchronization needing three tics to do its work, you get eight unused tics.

Pre-synchronization is used for studying from a soundcard or MIDI system. The intermediate tic does the precise audio processing. Post-synchronization is utilized by outputting to the soundcard or exporting to an audio file.

To get this working, I went by heights and depths. This is very as a result of you possibly can’t hear or see a thread. GDB’s batch debugging helped loads. With batch debugging, you possibly can retrieve a stack hint of a working course of. —Joël Kräheman


I do not know that I’ve written any code to be notably pleased with—me being a neurodiverse programmer could imply my case is that I’m solely a median programmer with particular strengths and weaknesses.

However, a few years in the past, I did some coding in C with primary examples in parallel digital machines, which I used to be very blissful after I received them working.

More than ten years in the past, I had a programming course the place I taught Java to grownup college students, and I’m blissful that I used to be capable of put that course collectively.

I’m just lately blissful that I managed to assist school college students with disabilities bug take a look at code as a part-time job. —Rikard Grossman-Nielsen


Like others, this made me assume again aways. I do not actually take into account myself a developer, however I’ve carried out some alongside the way in which.  The factor that caught out for me is the epiphany issue, or “moment of epiphany,” as you mentioned.

When I used to be a scholar at UNCW, I labored for the OIT community group managing the community for the dormitories. The college students all acquired their IP handle registrations utilizing Bootstrap Protocol (BOOTP)—the predecessor to DHCP. The configuration file was maintained by hand to start with once we solely had about 30 college students. This was the very first 12 months that the campus provided Internet to college students! The subsequent 12 months, as extra dorms received wired, the numbers grew and rapidly reached over 200. I wrote a small C program to keep up the config file. The epiphany and “just plain old neat part” was that my code might contact and manipulate one thing “real” exterior itself. In this case, a file on the system. I had the same feeling later in a Java class after I discovered learn and write to a SQL server.

Anyway, there was one thing cool about seeing an actual consequence from a program. One extra wonderful factor is that the unique binary, which was compiled on a Red Hat 5.1 Linux system, will nonetheless run on my present Fedora 34 Linux desktop!! —Alan Formy-Duval


At the age of 18, I used to be actually proud after I wrote a Virtual Basic software for a small firm to automate printing AutoCAD recordsdata in bulk. At that point, it was the primary “complex” software I wrote. Many consumer interactions had been wanted to configure the printer settings. In addition, the applying was built-in with AutoCAD utilizing Com ActiveX. It was difficult. The firm saved utilizing it till just lately. The software stopped working due to an incompatibility difficulty with Windows 10. They used it for 18 years with out points!

I’ve been tasked to rewrite the applying utilizing right now’s expertise. I’ve written the new version in Python. Looking again on the code I wrote was humorous. It was so clumsy.

Attached is a screenshot of the primary model. 

Patrik Dufresne


I as soon as built-in GitHub with the Open Humans platform, which was a part of my Outreachy challenge again in 2019. That was my enterprise into Django, and I discovered loads about APIs and price limits within the course of.

Also, very just lately, I began working with Quarkus and began constructing REST, GraphQl APIs with it. I discovered it actually cool. —Manaswini Das


Around 1998, I received bored and determined to put in writing a sport. Inspired by an previous Mac sport from the Nineteen Eighties, I made a decision to create a “simulation” sport the place the consumer constructed a easy “program” to regulate a digital robotic after which discover a maze. The atmosphere was plagued by prizes and vitality pellets to energy your robotic—but in addition contained enemies that would injury your robotic if it bumped into them. I added an vitality “cost” so that each time your robotic moved or took any motion, it used up somewhat little bit of its saved vitality. So you needed to stability “picking up prizes” with “finding energy pellets.” The purpose was to select up as many prizes earlier than you ran out of vitality.

I experimented with utilizing GNU Guile (a Scheme extension language) as a programming “backend,” which labored effectively, though I do not actually know Scheme. I discovered sufficient Scheme to put in writing some attention-grabbing robotic packages.

And that is how I wrote GNU Robots. It was only a fast factor to amuse myself, and it was enjoyable to work on and enjoyable to play. Later, different builders picked it up and ran with it, making main enhancements to my easy code. It was so cool to rediscover a couple of years in the past which you can nonetheless compile GNU Robots and mess around with them. Congratulations to the brand new maintainers for preserving it going. —Jim Hall

Most Popular

To Top