After 'Hello World!': Properties of a demo project when learning a new programming language
Whenever I learn a new programming language, I start with a simple "Hello World!" application, just like pretty much every other programmer. Usually, this is intended to test if compilers and/or the runtime environment are installed correctly. Afterward, the actual learning process begins. But before I properly start to study syntax, for example with a textbook or a course, I want to get a rough feeling for the new language. Therefore, I plunge directly into an application project that covers many features of a programming language.
Reasons for a demo project
For the purposes of a demo project, I am not interested in solving every subtask perfectly with neat language-specific tricks, but I want to get an overview of what to expect. As I mentioned earlier, it is important to me that I can get a rough feeling for the language. Since a good demo project covers plenty of useful features of the language, you can already get a notion of the syntax or how to use libraries.
Furthermore, you can get used to the documentation and other sources of reference as well as some insight into the community. For example, an active community on StackOverflow might point you to interesting articles, blogs or experts in the field. Most likely, you will find yourself in a situation where you are stuck at a very basic problem during the development of your demo project. It might be helpful to examine the most voted StackOverflow questions, for instance here are the ones for Rust.
Besides, you can compare your experience of the demo project with the implementations from previously learned programming languages. Are there any similarities? Where are the differences? Of course, this is only possible if the same demo project has already been tested in another language. Besides, it is advisable to re-evaluate the project and possibly even re-implement it after you have worked through the textbook or course, for example. You will revisit a lot of language features in a short period of time and it will help you to avoid your mistakes in future more serious projects.
At this point, it should be noted that this approach may not be suitable if you have no prior coding experience.
Which properties should be considered in a demo project?
A demo project should encompass many features of a programming language such as memory management, garbage collectors, or evaluation strategy (call by value? call by reference? ...). It tests common and recurring programming tasks and it forces you to search in the documentation and other online sources. The following list should not be considered as being complete but rather as a rough guideline for your project ideas.
- Basic Types (integers, booleans, ...)
- Strings (splitting, concatenating, comparing, ...)
- Arrays (splitting, concatenating, comparing, ...)
- stdin and stdout
- Basic Operators (if/else, loops, ...)
- Advanced Programming Concepts
- functions (call by value? call by reference? ...)
- classes (if the language is object-oriented)
- ...
- File I/O
- Networking
- (Internal) Library
- External Libraries
- Concurrency
My Personal Go-To Demo Project
Do you know the Internet Archive Wayback Machine? It captures and saves the state of a given web page such that you can restore it even when the web site disappeared or an article is locked behind a paywall (some magazines publish their top stories without a paywall for the first few hours but want to make you pay if you want to read it in the future). I adore this project since it allows me to bookmark interesting articles without the fear they might disappear when I want to revisit it in a few months or years.
So what does this have to do with my go-to demo project? I take all links from a given RSS feed and use the Wayback Machine's API to save each article. This sounds like a trivial program which you could easily solve with a few lines of code in pretty much every programming language. That is correct and it is exactly the reason why I chose this as my go-to project. With a few extensions to this project description, the project involves most of the properties of a suitable demo project given above.
First of all, you need to pass several parameters to the program, e.g. the URL of the RSS feed and the interval of checking the RSS feed. For instance, you could pass this as an argument to your program, or you could use a config file. Of course, there is no perfect solution since the only purpose of this project is to get an overview of the language. Ideally, you should try out many different options. This also applies to the other parts of the application, of course.
Most likely, you know web sites that split their articles into 2 or more pages in order to maximize their ad revenue (their rationale: the more websites you visit the more advertising you will see). Look for such a website and view the HTML source code in your favorite browser. You may find a link to a page that shows the whole article on one page. This would be the link you want to archive with the Wayback Machine. Otherwise, you may find a pattern in the page's URL, for example, each page has a ?page=1 parameter. Then, you will need a mechanism in your code that handles these patterns. Either way, your program comprises basic types, strings, and basic operators like if/else or loops.
Furthermore, you can store each link to an article in a file or a database, associated with metadata like the publishing date or the name of the authors. You can check whether the article is already saved in the Wayback Machine such that you prevent double-saving the page. Or you could store links to all articles of a given day in an array in order to save them a day later. You may check how the article's headline changed (see more about A/B testing of news headlines). Or be creative and come up with your own ideas what to do with arrays, files or libraries!
Conclusion
Demo projects before actually learning a programming language properly is a great way of exploring the syntax, the concepts, the community, the documentation and other resources of the language. Having a go-to demo project helps you to compare your newly acquired skills to your previous knowledge. Don't be afraid of making mistakes or of not finding the optimal solution (if there is such a thing as an optimal solution at all). It is part of the process and it helps you find interesting and difficult areas on which you should focus when you learn the language with a book or a course.