Some projects for a C Begginer ?
Some projects for a C Begginer ?
Hello.
First, sorry if this has been asked before, I did some research in the Wiki and Forums and couldn't find anything similar, so I'm posting this here.
I'm not a begginer in terms of Programming, I've been programming for about 3 years, I'm not an expert nor a "programmer" actually, but I know the basics of the Theory, and I've build some really small programs, mainly text adventures and so.
Some while ago I started learning C, I'm interesed in Low level programming, Hardware, etc. so obviously C is a must, obviously.
I know the basics, I'm not an expert C programmer, but I know the basics of the language (Syntax, operators, structures, control flow, pointers, arrays, stack/heap, etc.) I'm still waiting for my copy of K&R however.
I'm also familiar with Linux and UNIX in general, having installed Gentoo, Slackware, FreeBSD and several linux distros, so at least I'm familiar with building a Linux Kernel and using BASH.
I've stumbled upon OSDev, this looks like a nice community, an OS seems like a nice project, but too complicated for me (I suppose), so maybe you can suggest some projects ? I'm not looking to something like ProjectEuler, but something of this "level".
Or maybe some other things I'd need to learn ? Obviously I need to learn ASM but I'm trying to get more familiar with C at this moment.
Any suggestions ?
Thanks.
First, sorry if this has been asked before, I did some research in the Wiki and Forums and couldn't find anything similar, so I'm posting this here.
I'm not a begginer in terms of Programming, I've been programming for about 3 years, I'm not an expert nor a "programmer" actually, but I know the basics of the Theory, and I've build some really small programs, mainly text adventures and so.
Some while ago I started learning C, I'm interesed in Low level programming, Hardware, etc. so obviously C is a must, obviously.
I know the basics, I'm not an expert C programmer, but I know the basics of the language (Syntax, operators, structures, control flow, pointers, arrays, stack/heap, etc.) I'm still waiting for my copy of K&R however.
I'm also familiar with Linux and UNIX in general, having installed Gentoo, Slackware, FreeBSD and several linux distros, so at least I'm familiar with building a Linux Kernel and using BASH.
I've stumbled upon OSDev, this looks like a nice community, an OS seems like a nice project, but too complicated for me (I suppose), so maybe you can suggest some projects ? I'm not looking to something like ProjectEuler, but something of this "level".
Or maybe some other things I'd need to learn ? Obviously I need to learn ASM but I'm trying to get more familiar with C at this moment.
Any suggestions ?
Thanks.
Re: Some projects for a C Begginer ?
Hi,
One suggestion I have - why not try to make some of the data structures mentioned on the wiki - like for example a memory manager.
A memory manager can work hosted (with a few calls to mmap()), and you can debug with gdb and without having to go to baremetal. That might be a good introduction.
Cheers,
James
One suggestion I have - why not try to make some of the data structures mentioned on the wiki - like for example a memory manager.
A memory manager can work hosted (with a few calls to mmap()), and you can debug with gdb and without having to go to baremetal. That might be a good introduction.
Cheers,
James
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Some projects for a C Begginer ?
At some point, the chances of success in OS development are solely dependent on your ability to stay patient and your mental abilities for sound reasoning and dealing with large problems. Effectiveness at it comes with hours spent - which can be any project, but also OS development itself. If you know to expect that it won't go fast and that you'll have to start over at some point, feel free to give it a try.
As far as other projects are concerned, the only key point I'm missing on your list is one of scaling up. You already made a text adventure, now try to make a game in 3D.
As far as other projects are concerned, the only key point I'm missing on your list is one of scaling up. You already made a text adventure, now try to make a game in 3D.
Re: Some projects for a C Begginer ?
Woah, you were really fast to reply, thanks all.
That sounds good, I'll search for it.JamesM wrote: One suggestion I have - why not try to make some of the data structures mentioned on the wiki - like for example a memory manager.
For some reason I hate graphics, I can do some 2D stuff but I suppose I'll need some Physics/Math experience for 3D Development.Combuster wrote: As far as other projects are concerned, the only key point I'm missing on your list is one of scaling up. You already made a text adventure, now try to make a game in 3D.
Re: Some projects for a C Begginer ?
If you are interested in low-level programming, implementing a file system can be interesting and challenging. A program to read a FAT or ext2 file system is fairly simple (you would use it with a disk image rather than a real disk). Once you get that working you could then try writing to the "disk". The actual pysical reads and writes are trivial in this case, as you are just reading blocks from a file, so you can work on understanding the file-system structures.
I've always found that however daunting a project appears it turns out to be much easier than expected.
I've always found that however daunting a project appears it turns out to be much easier than expected.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Some projects for a C Begginer ?
There are lots of lessons to be learned in the OS development world as well. The question you need to ask yourself is what the difference is between OS development and solving a bunch of Project Euler things, or scene composition logic. Graphics have a lot of instant-reward value, but doing that or some memory manager or disk allocation scheme is nothing different from doing project Euler homework - it's just whatever visible purpose you add on top of it. For example, are you avoiding a full-fledged graphical game because your own OS will always stick in text console? Are you avoiding maths because you don't ever need efficient algorithms in your kernel?dysoco wrote:For some reason I hate graphics, I can do some 2D stuff but I suppose I'll need some Physics/Math experience for 3D Development.Combuster wrote:As far as other projects are concerned, the only key point I'm missing on your list is one of scaling up. You already made a text adventure, now try to make a game in 3D.
Because in those cases, you might enjoy life a lot more after getting yourself an Arduino instead. Those things are fun in their own right, but do not however lend themselves to teaching you to be a master software engineer.
- NickJohnson
- Member
- Posts: 1249
- Joined: Tue Mar 24, 2009 8:11 pm
- Location: Sunnyvale, California
Re: Some projects for a C Begginer ?
I'd also say that a memory manager (i.e. malloc implementation) is good practice. They use a lot of different data structures and often use pointer arithmetic, which are two things that you'll need to be able to work with fluently before writing an OS. I'd even go so far as to say that you should try writing multiple memory managers. Try using a different data structure for each, and try to optimize for different goals: memory usage, speed, fault tolerance, security, concurrency, etc.
You also might want to learn how to write multithreaded code in userspace (using something like pthreads) before attempting OS development. Being able to deal with concurrent and nondeterministic control flows is critical, because they are the rule, not the exception, in kernelspace.
If you want to try some easy hardware programming, try writing some simple games for the GameBoy Advance. The development tools and emulators are free and good, and documentation is comprehensive. The GBA lacks many of the things critical for making a proper OS, like an MMU, but will introduce you to basic hardware I/O and will force you to write efficient code (it has less than half a megabyte of RAM, and is clocked at only 16.8 MHz.)
You also might want to learn how to write multithreaded code in userspace (using something like pthreads) before attempting OS development. Being able to deal with concurrent and nondeterministic control flows is critical, because they are the rule, not the exception, in kernelspace.
If you want to try some easy hardware programming, try writing some simple games for the GameBoy Advance. The development tools and emulators are free and good, and documentation is comprehensive. The GBA lacks many of the things critical for making a proper OS, like an MMU, but will introduce you to basic hardware I/O and will force you to write efficient code (it has less than half a megabyte of RAM, and is clocked at only 16.8 MHz.)
Re: Some projects for a C Begginer ?
Going along the lines of a 3D game, something that is similar to a current game could be a possibility, especially if it's open source so if you get really stuck you could take hints from how someone else solved the problem. A few friends of mine over at http://gamedev.segfault.net.nz/sake are writing something called SAKE (said 'sar-kay') - Specificly Arbitrary Kube Engine, basically an engine that allows people to create games similar to Minecraft. It's written in C so maybe you could pop over and have a look at things.
Heck, you may even be inspired into writing a 3D game for yourself!
Heck, you may even be inspired into writing a 3D game for yourself!
phillid - Newbie-ish operating system developer with a toy OS on the main burner
- Schol-R-LEA
- Member
- Posts: 1925
- Joined: Fri Oct 27, 2006 9:42 am
- Location: Athens, GA, USA
Re: Some projects for a C Begginer ?
Sneaky little Schemer that I am, I'll throw in Scheme from Scratch, a project to write a simple Scheme interpreter in C. While Peter Michaux has posted his own code for it, there are several others who followed along the basic design with their own implementations (in a fit of perversity, I decided to implement my version in MIPS assembly language). It's a few weeks worth of part-time work, but it does make a good project for a long holiday. It gives you a basic idea of how to implement an interpreter, as well as exposing you to a language you probably aren't familiar with.
(And yes, this was originally posted on DaniWeb in answer to a similar request. I felt it made sense to repeated it here.)
(And yes, this was originally posted on DaniWeb in answer to a similar request. I felt it made sense to repeated it here.)
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Re: Some projects for a C Begginer ?
What about some parts of the standard C library?
You could even reuse some of it later.
You could even reuse some of it later.
Re: Some projects for a C Begginer ?
Seconded. I recommend implementing the functions defined in <string.h>. They are easy and small, give you a good idea at how pointers and C strings work, and also give a good practice of how to express a specified algorithm in a compact way (avoiding unnecessary allocations, compares and the like).mark3094 wrote:What about some parts of the standard C library?
Every good solution is obvious once you've found it.
Re: Some projects for a C Begginer ?
And then, in order to check that you are really ready and also able to read and understand the details in specs, implement stdio.h.
Re: Some projects for a C Begginer ?
Every good solution is obvious once you've found it.
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: Some projects for a C Begginer ?
Interestingly, I recently discovered how wrong somebody could implement stdio/C++ iostreams even when success was staring them right in the face...Solar wrote:
For you see, Windows is the only OS in the world in which the console truly understands Unicode, and has an API which works with Unicode characters, rather than Unix-style "The console system ignores the character set and requires the terminal and the application to negotiate it." So far so good.
But, of course, with such a convenient API on top of which to implement their wide character console IO on top of, the C library developers couldn't possibly get it wrong, right?
Right?
Oh wait. What wgetc does is call getc, then cast the result to a wide character, then return that. What wputc does is just pass the character to putc.
As it turns out, this is completely unfixable in C. In C++, you can at least re-implement the stream buffer to go direct to the console API for the IOStream objects (and I have done this! In fact, I should publish the code... because there are various tutorials on the internet which are both broken in mysterious ways, and manage to stuff up your non-Unicode I/O as well...)
Whats even worse is that I believe that the MinGW developers have somehow managed to replicate this brokenness (or maybe they're just delegating to the broken msvcrt?)
Re: Some projects for a C Begginer ?
Sorry, but this reads like Cthulhu-induced gibberish.
Besides, QNX does full Unicode since the early 90ies, just as an example.
For one, what you get if you call cmd.exe on a Windows box is not a console. What you get when you open a terminal on Unix is not a console. A console is what you have on a physical Unix box when you press Ctrl-Alt-1, and it's meant to flash "login:" pretty much indefinitely unless there is an emergency that requires the admin to actually and physically address the box. Whether or not that supports Unicode isn't much of an issue either way, IMHO, somewhat akin to Windows' "rescue console" (or whatever it's called). Besides, I didn't have any issues with Unicode on my console...
Everything else is done via terminals, or rather, terminal emulators, either on the box itself or remotely. That, IMHO, Unix does beautifully, and if you find fault at it I would ask you to elaborate on it to quench my ignorance of any issues that might remain with the concept.
/me confused...
Last time I looked, Windows still defines wchar_t to (UCS2) 16 bit width, a move that shot C++ wide strings in the foot so effectively that C++11 had to introduce another type of wide strings for fixing this mess, in a way so unabiguously that even Microsoft cannot screw it up (hopefully).Owen wrote:For you see, Windows is the only OS in the world in which the console truly understands Unicode...
Besides, QNX does full Unicode since the early 90ies, just as an example.
I am really not sure what you're talking about re console / terminal. I think you're confusing a couple of things, terminology-wise.Owen wrote:...and has an API which works with Unicode characters, rather than Unix-style "The console system ignores the character set and requires the terminal and the application to negotiate it."
For one, what you get if you call cmd.exe on a Windows box is not a console. What you get when you open a terminal on Unix is not a console. A console is what you have on a physical Unix box when you press Ctrl-Alt-1, and it's meant to flash "login:" pretty much indefinitely unless there is an emergency that requires the admin to actually and physically address the box. Whether or not that supports Unicode isn't much of an issue either way, IMHO, somewhat akin to Windows' "rescue console" (or whatever it's called). Besides, I didn't have any issues with Unicode on my console...
Everything else is done via terminals, or rather, terminal emulators, either on the box itself or remotely. That, IMHO, Unix does beautifully, and if you find fault at it I would ask you to elaborate on it to quench my ignorance of any issues that might remain with the concept.
Uh... wputc, wgetc? What in blazes are you talking about? libncursesw? What does that have to do with consoles, Unix or otherwise?Owen wrote:What wgetc does is call getc, then cast the result to a wide character, then return that. What wputc does is just pass the character to putc.
/me confused...
Every good solution is obvious once you've found it.