Rust has Reignited My Love for Programming
Tags: rust, programming, gui
Published: 2024-03-28 23:29:20

## Background

Throughout my programming journey, I've primarily used C++ and Python. C++ is required in college, so most of my non-webdev projects are written with it. Python, on the other hand, is a language for when I'm struggling to get something working in C++. GUI, for example, is infinitely easier in python. If I want to write a desktop app for a CLI tool, I could write one 100x faster in Python with something like [tkinter](https://docs.python.org/3/library/tkinter.html).

## The Problem

With C++, I found myself struggling with build systems more than actually coding (Yes I've tried CMake). Call this a skill issue, but the lack of a package manager makes writing fun side projects between university classes a huge pain.

Additionally, C++ is pretty hard to make cross-platform (in my experience). It seems like every library I tried using for desktop app development/game development had some quirk on Mac/Windows that made it very difficult to work with. Since I primarily use Windows, but my non-coder friends use Mac, I couldn't even get good feedback on my projects. I understand this is a product of Apple and its "walled garden", but that does not eliminate the problem.

This brings us to Python, my favorite language for hacking something together in an unreasonably short amount of time.

Python is really easy. Python is cross platform. Python's package manager is awesome. There is a lot to love about python. Why not just write everything in Python? I think you can predict the answer...

Python's speed is a huge issue for complex apps and games. An interesting result of this is that I find myself over-optimizing an app while writing it, because even small apps are visibly slower than a compiled program in C++.

I like types. Types are awesome. Whenever I write python, I *always* use explicit type hinting. However, I know that they aren't strict, which means weird behavior can still happen at times. I find that when I write Python I try to act as if it isn't Python. I'm trying to make the language something it is not.

## Finding Rust

I ran into a roadblock in my journey of learning to code. I kept finding issues that would completely derail development. My mountain of unfinished projects was piling higher and higher. I started thinking about alternatives that would solve my problems.

I wanted a language that has these features:
- Package manager
- Speed
- Strong type system
- Memory Safe
- Cross platform tools

I've known about Rust for a couple years, but never thought about giving it a try. I had seen snippets of it on YouTube videos. The syntax looked completely alien to me. The strict compiler scared me. It took almost 2 years of watching from the sidelines for me to finally try it.

## Using Rust

Learning Rust was intense. I basically dedicated every second of free time to the language in order to grasp its quirks. After getting over that hurtle though, I found that I am extremely productive with it.

Initially, fighting the compiler meant that programs would take a *lot* longer to write in Rust than Python and even C++. However, once the program compiles, it *will* work. There is no random crashing. There is no silently failing without an error. The errors are not 200 lines of cryptic text. Contrary to what many people say, I find that I get things done *quicker* in Rust than other languages.

Rust has made me a better programmer. Most of my programming knowledge is self-taught. This means that my old programs are not up to standards as far as being robust and secure. For example, whenever I wrote games with OpenGL, I didn't really handle errors. At most I would add print statements, but that's about it. This is a fault of me, not the languages I use; but they allow it. Rust on the other hand, requires that I handle errors and None values. Assuming I don't just throw around `unwrap`, my programs will follow proper error handling practices, drastically improving the safety and readability of my programs.

## Caution

This is **not** a diss to C++ and Python. I still love them dearly; and I use them both almost daily. I completely understand that a lot of my issues with C++ and Python come from a lack of experience (I've been coding for ~2 years). I just thought sharing my experience might help others experiencing similar issues. Rust may not be everyone's solution.

## Conclusion

Rust has reignited my initial love for programming that I found in high school. I find myself writing in other languages, wishing I had errors as values or Rust's enums. Rust gives me confidence that I am writing at least safe code, and possibly even good code. It might seem like a cop out to run to a new language to solve my problems, but I don't care. Rust worked for me.