Is C worth the effort?

Hello guys,
I have a little question.
I think about learning c or c++ because im very interessted in low Level programming. And because i love Unix Too i thought C would be the better choice since Most it Done in c. Or should i learn c++?
Because C++ has all this nice Features like oop and stuff that makes programming easyer.

What i want to do.later is Programm.on the.Nintendo ds and.such things. And perhaps some day a little OS Kernel
For arm or such thing well just for fun ofcause

Sry for.typos and so on. Writing from.Phone

Greets dryPants

OOP doesn't necessarily make everything easier. What matters is what you do with it. It's a programming style like any other. It's possible to write disorganized, messy C++ code and rigorously organized C. I always think you should learn C before you learn C++, C++ tries to hide a lot of the messier things but they're not really gone, and can bite you if you don't know them. It's a lot easier to understand with a proper foundation in C.

Writing in C makes it easier to export your code as libraries, even to other languages... Big ones like Perl and Python make it possible to build special loadable modules which use them, but there's a lot more hoops to jump through for calling C++ functions than C ones.

And if you want to program embedded things like handheld video games, C is probably the language you'll deal with. Also to handle the linux kernel, C is what you must know.

As for whether they're worth the effort... There's a plethora of other languages these days ranging from perl and python and ruby all the way to extremely high level things like javascript... For many purposes they're simpler and less effort than C. Except -- what were they all written in? C/C++, of course.

Every programming language is an abstraction layer between the bare machine and the human thought process. In some languages this layer is thicker than in others: in Assembler it is very thin (almost nonexistent) and in highly abstracted languages like Oberon it is very thick.

Both these concepts have up- and downsides: the thinner the abstraction layer is the more you are in contact with the real workings of the system. You have more to do and more things to observe but get to utilize the machine to its fullest capacity. The thicker this layer is the less you have to observe and the less you have to know about the real machine as you work against an abstracted (and simplified) concept of the system, but on the other hand the less efficient your code will be. All programming languages are tradeoffs in this respect (and some other areas).

The last 50 years saw a whole lot of programming paradigms: structured programming, object orientation, data-centered programming, and whatnot. Basically, all these paradigms are ways to help the programmer keep his code as organized and understandable (=> maintainable) as possible. There are good reasons to employ any of them and good reasons why to avoid them. For every paradigm i could write a demo program where it looks bad and another where it seems the natural thing to do.

Do the sensible thing: learn to program with an emphasis on algorithms, not on programming methods. It is like with (human) languages: if you know how to organize your thoughts well and how to express what you mean without any margin of error you will be able to transport that capability into any language, regardless how little you speak it. But if you know five different languages but have difficulties phrasing a simple fact your communication attempts will fail in any language.

It is not very popular nowadays, but i even suggest to start learning Assembler before anything else: only knowing in-depth how a system works will let you appreciated what a compiler does for you and knowing how to program in a structured language (C) will make you appreciate what a C++-compiler does in addition to a C-compiler once you switch from C to C++. There is a reason why Donald Knuth (my personal programming hero) developed his own virtual Assembly language for a hypothetical system for his book "The Art of Computer Programming".

I hope this helps.

bakunin

1 Like

At First thanks for your Help :slight_smile:
So you say learning c First makes more sence, because C++ hides some nasty stuff. That makes sence :stuck_out_tongue:
How much Assembler should i learn? And which? X86 or AMD64?
And yes Linux Kernel is also a nice topic i would like to explore in the future.
So learning c should be worth the effort.

Do you have some other good advices for me?

Unless you're digging deep into the parts of the kernel which do memory management and mode switching, you won't have a genuine need for assembly language, but there is some value in learning it. In assembly you see the mechanics of how everything is declared as physical memory -- local variables in C are stack-segment variables in assembly, global variables in C are data-segment ones in assembly, functions are memory addresses in code-segment in both C and assembly, etc, etc. C is technically not dependent on stacks or segments, but I dare you to show me a modern system which doesn't have these in some way.

amd64 is x86 with more and larger registers. Most instructions are the same, but more options are allowed for them.

Hi dryPants...

Yes. Python is a very strict language and has libraries for just about anything that anyone in the coding industry is likely to encounter.

Before deciding to hammer any hardware, (and yes I have done much in this area), experiment coding for something less likely to cause you serious headaches.

Once you feel confident try experimenting with an Arduino, USB type, as an example.

In *NIX flavours it is easy to R/W from/to even with shell scripting. I have uploaded much code to do this mainly in Python for multi-platform use, (including a serial port stock AMIGA A1200 with HW mods to the USB Arduino), I love "banging the metal"...

I personally love assembly but........
......don't expect to get to Ring 0 directly in current OSes you WILL have serious headaches finding that you can't. The days of MS-DOS where BIOS and other assembly access and calls are long gone.

Study things like ISA, PCI bus design and limitations as examples then progress to current technology. I studied the PCI slot for months only to realise my limitations at home built hardware was way beyond any beginners scope.

Hope this helps...

Well its not like i haven't any programming expirence. I learned already a bit of Python / ruby and started learning Java for school and private fun.
But o know i would take years to Master assembly language on x86 / AMD64. And i also know it will take some years till i can develop good in C but i really like this low Level things. Its so interessing i really want to learn it

edit:

Could someone suggest me a good source for learning the assembly language? Because everything i find is very old and I'm not sure if I can still use it :confused:

sorry for badgering you again, but I'm not sure where to start learning the assembly language. All the books I find are very old and I'm not sure if I should read them today.
Could you suggest me a book or a website to start learning?
That would be really helpful for me.
Greets

I would like to suggest you to learn C first as it would be easier to learn C++ after C as C++ contains advanced features of C.

search what linus torvalds thinks of C++

That's good enough for me :wink: