Essential Programming Insights: Lessons from 2022
Written on
Chapter 1: Diverse Paths in Programming
Programmers engage with a multitude of languages, environments, and tools. Some specialize in full-stack web development, leveraging modern frontend and backend technologies, while others focus on creating desktop applications, mobile apps, or independent services like daemons. The role of a programmer encompasses designing, developing, testing, and maintaining software. This profession is intricate; it often requires research, creative problem-solving, and the development of innovative solutions.
As programmers navigate their daily responsibilities or tinker with personal projects, they frequently encounter new challenges and discoveries. For instance, during my university studies, I stumbled upon GNU C compiler flags (e.g., gcc -S) that generate preprocessed, assembly, and object-code outputs.
In this article, I will share several programming lessons and insights I gained throughout 2022 while undertaking various tasks and personal projects.
Section 1.1: Mobile App Development with Go
You can indeed leverage Go for creating native mobile applications. Each mobile operating system provides developers with a software development kit (SDK) that allows them to access native operating-system-level APIs through libraries written in specific languages. For instance, Java or Kotlin can be utilized to interface with Android APIs via built-in packages.
The Go mobile project enables developers to embed the Go runtime as a platform-specific native library within mobile applications for both Android and iOS, allowing them to write application logic in Go. This approach facilitates sharing complex Go modules between web services and mobile applications. Check out this sample project that demonstrates running Go code within a Flutter native app using Go mobile.
The first video, "Don't learn to program in 2022," discusses common pitfalls for new programmers and emphasizes the importance of practical learning.
Section 1.2: Utilizing the $RANDOM Variable in Bash
Bash, a widely-used command language, is essential for terminal operations and scripting automation. It includes numerous built-in features that enhance productivity. One such feature is the $RANDOM variable, which generates random numbers.
For example, you can produce a random number within the range of 0 to 9 using the following command:
echo $(($RANDOM % 10))
Subsection 1.2.1: Git Notes for Enhanced Collaboration
When using Git, commit messages typically provide brief descriptions of code changes. However, if you need to attach additional information without cluttering the commit message, Git Notes is a useful feature. It allows you to associate a note with a specific commit using the git notes add command. This note can then be viewed with commands like git show or git log.
Section 1.4: Embracing DevOps Principles
DevOps is a philosophy that extends beyond system administration roles. It encourages software development teams to enhance productivity and product quality through automation. In 2022, I applied DevOps principles to nearly all the open-source projects I manage, as well as authored several Medium articles on the subject. Here’s one of the most popular pieces on employing DevOps concepts in open-source projects.
The second video, "How To Learn Programming for BEGINNERS! (2022/2023)," provides essential strategies for new programmers to navigate their learning journey effectively.
Section 1.5: Creating Universal macOS Binaries
In 2020, Apple transitioned to ARM architecture for their CPUs, replacing Intel x64 CPUs. They introduced the Rosetta 2 dynamic binary translator with the Big Sur operating system, allowing x64 binaries to run on ARM. For our open-source projects, we initially generated x64 binaries and relied on Rosetta for translation. However, we have since cross-compiled both x64 and ARM binaries to create universal macOS binaries.
Section 1.6: Command-Line Tools for GNOME Applications
Unix commands are well-known for enhancing programming efficiency. For those using GNU/Linux, commands like xdg-open assist in various automation tasks. I often use the GNOME screenshot tool for taking screenshots during technical writing. Recently, I discovered the command-line switches available for gnome-screenshot, which allow for programmatic screenshots via shell scripts. For instance, the following command captures a screenshot of the active window after a five-second delay:
gnome-screenshot -w -d 5
Section 1.7: Simplifying CLI Creation in Python
Python is a versatile programming language popular across various domains, including data science and software engineering. Many programmers utilize Python as a cross-platform alternative to Bash for scripting automation. When adding CLI support to Python scripts, you can use the built-in argparse or manually parse sys.argv. However, the Python Fire project can swiftly convert any Python script into a CLI without the need for extensive manual implementation.
Section 1.8: Flutter’s Ability to Render Native UI Elements
Flutter addresses cross-platform development challenges by providing a toolkit of platform-independent widgets and a highly efficient Dart-to-native communication protocol. When adding input fields in a Flutter application, the UI is rendered via the Skia library rather than as a native text input element. However, if you need to incorporate complex platform-specific GUIs within a Flutter app, the concept of platform views allows for this integration, albeit with performance trade-offs.
Section 1.9: The Pursuit of Perfect Code
Clean code practices encourage writing maintainable and high-quality code, such as using self-explanatory identifiers. However, striving for perfection through extensive code refactoring and overly strict reviews can hinder feature delivery speed and degrade code quality. As it turns out, perfect code is more of a theoretical concept, existing solely in the minds of developers. Seasoned programmers typically produce code that is "good enough" to meet delivery requirements.
In conclusion, I hope you have your own collection of insights and lessons from 2022. What programming wisdom did you find most beneficial this past year? Thank you for reading!