OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Apr 24, 2024 8:22 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: How would I start learning C for OS Development?
PostPosted: Thu Jan 19, 2017 3:54 pm 
Offline
Member
Member

Joined: Mon Jan 16, 2017 3:39 pm
Posts: 25
Hey... How would I learn C for my operating system? I know quite a lot of functions. How would I learn to use it?


Top
 Profile  
 
 Post subject: Re: How would I start learning C for OS Development?
PostPosted: Thu Jan 19, 2017 8:25 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 03, 2016 3:13 am
Posts: 64
I honestly wondered the same thing, but there are people here who may guide you in the proper direction.


Top
 Profile  
 
 Post subject: Re: How would I start learning C for OS Development?
PostPosted: Thu Jan 19, 2017 10:06 pm 
Offline
Member
Member
User avatar

Joined: Sun Dec 25, 2016 1:54 am
Posts: 204
Here ya go... good luck.

4.5 hour tutorial

https://youtu.be/-CpG3oATGIs

Quote:
C Programming Language is the most popular computer language and most used programming language till now. It is very simple and elegant language.
1) This is by far the most comprehensive C Programming course you'll find here, or anywhere else.
2) This C Programming tutorial Series starts from the very basics and covers advanced concepts as we progress. This course breaks even the most complex applications down into simplistic steps.
3) It is aimed at complete beginners, and assumes that you have no programming experience whatsoever.
4) This C Programming tutorial Series uses Visual training method, offering users increased retention and accelerated learning.

Every programmer should and must have learnt C whether it is a Java or C# expert, Because all these languages are derived from C. In this tutorial you will learn all the basic concept of C programming language. Every section in this tutorial is downloadable for offline learning. Topics will be added additional to the tutorial every week or the other which cover more topics and with advanced topics.
This is we will Learn Data Types, Arithmetic, If, Switch, Ternary Operator, Arrays, For Loop, While Loop, Do While Loop, User Input, Strings, Functions, Recursion, File I/O, Exceptions, Pointers, Reference Operator , memory management, pre-processorsand more.
c tutorial for beginners. C programming tutorials for beginners.

_________________
Plagiarize. Plagiarize. Let not one line escape thine eyes...


Top
 Profile  
 
 Post subject: Re: How would I start learning C for OS Development?
PostPosted: Fri Jan 20, 2017 1:06 am 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1108
WaterOS wrote:
Hey... How would I learn C for my operating system? I know quite a lot of functions. How would I learn to use it?


Code:
<rant_mode>


You need a book like Programming Windows by Petzold or Windows via C/C++ by Richter, Nasarre, Russinovich, but for your OS, not for Microsoft Windows. I don't think such a book exists. I don't think your OS exists or qualifies to be called an OS either. So...

Code:
</rant_mode>


Get The C Programming Language 2nd ed by Kernighan and Ritchie (AKA K&R book on ANSI C (AKA C89)) and learn the language from it.

Next dive into the language standard and, perhaps, into some other truly informative reading:

The latest C standard is from 2011 (do we call it C11?), but you don't need to concern yourself with it now. Most of the things are in C89 and C99.


Top
 Profile  
 
 Post subject: Re: How would I start learning C for OS Development?
PostPosted: Fri Jan 20, 2017 1:37 am 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1108
dchapiesky wrote:
Here ya go... good luck.

4.5 hour tutorial

https://youtu.be/-CpG3oATGIs

Quote:
C Programming Language is the most popular computer language and most used programming language till now. It is very simple and elegant language.
1) This is by far the most comprehensive C Programming course you'll find here, or anywhere else.
2) This C Programming tutorial Series starts from the very basics and covers advanced concepts as we progress. This course breaks even the most complex applications down into simplistic steps.
3) It is aimed at complete beginners, and assumes that you have no programming experience whatsoever.
4) This C Programming tutorial Series uses Visual training method, offering users increased retention and accelerated learning.

Every programmer should and must have learnt C whether it is a Java or C# expert, Because all these languages are derived from C. In this tutorial you will learn all the basic concept of C programming language. Every section in this tutorial is downloadable for offline learning. Topics will be added additional to the tutorial every week or the other which cover more topics and with advanced topics.
This is we will Learn Data Types, Arithmetic, If, Switch, Ternary Operator, Arrays, For Loop, While Loop, Do While Loop, User Input, Strings, Functions, Recursion, File I/O, Exceptions, Pointers, Reference Operator , memory management, pre-processorsand more.
c tutorial for beginners. C programming tutorials for beginners.


I strongly discourage using tutorials to learn C. It's not a particularly friendly language that forgives its misuse and abuse by those who have a very incomplete and/or distorted view of what C really is. Nearly all C tutorials are incomplete, inaccurate or outright wrong. There have been plenty of books on C of the same poor quality and I have had a chance to pick up don't's instead of picking up do's from them. I then had to unlearn the bad things and learn the language the right way, paying attention to the most problematic aspects of the language, including undefined behavior, implementation-defined behavior and unspecified behavior. Those behaviors are bound to bite when writing things like operating systems. Tutorials will deceptively show the ease/simplicity of the language in simple programs. But there's a lot they won't tell. Because either the tutorial authors themselves don't quite know enough or because they just don't have the time or energy to essentially duplicate the knowledge contained in approx. 600 pages of the language standard (we can probably halve that number because not everyone is going to use every bit of the language library or write a C compiler, but that would still be a lot).

If someone is about to learn their first programming language, they should not choose C. Learning the basics of programming while using an unfriendly and unforgiving language is no fun. The fact that a C program compiles is nowhere a guarantee that it's correct. The fact that a C program appears to work as expected is nowhere a guarantee that it will continue to do so when moved to another computer or another compiler or a newer version of the same compiler.


Top
 Profile  
 
 Post subject: Re: How would I start learning C for OS Development?
PostPosted: Fri Jan 20, 2017 3:56 am 
Offline
Member
Member
User avatar

Joined: Sun Dec 25, 2016 1:54 am
Posts: 204
[rant] I learned C as my first language when I was 13 and all I had was Mark William's Let's C on an orginal IBM PC that still had the cassette recorder connector beside the keyboard connector. If it was good enough for me, then it's was good enough for anyone now. [/rant]

alexfru wrote:
It's not a particularly friendly language that forgives its misuse and abuse by those who have a very incomplete and/or distorted view of what C really is.


It is quite friendly - in that it does not limit you in how you express yourself... unlike say Java (the language that binds your hands in wool mittens and wraps you up in a carpet to protect you.) The WHOLE POINT of using C in the context of an OS is that it LETS YOU DO ANYTHING.... And needing forgiveness from a language is stupid - I WANT to poke a byte at address 0x100 (to use BASIC nomenclature) --- I WANT to see what happens when I rolls over 2000 bytes beyond 0xb8000 - just to see.. WHY cause I got's ta' learn to debug sometime... why not now?

alexfru wrote:
The fact that a C program compiles is nowhere a guarantee that it's correct


You are completely right. And there is a library full of thesis papers on trying make correct programs. There are hundreds of solvers, boolean expression evaluators, and design by contract.... none of which work unless you understand why they are telling you what they tell you... thus trial, error, gdb, and freakin stack trace.

However, in terms of the beginner, there will never be a correct program. In terms of the amateur, there will never be a correct program. And in terms of the professional - nada. Why? Cause there's always going to be a patch. There will always be a new idea that breaks old ones... again trial, error, gdb, and this time a break point.

alexfru wrote:
The fact that a C program appears to work as expected is nowhere a guarantee that it will continue to do so when moved to another computer or another compiler or a newer version of the same compiler.


Moot. Moooooooot. Does not enter into the discussion. Who CARES? Trying to design for the future of compilers controlled by those you do not pay is ludicrous. In C the variable name "new" used to be used like gangbusters until some jackass came along and made it a keyword in C++. "auto" used to mean one thing and now it doesn't. Things evolve, if your program is important enough you go with the flow. If your program is an OS you use gcc 4.3 for 10 or so years before upgrading to 4.6


[rant] There should be a RANT button in the editor beside Quote and Code [/rant]

WaterOS - learn C and have fun - then you can rant too!

_________________
Plagiarize. Plagiarize. Let not one line escape thine eyes...


Top
 Profile  
 
 Post subject: Re: How would I start learning C for OS Development?
PostPosted: Fri Jan 20, 2017 4:06 am 
Offline
Member
Member
User avatar

Joined: Thu Mar 10, 2016 7:35 am
Posts: 167
Location: Lancaster, England, Disunited Kingdom
And these youngsters learning C should be CANED if they make mistakes: it'll teach them not to do it again.
That's what happened in my day and it never did me any harm!!!

[sorry - couldn't resist it]


Top
 Profile  
 
 Post subject: Re: How would I start learning C for OS Development?
PostPosted: Fri Jan 20, 2017 4:13 am 
Offline
Member
Member
User avatar

Joined: Sun Dec 25, 2016 1:54 am
Posts: 204
MichaelFarthing wrote:
And these youngsters learning C should be CANED if they make mistakes: it'll teach them not to do it again.
That's what happened in my day and it never did me any harm!!!

[sorry - couldn't resist it]


luxury.

I had to manually clean 8" floppy drives with a pencil eraser if I didn't know the hexadecimal value of 10 octal...

interestingly, where I hung out as a kid there were always Bell Telephone employees who were Tandy Color Computer aficionados - a whole clique of 'em - and they would corner you and make fun of you if you couldn't decode the color stripes on a resistor they just happened to have in their shirt pocket...

Those were the days when you couldn't tell the difference between an engineer and a pedophile.

_________________
Plagiarize. Plagiarize. Let not one line escape thine eyes...


Top
 Profile  
 
 Post subject: Re: How would I start learning C for OS Development?
PostPosted: Fri Jan 20, 2017 4:19 am 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1108
dchapiesky wrote:
[C] is quite friendly - in that it does not limit you in how you express yourself... unlike say Java (the language that binds your hands in wool mittens and wraps you up in a carpet to protect you.) The WHOLE POINT of using C in the context of an OS is that it LETS YOU DO ANYTHING....


Except, it must be done by the rules of the language, or you can get screwed.

dchapiesky wrote:
However, in terms of the beginner, there will never be a correct program. In terms of the amateur, there will never be a correct program. And in terms of the professional - nada. Why? Cause there's always going to be a patch.


Except, it may be thousands of credit card numbers and millions of dollars too late.

dchapiesky wrote:
alexfru wrote:
The fact that a C program appears to work as expected is nowhere a guarantee that it will continue to do so when moved to another computer or another compiler or a newer version of the same compiler.


Moot. Moooooooot. Does not enter into the discussion. Who CARES? Trying to design for the future of compilers controlled by those you do not pay is ludicrous. In C the variable name "new" used to be used like gangbusters until some jackass came along and made it a keyword in C++. "auto" used to mean one thing and now it doesn't. Things evolve, if your program is important enough you go with the flow. If your program is an OS you use gcc 4.3 for 10 or so years before upgrading to 4.6


In my understanding the flow is such that the Linux kernel compiles with a bunch of compiler options making gcc behave as in good old days when people were able to ignore the C standard and get away with it because compilers (and computers they ran on) weren't powerful enough. Most of undefined behavior was defined in 1989 and hasn't changed much since, so bad code not working anymore shouldn't come as a surprise, and yet it does. Or people force the compiler to be dumb (disable optimizations) and mute (disable or ignore warnings).


Top
 Profile  
 
 Post subject: Re: How would I start learning C for OS Development?
PostPosted: Fri Jan 20, 2017 4:24 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 723
Location: Tallinn, Estonia
alexfru wrote:
(do we call it C11?), but you don't need to concern yourself with it now. Most of the things are in C89 and C99.


We do, indeed. Please concern yourself with this latest standard, as it makes C much more pleasant to use.

_________________
Learn to read.


Top
 Profile  
 
 Post subject: Re: How would I start learning C for OS Development?
PostPosted: Fri Jan 20, 2017 4:27 am 
Offline
Member
Member
User avatar

Joined: Sun Dec 25, 2016 1:54 am
Posts: 204
alexfru wrote:
In my understanding the flow is such that the Linux kernel compiles with a bunch of compiler options making gcc behave as in good old days when people were able to ignore the C standard and get away with it because compilers (and computers they ran on) weren't powerful enough. Most of undefined behavior was defined in 1989 and hasn't changed much since, so bad code not working anymore shouldn't come as a surprise, and yet it does. Or people force the compiler to be dumb (disable optimizations) and mute (disable or ignore warnings).


I can see you are probably a purist and I can identify with that. In my work I have to be able to deterministically reproduce exactly the same code in exactly the same manner. This task amounts to turning off updates and literally building my entire toolchain from the same tarballs. It is infuriating but it has to be done.

But I must disagree with you, if only because of the context of this thread - a beginner wanted to know how to use C - not java, not tcl, not lisp, not smalltalk... C.

The issues you are raising, while valid, have no place in a discussion about learning C.

where they would be appropriate:

Long Term Design
Long Term Maintenance
Deployment
Testing (especially against multiple vendor compilers)
Analysis
Etc...

In other words, once young WaterOS has a codebase worth troubling over.

_________________
Plagiarize. Plagiarize. Let not one line escape thine eyes...


Top
 Profile  
 
 Post subject: Re: How would I start learning C for OS Development?
PostPosted: Fri Jan 20, 2017 5:22 am 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1108
dchapiesky wrote:
alexfru wrote:
In my understanding the flow is such that the Linux kernel compiles with a bunch of compiler options making gcc behave as in good old days when people were able to ignore the C standard and get away with it because compilers (and computers they ran on) weren't powerful enough. Most of undefined behavior was defined in 1989 and hasn't changed much since, so bad code not working anymore shouldn't come as a surprise, and yet it does. Or people force the compiler to be dumb (disable optimizations) and mute (disable or ignore warnings).


I can see you are probably a purist and I can identify with that. In my work I have to be able to deterministically reproduce exactly the same code in exactly the same manner.


My first full time job had projects that needed to compile with different compilers for different architectures and yield identical results (save performance differences). In my next full time job security and reliability of several projects were very important. So, this demanded writing solid and portable code and testing and reviewing code for language-specific defects.

But before we get there, we have to start somewhere. Naturally, nobody's born with knowledge of C.

I started to learn C in the late 90's. Many got internet access for the first time in Russia in 96 or so. For me it was very painful to download an application of interest that wouldn't compile or would but wouldn't work and I had to go through a lot of trouble to make them compile and work without knowing well the language or what someone else's code was supposed to do and how. I didn't have the right books nor a copy of the language standard. I had to reconstruct the language model as described in the standard by trial and error, from bits found in newsgroups and other places online. This is the wrong way to do it. It's inefficient and there still remain gaps after the exercise. How do you close them? You learn the language the right way. You may do it on the job. But you may not always get the job you want if the potential employer sees gaps in your knowledge in the areas deemed crucial.

Further, unlearning/relearning is problematic by itself. So, why not do things the right way when everything you need to do it is available (books, standards, advice, etc)?

dchapiesky wrote:
But I must disagree with you, if only because of the context of this thread - a beginner wanted to know how to use C - not java, not tcl, not lisp, not smalltalk... C.

The issues you are raising, while valid, have no place in a discussion about learning C.


I'm afraid we don't have an agreement here. :)

Edit: I should remind you that the context is "How would I learn C for my operating system?". It's gonna be especially tough to make bad code work without crashing, hanging or otherwise misbehaving with minimal debugging facilities.


Top
 Profile  
 
 Post subject: Re: How would I start learning C for OS Development?
PostPosted: Fri Jan 20, 2017 7:54 am 
Offline
Member
Member

Joined: Mon Jan 16, 2017 3:39 pm
Posts: 25
Umm... hmm... I thought I wanted to know how to use C for OS development? I know many functions already. You mean you just learn it naturally, right? Then, it comes to you? Well, I started Assembly with MS-DOS DEBUG and it gave me so much knowledge. Thank you for the 4.5 hours tutorial link by the way, guys!


Top
 Profile  
 
 Post subject: Re: How would I start learning C for OS Development?
PostPosted: Fri Jan 20, 2017 8:49 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 723
Location: Tallinn, Estonia
WaterOS wrote:
I know many functions already.


This doesn't make any sense. C language does not have any functions "to know", except the actual syntax for declaring and defining functions.

Which functions do you know then?

_________________
Learn to read.


Top
 Profile  
 
 Post subject: Re: How would I start learning C for OS Development?
PostPosted: Fri Jan 20, 2017 9:52 am 
Offline
Member
Member

Joined: Mon Jan 16, 2017 3:39 pm
Posts: 25
dozniak wrote:
WaterOS wrote:
I know many functions already.


This doesn't make any sense. C language does not have any functions "to know", except the actual syntax for declaring and defining functions.

Which functions do you know then?


Everything has functions. Java has system.out.println ;)

Is there something when you learn C for OS development? I don't want articles saying "Here's a tutorial for C. I learned from IBM's old website that isn't even on Archive... Try this out. You shouldn't use C. You should use Pascal or Basic".

I want some references for using C with programming an OS.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 132 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group