[SOLVED] Advice on how to move on from being a beginner in C.
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Advice on how to move on from being a beginner in C.
To stave off boredom after retirement I got hold of a copy of Kernighan and Ritchie and started reading it. Of course, I could not resist trying the code. However, K&R was a bit too hard for an elderly newcomer to C, so I moved to KN King's 'C programming - a modern approach'. This was more accessible and I have completed it and many of the exercises/ programming projects in it.
So what next? I think that to get better I need to write programs. However I struggle to think of suitable ideas.
A Google search produced suggestions like Rock, paper, scissors, which is not too interesting. However I am not good enough to tackle harder problems. I am doing this for fun and would like to stick to C.
So, my question is, how do you take the next step from being a complete novice to becoming a bit better? I feel like I have stalled. Any advice on how to move forward?
You might consider following the OpenBSD project on a spare machine. Specifically their current branch is of use since the updates are distributed only as patches to the system's source code. If you start by installing a snapshot, unpacking the source tree there, and then start tracking -current via the relevant mailing lists (source-changes and tech and maybe bugs) that will give you a lot of small pieces to handle and examine. Just a head up -- those three lists should be considered read-only at the beginning.
Their style is quite clear and they have a strong emphasis on both readability and correctness. Some parts of OpenBSD will be too advanced, but others will be within reach. And along the way it might give you ideas to work on for your own programs or, once in a while, a patch for them.
as it was written, use it. Write your own program. To make it more interesting try to find a goal for yourself. For example implement a simple game, calculator or lottery number generator.
The three most important things are: practice, practice and more practice.
The program that prints its own source sounds interesting. A printf that prints #include <stdio.h> and everything else, including itself I suppose... hmm
Also tracking OpenBSD - I don't have a spare machine but I could install it on Virtualbox.
Sounds more fun than suduko.
I will look into all of them.
Ideally, you would program something that you find personally useful. For example, maybe you want to search for file names that contain special characters, because those can be annoying later on (when, for example, sharing files with someone who uses Windows).
C isn't necessarily the best programming language to write such a utility with, but it'll do fine and you'll feel better creating something that you actually can use and probably learn a lot along the way.
If there's no such utility that comes to mind, you can try some old school 1970's style BASIC games. Daleks/Robots is a good one that's pretty easy to code and also can be expanded into a dungeon crawler. Each "turn", you just print out a map showing your position and the Daleks, and user input is simply movement in one of the 8 directions or to wait in place.
Call this "Well intended, but gruff sounding advice"
A common misnomer I'm concerned about, may or may not be an issue for you. And I'm not about forcing anyone to follow a direction they're not inclined to.
The misnomer is that people embark upon learning a "language" and they feel this will make them a programmer. Their project challenges will likely grow, and depending upon the person, their programming may be limited by their own bias, and also limited collaborative exposure to other designers.
Some people will say, (a) I have to start somewhere, that is true, or also (b) I'm really doing this for fun, please help me/guide me, but do not criticize.
Where I'm coming from is that programming is solving a problem or using a process/algorithm to do things, it's not merely the acion of writing and running code.
Example: auto loan, simple interest. 10,000 @ 5% over 4 years. Calculate the payment. A: ((10,000 x 0.05 x 4) + 10,000)/48 = Monthly payment
Then you can modify that to compute compounding interest, accept variable inputs for financed amount, interest rate, and term.
Once you know WHAT you want to do, and HOW in spoken language a.k.a. pseudocode, the actual programming can be done in any language and using numerous means within most languages to attain the same result. And within any language there are multiple ways to achieve similar, correct results.
If all you ever wish to do is "write some programs" please understand that as your sophistication of projects grows, similarly those who haven't followed your start and progress, may challenge from the perspective of your DESIGN. And you may take this as criticism. Please bear in mind that many experienced persons have done this a lot, for years, for work or academia, and encountered design challenges, which ultimately grew their knowledge and abilities, that is really where people are coming from, and they also have heard critical analysis of their former designs and code, it is normal, versus harshly intended criticisms.
Not at all trying to discourage anyone from this type of exploration, just making my personal distinction between writing code and programming. I would very much be the type who would interpret most person's code questions from the perspective that they are trying to learn the subject of programming not just code. Maybe that's an unpopular stance, I guess my bias is that I've solved problems for years in many languages, using many design manners, and also constantly improved my knowledge and abilities to design and code better. To whit, and I've lived this, one can take on a programming project in any language even if they've never used that language or heard of it before, but still be successful if they understand how to frame a problem and design a process to solve it.
Call this "Well intended, but gruff sounding advice"
The misnomer is that people embark upon learning a "language" and they feel this will make them a programmer. Their project challenges will likely grow, and depending upon the person, their programming may be limited by their own bias, and also limited collaborative exposure to other designers.
Your advice does not sound at all 'gruff', instead it sounds like wise words from someone with years of experience behind them.
I am humble enough to know that writing a few programs will not make me a programmer, just as replacing a faulty washer does not make me a plumber. I appreciate that someone who has made a living as a programmer, in any setting, commercial or academic, knows far more than I ever will.
I play golf sometimes and want to improve my short game. I know that a couple of hours practice and watching a golf video does not make me a pro. I just want to get 'bit better than the last time' I played, if you see what I mean.
I might be doing this for 'fun' as I put it, but I do want to get better. So I appreciate when people here give me advice and I reflect on it and try my best to understand it. I will never call myself a programmer, just like I will never be a 'golfer'. I leave that to the pros.
I suspect that some of the people who so generously offer their time and advice here are very, very knowledgeable indeed. As in outstandingly good. I value any advice from such people. Indeed it would be foolish not to.
But you could also begin to expand your horizons, say to “C++.”
Furthermore, “git repository” websites such as “GitHub” and “SourceForge” contain thousands of “complete applications,” searchable by language. You can use this to encounter, and explore at your leisure, fully-developed and debugged applications that are usually not trivial. (Although “instructional” projects are out there too.) I am a firm believer in the maxim that: ”you can learn a lot by watching.”
This is also important when you think of something that you’d like to do. “Has somebody else already done it?” (Likely.) But maybe you can improve upon it. The key idea, today, is that “nobody starts in a vacuum.” Instead, “we build on the shoulders of giants.”
Last edited by sundialsvcs; 01-21-2024 at 05:18 PM.
Yes, although it is almost offtopic, just an idea:
I have some esp32 and esp8266 boards. You can create useful things with them, if you are interested. There is a lot of ready-made c/c++ code available for them, you just have to adapt it to your needs. Sometimes it is easier, but obviously can be difficult too.
Yes, although it is almost offtopic, just an idea:
I have some esp32 and esp8266 boards. You can create useful things with them, if you are interested. There is a lot of ready-made c/c++ code available for them, you just have to adapt it to your needs. Sometimes it is easier, but obviously can be difficult too.
Thank you pan64 for the suggestion. I searched them, and they look like interesting boards.
However, I have found MIT's Xv6 https://pdos.csail.mit.edu/6.828/2023/xv6.html and I have been tinkering with writing a few basic user programs. I think the MIT course that goes with Xv6 gets very hard quite quickly, so I will take my time. Last year I got Research Unix Version 6 running in a SimH PDP-11/40 Emulator, so Xv6's 'modern' take on Unix sounds like something I would be interested in.
As well as thanking pan64, I would like to express my gratitude to all of you who took the time to answer me.Your responses helped focus my thoughts and have encouraged me to keep exploring.
Thank you pan64 for the suggestion. I searched them, and they look like interesting boards.
However, I have found MIT's Xv6 https://pdos.csail.mit.edu/6.828/2023/xv6.html and I have been tinkering with writing a few basic user programs. I think the MIT course that goes with Xv6 gets very hard quite quickly, so I will take my time. Last year I got Research Unix Version 6 running in a SimH PDP-11/40 Emulator, so Xv6's 'modern' take on Unix sounds like something I would be interested in.
As well as thanking pan64, I would like to express my gratitude to all of you who took the time to answer me.Your responses helped focus my thoughts and have encouraged me to keep exploring.
I have to say this is the best, you have your own way. Good luck!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.