Minimal skills

Polytropon freebsd at edvax.de
Fri Jun 5 04:23:55 UTC 2020


On Thu, 4 Jun 2020 22:07:27 -0600, Brandon helsley wrote:
> Then you are recommending new learning material for C?

You don't do anything wrong by reading older C books like
the original K&R, but don't assume that the language and
its usage hasn't changed. Newer books will surely be written
with ANSI C and newer standards in mind. Sometimes the older
material can help you understand certain things better,
maybe because newer material either assumes it as known,
or simply doesn't mention it at all. It is never bad to
know older versions of the C language because you will
surely find code where you might be tempted to think: "Why
did the programmer do it this way? C has a specific construct
for that!" - except when the code was written, the C standard
did _not_ have that specific construct, so the programmer
had to invent it before its time. :-)

Personally, I would say the best approach is to have an
older and a newer book about C. The basic K&R material
is _never_ wrong; add knowledge about the new standards,
because you will also face code with those in mind.

Here is something for illustration:

	https://olvemaudal.com/2011/10/10/deep-c/

Depending on what you want to deal with (in FreeBSD code),
you'll need a certain level of understanding: not just the
C language, but also the library functions used. Luckily
all the sources are present in /usr/src, so when you encounter
a bug, you can always find out _where_ it comes from, and
therefore have a good starting point.

Many years ago, I solved a data recovery problem by reading
and modifying the code of the fsck program for the UFS
filesystem, and reading the McKusick paper on UFS. Without
understanding C, and without understanding how UFS works,
I would not have been able to do so.



> Is it C or C+ or C++ that I'm to be benefited to learn
> when working with freebsd?

FreeBSD (as the operating system) contains sources mostly
in the form of C and assembly (here, primarily the drivers),
but there's also C++, simply because there is no language
that can be considered "one size fits all". You should
probably know the fundamentals of C, so you recognize
the typical elements of the language. From this foundation,
you will be able to understand the purpose (!) of code,
rather than just the components it is composed of.

As FreeBSD consists of elements on different levels of
complexity, such as boot code, standard libraries, user
programs, filesystem code, device drivers, communication
stacks, and so on, the means of implementation also differ.
This is not a mistake - it's the logical conclusion.



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list