MESSAGE
DATE | 2008-06-29 |
FROM | Ruben Safir
|
SUBJECT | Re: [NYLXS - HANGOUT] C Programing Workshop
|
On Sun, Jun 29, 2008 at 08:36:20PM -0400, Ronny Abraham wrote: > Ruben, just trust me on this enough to download the book and read a > chapter. You'll see exactly what I mean if you do that. It's worth > it. I'm not steering you wrong on this. And if I am, you'll only end > up losing 20 minutes of your life. > > autoconf would be great! That alone would be enough to get me to sign > up. The only reason I didn't mention it, is because I didn't think > you'd be willing to deal with it. > > As far as C is concerned, it seems more reasonable to me to stick with > the Kernigan and Ritchie book, as that does a great job and it's the > standard everyone uses anyway. But any book can get the job done > really. C is a workhorse and pretty simple to figure out. >
The King book is actually very superior to K&R. It teaches C concepts exceptionally well. It's just damn expensive. I can always tell someone who learned C from K&R. They tend to do some weird things.
> The Strousberg text is a massive pain in the ass to deal with. I > know, they tried using it at NYU and everyone, I mean EVERY ONE of the > students bought another text to deal with the course (including me). > No one understood what the hell the Professor teaching the course was > saying, and he was actually pretty damn good (he's the current head of > the compsci grad division).
Was that Meltzer? What was his name?
> Of course, I hadn't heard of Eckel then, > so I ended up making the grade without understanding a thing. Which > is probably how everyone else did too. > > I think Strousberg is good if you have a pretty fair grasp of the > language before you pick it up. Otherwise, it's useless. > > Compared to Python, or Scala, or Smalltalk, C++ is a horrible > language.
You can make some serious money with Smalltalk if you know it.
> No question about it. But it definitely has it's uses and > since it's very popular it's well worth learning. > > However, I don't agree with your objections to OO. Building a thing > in chunks that interact seems to me to be the basis of OO. It works > and when it's done right it makes things a lot clearer which is all I > really care about. >
Debugging simplifiation and reuse is the main goal OO or any other programming format. I thnk your agreeing with me, not disagreeing. But if you jump straight to OO programming without the grounding to procedureal programing, you won't have a damn clue what your code does, let alone how it affects security or what it does in gdb.
Remember -> In, Out, Side Affect, Repeat.....
Its the Universal Law.
Ruben
> On Sun, Jun 29, 2008 at 3:44 PM, Ruben Safir wrote: > > On Sun, Jun 29, 2008 at 02:47:24PM -0400, Ronny Abraham wrote: > >> If you're going to teach a class, I think it's important to also go > >> into makefiles. Personally, I hate makefiles and prefer to use scons > >> (it's python based and a hell of a lot simpler). Nevertheless, you > >> need to know how makefiles work if you want to do anything usefull > >> with the majority of projects out there. I would sign up for a class > >> if you intend to explore that aspect. > >> > > > > > > Yeah, I agree. We should conver autoconf and make at some point. > > > >> Also, if you are going to go into C++, it's better to stick with Bruce > >> Eckels book Thinking > >> in C++ It's downloadable and free (as in beer), so there is no > >> reason not to use it. It's also the best book you are ever going to > >> find on the language. > >> > > > > We can use any book that you desire, but I'm going to stick with my text and > > will refer to it. I'm not extremely happy with the text, but I have a head > > start with it. I really was thinking of using the Strousberg tet. > > > >> He has a second volume covering the Standard Template Library, but > >> unfortunately I never found the time to go through it. > >> > >> The thing that makes Eckel stand out is that he explains why things > >> are done in a certain way. > > > > For what it is worth, I believe the paragin for OO languages is sommewhat > > contrite, and I'm intersted in why things are done in a certain way > > only to the degree that things are made easier to debug and read...period. > > I go over much of this conceptually in the advanced Perl class, but frankly > > the OO guys are whacked. Squeezing out all proceduale code from a launguage > > defies the basic logic of how computers work and makes for a lot of bad > > code which is tough on y carpul tunnel syndrome. > > > >> And since he was on the standards board > >> for 10 years, he also has no problem being open about what is wrong > >> with the language. > >> > > > > A lot is wrong with C++ and nearly every other language. C++ is famous for > > making people unhappy, and so is c and LISP and Perl and any language that > > has been around and used enough to bread contempt ;) > > > > Ruben > > > >> -ron > >> > >> On Sat, Jun 28, 2008 at 10:04 PM, Ruben Safir wrote: > >> > The C programming language was invented side by side with Unix. The King text goes through > >> > much of the history of the language. Here I'd like to make a few points both in the general > >> > and specific to GNU/Linux as a platform for C development. > >> > > >> > Oxymoronic as it sounds C language is a bare bones specification without anything useful. > >> > All it requires is the keyword main, which defines the root function that everything else > >> > is piled into. Everything that C does is imported from external libraries. These libraries > >> > are defined, in the simplist case, on top of your program. > >> > > >> > For example, on page 10 of the King book is the following program: > >> > > >> > #include > >> > > >> > main(){ > >> > printf("To C, or not to C: that is the question \n"); > >> > } > >> > > >> > which was inherited from the K&R text. The first line defines the > >> > library stdio.h which c is to import. The main keyword is present > >> > (which defines the required function main() to be explained later, > >> > and the function printf which is defined in the library stdio.h. > >> > > >> > Unlike programming languages such as Perl, Python and Rudy, C is a compiled > >> > programming language. It needs a compiler to make a binary program that > >> > can then be executed. The binary has machine like instructions which your > >> > computer can directly understand. Unfortunately, your computer doesn't speak > >> > English (or Spanish, Russian, Japanese, Manderin, Hebrew, or Udo). It speaks > >> > binary. C is the interface between human language and machine code. The binaries > >> > are very low level and C as a language, today, is considered to be very close to > >> > the machine. You'd have to write programs in Assembly to get much close to your CPU. > >> > > >> > Therefor, you need a C compiler to translate your C Programming text into machine code. > >> > At one time suc compilers were expensive and hard to get. Thanks to Richard Stallman and > >> > friends, today we have compilers on almost every GNU based system. That compiler is called > >> > gcc. Compilers do three things: Parse, compile and link. > >> > > >> > When you call: > >> > > >> > gcc file.c > >> > > >> > It loads file.c into the compiler. It then parses the programming you created and checks > >> > for errors. It then analysis the symbols in your program and looks for their programming > >> > definitions in the libraries that you call with #include. It then the different code > >> > machine code peices it finds into a single binary. > >> > > >> > The gcc compiler is very complex and learning C includes learning much about the compiler > >> > and also the debugger, called gdb. Both are documented with man pages, and have full books > >> > which are available from the Free Software Foundation and worthy additions to your library. > >> > Both are included in the NYLXS library as references. > >> > > >> > Any editor can be used to make C programs, but I strongly recommend learning either EMACS > >> > or VI. EMACS has a GNU version, and VI has a version called VIM which can be downloaded and > >> > used. I perfer the VIM editor and will use in in example and demonstrations. No editor > >> > wars are needed here. I will say, however, if your using EMACS, then LEARN it. It is not > >> > Microsoft Notepad. > >> > > >> > After editing this first program run the following command on the command line: > >> > For this workshop, the "$" or "ruben-at-www2:~/cprog>" is the shell prompt. Your prompt > >> > on the NYLXS server will look like the second example. > >> > > >> > > >> > $ gcc -Wall file1.c -o file1 > >> > > >> > the output will look like this: > >> > ruben-at-www2:~/cprog> gcc -Wall file1.c -o file1 > >> > file1.c:3: warning: return type defaults to `int' > >> > file1.c: In function `main': > >> > file1.c:5: warning: control reaches end of non-void function > >> > ruben-at-www2:~/cprog> > >> > > >> > > >> > The compiler gives you 3 warning messages. I won't go into them currently, but in a few > >> > weeks it should make sense to you. We will, however, fix the warnings later. For now, if > >> > you look at your directory > >> > > >> > ruben-at-www2:~/cprog> ls -l > >> > total 12 > >> > -rwxr-xr-x 1 ruben staff 7041 2008-06-28 21:45 file1 > >> > -rw-r--r-- 1 ruben staff 86 2008-06-28 21:35 file1.c > >> > > >> > file1.c is the file we are editing. You see it has no permisions to be executed. > >> > file1 is the new executable we created. In addition. you see that it is executable. > >> > gcc makes it executable permisions for us in most systems. We run our new program > >> > on the command line like this: > >> > > >> > ruben-at-www2:~/cprog> ./file1 > >> > To C, or not to C: that is the question > >> > > >> > The C language defines the function main() and not much else. However, it is defined > >> > as a function that returns an integer. We didn't return anything. We can fix this with > >> > a "return function". > >> > > >> > We return a 0 by convention unless we are trying to indicate an error or other message. We also > >> > put the keyword 'int' infront of main which explicitly defines that main returns integers. > >> > > >> > Our program not looks like this: > >> > > >> > #include > >> > > >> > int main(){ > >> > printf("To C, or not to C: that is the question \n"); > >> > return 0; > >> > } > >> > > >> > and when we compile: > >> > > >> > ruben-at-www2:~/cprog> gcc -Wall file2.c -o file2 > >> > ruben-at-www2:~/cprog> > >> > > >> > No warnings. > >> > > >> > and when we run it, it looks like this: > >> > > >> > ruben-at-www2:~/cprog> ./file2 > >> > To C, or not to C: that is the question > >> > ruben-at-www2:~/cprog> > >> > > >> > > >> > > >> > Next - Comments and C varriable basics. > >> > > >> > > >> > > >> > -- > >> > http://www.mrbrklyn.com - Interesting Stuff > >> > http://www.nylxs.com - Leadership Development in Free Software > >> > > >> > So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 > >> > > >> > http://fairuse.nylxs.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 > >> > > >> > "Yeah - I write Free Software...so SUE ME" > >> > > >> > "The tremendous problem we face is that we are becoming sharecroppers to our own cultural heritage -- we need the ability to participate in our own society." > >> > > >> > "> I'm an engineer. I choose the best tool for the job, politics be damned.< > >> > You must be a stupid engineer then, because politcs and technology have been attached at the hip since the 1st dynasty in Ancient Egypt. I guess you missed that one." > >> > > >> > (c) Copyright for the Digital Millennium > >> > > > > > -- > > http://www.mrbrklyn.com - Interesting Stuff > > http://www.nylxs.com - Leadership Development in Free Software > > > > So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 > > > > http://fairuse.nylxs.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 > > > > "Yeah - I write Free Software...so SUE ME" > > > > "The tremendous problem we face is that we are becoming sharecroppers to our own cultural heritage -- we need the ability to participate in our own society." > > > > "> I'm an engineer. I choose the best tool for the job, politics be damned.< > > You must be a stupid engineer then, because politcs and technology have been attached at the hip since the 1st dynasty in Ancient Egypt. I guess you missed that one." > > > > (c) Copyright for the Digital Millennium > >
-- http://www.mrbrklyn.com - Interesting Stuff http://www.nylxs.com - Leadership Development in Free Software
So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998
http://fairuse.nylxs.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
"Yeah - I write Free Software...so SUE ME"
"The tremendous problem we face is that we are becoming sharecroppers to our own cultural heritage -- we need the ability to participate in our own society."
"> I'm an engineer. I choose the best tool for the job, politics be damned.< You must be a stupid engineer then, because politcs and technology have been attached at the hip since the 1st dynasty in Ancient Egypt. I guess you missed that one."
© Copyright for the Digital Millennium
|
|