[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Book questions



On Tue, Apr 14, 2015 at 12:36:28AM +0800, Bret Busby wrote:
> On 13/04/2015, Reco <recoverym4n@gmail.com> wrote:
> 
> <snip>
> 
> >Learning C is simple and
> > fun. Just read classic K&R treatise, do all the examples. Did so back in
> > high school, and no brain was damaged in the process :)
> > The only problem today is to get a C compiler that understands K&R C.
> >
> 
> I have not programmed in "C" for about 20-25 years, now, but, from
> memory, with compilers, like "C" compilers, don't they have a switch
> that can be set,  so that they accept only ANSI code, such as ANSI
> "C"?

*ANSI* C - yes. For instance, gcc has this wonderful '-ansi' switch.
It's even possible to choose the exact version of ANSI C standard (i.e.
-std=c99).
*K&R* C - no. At least, gcc-4.7 has no switch for this that I'm
aware of.


> The question is, what is the nature of the understanding that you want
> of Linux? Is it the interaction between the layers, for example, the
> HAL and the higher layers; is it the multitasking; is it understanding
> administration (such as, do not do one of the whoopsies - using "chmod
> .", as one (other) student did, when I was learning UNIX), is it
> scripting and shell processing, or, is it the "design and
> implementation" of the operating system, and, in that, does what you
> want, include comparative design and implementation of operating
> systems?

Let's see as I didn't have OS design in mind. Something like:

Exit codes and their value in real life.
Strings handling, memory allocation.
Process control and daemonisation (sp?).
Signal handling.
Inter-process communication (sockets, pipes).
IP protocol use and abuse.
Shared memory.
Threads.
Libraries and their usage.

Bonus points are granted if code can be compiled on more than one
processor architecture. Extra bonus points for doing it in more than one
POSIX-compatible OS.

Of course, those are basics. There's nothing in those that cannot
be implemented in any programming language.

But then - you encounter a mis-behaving program. You use strace(1) or
ltrace(1) and, hey, suddenly you understand what's going on without even
looking at the source. You can use gdb to pull out tricks deemed
impossible by others. You can use valgrind to point out memory leaks or
use-after-free. All that possible by the fact you've learned C, and
you can't get more closely to OS than using C.

That does not invalidate the fact that learning C as a first
programming language can be pretty hardcore (I was taught BASIC first,
then Pascal), and for the complex program you'll probably want something
else as by today's standards C has poor result/effort ratio.

And please think of the children :) Teaching young ones something as
volatile and ever-changing as Python (or, $DEITY forbid, Ruby) can be
considered cruel and abusive :)

Reco


Reply to: