Advertisement

C or C++?

Started by April 11, 2001 02:38 PM
75 comments, last by Chronoslade 23 years, 10 months ago
quote:
Original post by flame_warrior
If c++ can support whatever C can do then can''t systems programming, Device drivers etc be done in c++ ?



Depends on what you''re working with. MS Windows NT DDK only supports C, though I believe there are 3rd party C++ compilers. Embedded CPUs are a mixed bag--you always get at least an assembler, sometimes you get a C compiler, and now you''re getting more and more with C++ compilers. When dealing with systems programming, you have to use the tools available (and usually don''t have much of a choice!)

The difference between C and C++ is that C++ offers a great selection of Advanced programming tools, such as Generic Templates and Object Oriented Abstractions.

The problem with these is that most beginners do not have enough programming experience to understand how and when to use these tools, and most of the time end up getting confused, writing awful programs, having a bad experience and badmouthing C++ for the rest of their lives.

However, C++ allows the older paradigms of procedural programming to be used, which is where a beginner programmer should start. Object oriented programming is such a difficult concept to start with, so perhaps it is best for a newbie to start using basic encapsulation, instead of trying to jump right into the more advanced features of C++.

practice around with using structs and functions first, then slowly evolve to OOP, thats my advice.

And be damned sure you understand pointers really well before you tackle the more advanced features of C++.

===============================================
Have I no control, is my soul not mine?
Am I not just man, destiny defined?
Never to be ruled, nor held to heel!
This is my signature. There are many like it, but this one is mine. My signature is my best friend. It is my life. I must master it as I must master my life. My signature, without me, is useless. Without my signature, I am useless.
Advertisement
My advice is this: learn C if you want to become a systems programmer (OS, device drivers, low level stuff), and C++ if you are more interested in high level programming (applications like word processors, spreadsheets, and games).



--------------------------------------------------------------------------------


BS
--------------------------------------------------

Whats wrong with that statement? C is better for that kinda stuff. If you don''t agree, then look at most operating systems: coded in C. In fact, other than BeOS relatively few OSes are in anything but C. Of course you can make an OS in C++, but it will be a bloated monster. The right tool for the job.

-----------------------------

A wise man once said "A person with half a clue is more dangerous than a person with or without one."

The Micro$haft BSOD T-Shirt
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt
quote:
Original post by ImmaGNUman

Whats wrong with that statement? C is better for that kinda stuff. If you don''t agree, then look at most operating systems: coded in C. In fact, other than BeOS relatively few OSes are in anything but C.




And you think because most operating systems are written in C means that C is better for writing operating systems? That''s not proof, that''s jumping to conclusions. There are many possibilities for them being written in C, one of them being that the OS may have been written years ago when C was more popular and compilers for C++ were substandard. Could be that the OS was written by older more experienced programmers who grew up using C, thus felt more comfortable with it. Etc, etc, etc.

quote:
Original post by ImmaGNUman

Of course you can make an OS in C++, but it will be a bloated monster. The right tool for the job.




Why would it be a bloated monster exactly? Are you saying that all C++ programs are bloated monsters? Ever look at how bloated Windows is? Guess what, it''s written in C. Generally, languanges don''t bloat code, programmers do.


- Houdini
- Houdini
And you think because most operating systems are written in C means that C is better for writing operating systems? That''s not proof, that''s jumping to conclusions. There are many possibilities for them being written in C, one of them being that the OS may have been written years ago when C was more popular and compilers for C++ were substandard. Could be that the OS was written by older more experienced programmers who grew up using C, thus felt more comfortable with it. Etc, etc, etc.

-------------------------------------------

I have a friend in the business. He works with the Linux operating system(got me into it) and outwardly says its easier for him to work with C. If you want to contact him I can give you a way too.

-------------------------------------------

Why would it be a bloated monster exactly? Are you saying that all C++ programs are bloated monsters? Ever look at how bloated Windows is? Guess what, it''s written in C. Generally, languanges don''t bloat code, programmers do.

-------------------------------------------

I never said C++ produces huge programs. In fact, I use C++ myself as a hobby to produce (rather crappy(dont take this as me saying C++ is rather crappy )) games. Of course bloatware can be written in C, but with operating systems, its generally easier to make a bloatware OS in C++. (I can fit Mandrake Linux and Windows 98 on a harddrive that couldnt even support BeOS''s basic features).




-----------------------------

A wise man once said "A person with half a clue is more dangerous than a person with or without one."

The Micro$haft BSOD T-Shirt
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt
quote:
Original post by ImmaGNUman

And you think because most operating systems are written in C means that C is better for writing operating systems? That''s not proof, that''s jumping to conclusions. There are many possibilities for them being written in C, one of them being that the OS may have been written years ago when C was more popular and compilers for C++ were substandard. Could be that the OS was written by older more experienced programmers who grew up using C, thus felt more comfortable with it. Etc, etc, etc.

-------------------------------------------

I have a friend in the business. He works with the Linux operating system(got me into it) and outwardly says its easier for him to work with C. If you want to contact him I can give you a way too.



You are only supporting Houdini''s point by providing more anecdotal evidence; i.e., are we to assume that simply because one programmer finds C easier to use that all systems programmers should use C?


quote:
Original post by ImmaGNUman

Why would it be a bloated monster exactly? Are you saying that all C++ programs are bloated monsters? Ever look at how bloated Windows is? Guess what, it''s written in C. Generally, languanges don''t bloat code, programmers do.

-------------------------------------------

I never said C++ produces huge programs.



You said that the use of C++ to write an OS would produce a bloated monster. Perhaps you meant something different?


quote:
Original post by ImmaGNUman

Of course bloatware can be written in C, but with operating systems, its generally easier to make a bloatware OS in C++. (I can fit Mandrake Linux and Windows 98 on a harddrive that couldnt even support BeOS''s basic features).



The first sentence is only true for incompetent C++ systems programmers. The second sentence is merely anecdotal evidence.

As Houdini demonstrated, your entire argument is crap. Almost anything you can do in C, you can also do in C++; thus, the production of "bloatware" in C++ vs. C depends on the programmer. I will not assume that all C++ systems programmers are incompetent.
Advertisement
quote:
Original post by ImmaGNUman

I have a friend in the business. He works with the Linux operating system(got me into it) and outwardly says its easier for him to work with C. If you want to contact him I can give you a way too.




It''s because it''s easier for him doesn''t make C the better language for everyone programming operating systems.

quote:
Original post by ImmaGNUman

I never said C++ produces huge programs. In fact, I use C++ myself as a hobby to produce (rather crappy(dont take this as me saying C++ is rather crappy )) games. Of course bloatware can be written in C, but with operating systems, its generally easier to make a bloatware OS in C++. (I can fit Mandrake Linux and Windows 98 on a harddrive that couldnt even support BeOS''s basic features).




I''ll agree it''s easier to create bloatware in C++. To create small fast programs you need to have a very good understanding of C++, and of what happens behind the scenes.

However, I still feel that neither language superior for programming operating systems.


- Houdini
- Houdini
quote:
The C++ Programming Language, by Bjarne Stroustrop

Early applications tended to have a strong systems programming flavor. For example, several major operating systems have been written in C++ [Campbell,1987] [Rozier,1988] [Hamilton,1993] [Berg,1995] [Parrington,1995] and many more have key parts done in C++. I considered uncomprising low-level efficiency essential for C++. This allows us to use C++ to write device drivers and other software that rely on direct manipulation of hardware under real-time constraints. In such code, predictability of performance is at least as important as raw speed. Often, so is compactness of the resulting system. C++ was designed so that every language feature is usable in code under severe time and space constraints [Stroustrop,1994$4.5].



The idea that C++ is only for high-level apps is absurd.
You should all probably be refering to bad use of OOP causing bloat, not C++. You can still do procedural and modular programs in "C++" that look and turn out exactly like the "C" program would/did/does/whatever.

"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
Resist Windows XP''s Invasive Production Activation Technology!
http://druidgames.cjb.net/
Eventhough I am not an expert, I must say its going to be the programmer that creates the bloatware. If you take the time and completely plan out your idea before you try to code it, you should come out with a pretty good code. A lot of programmers(and what i used to do) would be make a very basic design and figure out the rest as you go. This can cause frustration and and sometimes useless code. Take the time, plan it.....just because a program has bloated code dont blame the language, it just does what you tell it, blame the programmer that wrote it.

"There is humor in everything depending on which prespective you look from."
"There is humor in everything depending on which prespective you look from."

This topic is closed to new replies.

Advertisement