Welcome, Guest. Please login or register.

Author Topic: Beginners 'C' programing group  (Read 13092 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline mikeymike

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 3420
  • Country: 00
    • Show all replies
Re: Beginners 'C' programing group
« on: February 12, 2004, 10:24:59 PM »
I'm trying to learn C though not on AmigaOS, at least not yet/considered it/sort of thing.

I'll get me coat :-)


... I tried to learn C once, off a guide on the net.  They got the "Hello World" code wrong.  I kind of gave up after that for a good long while :-)

I've now got a couple of books on the subject.  I've yet to read them, but... :-)
 

Offline mikeymike

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 3420
  • Country: 00
    • Show all replies
Re: Beginners 'C' programing group
« Reply #1 on: February 13, 2004, 12:32:36 AM »
I asked some techie friends a while back what they thought would be the best language for me to really get into programming.  They all suggested C.  So here I am :-)

 

Offline mikeymike

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 3420
  • Country: 00
    • Show all replies
Re: Beginners 'C' programing group
« Reply #2 on: February 13, 2004, 08:58:20 AM »
Well I'm interested in the idea, so chances are I'd frequent it probably more often than moderators just 'checking up', so I think you're safe there :-)
 

Offline mikeymike

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 3420
  • Country: 00
    • Show all replies
Re: Beginners 'C' programing group
« Reply #3 on: February 13, 2004, 12:33:33 PM »
Quote
Quote
Remember the whole nature of the new OS rewrite was to keep away from the metal so the rationale for writing in C or assembler and directly hitting the hardware is no longer there.

I'm afraid you got that quite wrong. There was never any need to hit the bare metal. People were just not used to program a multitasking environment and therefore made quite illegal assumptions about how the computer allocated its resources.

While he did get that quite wrong, so was your explanation :-)

Assembly for example hits the hardware directly.  The programmer tells the computer what memory/chip addresses he wants to reference, and the computer will access those exact addresses.  If they don't exist, the program will fail in one way or another.  Assembler is what's known as a "low level" programming language.  You pedantically and exactly program the computer.  You also need to use an implementation of Assembly that matches your CPU.

C is a higher level programming language than Assembly.    So for example you can use a compiler called 'gcc', which is written for particular operating systems and certain architectures like x86 (rather than a particular x86 CPU).  If you program in C, most of the legwork in specifying memory ranges for your program is done for you (though I don't know much about C, I think you can do things like specify particular memory ranges if you needed to).

Getting back to the point.  There's a reason why programmers "hit the hardware" directly.  Program performance is a damn sight better, and while Assembly programming is extremely pedantic, it is more flexible.  But you couldn't write a program to run on a modern operating system in Assembly, because the OS handles memory, cache, and hardware resources, it would tell your nasty little program that tries to circumvent it to get stuffed.

If say AmigaOS were completely written in C and then used on stock Amigas, it would be slower.  Most of the performance and responsiveness is derived from hitting the hardware directly.  OS4 is virtually a complete re-write from previous versions partly because of the architecture change, but mainly due to how the previous versions were programmed.

Someone can probably do a better job of explaining than I can :-)
 

Offline mikeymike

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 3420
  • Country: 00
    • Show all replies
Re: Beginners 'C' programing group
« Reply #4 on: February 13, 2004, 01:12:45 PM »
Quote
You'd be surprised for a "high level" language how low level C really is. Its much lower level than BASIC type languages and as a compiled language it is faster mostly due to the fact that it is quite close to the machine level already.

Which is why I said "higher level" :-)

 

Offline mikeymike

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 3420
  • Country: 00
    • Show all replies
Re: Beginners 'C' programing group
« Reply #5 on: February 14, 2004, 11:44:58 AM »
Quote
Still, why waste time with C when C++ exists?

Reading the rest of the thread might help :-)