C in today's world? Is it useful to know?

ThatWasFat

Member
Dec 15, 2001
93
0
0
Well, I am kind of curious about C, because I like the idea of an extrmely fast language, native to Linux (I like Linux), and really low level, with lots of power. But, is C worth doing over C++ in today's world? Is the Linux programmer useful at all? Or should I go with C++? Or a higher level language. Also, what language do people write drivers in? I would LOVE LOVE LOVE to work for ATI or nVidia writing drivers. But, a head start is always good before I get to college, and I would like to get that head start now.

So, to recap.

A.) is C usful now?
B.) What are drivers written in?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
C++ works just as well as C in Linux. But that doesn't make C any less usefull.

Almost all drivers you find will be C with some inline asm if necessary.
 

ThatWasFat

Member
Dec 15, 2001
93
0
0
But is C useful today? Because I am picking up C pretty easily, with my limited C++ background. I can just move along with learning C if you people think it's a good idea.
 

BFG10K

Lifer
Aug 14, 2000
22,709
3,003
126
C is a subset of C++. Therefore if you learn C++ thoroughly you should know most of C.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
C is a subset of C++. Therefore if you learn C++ thoroughly you should know most of C.

Not that that's incorrect, but more correct is C++ is the successor to C. That's why it was named C++, it was a geek pun.

And I would suggest learning C first, it's a simpler language and unlearning all the OO stuff to get a handle on C would probably be harder than learning the C++ OO stuff after you know C.

Either way both will work and are extremely usefull. probably over 80% of all apps written for any OS are done in C, not counting small scripts or inhouse VB programs.
 

manly

Lifer
Jan 25, 2000
13,286
4,060
136
Nothinman,

C is a subset of C++. That was a design goal; Stroustrup originally called the language "C with classes".

I somewhat disagree with you though. It's somewhat well-known that C hackers can have a difficult time jumping to C++ because they don't think and design using OOP.

So if the goal is to learn C++, I'd say learning C first is not advisable. I wouldn't say you need to unlearn OOP if you later use C. Even with OOP, there's a fair amount of functional decomposition going on; it's just that the essential design is decomposed into objects.

But if you're accustomed to a procedural programming style, it can be difficult to make the mental leap to OOP.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
C is a subset of C++. That was a design goal; Stroustrup originally called the language "C with classes".

The reason I said what I did was because C was first, C++ was it's successor; I didn't disagree with him, just the wording which made C++ seem like it was better simply because it was newer. OK so I'm strange, but you have to decide whether you need the features of C++ in your program, not everything benefits from classes, templates, etc.

I somewhat disagree with you though. It's somewhat well-known that C hackers can have a difficult time jumping to C++ because they don't think and design using OOP.

Well since I'm not a professional developer, learned some of both in school and only really know enough to hack other people's code and write small programs myself, I won't argue =) But, work free time permitting, I'm trying to change that =)
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
C is used with many embedded systems.

The vehicle that you drive has an Engine control module which is running realtime (not Unix) and has an excellent chance of being written in C.

Most smart appliances have C inside the micro-processors.
 

thornc

Golden Member
Nov 29, 2000
1,011
0
0
I think the correct phrase should be: C++ is a superset of C.

As for learning C, I think it depends on what you want to do. If your planning to do real low level stuff it is a must know, if not
just go with C++ you will not be loosing anything special...

I think that Bruce Eckell has a point when in his book "Thinking in C++" it teachs the "C in C++" and that's it no more C in the book.

And Nothinman is correct when he says that that drivers are written in C or assembler...well in fact only the real
lowest level stuff in drivers will be in assembler that is usually embedded in C.

The point is that with C you get speed and with C++ you get ease of use. In the "Practice of programming" you can
find good examples of this. They have a program that is written in several languages (C,C++,Java and Perl) and the
C version is the fastest but also it's the one with more of code to acomplish the task!
 

manly

Lifer
Jan 25, 2000
13,286
4,060
136
It's a common myth that C++ is slower than C. Originally, C++ compilers were inferior but that was many years ago.

Modern C++ is a high-level language, and you simply pay for whatever language/library features you use.
 

travler

Senior member
Feb 28, 2002
220
0
0


<< C is used with many embedded systems.

The vehicle that you drive has an Engine control module which is running realtime (not Unix) and has an excellent chance of being written in C.

.
>>



one of my comp sci professors writes code for Ford for that very thing. using C of course.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
It's a common myth that C++ is slower than C. Originally, C++ compilers were inferior but that was many years ago

But it is true that C++ has slightly larger memory overhead for things like classes. That's one of the reasons low level things like the Linux kernel are written in C instead of C++. Having a linked list of structs for each memory page uses less memory than a class for each page.

For normal applications this doesn't mean anything, a few bytes here and there are nothing, more is probably lost to alignment.

The general point is that if you're just doing regular userland apps either one will work fine, both compile into small, fast executables and more depend in the libraries you use than the language itself. And C++ may make things easier if you have larger applications because classes and such make reusing code/objects easier.
 

kylef

Golden Member
Jan 25, 2000
1,430
0
0
Let me get this straight: you currently don't know C++ or C, right?

While it's true that you don't need to know C to learn C++, it certainly helps to understand "what's really going on" behind the scenes.

IMHO, everyone should learn procedural programming first. Whether it's with Pascal or C or Basic. Because unless the concepts of procedural programming are understood first, OO will only confuse things further.

Basically, you won't regret learning C if you're planning on learning C++ anyway. There is enough code out there written in C to make it a programming staple for years to come. And its speed is unmatched. The standard library be damned!
 

hooj

Member
Mar 26, 2002
192
0
0


<< Let me get this straight: you currently don't know C++ or C, right?

While it's true that you don't need to know C to learn C++, it certainly helps to understand "what's really going on" behind the scenes.

IMHO, everyone should learn procedural programming first. Whether it's with Pascal or C or Basic. Because unless the concepts of procedural programming are understood first, OO will only confuse things further.

Basically, you won't regret learning C if you're planning on learning C++ anyway. There is enough code out there written in C to make it a programming staple for years to come. And its speed is unmatched. The standard library be damned!
>>



Yea I would agree I started learning C first then moved on to an OO langauge like Java. The stuff I learnt in C helped me a lot when I came to learn a new language