Comment by π stack
Re: "Suggestions for first project"
Something not too complicated that you would enjoy!
2025-12-17 Β· 5 months ago
9 Later Comments β
π RubyMaelstrom Β· Dec 17 at 09:06:
Many (most?) large software projects are still written in some variety of C. Sometimes taking a peek at the code for your favorite operating system, game, etc can be a little overwhelming but also an interesting learning experience.
One good way to keep a project simple is by having some limitations. I would recommend getting a Pi Nano ($5-10) and writing some C code for it, since it's one of the two officially supported development languages for them. Just flashing the LED a little bit to indicate something is fun and you'll learn the syntax.
π norayr Β· Dec 17 at 16:24:
you may want to write your own libc, since the standard one is not the most beautiful and safe in the world(both c and libc interface are old, back then we did not come up with what is good design yet), and since you're coming from the background of other languages, probably more modern, you'll feel the lack of better designed or more consistent function interfaces or even proper strings.
sorry, i don't romantisice c, to say the least.
don't want to start a holy war of course. but yeah, that's what i would want to do in c first.
π ingrix Β· Dec 18 at 05:00:
You should write a tool like netcat, something that can either connect to another host or listen on a port (any of TCP, UDP, or unix sockets) and write user input to the socket or print incoming network data to the screen. The functionality is straightforward enough that you know what it's supposed to do, you can easily test it all on your local machine, all of its fundamental capabilities are available without bundling up a bunch of dependencies, and it will show you how to use standard C library features like:
- parsing command line options (e.g. getopt())
- user input and output to stdin/stdout (fscanf(), fgets(), fprintf())
- network sockets (socket(), connect(), bind(), listen(), accept(), send(), recv(), etc)
- DNS resolution (getaddrinfo(), gethostbyname())
- prioritizing and handling multiple pending input/output channels (select(), poll(), epoll())
- portability considerations, since you can (if properly implemented) build it on linux, BSD, illumos, etc.
If you do this you can make the command line arguments in whatever style you like too which is nice. You also have plenty of opportunity to make it as complicated as you want later. Provide a flag so it can parse http responses, give it TLS capabilities, etc.
If you do a good job of bundling up the functionality at coherent boundaries you can also use it as a basis for a library in projects you write later too, so it's not just a one-off useless project.
π ingrix Β· Dec 18 at 05:06:
Addendum to the above: a project like that also has some convenient "check points" you can use to give yourself achievable and recognizable goals. First, make something that can connect to an existing netcat listening on localhost and then immediately close the connection. Next, have it connect, send data, and then close the connection (so you see the output on the existing netcat listener's output). Then connect, send data, and wait for a single line of data from the existing netcat listener (that you'd punch into the listener's terminal manually), then exit. Make it fancier from there. That's how I'd recommend you get a toe-hold on it.
π» Christopher Β· Dec 18 at 16:20:
I would suggest creating a simple game. To keep things easy just print out the board (or whatever) as ASCII art in the terminal so you don't have to wrestle with GUI libraries until later.
Back when I was learning C in the mid-'90s I recreated a Commodore 64 BASIC game called "Stranded" (from a book called "Games Commodores Play"). It's played on a board like a chess board so it was easy to print out in text, something like this:
Then later you can try writing a maze solver if you want to learn recursion.
π stack Β· Dec 18 at 18:03:
First and foremost, especially since you've stated you are familiar with coding in general but just don't know C, your choice of project is very individually depends on what brings you joy! C is a pragmatic language used to solve problems, for the last 50 years. It's not exceptionally pretty, ugly, or complicated.
It can be confounding, and your early experience may alter how you think about it. My first experience was with Borland C on a Compaq -- spending a day unable to compile a simple program -- because I did not have a carriage return after the final line. The error message was generic and not helpful. This was not a C problem, but a compiler bug, and compilers are incredibly good now, even providing suggestions when you mis-spell an identifier...
That experience had shaped not just a multi-decade hatred of C, but my entire career! I wound up writing many interpreters and compilers to avoid C. Pretty much all of my coding activities (some extremely satisfying, and some profitable) were done with my hand-crafted tools. But in the last few years I've learned to really appreciate and even enjoy C for what it is -- a ubiquitous, concise and proven language that does not get in your way (much) or try to save you from being an idiot.
So pick something you like -- a game, a network tool as @ingrix suggested, a graphics 'demo', or whatever you would find _fun_ working on for a few weeks, and run with it.
Finally, I would suggest not using a fancy IDE, or even mess too much with make, but keep your code in a single file. I know it's not exactly the C way, but trust me, it will save you a ton of frustration and confusion until you are comfortable with the system and have a need to compartmentalize functionality into different independently compiled units, and dealing with include files and linking.
You may never need more than a single file! I built a (what I consider a really good for my purposes) gemini server in a single file of ~500 lines. If you want to take a look, it's at:
β https://tildegit.org/stack/fornax
Final thought... I became a much better C coder after a few years of Common Lisp!
π argyle Β· Dec 18 at 22:50:
Something that solves a problem you have is always a motivation to finish.
π½ Retro Β· Dec 19 at 09:25:
It's been a long while since I've done any, but I enjoyed bare metal C on microcontrollers. You get a real feeling for C's strong points and a greater appreciation for how (simple) CPUs work.
I remember that Arduino (or really any microcontroller development board) could be programmed in C using open source toolchains. So maybe a project with one of the kits you can buy?
π» Christopher Β· Dec 19 at 18:20:
@stack makes an excellent pointβdo what brings you joy. I personally find joy in reimplementing existing software and possibly improving upon them. I think it's because I like to prove to myself that I can, and I also learn how stuff works by doing. (I also enjoy recreating software for other platforms, sometimes esoteric platforms, than the original was made for.) But you may not find joy in it, and that's OK.
What sort of things are you interested in? Networking? Gaming? Let your interests guide you. But whatever you do I recommend starting with a simple enough project that you can complete it in a reasonably short time, where "reasonably short time" depends on your attention span (mine can be as short as a weekend for some projects).
Original Post
Suggestions for first project β I have always had a great deal of respect for C, and I would like to start writing in it. However, while I am skilled in other languages, I basically don't know any C off the top of my head. I find that I learn better and faster by attempting projects, rather than working through a book ir taking a class. For example, to learn Perl, I am working on a basic disk image writer that's coming along nicely. So, what do you think might be a good idea for my first C...