C or C++ something else....

V

vadam17

Thanks for your answers.
I already know programming in Java and I am starting studying the
perl. I would like to learn C or C++ but I need someone to tell me
the + and - of each one. I have noticed that every computer exploit
and almost every linux program is builted in C why is that? Because
they just know to program in C or C is better for that kind of
programs and why? Can somebody give an example of big project that
you can achive with C and you cant with C++ or vice versa? Also can
somebody suggest me a book for both of them ! (I dont want something
for begginers i want something to be as much complete book as it can
be, with all the topics you need to know for a programming language
.)Sorry for the number of the questions but i am a little bit
confused.
Thanks one more time
 
V

Victor Bazarov

Big-Goofy said:
Thanks for your answers.
I already know programming in Java and I am starting studying the
perl. I would like to learn C or C++ but I need someone to tell me
the + and - of each one.

I hope you're not blind and should see the two pluses in C++... I
don't see any minuses there, do you? Neither does C have any minuses.
It just doesn't have any pluses, that's all.
I have noticed that every computer exploit

Is that what you're trying to get into?
and almost every linux program is builted in C why is that? Because
they just know to program in C or C is better for that kind of
programs and why? Can somebody give an example of big project that
you can achive with C and you cant with C++ or vice versa?

Find Bjarne Stroustrup's home page and read all of it.
Also can
somebody suggest me a book for both of them ! (I dont want something
for begginers i want something to be as much complete book as it can
be, with all the topics you need to know for a programming language
.)Sorry for the number of the questions but i am a little bit
confused.

Just Google for book suggestions. It's getting really old. Show us
that you're ready to learn either of the languages by applyting some
effort to collecting information.

V
 
P

Phlip

Big-Goofy said:
I already know programming in Java and I am starting studying the
perl.

I have used Perl for years, and come to the conclusion that its author,
Larry Wall, must be a very fast, accurate typist.

Download Ruby to see how clean and elegant a language can get!
I would like to learn C or C++ but I need someone to tell me
the + and - of each one. I have noticed that every computer exploit
and almost every linux program is builted in C why is that?

Roughly speaking, C is older and more Standard, so it has a much bigger
establish corpus of legacy code. Including Linux. By "more Standard" I mean
that more Standard-compliant code has been written to work in more
Standard-compliant compilers than C++.

(I suspect we still don't have a standard-conforming compiler, despite
almost a decade of a ratified Standard. And I suspect that the committees
are upgrading this Standard before it even achieves compliance!!)

Entry level programmers don't need to worry about any of that. Learn C++
first, and learn enough C to diagnose and debug it. Learn C++ as a
high-level language, starting with features like std::string. Then learn C
things like strlen(), so you can avoid the troubles these cause.
Because
they just know to program in C or C is better for that kind of
programs and why?

Anything you can do in C, you can do the same way, with better typesafety
and more conveniences, in C++.

Almost anything you can do in C, you can do better in C++ using Object
Oriented, Generic, and similar paradigms.

The only thing you can't do is the very last step of optimization. Kernels
like Linux's need that (and you _don't_), so they must use C-style code. C++
can compile C-style code, so they still don't need C.

Most C code can be tweaked to compile in C++. But Linux shouldn't compile as
C++ because Linux works on many kinds of CPU hardware, and some of them
don't have C++ compilers. Only situations without a C++ compiler strictly
need C.
Can somebody give an example of big project that
you can achive with C and you cant with C++ or vice versa?

C++ is better for very large projects because it allows you to create
modules and components better than C. C has poorer support for
encapsulation, which is a good high-level technique to prevent bugs.
Also can
somebody suggest me a book for both of them ! (I dont want something
for begginers i want something to be as much complete book as it can
be, with all the topics you need to know for a programming language
.)

Tip: Most programming today should not be in a C language at all. It should
be in a soft rapid language (like Ruby or Python) where you don't need to
reinvent the wheel all the time.

To proceed in C++, read /The C++ Programming Language, 3rd Edition/ by
Bjarne Stroustrup. It fits the "complete" spot you requested.
 
L

loufoque

Phlip wrote :
Roughly speaking, C is older and more Standard, so it has a much bigger
establish corpus of legacy code. Including Linux. By "more Standard" I mean
that more Standard-compliant code has been written to work in more
Standard-compliant compilers than C++.

AFAIK, there is only one frontend which is compliant to the latest C
standard, just like for C++.
And it's the same one, actually.

The only thing you can't do is the very last step of optimization. Kernels
like Linux's need that (and you _don't_), so they must use C-style code. C++
can compile C-style code, so they still don't need C.

Not really.
A lot of notable C++ features are not only acceptable in a kernel but
can also boost its performance and improve its design.
 
P

Phlip

loufoque said:
Not really.
A lot of notable C++ features are not only acceptable in a kernel but can
also boost its performance and improve its design.

Oops; right. I was trying too hard to say "C++ is always better than C, even
for C-style optimization" that I forgot about "C++-style optimization".

An OS kernel built out of a sick "expression metatemplate" package, taking
hours to compile, would shred!!!

And would still be maintainable, unlike the raw Assembly it would compete
with.
 
K

kwikius

Phlip wrote:
Most C code can be tweaked to compile in C++. But Linux shouldn't compile as
C++ because Linux works on many kinds of CPU hardware, and some of them
don't have C++ compilers. Only situations without a C++ compiler strictly
need C.

re: Linux, AFAIK Linus Torvalds just plain doesnt like C++, and that
is the beginning and end of the matter. Theres an interview or quote
somewhere... but where I don't know.

regards
Andy Little
 
R

Ron Natalie

kwikius said:
Phlip wrote:


re: Linux, AFAIK Linus Torvalds just plain doesnt like C++, and that
is the beginning and end of the matter. Theres an interview or quote
somewhere... but where I don't know.
Linux, fortunately, has gone way beyond the personal whims of Linus.
Just about every implementation of Linux I've seen uses the GCC suite
for it's compilers which pretty much comes with both C and C++. The
few exceptions also provide C++ environments.

There's no trememdously compelling reason to NOT allow C++ in the
kenrel. There are user-mode programs in LINUX that are written in
C++ (and a bunch of them like the X libraries would fare better had
they been written in a real object-oriented language rather than a
half-assed attempt to implement OO concept in strict C.
 
L

loufoque

kwikius wrote :
re: Linux, AFAIK Linus Torvalds just plain doesnt like C++, and that
is the beginning and end of the matter. Theres an interview or quote
somewhere... but where I don't know.

Did you mean this quote ? (It's from 2004 I think)
You can obviously see he doesn't know C++ well and that moreover he does
nothing more than insult C++ and the people that use it.

[Beginning of quote]

The fact is, C++ compilers are not trustworthy. They were even worse in
1992, but some fundamental facts haven't changed:

- the whole C++ exception handling thing is fundamentally broken. It's
_especially_ broken for kernels.
- any compiler or language that likes to hide things like memory
allocations behind your back just isn't a good choice for a kernel.
- you can write object-oriented code (useful for filesystems etc) in C,
_without_ the crap that is C++.

In general, I'd say that anybody who designs his kernel modules for C++ is
either
(a) looking for problems
(b) a C++ bigot that can't see what he is writing is really just C anyway
(c) was given an assignment in CS class to do so.

[End of quote]
 
A

arnuld

So you want to learn C or C++. (thank God, you did not ask C/C++ ).

Q: do you want to eat an apple or an orange?

A: http://www.parashift.com/c++-faq-lite/ &
http://www.research.att.com/~bs/papers.html

C & C++ are different lanugaes. you do not need to post it here, do
these 4 things:

1.) First, write down your goals & plan of your career, where & why you
want to go & in which direction (you know "software world" has many
domains or application areas)

2.) Search for jobs you want on your faourite (but also popular) job
site. i like "www.monsterindia.com" (as i live in India)

3.) after collecting the information from last 2 points, now, search
the archives of 4 newsgroups "comp.lang.c", "comp.lang.c++",
"comp.lang.c++.moderated" & "alt.comp.lang.learn.c-c++" with following
keywords: "c or c++", "why c++", "why c" etc. etc. then read all the
information. If you have a printer(like me, i have a dot-matrix :),
then take print-outs of things which seem important from the
perspective of information you collected from points 1 & 2.

4.) know that its 14th day since you started from point 1.

this will 1st, remove the "fog of confusion" & 2nd, you will get a much
better, an accurate & focused answer.

actually i was pondering into the same confusion & i relieved my pain
in the same way (but i used quite "a trial & error method" & what i
told you is the *extract* of my experience).

C is older than C++ & was standardized almost a decade ago & hence it
has large community base. even Linus Torvald created Linux kernel many
years ago (IIRC in early 1990s & C++ was standardized in 1998, the year
C++ Primer 3/e was published)
Can somebody give an example of big project that
you can achive with C and you cant with C++ or vice versa?

do the 4 points.
Also can somebody suggest me a book for both of them !

Now, that will be a "recipe for disaster", if somebody does so.
(I dont want something
for begginers i want something to be as much complete book as it can
be, with all the topics you need to know for a programming language
.)Sorry for the number of the questions but i am a little bit
confused.

read & do those 4 points, only then ask for a book. Otherwise you will
waste a lot of money which you can earn later but you can not earn the
time you will loose.


take care

thanks

"arnuld'
 
A

arnuld

Victor said:
I hope you're not blind and should see the two pluses in C++... I
don't see any minuses there, do you? Neither does C have any minuses.
It just doesn't have any pluses, that's all.
Ha...Ha...Ha....


Is that what you're trying to get into?

Hmmm... Victor is really serious here.
Find Bjarne Stroustrup's home page and read all of it.


Best Answer Award, so far.

"arnuld"
 
J

Jens Theisen

Big-Goofy ([email protected]) said:
I already know programming in Java and I am starting studying the
perl.

If you're free to choose, I'd suggest Python over Perl; it's much,
much easier.
I would like to learn C or C++ but I need someone to tell me
the + and - of each one. I have noticed that every computer exploit
and almost every linux program is builted in C why is that?

In part, your question is narrowing your view on what's naturally
written in C. I'm currently writing this article under gnus, which is
written in emacs-lisp; so is running under Linux as well?

In the sense of what's coming with a typical linux distribution, there
is a lot more than C software; C++, Java, Perl, Python, PHP, various
SQL-type stuff are only some of them.

I'm not aware of language comparison books, and every language
comparison I saw so far was biased and unfair.

Generally you probably want to have a problem or interesting project
first and then decide what language to use for it. C and C++ are
strong in correctness, performance and interfacing lower level
libraries. The higher level languages usually come with better
reusable code for specific problem areas, such as web development for
Python and PHP.
Can somebody give an example of big project that
you can achive with C and you cant with C++ or vice versa?

For C and C++, I'd sum it up as follows: C++ is safer and more
expressive, but also much more complex. For the type of stuff
you can do with them, they are, however, relatively similar - compared
to higher level languages.
Also can
somebody suggest me a book for both of them ! (I dont want something
for begginers i want something to be as much complete book as it can
be, with all the topics you need to know for a programming language
.)

For C++, Accelerated C++ is recommended by a lot of people, though I
don't know it myself. I learned with the C++ Programming Language by
Stroustrup. There is also Effective C++, More Effective C++ and
Effective STL by Scott Meyers which are a must-read (they are quite
thin). Of course, you shouldn't read all this before you begin coding.

On C, I can't really tell; however, there is _much_ less to say about
it than about C++, as far as the language is concerned. There is the
old classic The C Programming Language by K&R, which is what I have
used, and found to be okay.

I would focus on one of these language first, and rather not mix them
up at the beginning.

Best regards,

Jens
 
G

Gianni Mariani

Phlip wrote:
.....
The only thing you can't do is the very last step of optimization. Kernels
like Linux's need that (and you _don't_), so they must use C-style code. C++
can compile C-style code, so they still don't need C.

There is no good reason not to use C++ to develop a kernel. There are
many great reasons to use it however.
 
G

Greg Comeau

I already know programming in Java and I am starting studying the
perl. I would like to learn C or C++ but I need someone to tell me
the + and - of each one. I have noticed that every computer exploit
and almost every linux program is builted in C why is that? Because
they just know to program in C or C is better for that kind of
programs and why? Can somebody give an example of big project that
you can achive with C and you cant with C++ or vice versa? Also can
somebody suggest me a book for both of them ! (I dont want something
for begginers i want something to be as much complete book as it can
be, with all the topics you need to know for a programming language
.)Sorry for the number of the questions but i am a little bit
confused.

In your quest, you may want to consider these data points as well:

http://www.research.att.com/~bs/applications.html
http://www.research.att.com/~bs/new_learning.pdf
http://www.research.att.com/~bs/sibling_rivalry.pdf
http://www.ddj.com/showArticle.jhtml;jsessionid=NY5FDFQI1LHNYQSNDLPSKH0CJUNN2JVN?articleID=184401543
http://www.ddj.com/showArticle.jhtml;jsessionid=NY5FDFQI1LHNYQSNDLPSKH0CJUNN2JVN?articleID=184401555
http://www.ddj.com/showArticle.jhtml;jsessionid=NY5FDFQI1LHNYQSNDLPSKH0CJUNN2JVN?articleID=184401562
 
G

Greg Comeau

Linux, fortunately, has gone way beyond the personal whims of Linus.
Just about every implementation of Linux I've seen uses the GCC suite
for it's compilers which pretty much comes with both C and C++. The
few exceptions also provide C++ environments.

There's no trememdously compelling reason to NOT allow C++ in the
kenrel. There are user-mode programs in LINUX that are written in
C++ (and a bunch of them like the X libraries would fare better had
they been written in a real object-oriented language rather than a
half-assed attempt to implement OO concept in strict C.

Indeed that's so, but C++ is not being used in LINUX and Linus
has a lot to do with it initially as I recall. I'm uncertain
why a spin-off has never occured, OTOH, it would probably need
a good reason over "just because we can".
 
S

scott urban

kwikius wrote :
re: Linux, AFAIK Linus Torvalds just plain doesnt like C++, and that
is the beginning and end of the matter. Theres an interview or quote
somewhere... but where I don't know.

Did you mean this quote ? (It's from 2004 I think)
You can obviously see he doesn't know C++ well and that moreover he does
nothing more than insult C++ and the people that use it.

[Beginning of quote]

The fact is, C++ compilers are not trustworthy. They were even worse in
1992, but some fundamental facts haven't changed:

<snip remainder of Linus spewage>

Yeah, raise your hand if you haven't read some overly-opinionated,
half-informed, inflammatory drek from Linus T. on 5 or more different
subjects.

That's ok, Linux is fun and I appreciate what he did/does. That
doesn't mean everything he says is gospel, and he probably knows that
he's sometimes an inflammatory blowhard. After all, who isn't a
blowhard at one time or another? Only when I do it, people don't quote
me.
 
G

Gianni Mariani

Greg Comeau wrote:
....
Indeed that's so, but C++ is not being used in LINUX and Linus
has a lot to do with it initially as I recall. I'm uncertain
why a spin-off has never occured, OTOH, it would probably need
a good reason over "just because we can".

My experience is that with well written C++ interfaces, it becomes much
easier to find bugs sooner. The kinds of bugs I see being patched in
Linux remind me of the issues I would run into in my C code which are
mostly cleared up with a good C++ interface.

I think the Linux maintainers have a much harder job maintaining C code
now than if they would be working on a good C++ base.

Some of the kernel maintainers probably agree that C++ would be a better
alternative to C but they're not willing to push the point.

There will come a day when a kernel spin-off will start using C++ and as
long as they can be backwards compatible with the C drivers (at a source
code level) there might be a chance to do it.
 
A

arnuld

Gianni said:
Greg Comeau wrote:
My experience is that with well written C++ interfaces, it becomes much
easier to find bugs sooner. The kinds of bugs I see being patched in
Linux remind me of the issues I would run into in my C code which are
mostly cleared up with a good C++ interface.

i do think so & write now i am learning C++ from C++ Prime 4/e (an
illegal copy :-( i got as .chm file, 4/e edition is not available in
India, neither is "Accelerated C++")
> There will come a day when a kernel spin-off will start using C++ and as
long as they can be backwards compatible with the C drivers (at a source
code level) there might be a chance to do it.

that is already happened. check: http://l4ka.org/projects/pistachio/

also see: http://www.gnu.org/software/hurd/hurd-paper.html

these 2 are my favourites but 2nd one is written in C.
 
G

Greg Comeau

Greg Comeau wrote:
...

My experience is that with well written C++ interfaces, it becomes much
easier to find bugs sooner. The kinds of bugs I see being patched in
Linux remind me of the issues I would run into in my C code which are
mostly cleared up with a good C++ interface.

I think the Linux maintainers have a much harder job maintaining C code
now than if they would be working on a good C++ base.

I have not followed it's history at a micro level, but it would
seems to me that over the years that they'd had to rewrite
whole parts even in C. I'm not saying that means to rewrite
those parts in C++, but just that as things progressed some
mistakes and etc must have been detected and resolved with
non-hack solutions. I can't imagine that wasn't the case for
parts, and can't imagine things like overall style and design
had nothing to do with it.
Some of the kernel maintainers probably agree that C++ would be a better
alternative to C but they're not willing to push the point.

There will come a day when a kernel spin-off will start using C++ and as
long as they can be backwards compatible with the C drivers (at a source
code level) there might be a chance to do it.

Well, Comeau C/C++ now supports a ton of gccisms, and I've been
informed can be used to successfully compile LINUX, if that helps
anybody :)
 
I

Ivan Vecerina

: Thanks for your answers.
: I already know programming in Java and I am starting studying the
: perl. I would like to learn C or C++ but I need someone to tell me
: the + and - of each one. I have noticed that every computer exploit
: and almost every linux program is builted in C why is that? Because
: they just know to program in C or C is better for that kind of
: programs and why? Can somebody give an example of big project that
: you can achive with C and you cant with C++ or vice versa?

The main advantage of C compared to C++ is simplicity of the language.
C remains true to its roots as a "portable assembly language": little
to nothing happens behind the scene.
C++ has become a quite complex language. It supports a number of very
different programming styles (or "paradigmns"). Because there are many
more ways to implement a solution to a problem, confusion and somtimes
disagreements arise: it is easy, especially for a beginner, to find
new ways to shoot oneself in the foot, or to write inefficient or
unmaintainable code.

This is why, for large open source projects that have a large developer
base, C is sometimes an easier choice. Also, in some industries (e.g.
embedded systems), the fact that C is so well studied (coding style,
caveats, limitations) makes it feel like a less daring choice.

The reality is: C++ is a significantly more powerful language, and
has many features that allow writing more robust code. But it takes
years to master it completely (including its C subset).

: Also can
: somebody suggest me a book for both of them ! (I dont want something
: for begginers i want something to be as much complete book as it can
: be, with all the topics you need to know for a programming language
: .)

If you are looking for books, you can find inspiration in:
http://brian.accu.org/bookreviews/public/reviews/0sb/index.htm

Some picks to start with:
- Accelerated C++
- Thinking in C++ (free pdf version legally available online)
And then, well, all the highly recommended books found at
http://brian.accu.org/bookreviews/public/reviews/0sb/advanced_c__.htm
It depends on which area of the language you want to master...

: Sorry for the number of the questions but i am a little bit
: confused.
Prepare for a long but rewarding journey...

Ivan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top