Difference between revisions of "Intro to Programming With C"

From FreekiWiki
Jump to navigation Jump to search
Line 17: Line 17:
 
== C vs. C++ ==
 
== C vs. C++ ==
  
C++ was developed later in the game when the Object Oriented language craze began.  The most obvious difference is that C is procedural based and C++ is object basedHowever, C++ was implemented as a superset of C, so the entire C language is embedded in C++ including the procedural paradigm.  In many cases the language is referred to as C/C++.
+
C++ was developed later in the game when the Object Oriented language craze began.  The most obvious difference is that C is procedural and C++ is object oriented.  C++ was implemented as a superset of C, so the entire C language is embedded in C++ including the procedural paradigm.  In many cases the language is referred to as C/C++.
 
 
  
 
== Some Historic notes ==
 
== Some Historic notes ==

Revision as of 15:22, 2 January 2010

This is a work in progress

Contact is Kurt Krueger allez@att.net

At some time before the first class is taught, there will be useful information in this Wiki.

However, unlike the page for the Bash class, there will be no attempt to make this a web course.


Why C ?

C can be defined as the root of all evil. It was developed in the 70's for the purpose of generating neat programs. One of the neat things created was the Unix operating system, Linux is a PC port of Unix. All languages developed under Unix have their roots in C. C is still widely used in the industry.


C vs. C++

C++ was developed later in the game when the Object Oriented language craze began. The most obvious difference is that C is procedural and C++ is object oriented. C++ was implemented as a superset of C, so the entire C language is embedded in C++ including the procedural paradigm. In many cases the language is referred to as C/C++.

Some Historic notes

In the days preceding the C language, operating systems were generally written in assembly code. This is a very low level and tedious, error prone way to write code. But since assembly code is one to one with the underlying processor's instruction set it created very fast and concise code. The coder also had full control of anything the processor could do.

About the time that C was conceived, a ground breaking computer architecture was created by Digital Equipment Company (DEC, bought by Compaq, in turn bought by HP) named the PDP-11. One of its claims to fame was a stack based instructions. The implementation of these instructions was native to the hardware. Competitor's hardware would require several instructions to accomplish the same thing. This was very important in the days where maximum computer memory was in kilobytes and clock speeds were under 1 Mhz. The PDP-11 could handle a maximum of 28K or memory as it was created as a mini computer.

The developers of the C language wanted something that was of a higher level, e.g. more readable and more productive. But they didn't want to lose any of the control that assembly language afforded. This resulted in syntactic constructs that were strange to the mainstream programmers of the day (i.e. *p++ = *t++, this resulted in a single hardware instruction that moved an item of data in memory AND set up to move the next data item). You only had 28K of memory, you had to as much as possible with each code instruction so you had some memory left over for your data.