Source of the title image: https://commons.wikimedia.org/wiki/File:Logo_C_sharp.svg
If you’re a software engineer, you’ll probably have learned multiple programming languages either due to your interest or need. That is, while you may have a main language, you need to learn a new language for different projects. In my case, expecting my next few projects to require knowledge of C#, I was looking for some smart ways to learn it efficiently - methods that are not mundane but still cover essential parts of the language.
Then I came across a few videos by ThePrimeagen about learning a new programming language. Primeagen is one of the most famous IT influencers, and I’ve been enjoying his videos on YouTube for quite a while. So, I thought it was a good opportunity to try his method and see if it works for me.
What is "Primeagen’s way?"
The video above and a short are the resources that I followed. In short, his method for learning a new programming language can be summarized in three to four steps:
- First, skim through the documentation of the language and briefly review its syntax.
- Second, try several exercises from Advent of Code to get some ideas about the language.
- Third, implement a very simple chat client.
- Finally, work on a larger project.
A disclaimer: I tried the first three parts but omitted the final one, since it is expected to be a long-term project and it doesn’t only involve pure software engineering skills. Also, I chose to implement a chat server instead of chat client, because I was more familiar with the backend programming.
How I followed "Primeagen's way"
1. A tour of the language
To begin the first step, I chose to skim through Tour of C#. While it wasn't a thorough introduction, it allowed me to sketch a broad overview of the language, including the following:
- Basic types, operations, loops, conditions
- OOP features such as
class
,struct
, inheritance, and access modifiers - LINQ (I felt this was a really cool feature of the language)
- Asynchronous programming
In addition to "Tour of C#", I explored other pages and tried to get familiar with the language. My first impression was that C# is very much like Java, but with a few features for functional programming such as Delegates.
2. Ten exercises of Advent of Code
Then I dived into Advent of Code, a popular platform for challenging and fun coding exercises. I only tried ten (five days, two problems per day) days of exercises from the 2024 version, because I didn’t want to focus solely on coding exercises.
- To solve the problems, I began with printing “Hello, World!” on my local machine. So I installed .NET SDK (version 9.0) and generate a CLI template with it.
- Then I learned how to read data from
.txt
files on disk. I used.txt
files for reading the inputs. - I practiced a few OOP concepts, such as access modifiers, namespaces, inheritance, and
static
keywords. - I used built-in data structures like
LinkedList<T>
andDictionary<K, V>
.
Although this was a good start, I began to wonder whether doing AoC is an ideal way to learn a new language.
- The platform provides no hint, so you must devise on your own solutions. This might encourage brute force methods instead of teaching yourself efficient data structures or language-specific features.
- Many problems involve extensive use of regex to parse input data, which can shift your focus from learning the language itself to searching for various regex patterns.
- A few exercises were tricky, taking up much longer time to complete than expected.
In retrospect, it could have been more effective to solve easy-level problems on LeetCode instead. Platforms like NeetCode offer helpful recommendations, such as "NeetCode 150".
This is my repo for AoC.
3. Implementing a chat server
After completing the first ten exercises from AoC, I moved on to the next step - implementing a chat server. At this point, I wasn’t really sure what Primeagen meant by "implementing". Did he mean I should start from scratch and use low-level socket libraries? Or was I allowed to simply use a well-tested web framework? I thought the former would be daunting, so I chose the latter approach and looked up the .NET documentation.
There are several ways to implement backend APIs in .NET. I chose the controller-based APIs because they were simpler and required less boilerplate than the “classic” MVC, but still more structured than the minimal APIs. Since I expected to frequently encounter old-style C# code, I thought it would be a good opportunity to get used to the old OOP style of C#. For implementing chat communication, I referenced .NET’s WebSockets documentation.
During the project, I learned how .NET handles a web application in general. It was interesting to compare .NET with Python frameworks that I was familiar with. It was very similar to FastAPI, where APIs are declared rather than manually implemented, and it is allowed to adjust details such as middlewares and other initial configurations. It was also similar to Django, since DB migration and ORM were fully integrated through Entity Framework Core.
However, I am not sure I learned any advanced features of C# throughout this project, because I literally followed the well-structured documentation rather than implementing my own functions. I didn’t need to exploit several strong features of C#. Alternatively, I might have had a better chance to try advanced C# features, if I had started by implementing a web server from scratch. However, as I mentioned earlier, that would have turned into a much longer project.
This is the repo for my chat server project.
Is Primeagen’s way recommendable for learning a new language?
I don’t like to say this silver bullet phrase but… "it depends". However, I would like to extend the sentence as follows: "it depends on the LANGUAGE of choice".
Is the language similar to the one you are already familiar with?
For example, if your main language is Python or JavaScript, learning C++ or Rust as a new language might be more difficult and certainly I can’t recommend Primeagen’s way. However, if it is Ruby, the initial effort required would be much lower. In my case, I was a little bit familiar with Java, so picking up the features and syntax of C# was relatively smooth.
Are there good resources for the language or frameworks?
Personally, I think this is one of the most important aspects of learning a new language (or any new technology in general). Compared with Ruby or Python, C# has a very good collection of the official documentation pages and it is very beginner-friendly.
Do you already have a clear idea about a fun project?
You may recall that I omitted the last step - doing an actual project of your interest. When working on your own project, you will need to consider logic involving data structures and algorithms, as well as organize a larger project, where you have to take care of building and publishing the application.
In other words, you will learn the nuts and bolts of the features of the language applied to the application. But I think this is more about how to design a product and not just about learning a new language. So I think this step must be about a project that you are already familiar with, and you have a clear design for the entire application.
Conclusion
To summarize, I suggest you to try this Primeagen’s way if
- the language you want to learn is similar to a language you are already familiar with; otherwise you would be better off starting from a few tutorials,
- you can easily access beginner-friendly resources for the language, and
- you have a fun project and you already have a clear idea about it.
Additionally, if I start over Primeagen’s way again for another language, I would probably try my own variation as follows:
- First, skim through a concise tutorial that covers the essential concepts of the language.
- Next, solve all the easy-level problems from "NeetCode 150".
- Implement a simple multi-threaded web server. Rust’s THE BOOK has a good example.
Overall, it was a good experience, and I learned a lot from Primeagen’s approach. However, I think you need to modify it to suit your own case.
Top comments (0)