LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 07-16-2004, 06:00 AM   #1
programmershous
Member
 
Registered: Mar 2004
Distribution: Diverse
Posts: 77

Rep: Reputation: 15
Post C++ language : badly designed ?


Hello all,

I wrote a page about C++ : http://www.ifrance.com/programmershouse/
What do you think about it ?
It is an introduction to C++, what else usefull could I add ?

thanks
---------

C++ LANGUAGE :

One of the languages known as "Object Oriented", i.e. which uses the concept of classes.
It is a language which takes as a starting point the C language.
It was created by Bjarne Stroustrup in 1990.
C++ was standardized (ANSI/ISO) in 1997.

It is a badly conceived and complicated language : to avoid, like Basic, Pascal, C # and others.

C++ disadvantages :
* It is not portable.
* Code is not protected.
* It doesnt control the types.
* It is not multitask.
* Memory management is complicated.

COMPILERS :
Allows to go from the code (.c) to the executable (.exe).

The best compilers are :
GCC http://www.mingw.org/download.shtml <-- the best
LCC http://www.cs.virginia.edu/~lcc-win32/
CYGWIN http://sources.redhat.com/cygwin/
MINGW32 http://www.mingw.org/download.shtml

LINKS :

BOOKS :
Many C++ books are full of blah-blah which dont mean ANYTHING ! Dont buy any of them. You will lose your time and money and sanity.
Except : « The C++ programming language », third edition, Bjarne Stroustrup
 
Old 07-16-2004, 06:10 AM   #2
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
I agree with some points and I think they are good, especially the one about memory management. However, there're plenty of good books, specially "How Not to Program in C++" and "The Definitive Guide to GCC".

When I write (or try) critics, I try to see both sides of something, the good and the bad ones. I also try to not be to fanatic about one specific thing: Saying that only one book about C++ is good and all others are waste of money considering the number of books, pocket books, electronic books and etc written about C++ exist (and I doubt you read more then 3 or 4) is way to personal and add little to the article/review...

But indeed, this is just my personal thoughts
 
Old 07-16-2004, 10:33 AM   #3
ugenn
Member
 
Registered: Apr 2002
Posts: 549

Rep: Reputation: 30
Re: C++ language : badly designed ?

Programming languages are merely tools to get a particular job done. Each has its own strengths and weakenesses depending on the requirements of the application. So your article is pretty meaningless without actually stating the genre of software to be coded in C++.


Quote:

C++ disadvantages :
* It is not portable.
* Code is not protected.
* It doesnt control the types.
* It is not multitask.
* Memory management is complicated.
C++ was designed to add object oriented constructs to the existing C language and also to be as compatible with C as possible. It thus will always have a low-level bias. The "disadvantages" you mentioned are by products of these requirements. Some points to note too:

- C++ code that adheres to the ISO standards is portable.
- I'm not too sure about what you mean by code being not protected. Could you elaborate more?
- Likewise with "it doesn;t control the types".
- The language itself doesn't know anything about threading, but system calls do provide that feature.
 
Old 07-16-2004, 11:00 AM   #4
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
You bring up some criticisms that have been leveled at C++ many times in the past, but you haven't actually provided any kind of support for your argument that C++ was "badly conceived" and should be avoided.

I find it especially curious that your page on the C language says "The best programming language", when most of those C++ criticisms may also apply to C - even more so, in some cases. Memory management in C is even more complicated than in C++ (since the programmer must know how much to allocate; the C++ 'new' does that for us); C is more weakly typed than C++ is. Portability problems could be said to apply to any language not using a virtual machine of some sort; tell me, how long (in bits) is a 'long int' in C or C++? The length differs by architecture, making code dependent on a particular length less portable.
 
Old 07-17-2004, 08:31 AM   #5
programmershous
Member
 
Registered: Mar 2004
Distribution: Diverse
Posts: 77

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by wapcaplet
You bring up some criticisms that have been leveled at C++ many times in the past, but you haven't actually provided any kind of support for your argument that C++ was "badly conceived" and should be avoided.

I find it especially curious that your page on the C language says "The best programming language", when most of those C++ criticisms may also apply to C - even more so, in some cases. Memory management in C is even more complicated than in C++ (since the programmer must know how much to allocate; the C++ 'new' does that for us); C is more weakly typed than C++ is. Portability problems could be said to apply to any language not using a virtual machine of some sort; tell me, how long (in bits) is a 'long int' in C or C++? The length differs by architecture, making code dependent on a particular length less portable.

With C I can allocate what I need where I need. ok I have to know the processor architecture, but at least I control all what is happening. This is not the case with C++. With C++, the black box does it for you and not in a very optimized way. C++ "new" can lead to undetectable memory errors in some cases.

Portability is easily solved in C when one use architecture independant types.
 
Old 07-17-2004, 08:35 AM   #6
programmershous
Member
 
Registered: Mar 2004
Distribution: Diverse
Posts: 77

Original Poster
Rep: Reputation: 15
Re: Re: C++ language : badly designed ?

Quote:
Originally posted by ugenn
[B]Programming languages are merely tools to get a particular job done. Each has its own strengths and weakenesses depending on the requirements of the application. So your article is pretty meaningless without actually stating the genre of software to be coded in C++.]
No because I am talking about programming in general. A good language should be good for all tasks not only for one type. C does it pretty well.

Quote:
C++ was designed to add object oriented constructs to the existing C language and also to be as compatible with C as possible. It thus will always have a low-level bias. The "disadvantages" you mentioned are by products of these requirements.
That doesnt excuse the "disadvantages". Java succeeds much better.
 
Old 07-17-2004, 11:06 AM   #7
ugenn
Member
 
Registered: Apr 2002
Posts: 549

Rep: Reputation: 30
Re: Re: Re: C++ language : badly designed ?

Quote:
Originally posted by programmershous
No because I am talking about programming in general. A good language should be good for all tasks not only for one type. C does it pretty well.
Firstly, there is no such thing a one size fits all language. Do you often see C/C++ being used for dynamic web development? No. Yes, C/C++ CAN be used for such a task, but it certainly is far from GOOD (the argument at hand), that is why you hardly see it used that way.

And it's funny how you think C "does it pretty well" when they suffer from the same "deficiencies". Earlier posters have addressed these issues in detail, so I'll not restate them.

Quote:

That doesnt excuse the "disadvantages". Java succeeds much better.
Quote:

In another post you wrote:
With C I can allocate what I need where I need. ok I have to know the processor architecture, but at least I control all what is happening. This is not the case with C++. With C++, the black box does it for you and not in a very optimized way. C++ "new" can lead to undetectable memory errors in some cases.
You seem to be contradicting your post above by bringing up Java since Java gives you far less control with automatic garbage collection. When then does it succeed better?
 
Old 07-17-2004, 02:07 PM   #8
programmershous
Member
 
Registered: Mar 2004
Distribution: Diverse
Posts: 77

Original Poster
Rep: Reputation: 15
Re: Re: Re: Re: C++ language : badly designed ?

Quote:
Originally posted by ugenn
Firstly, there is no such thing a one size fits all language. Do you often see C/C++ being used for dynamic web development? No. Yes, C/C++ CAN be used for such a task, but it certainly is far from GOOD (the argument at hand), that is why you hardly see it used that way.


do you use PHP for coding a processor, signal processing algorithms, drivers, OS (like unix and linux for ex), etc etc.
yes C language could also do dynamic web develoment, but the code would be quite long, but it CAN do it. C language is close to the machine language, so anything a machine can do, C can do, that means all.

Quote:
And it's funny how you think C "does it pretty well" when they suffer from the same "deficiencies". Earlier posters have addressed these issues in detail, so I'll not restate them.
C is not perfect, but other languages are not better.

Quote:
You seem to be contradicting your post above by bringing up Java since Java gives you far less control with automatic garbage collection. When then does it succeed better?
no java is better than C++ cf my page on Java
It is a cousin of C++ with some notable differences :
* It is portable : the same executable file can be used by any processor.
* It is protected : mechanism of code control.
* It is robust : it controls the types.
* It is powerful : because multitask.
* "Garbage Collector" manages the memory automatically. (I think better than C++)
Java is better than C++ as an object oriented language. You cannot compare it with C which is not oo.
 
Old 07-17-2004, 03:10 PM   #9
ugenn
Member
 
Registered: Apr 2002
Posts: 549

Rep: Reputation: 30
Re: Re: Re: Re: Re: C++ language : badly designed ?

do you use PHP for coding a processor, signal processing algorithms, drivers, OS (like unix and linux for ex), etc etc.
yes C language could also do dynamic web develoment, but the code would be quite long, but it CAN do it. C language is close to the machine language, so anything a machine can do, C can do, that means all.


I've already stated in an earlier post that C is designed with a low-leve bias. And as such, it is the perfect tool for those things you have mentioned. It is however, NOT ideal for high-level development like web dev, and therefore far from being your claim of "A good language should be good for all tasks" in your earlier post. My point from the very start is that there is no one perfect language, but there is the right kind of tool for the right kind of job.

C is not perfect, but other languages are not better.

As per the previous point. Use the right tool for the right job. And those tools includes C++.

no java is better than C++ cf my page on Java
After rereading your page and earlier posts, I think your assumption on memory management in C++ is way off. You are assuming that C+ has some sort of gc capability and then go off to compare that assumed gc with Java's gc. The thing is that C++ itself does no automatic memory mgmt, so there is no basis for the comparison at all. Any heap mem which you have allocated, you are responsible for freeing, similar to straight C. In fact, C++ exception handling capability actually simplifies resource clean up...

eg. Imagine a function that needs to alloc heap mem in different places, and release them on any errors.

In straight C, unless you use gotos, your cleanup code gets compounded in every error check. eg...

Code:
  char *p1 = NULL, *p2 = NULL, *p3 = NULL;
  p1 = (char*)malloc( blah blah );
  if ( !p1 ) return;
  ...
  /* some code here */
  ...
  p2 = (char*)malloc( blah );
  if ( !p2 ) {  free( p1 );  return; }

  /* more code */
  p3 = (char*)malloc( blah );
  if ( !p3 ) { free(p1); free(p2); return; }
C++ exceptions solves this very elegantly:
Code:
  char *p1 = NULL, *p2 = NULL, *p3 = NULL;
  try {
    p1 = new char[ xxxx ];
    // some code
    p2 = new char[ xxxx ];
    // more code
    p3 = new char[ xxxx ];
  }
  catch ( ... ) {
    delete [] p1;
    delete [] p2;
    delete [] p3;
  }
 
Old 07-17-2004, 03:26 PM   #10
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
programmershous, it sounds to me as though you are mostly interested in debating your viewpoint, rather than being open to the comments and suggestions you asked for in your original post. Here are my suggestions, if you wish to improve your webpage about C++:
  • Provide support for your claim that C++ is badly conceived
  • Explain "code is not protected" and "it is not multitask." I don't know what those mean, and I have a computer science degree.
  • Describe why you think memory management is complicated. As you've admitted yourself, memory management in C is more complicated (i.e., requiring more programmer intervention and planning).
  • You've also stated that using architecture independent types in C helps with portability problems. Explain why the same is not true of C++; why isn't C++ just as portable as C?
  • Explain why the predominance of bytecode-compilation in Java makes it more portable than C++. You can compile C++ to Java bytecode if you like, and execute it on any platform that has a JVM. In fact, you can compile a whole bunch of languages to Java bytecode if you so desire. There is nothing special about the Java language that makes its binaries run on many platforms.

Basically, I think if you're going to make such broad condemnations of the language, you should at least back those statements up with some comparisons to other languages: why C++ does certain things poorly that other languages do well.

You have claimed that no language is better than C. Given the many other languages that are available, would you use C to do dynamic web processing? Would you use C to manipulate strings? If so, more power to you, but other languages most certainly are better than C for those things (PHP and Perl, respectively, are two that come to mind).

Also, if you believe that "C is close to the machine language", you haven't done any kind of coding in lower-level languages, nor have a very good understanding of what "machine language" is actually like. C is a relatively high-level language. It has a strong level of capability for low-level coding (especially since it's possible to embed assembly into it), but I would hardly say it's anywhere close to machine language. Even modern assembly languages are somewhat abstract and high-level in some respects.

Last edited by wapcaplet; 07-17-2004 at 04:50 PM.
 
Old 07-17-2004, 05:49 PM   #11
Stack
Member
 
Registered: Oct 2003
Distribution: FreeBSD
Posts: 325

Rep: Reputation: 30
Quote:
C++ disadvantages :
* It is not portable.
* Code is not protected.
* It doesnt control the types.
* It is not multitask.
* Memory management is complicated.
I have written my fair share of MIPS assembler and i can tell you C is extremely close to assembler. ANSI C is pretty much just providing a way to write assembler with no need to type out oddles of registers and load words. C was never designed to be friendly and hold your hand like java.

Now lets rip to shread those points up there...
1). Nothing is portable. Except assembler on the same platform with no calls to any kernels. Java is not portable either since the whole damn thing runs in a virtual operating system that someone wrote for your platform.
2). Show me code that is protected... Nothing is protected from a debugger! Encrypted code doesnt work either since the key to decrypt it is somewhere in there...
3). It doesnt need to... Remeber this is like a friendly assembler. There are no such things as types in the first place.
4). It is not multitasking? Ever heard of threads?
5). It is just as complicated as assembly.

C++ has all the features of C...

Last edited by Stack; 07-17-2004 at 05:56 PM.
 
Old 07-17-2004, 10:51 PM   #12
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
Stack: i never seen mips assembly, but i done some x86 assembly, and i cant seem to see how c is like it very much (but there are some resemblances) .... and i think c is a lot less complicated then assembly, in assembly you have to move this around, call this, find what part of memory the screen is located at, move everything there

assembly is easier to use then c for some things tho ... but in c you don't have to know what the number are (so less research,) just as the computer to fetch them for you, and store them in some variable to use them later
 
Old 07-18-2004, 12:40 AM   #13
blk96gt
Member
 
Registered: Jun 2004
Location: Nacogdoches, TX
Distribution: Ubuntu 7.04
Posts: 230

Rep: Reputation: 30
Profanity is the one language all programmers know.
 
Old 07-18-2004, 01:32 AM   #14
Capt_Caveman
Senior Member
 
Registered: Mar 2003
Distribution: Fedora
Posts: 3,658

Rep: Reputation: 69
Quote:
Originally posted by blk96gt
Profanity is the one language all programmers know.

Very portable too
 
Old 07-18-2004, 02:15 AM   #15
blk96gt
Member
 
Registered: Jun 2004
Location: Nacogdoches, TX
Distribution: Ubuntu 7.04
Posts: 230

Rep: Reputation: 30
Oh yeah, works in any environment.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux designed for a TERMINAL exclusively??? ecsed Linux - Software 6 07-06-2005 10:15 AM
What do you cosnider to be the best designed personal websites pembo13 General 33 11-10-2004 04:30 PM
Linux purpose-designed keyboard hand of fate Linux - Hardware 14 03-26-2004 07:47 PM
Re-do poorly designed install southsibling Linux - Software 5 12-13-2003 09:33 PM
Linux: not designed for casual users Berryd Linux - Newbie 6 02-16-2002 09:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 08:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration