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

Re: How should learning to program in c++ be approached, if learning objectives are sought to be customised?



On Mon, 30 May 2022 22:31:56 +0530
"Susmita/Rajib" <bkpsusmitaa@gmail.com> wrote:


>  To me, c appears as a hodge podge of low level and
> high level programming languages. Not a complete programming language
> in itself. c language appears to encourage a complex ecosystem of
> numerous programmers coming from diverse fields, all working as
> individual parts of a very complex machinery.

C is a language core, very low level and the implementation can be very
fast, almost one-to-one with assembler.

It is completely useless by itself, and will only actually do things
with the assistance of libraries. It requires a library to read a
keyboard, write to a screen etc. There is a set of standard libraries
provided with any C implementation.

> But c ecosystem appears to discourage a complete programmer who has a
> complete idea of the entire machinery and its individual components. A
> slight imbalance in super-specialisation could bring down an entire
> system.

If you're saying there should be a definitive set of libraries, and
nobody should ever be permitted to extend this set, I think you're on a
non-starter. C itself is fully defined and easy to learn. The idea of
learning the functions and interfaces of every library ever written for
C is not a trivial one, and when you finish you'll find another few
thousand were written while you were doing it.
> 
> I was really excited by the scope provided by Java. It appeared so
> easy to me that I could easily build a functional program, to aid
> memorising alphabets abcd... in the reverse, "which alphabet came
> before which alphabet" using a random function, in a graphical
> environment.
> 
> I had read that Java could be used to build an entire Operating System
> up by itself.

That is exactly what C was written to do, specifically in order to
write Unix. See Ken Thompson and Dennis Ritchie.

> In essence, therefore, device drivers as well.
> Unfortunately, that project of building an OS in Java was dropped long
> back. Java isn't used for building device drivers for the industry, so
> far as I have gathered.

I've seen a device driver written in Delphi, which is a visual OO
Pascal. That's hardly assembly language. I rather suspect that device
drivers are written in whatever way suits the programmer, rather than
using a particularly specified language.
> 

>  But I would request
> more specificity here:    (a)  if c++ could be used without using any
> other programming language to build a device driver. (b)  If it is
> practised industrially.

Why is this important to you? If you plan to spend much time writing
device drivers yourself, you will find out for yourself the most
practical way to do it. You pick the programming language (and OS, and
hardware platform) to suit the job to be done, not the other way
around.
> 
> I often wonder aloud why c wasn't re-built to have the modularity and
> OOP structure of Java. 

Isn't that basically what Stroustrup did, arguably not in the best
possible way? C++ is much older than Java, which almost certainly drew
heavily on experience with C++. But Java was designed as an interpreted
language, like Pascal, and while it can be compiled to machine code,
that wasn't really the intended usage, so it's not really built for
speed.

> Yes, I know
> that the demand wasn't there, when programmers thought that 1024KB
> would address all problems of the world.

C was written when 64K of RAM was typical, for the early minicomputers.
> 
> But a language could be re-built to incorporate every programming
> need. Then aided by a huge library of code snippets, functions,
> objects, etc., like Oracle Java repository. But to reach the lowest
> level possible.
> 
It seems to me you've pretty much described C, as well as what you said
was wrong with it.

As an aside, I've always found the best way of learning a new language
was to have a project of my own and to use the language manuals to find
out how to achieve what I needed to do. I learned Pascal on the BBC
Micro in writing a simple business program (no practical spreadsheet
for 32K of RAM), and my first C program wasn't Hello World, it was a
recursive program using pointers to optimally fit audio tracks on
cassettes.

-- 
Joe


Reply to: