OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:07 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 30 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Advanced programming concepts
PostPosted: Sat Dec 31, 2016 3:21 pm 
Offline
Member
Member
User avatar

Joined: Tue Mar 06, 2007 11:17 am
Posts: 1225
REMEMBER: You must first remember what program you wanted to do originally. Write it down in your notes, and also here.

What program do you want to do? Based on that, is the right way to learn the different functions, googling each function you need to use as you need to know how to use them.

It's like studying a career for a field. You will not achieve much more than general knowledge if you study sequentially. You will achieve lots of stuff and goals if you treat your own ideas and programming goals, projects and actual applications you want to create, as the most important.

Just like when you choose a career. Here you need to choose a program or several ones you want to do, and then let all the available resources and information help you, but let your program dictate what you want to learn. After several programs or even after several pieces of your program, you'll find you'll become an expert all the same, but in a more useful way, writing the programs you wanted to create when you decided to learn how to program.

_________________
Live PC 1: Image Live PC 2: Image

YouTube:
http://youtube.com/@AltComp126/streams
http://youtube.com/@proyectos/streams

http://master.dl.sourceforge.net/projec ... 7z?viasf=1


Top
 Profile  
 
 Post subject: Re: Advanced programming concepts
PostPosted: Sat Dec 31, 2016 3:48 pm 
Offline
Member
Member
User avatar

Joined: Sun Dec 25, 2016 1:54 am
Posts: 204
Mark12 wrote:
Hey, I'm midway to learning C anyway. I don't think I should give up now.


I cannot agree with the suggestion to learn Java first. Please keep up with the C.

If anything, learning C helps you to understand how the actual machine works.

Go spend $50 on a single board computer like a raspberry pi or such and learn C on it.

Why?

Because you can fiddle with memory. You can fiddle with output ports. Watch lights flash on and off in a while() loop. Read the state of a button (1) and put a dot on the screen.

It is a visceral wonderful experience. Probably 99% of the people on this forum do what they do cause they love it. Just look at the thread about WOW Moments with your OS!

Java will never give you that.

The world needs more C programmers... Join Us.

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


Top
 Profile  
 
 Post subject: Re: Advanced programming concepts
PostPosted: Sat Dec 31, 2016 3:55 pm 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
This is the attitude I was talking about. Stay well away from it. :)

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
 Post subject: Re: Advanced programming concepts
PostPosted: Sat Dec 31, 2016 5:22 pm 
Offline
Member
Member
User avatar

Joined: Sun Dec 25, 2016 1:54 am
Posts: 204
Love4Boobies wrote:
.....People tend to get attached to things and form cults around them....

This is the attitude I was talking about. Stay well away from it. :)


Not quite clear how I was expressing an attitude other than perhaps cheering the C language camp at the end.

The meat of my post was to expound on the use of a raspberry pi as a means of learning the hardware through learning about C. I believe the term "visceral" sums it up.

Staying well away from it? Exactly how did anyone ever become a programmer without becoming enamored of it? without becoming obsessive about it? Geez this is osdev.org where people can tell you the Nth bit to set PE...

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


Top
 Profile  
 
 Post subject: Re: Advanced programming concepts
PostPosted: Sat Dec 31, 2016 5:51 pm 
Offline
Member
Member
User avatar

Joined: Tue Aug 02, 2016 1:52 pm
Posts: 286
Location: East Riding of Yorkshire, UK
dchapiesky wrote:
Mark12 wrote:
Hey, I'm midway to learning C anyway. I don't think I should give up now.


I cannot agree with the suggestion to learn Java first. Please keep up with the C.

If anything, learning C helps you to understand how the actual machine works.

Go spend $50 on a single board computer like a raspberry pi or such and learn C on it.

Why?

Because you can fiddle with memory. You can fiddle with output ports. Watch lights flash on and off in a while() loop. Read the state of a button (1) and put a dot on the screen.

It is a visceral wonderful experience. Probably 99% of the people on this forum do what they do cause they love it. Just look at the thread about WOW Moments with your OS!

Java will never give you that.

The world needs more C programmers... Join Us.


I think that a microcontroller like an ATMega (and a tool to write your program to it) would be a better investment.
They're usually cheaper and a lot more fun to play with, and you can learn a bit about electronics too.

_________________
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Compiler Development Forum


Top
 Profile  
 
 Post subject: Re: Advanced programming concepts
PostPosted: Sat Dec 31, 2016 5:55 pm 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
I just meant that I think the healthy attitude to have is to work on the problems that are interesting to you instead of declaring your allegiance to a tool or to a camp. If you do the latter, you are likely to come up with inappropriate solutions or no solutions at all.

Regarding the C and the RPi, I also have to disagree. What's so different between pressing a key on your keyboard and having a pixel light up on the screen and having a button and an LED connected to a couple of GPIO pins and doing what is essentially the same thing? If he just wants to learn C, he probably shouldn't get distracted by what are esentially toys. And, as I've explained, conflating C with hardware programming is the wrong way to think about C.

If he really wants to learn about hardware, then he should pick up a book on computer architecture, assembly, and/or electronics. That's its own separate subject and there's no need to artificially fuse them together even if they may have some overlap as far as practical applications are concerned.

If your argument was that hardware programming can help him understand how to write better C or better code in general, then I also have to disagree. The real challenge in programming is designing good abstractions and having good theoretical grounding (algebra, trig, calculus, how to design and analyze an algorithm, etc.). Seeing your loop in action by playing around with blinky lights, buzzers, and spinning things will only take him so far. Most children no older than 5 can write that sort of code with a little exposure but they certainly can't write any code that's worth anything.

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
 Post subject: Re: Advanced programming concepts
PostPosted: Sat Dec 31, 2016 9:12 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 03, 2016 3:13 am
Posts: 64
So where is this thread going?


Top
 Profile  
 
 Post subject: Re: Advanced programming concepts
PostPosted: Sat Dec 31, 2016 9:40 pm 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
Despite the title, the thread was always about C and learning C. I don't think we've moved away from that. :)

It's alright for people to disagree. Perhaps you can still get something useful to you out of all these replies.

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
 Post subject: Re: Advanced programming concepts
PostPosted: Sun Jan 01, 2017 12:15 am 
Offline
Member
Member
User avatar

Joined: Sun Sep 19, 2010 10:05 pm
Posts: 1074
When I got started in osdev, I avoided assembly like the plague. But I eventually learned it through osmosis, because half of the code examples that you find are written in assembler.

And, assembler is as close to the language that the CPU understands that you can get, short of using a hex editor.

C, on the other hand, will generate several CPU instructions per line of code. To me, the 1 to 1 nature of assembly lines to CPU instructions makes it much easier to understand when you are just getting started.

I would start with assembly, then move to C, then C++, then C#. But that's just my opinion. If someone had told me to learn things in that order 7 years ago, I would have just ignored them. So, whatever... :)

_________________
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott


Top
 Profile  
 
 Post subject: Re: Advanced programming concepts
PostPosted: Sun Jan 01, 2017 12:30 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
Why is it relevant to know precisely what instructions a CPU is executing when running a program compiled from C, as long as it adheres to the program's semantics? And how do you translate that knowledge across compilers or architectures?

(I'm not counting the incredibly rare case where a super tight loop needs to be micro-optimized as hell because slightly more powerful hardware is unavailable since that does sound like a valid use for assembly, unlike simply wanting to have a single instruction generated per line of code, which to me sounds like an arbitrary desire.)

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
 Post subject: Re: Advanced programming concepts
PostPosted: Sun Jan 01, 2017 1:07 am 
Offline
Member
Member
User avatar

Joined: Sun Dec 25, 2016 1:54 am
Posts: 204
Happy New Year!

I read my post again after a while... I see how you read it now. No disagreements just the warm glow of my old 20" CRTs cooking my brains.

Someone mentioned osmosis - it's true... OSDev best place for it.

May your OS not SEGV

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


Top
 Profile  
 
 Post subject: Re: Advanced programming concepts
PostPosted: Sun Jan 01, 2017 1:19 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
dchapiesky wrote:
May your OS not SEGV


That's unlikely to happen, unless you run your OS inside of another OS. :)

Happy New Year!

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
 Post subject: Re: Advanced programming concepts
PostPosted: Sun Jan 01, 2017 3:17 am 
Offline
Member
Member
User avatar

Joined: Sat Dec 03, 2016 3:13 am
Posts: 64
Happy new years to all of you too.


Top
 Profile  
 
 Post subject: Re: Advanced programming concepts
PostPosted: Sun Jan 01, 2017 2:29 pm 
Offline
Member
Member
User avatar

Joined: Sun Sep 19, 2010 10:05 pm
Posts: 1074
Love4Boobies wrote:
Why is it relevant to know precisely what instructions a CPU is executing when running a program compiled from C, as long as it adheres to the program's semantics? And how do you translate that knowledge across compilers or architectures?

Because, as an os developer, you are going to be responsible for implementing a lot of platform specific code, like interrupt handlers, before you can do things like open files or create threads.

And, as I said, a lot of examples on this site are written in assembly only. So you're probably going to need to learn it anyway.

In OS development, there are a few things that you just can't do in C, so if you had to pick just one language...

But I was just trying to point out that IF you wanted to understand how your machine really worked, I would recommend starting with assembler, so that you could see every stage of the process, rather than just typing one line of code that invisibly does 100 things, depending on which compiler you used.

But, either way works. In the end, you'll end up at the same place.

_________________
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott


Top
 Profile  
 
 Post subject: Re: Advanced programming concepts
PostPosted: Sun Jan 01, 2017 3:14 pm 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
Well, the question was about which order things should be learned in. I'm not advocating that assembly not be used when writing a kernel. Obviously, C is designed to be portable so it's more of a common denominator of typical machines so you can't really write a full OS in standard C. But the OP expressed his interest in learning C, not learning how the hardware works. (And I don't think assembly alone teaches that very well anyway because it misses out on all the architectural details.) However, "higher-level" languages do make it possible to write most of an OS portably (you can even abstract interrupts using mechanisms such as signals---in the case of C, that is their original rationale), with very few exceptions (like context switching and other platform-specific things, such as switching CPU modes in the case of x86).

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 40 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