Programming Leftovers
-
Rust allows redeclaring local variables to great benefit
A lot of programming languages allow variable shadowing in new scopes. Early on, you learn that it can cause errors and can be confusing, but is situationally appropriate sometimes.
Something that's less commonly allowed is redeclaring variables to shadow them locally. And when it is allowed, it's often considered bad practice and confusing.
-
Programming on Unix and automatic memory management
This isn't just an aspect of general Unix development after all sorts of people got their hands on it (and created things like Perl). In Bell Labs Research Unix and then Plan 9, I think pretty much every new language (or language) created for and on Unix was one with automatic memory management. One exception is Plan 9's Alef, but no less a person than Rob Pike has said that one reason for Alef's failure was its lack of automatic memory management.
-
Rails quick tips #7: Project-specific .irbrc
In a previous installment of this series, I wrote about adding a project-specific .pryrc to Ruby/Rails projects. However, over the past couple of years, IRB gained some nice features and I don’t use Pry much anymore because it’s one less dependency I need to worry about. That doesn’t mean I want to give up on per-project configuration files though, which turned out to be slightly more complicated with IRB.
-
Autocorrecting my Git Commands
I spend most of my day at the command line and, although I took a couple of years of typing classes in high school, typos are constantly tripping me up.
With a lot of my time on the command line being spent using git, I like to take advantage of git’s ability to fix typos automatically. In my dot files I run this command as part of my git configuration: [...]
-
[Old] Measuring the Impact of False Sharing
In this article, I would like to find out the concrete performance penalty of false sharing for my data structure. I'll be measuring the effects on both ARM (Apple Silicon) and x86 (Intel/AMD) processors.
-
The 27 Best IDEs and Code Editors for Linux
C is an excellent, powerful, and general-purpose programming language that offers modern and generic programming features for developing large-scale applications ranging from video games, search engines, and other computer software to operating systems.
C language is usually considered the base for many other programming languages (C++, JavaScript, Java, PHP, Perl, Python, and more) due to its easy and efficient language design which includes a relatively small set of features that can be used to develop more complex systems and applications.
-
C vs. Go: Comparing programming languages
Go is a modern programming language that derives much of its history from the C programming language. As such, Go is likely to feel familiar to anyone who writes programs in C. Go makes it easy to write new programs while feeling familiar to C programmers but avoiding many of the common pitfalls of the C programming language.
This article compares a simple C and Go program that adds the numbers from one to ten. Because this program uses only small values, the numbers won't grow to be too big, so they only use plain integer variables. Loops like this are very common in programming, so this simple program makes it easy to compare C and Go.
-
Retry your Python code until it fails
Sometimes, a function is called with bad inputs or in a bad program state, so it fails. In languages like Python, this usually results in an exception.
But sometimes exceptions are caused by different issues or are transitory. Imagine code that must keep working in the face of caching data being cleaned up. In theory, the code and the cleaner could carefully agree on the clean-up methodology to prevent the code from trying to access a non-existing file or directory. Unfortunately, that approach is complicated and error-prone. However, most of these problems are transitory, as the cleaner will eventually create the correct structures.
Even more frequently, the uncertain nature of network programming means that some functions that abstract a network call fail because packets were lost or corrupted.
A common solution is to retry the failing code. This practice allows skipping past transitional problems while still (eventually) failing if the issue persists. Python has several libraries to make retrying easier. This is a common "finger exercise."
-
Learn Tcl/Tk and Wish with this simple game
Explore the basic language constructs of Tcl/Tk, which include user input, output, variables, conditional evaluation, simple functions, and basic event driven programming.
My path to writing this article started with a desire to make advanced use of Expect which is based on Tcl. Those efforts resulted in these two articles: Learn Tcl by writing a simple game and Learn Expect by writing a simple game.
I do a bit of Ansible automation and, over time have collected a number of local scripts. Some of them I use often enough that it becomes annoying to go through the cycle of:
I use macOS on a daily basis. What I really wanted was a menu item or an icon to bring up a simple UI to accept parameters and run the thing I wanted to do, like in KDE on Linux.
-
CREATE commands in PostgreSQL releases
Here is a fun little view on the progress of PostgreSQL. Consider the number of “CREATE SOMETHING” commands each release contains. As more features are added over time, more such CREATE commands are added.
-
Ten Years of Penguicon Pop Tarts
At the closing ceremony, the con chair asked the GoHs there was anything that went wrong. I said something along the lines of “you were magnificent. the only thing I could possibly say is that there was no toaster for the Pop Tarts.”