C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28695
Number of posts: 94715

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Is C++ the best language? Posted by daviddaly on 18 Oct 2007 at 11:36 AM
For a long time I have debated with my friends/colleagues my reasons for thinking that C++ is the best all round programming language. I finally got round to posting this on my blog (Is C++ The Only Real Language?). I’d love to know what everyone else thinks. Is my assessment fair? Or should the program language crown be more deservingly allocated to another language?
Report
Re: Is C++ the best language? Posted by Lundin on 18 Oct 2007 at 1:05 PM
Comments about the blog:

- Why isn't C evaluated? It gets 10.5 points on that scale, losing 0.5 points for lacking inheritance, though it supports every other aspect of OO, although not in a syntax-appealing way.

- Nobody in the computer industry but the americans give a damn about ANSI any longer. ISO is what matters.

---

My own opinion about programming languages is, in order to qualify as one of the best, the language shall:

- Have somewhat logical syntax. Excludes VB. C/C++ barely qualifies .

- Be platform-independant. This is as fundamental as it can get, it is the least you can require of a general-purpose language.

- Have no need of an interpreter or runtime junk. VB, Java and .NET are typical examples of why. And why make slow and memory consuming programs requiring a load of bulky files, when you can make fast ones without the need of additional files instead?

- Lack garbage collection. Not sure about anyone else, but garbage collection just makes me laugh. What comes to my mind is "I have such a hard time finding my memory leak bugs, and instead of learning how to program properly, I would rather have my program actively finding them for me in runtime." (I'm not counting smart pointers as garbage collection - those are another story)

- Support multi-threading on a language level, or by including POSIX threads as part of the standard.
Report
Re: Is C++ the best language? Posted by BitByBit_Thor on 18 Oct 2007 at 1:15 PM
: - Have somewhat logical syntax. Excludes VB. C/C++
: barely qualifies .

Makes me curious what language you think has a logical syntax?

I agree that *most* of the time, C/C++ has a more logical syntax than VB. VB mostly lacks blocks ( { ...} ), in which case you get constructions like "Something ... End Something" which is a bit messy imo.

Best Regards,
Richard

The way I see it... Well, it's all pretty blurry
Report
Re: Is C++ the best language? Posted by Lundin on 18 Oct 2007 at 1:53 PM
: : - Have somewhat logical syntax. Excludes VB. C/C++
: : barely qualifies .
:
: Makes me curious what language you think has a logical syntax?


VB... arrays start at index 0 or 1, take a chance. File handling uses a completely different syntax than the rest of the language. Plenty of loop syntax lacking purpose. Variables don't need to be declared, and their type might be random or huge "variants". You can pass variables by reference, but not use a reference of a variable in the code. Functions and sub-routines are different things. Error handling is handled by goto. And so on...

C/C++: Type sizes of integers is a mess. if/for/while statements dont need {} if there is only one instruction following. Switch-case statements and their completely illogical syntax. Argument lists, printf/scanf. The funky ?: operator. Bitwise & has lower priority than ==. Assignments may be done inside statements. The ',' operator. The macro syntax!! Strings declared with "" adds invisible null termination. The magical NULL in C (which might be the most fuzzy thing ever made). C++ inheritance in general with virtual/private/protected/public all over the place, meaning completely differnt things depending on the situation. Multiple inheritance. new and new[] are different operators. friends. The pure evil syntax of STL. And so on...

Thinking of it, I definitely don't think C/C++ qualifies as logical.

Java and C# would be good examples of logical syntax. (Except Java's file handling which was clearly designed by a madman.)
Report
Re: Is C++ the best language? Posted by zibadian on 18 Oct 2007 at 9:46 PM
: : : - Have somewhat logical syntax. Excludes VB. C/C++
: : : barely qualifies .
: :
: : Makes me curious what language you think has a logical syntax?
:
:
: VB... arrays start at index 0 or 1, take a chance. File handling
: uses a completely different syntax than the rest of the language.
: Plenty of loop syntax lacking purpose. Variables don't need to be
: declared, and their type might be random or huge "variants". You can
: pass variables by reference, but not use a reference of a variable
: in the code. Functions and sub-routines are different things. Error
: handling is handled by goto. And so on...
:
: C/C++: Type sizes of integers is a mess. if/for/while statements
: dont need {} if there is only one instruction following. Switch-case
: statements and their completely illogical syntax. Argument lists,
: printf/scanf. The funky ?: operator. Bitwise & has lower priority
: than ==. Assignments may be done inside statements. The ','
: operator. The macro syntax!! Strings declared with "" adds invisible
: null termination. The magical NULL in C (which might be the most
: fuzzy thing ever made). C++ inheritance in general with
: virtual/private/protected/public all over the place, meaning
: completely differnt things depending on the situation. Multiple
: inheritance. new and new[] are different operators. friends. The
: pure evil syntax of STL. And so on...
:
: Thinking of it, I definitely don't think C/C++ qualifies as logical.
:
:
: Java and C# would be good examples of logical syntax. (Except Java's
: file handling which was clearly designed by a madman.)

Java's file handling looks a bit illogical at first, but it is ver logical and flexible. As a programmer one can decide for himself which reading capabilities the program needs. By separating the actual source of the data from the way it is perceived by the program, Java has a single way of reading from files, networks, memory, pipes, etc.
I found this easier than using one way to read from a file, and another to read from the network.
Other filehandling commands are just as logical: Create a representation using the File object. Then perform an action on that representation. This is not that illogical way of doing things for an OO language.
Report
Re: Is C++ the best language? Posted by Lundin on 18 Oct 2007 at 11:21 PM
In my opinion the problem is that you have way too many fuzzy "streams" or whatever they call them, that you need to connect together in the right order. When I wrote Java, it was always a pain to get it working, compared to the rest of the language which is very intuitive.

Instead, I think they should just have passed a big bunch of arguments to one standard "i/o object", and let the user configure it for file handling, port i/o, pipes or whatever he wants it to use. Kind of like CreateFile() in Windows, but not restricted only to files and ports.
Report
Re: Is C++ the best language? Posted by zibadian on 18 Oct 2007 at 1:26 PM
: Comments about the blog:
:
: - Why isn't C evaluated? It gets 10.5 points on that scale, losing
: 0.5 points for lacking inheritance, though it supports every other
: aspect of OO, although not in a syntax-appealing way.
:
: - Nobody in the computer industry but the americans give a damn
: about ANSI any longer. ISO is what matters.
:
: ---
:
: My own opinion about programming languages is, in order to qualify
: as one of the best, the language shall:
:
: - Have somewhat logical syntax. Excludes VB. C/C++
: barely qualifies .
:
: - Be platform-independant. This is as fundamental as it can get, it
: is the least you can require of a general-purpose language.
:
: - Have no need of an interpreter or runtime junk. VB, Java and .NET
: are typical examples of why. And why make slow and memory consuming
: programs requiring a load of bulky files, when you can make fast
: ones without the need of additional files instead?
:
: - Lack garbage collection. Not sure about anyone else, but garbage
: collection just makes me laugh. What comes to my mind is "I have
: such a hard time finding my memory leak bugs, and instead of
: learning how to program properly, I would rather have my program
: actively finding them for me in runtime." (I'm not counting smart
: pointers as garbage collection - those are another story)
:
: - Support multi-threading on a language level, or by including POSIX
: threads as part of the standard.

- I agree that interpreters and VM's are often the cause of many head-aches. For Java there are several ahead-of-time (AOT) compilers, which will remove that problem.
- Garbage collection is great to reduce memory-leaks, but it doesn't completely remove memory leaks due to bad programming. It is possible to make self referencing objects, which certainly will create memory leaks if left unchecked by the programmer. They also help to keep the code more readable, by removing the need to include deallocation code.
Report
Re: Is C++ the best language? Posted by Lundin on 18 Oct 2007 at 1:33 PM
: - Garbage collection is great to reduce memory-leaks, but it doesn't
: completely remove memory leaks due to bad programming. It is
: possible to make self referencing objects, which certainly will
: create memory leaks if left unchecked by the programmer. They also
: help to keep the code more readable, by removing the need to include
: deallocation code.


That can all be solved with smart pointers (auto_ptr and similar).
Report
Re: Is C++ the best language? Posted by Jonathan on 4 Dec 2007 at 2:06 AM
Hmmm...

: - Be platform-independant. This is as fundamental as it can get, it
: is the least you can require of a general-purpose language.
:
: - Have no need of an interpreter or runtime junk. VB, Java and .NET
: are typical examples of why. And why make slow and memory consuming
: programs requiring a load of bulky files, when you can make fast
: ones without the need of additional files instead?
These two are somewhat at odds with each other. There are a lot of very different platforms out there, both operating system wise and hardware wise. VMs do the abstraction layer for this once and provide it for many programs to take advantage of. If you decide to do all the work yourself, you may well find you end up with as much stuff sitting around to handle that anyway. Have you ever seen a program that has to run on over 50 different platforms with consistent as possible semantics and see the amount of code that goes into this?

: - Lack garbage collection. Not sure about anyone else, but garbage
: collection just makes me laugh. What comes to my mind is "I have
: such a hard time finding my memory leak bugs, and instead of
: learning how to program properly, I would rather have my program
: actively finding them for me in runtime."
Sorry, but to me this is about as stupid as saying you'll program in assembly rather than using a high level language with a compiler, and that people who use high level languages haven't learned to program properly.

Garbage collection is a TOOL. Like a compiler, the point is that we get the computer to the hard work for us. Because that's why we're paying for it rather than sitting there doing our calculations by hand, right?

I know GC isn't suitable for every situation, but for the majority it's just fine. The industry would do a whole lot better if programmers were more interested in delivering what their clients needed than placing themselves above the tools that are there to help them do just that.

: - Support multi-threading on a language level, or by including POSIX
: threads as part of the standard.
Support concurrency of some kind, for sure. The languages of the future will hopefully make a better job of hiding away the gritty details of concurrency though. Then we'll have a bunch of people who say, "I'm not going to use X feature that helps me write concurrent programs that behave correctly! Threads and mutexes all the way!"

Jonathan
###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
Report
Re: Is C++ the best language? Posted by Lundin on 4 Dec 2007 at 3:25 AM
: : - Lack garbage collection. Not sure about anyone else, but garbage
: : collection just makes me laugh. What comes to my mind is "I have
: : such a hard time finding my memory leak bugs, and instead of
: : learning how to program properly, I would rather have my program
: : actively finding them for me in runtime."
: Sorry, but to me this is about as stupid as saying you'll program in
: assembly rather than using a high level language with a compiler,
: and that people who use high level languages haven't learned to
: program properly.
:
: Garbage collection is a TOOL. Like a compiler, the point is that we
: get the computer to the hard work for us. Because that's why we're
: paying for it rather than sitting there doing our calculations by
: hand, right?
:
: I know GC isn't suitable for every situation, but for the majority
: it's just fine. The industry would do a whole lot better if
: programmers were more interested in delivering what their clients
: needed than placing themselves above the tools that are there to
: help them do just that.

The difference is that you can make a high level language program as fast as an assembler program if you wish to sacrifice the readability of the code. You cannot however disable garbage collection in languages like Java/C#, if you would desire to avoid memory leaks by for example using smart pointers instead. GC is not a tool, since you get it whether you wish to use it or not.

My point is that garbage collection is a poor solution. Smart pointers are better, and they aren't harder to use than any other kind of variable. If you use smart pointers, you don't need garbage collection. I don't think it is too much to ask of a programmer to study smart pointers for a few days in order to increase his program's performance drastically. Smart pointers can be used in time-critical applications, while garbage collection cannot be used there.

---

Also I would ask you to use a more polite tone in your replies. Calling another poster or their arguments for stupid is not ok, nor is flaming of any kind. Had this post been directed to anyone else but myself, I would have removed it.
Report
Re: Is C++ the best language? Posted by Jonathan on 10 Dec 2007 at 1:27 AM
: You cannot however disable garbage collection in languages like Java/C#,
: if you would desire to avoid memory leaks by for example using smart
: pointers instead. GC is not a tool, since you get it whether you wish to
: use it or not.
If you have a situation where GC is not appropriate, that simply means you shouldn't use a language that forces it on you. It doesn't mean the language isn't appropriate for tasks where GC is suitable to use.

: My point is that garbage collection is a poor solution. Smart
: pointers are better, and they aren't harder to use than any other
: kind of variable. If you use smart pointers, you don't need garbage
: collection. I don't think it is too much to ask of a programmer to
: study smart pointers for a few days in order to increase his
: program's performance drastically. Smart pointers can be used in
: time-critical applications, while garbage collection cannot be used
: there.
People have done thorough analysis of performance with GC and explicit allocation, and it's far from clear cut that one is better than the other - it's situation dependent. Here is one such paper you may find interesting.
http://www.cs.umass.edu/~emery/pubs/gcvsmalloc.pdf

Also, GC can be used in situations where you've got time bounds, with the correct algorithms. See this paper:
http://www.cs.cmu.edu/~guyb/papers/gc2001.pdf

: Calling another poster or their arguments for stupid is not ok
I was disagreeing with the statement, which I think is wrong, rather than calling you stupid. Sorry for any offense caused.

Jonathan
###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
Report
Re: Is C++ the best language? Posted by jadix on 19 Oct 2007 at 3:22 AM
: For a long time I have debated with my friends/colleagues my reasons
: for thinking that C++ is the best all round programming language. I
: finally got round to posting this on my blog
: ([link=http://outofthetriangle.wordpress.com/2007/10/18/is-c-the-only
: -real-language/]Is C++ The Only Real Language?[/link]). I’d love to
: know what everyone else thinks. Is my assessment fair? Or should the
: program language crown be more deservingly allocated to another
: language?
:


man C++ is not good enough for many reasons:

1- array out of bound exception... it doesnt check the array bound at compile time which is very bad... not as java.

2- there is a violation in the class design. i mean we can access a private member from outside of the class using the friend class modifier.

3- Templates in C++ are error prone and soo complicated comparing to Java Object type

4- pointer in C++ are not safe as java's pointers

but as a system language C++ is good .. or if you want to use C++ in building games...
Report
Re: Is C++ the best language? Posted by Lundin on 19 Oct 2007 at 4:51 AM
: 3- Templates in C++ are error prone and soo complicated comparing to
: Java Object type

The Java Object type is not something to brag about. Both C++ and C# have better ways.

C++ templates accepts primitive data types, Java Objects don't, you need to use real ugly wrapper classes to even be able to pass common integers, since Java isn't a pure object-oriented language, unlike C# where everything's objects.

As for C++ templates, they are complicated, but way more powerful once you have them working. Take this example:

  ifstream fin("dummy.txt");
  if(!fin.is_open())
  {
    /* error handling */            
  }
  istream_iterator<SomeType> fin_it (fin), end;
  ostream_iterator<SomeType> cout_it(cout, "\n");
  copy(fin_it, end, cout_it);
  fin.close();


This opens a file containing custom "SomeType" objects, reads them and prints them all to the screen in a type-specific manner. In 6 lines of code. Need another i/o source? Change one argument to the constructors. Need another type? Change the template type. Add another copy() line and you can get the data inside any container type of your choise, sorted in any way you like.

Hardly complicated, though the complexity is hidden among operator overloading, function objects etc, and those are things that Java lacks, for good and bad.


: 4- pointer in C++ are not safe as java's pointers

Java references are very much unsafe, since you don't explictly write that you are passing the argument by reference. They expect that everyone simply knows that, and thinks of it when they are writing a function. So if you step in straight from C/C++, Pascal or whatever and start writing Java, you will almost certainly trash a fair amount of function parameters since they look as if they were passed by value. Or forgetting to compare the passed parameter with "this" when writing an "equals" function.


If you want to preach Java over C++, you should mention inheritage, inferfaces, intuitive OO design etc, because that is where Java gets the real advantage, being way more clean and logical. And of course the platform independance, as well as and the Java applets that can run from any modern web browser.
Report
Re: Is C++ the best language? Posted by zibadian on 19 Oct 2007 at 7:13 AM
: : 3- Templates in C++ are error prone and soo complicated comparing to
: : Java Object type
:
: The Java Object type is not something to brag about. Both C++ and C#
: have better ways.
:
: C++ templates accepts primitive data types, Java Objects don't, you
: need to use real ugly wrapper classes to even be able to pass common
: integers, since Java isn't a pure object-oriented language, unlike
: C# where everything's objects.
:
: As for C++ templates, they are complicated, but way more powerful
: once you have them working. Take this example:
:
:
:   ifstream fin("dummy.txt");
:   if(!fin.is_open())
:   {
:     /* error handling */            
:   }
:   istream_iterator<SomeType> fin_it (fin), end;
:   ostream_iterator<SomeType> cout_it(cout, "\n");
:   copy(fin_it, end, cout_it);
:   fin.close();
:
:
: This opens a file containing custom "SomeType" objects, reads them
: and prints them all to the screen in a type-specific manner. In 6
: lines of code. Need another i/o source? Change one argument to the
: constructors. Need another type? Change the template type. Add
: another copy() line and you can get the data inside any container
: type of your choise, sorted in any way you like.
:
: Hardly complicated, though the complexity is hidden among operator
: overloading, function objects etc, and those are things that Java
: lacks, for good and bad.
:
:
: : 4- pointer in C++ are not safe as java's pointers
:
: Java references are very much unsafe, since you don't explictly
: write that you are passing the argument by reference. They expect
: that everyone simply knows that, and thinks of it when they are
: writing a function. So if you step in straight from C/C++, Pascal or
: whatever and start writing Java, you will almost certainly trash a
: fair amount of function parameters since they look as if they were
: passed by value. Or forgetting to compare the passed parameter with
: "this" when writing an "equals" function.
:
:
: If you want to preach Java over C++, you should mention inheritage,
: inferfaces, intuitive OO design etc, because that is where Java gets
: the real advantage, being way more clean and logical. And of course
: the platform independance, as well as and the Java applets that can
: run from any modern web browser.
:
Here's the Java object reader and printer, for those who are interested:
ObjectInputStream ois = ObjectInputStream(new FileInputStream("dummy.txt"));
Object o = ois.readObject();
while (o != null) {
  System.out.println(o.toString());
}
o.close();

This works for all objects, which implement the Serializable interface.
Report
Re: Is C++ the best language? Posted by Lundin on 19 Oct 2007 at 9:33 AM
:
: 
: ObjectInputStream ois = ObjectInputStream(new FileInputStream("dummy.txt"));
: Object o = ois.readObject();
: while (o != null) {
:   System.out.println(o.toString());
: }
: o.close();
: 
:
: This works for all objects, which implement the Serializable
: interface.


Isn't that just one object though? Perhaps you ment to place it inside the while loop, or...? And you would need different code depending on if you want to print to screen or to a file.
Report
Re: Is C++ the best language? Posted by zibadian on 19 Oct 2007 at 10:10 AM
: :
: : 
: : ObjectInputStream ois = ObjectInputStream(new FileInputStream("dummy.txt"));
: : Object o = ois.readObject();
: : while (o != null) {
: :   System.out.println(o.toString());
   o = ois.readObject();
: : }
: : o.close();
: : 
: :
: : This works for all objects, which implement the Serializable
: : interface.
:
:
: Isn't that just one object though? Perhaps you ment to place it
: inside the while loop, or...? And you would need different code
: depending on if you want to print to screen or to a file.

You're correct. There's one line missing. If you want to explicitly control where the output is going then the code becomes 1 line longer:
ObjectInputStream ois = ObjectInputStream(new FileInputStream("dummy.txt"));
PrintStream tos = System.out;
Object o = ois.readObject();
while (o != null) {
  tos.println(o.toString());
  o = ois.readObject();
}
o.close();

It is possible to shorten the code by inserting the assignment of o into the while condition, but I simply hate that because it decreases readability.
It is also possible to use a for()-loop, but I'm not used to use those without a counter.
Report
Re: Is C++ the best language? Posted by Jonathan on 4 Dec 2007 at 2:15 AM
: 1- array out of bound exception... it doesnt check the array bound
: at compile time which is very bad... not as java.
Erm, actually Java does the majority of those checks at runtime.

: 2- there is a violation in the class design. i mean we can access a
: private member from outside of the class using the friend class
: modifier.
In Java we can do this with reflection.

: 3- Templates in C++ are error prone and soo complicated comparing to
: Java Object type
Huh? That's like saying apples from England are so much tastier than oranges from Spain. If you're going to compare templates with anything in Java, it's generics you should be comparing it to.

: 4- pointer in C++ are not safe as java's pointers
True in that you can have pointers in C++ that point into areas of memory that are deallocated, never allocated or allocated for something else. The thing that always amused me in Java is that they are called references rather than pointers - until you try and access a null one and then you get a NullPointerException.

: but as a system language C++ is good .. or if you want to use C++ in
: building games...
Sure. It's about choosing the right tool for the job. Sometimes C++ is that. Sometimes it isn't. There's no one true language.

Jonathan
###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
Report
Re: Is C++ the best language? Posted by daviddaly on 30 Oct 2007 at 1:26 PM
Thanks to everyone one for their replies and comments. I have posted my response to some of them as a comment on my original blog post.

Report
Re: Is C++ the best language? Posted by Actor on 27 Nov 2007 at 12:01 AM
: For a long time I have debated with my friends/colleagues my reasons
: for thinking that C++ is the best all round programming language. I
: finally got round to posting this on my blog
: ([link=http://outofthetriangle.wordpress.com/2007/10/18/is-c-the-only
: -real-language/]Is C++ The Only Real Language?[/link]). I’d love to
: know what everyone else thinks. Is my assessment fair? Or should the
: program language crown be more deservingly allocated to another
: language?
:
Since you've already confessed (on your blog) that you "(rather deviously) posed questions that were bound to make C++ score comparatively well" I think we should take a look at the criteria you established.


1. Does the language compile?
Entirely beside the point. Whether a language is implemented as a compiler or an interpreter is not usually part of the language definition. Although BASIC is usually thought of as an interpreted language there are plenty of BASIC compilers out there. And while Pascal is usually compiled the book Oh! Pascal! comes with a disk that includes a Pascal interpreter. I'll bet if you looked hard enough you could find a C++ interpreter, or could write one yourself. This factor does not deserve to be considered let alone be worth two points.

2. Are a variety of IDEs and compilers from multiple vendors available for the language?
Also beside the point. The availability of IDEs is not a metric for how good the language is but for how popular it is. And popularity is also not a metric for how good a language is. I'll extend that argument to the requirement for IDEs from multiple vendors. The rule penalizes a language if one vendor is so successful that his product dominates the market. Delphi, by the way, is actually "Visual Pascal" but Borland could not call it that for fear of infringing on Microsoft's trademark. In the extreme case I'll take the position that "real programmers don't need an IDE, just a text editor and a command line compiler."

3. Does the language support multiple operating systems?
Again beside the point. Popular languages get implemented on popular operating systems. It also seem to be sort of upside down. Languages do not support operating systems. Operating systems support languages. But I'll give you this one simply because most good languages get implemented on most OS.

4. Can the language create stand alone applications?
Again beside the point. This is not normally something that is found in the language definition. It's entirely implementation dependent.

5. Does the language support object orientation?
I'll give you this one.

6. Is the language commonly used to write device drivers and other low level software?

7. Does the language support pointers and direct memory allocation?
I personally consider both 6 & 7 a negative, but I'll give you both. Nolo contendre.

8. Is there an ANSI standard for the language?
Duh. Is there any language (one that would be a serious contender of "best language) that doesn't have an ANSI (or ISO) standard? What language did you have in mind? Forth? Naw! I think even Forth has a standard.

9. Has the language ever been used to write an operating system?
The most reverse engineered of the lot, obviously intended to promote C/C++. C was created just to write an OS (Unix). Actually, you might be surprised to find how many languages have been "bootstrapped," i.e., had a compiler written in the same language that was being implemented.

10. Does the language fit into the “if it’s possible it can be done” category?
This requirement (and #9 also) are just sneaking #7 (pointers and DMA) in a second (and third) time since that's all that's really required.


I'd like to add ...
11. Does the language have an annual "obfuscated code" contest and/or a best selling (fill in name of language here) puzzle book?
If so, subtract three points. This is not a minor consideration. In any major programming effort, major meaning a minimum 2000 nccl, programming in C, instead of Cobol, Fortran, Pascal, etc, is a continuous bug hunt. I firmly believe that most of the bugs that plague the software buying public, the ones that got by both the programmers and the beta testers, would not exist were the dominant languages not C/C++ and their derivatives.


Personally, I don't care for the idea of a "best language" since it implies that some general purpose language exists that is a panacea for every programmer's ills. There just isn't any such animal. C was invented to write an operating system and by extension also serves to write drivers. That it was ever used to do anything more than that is an accident of history, a misfortune that computer has suffered from for over two decades with no end in sight. There are plenty of programming problems out there (most in fact) for which C is not the best answer, albiet (#10) it is an answer.

I'd like to know what other languages you are familiar with. In my experience most C/C++ enthusiasts either started out as assembly language programmers or else were taught C/C++ as a first language (Bad choice for a first language). Those who started, as I did, with Fortran, Cobol and BASIC as first languages tend to not like it. I'll admit that I have not polled enough programmers to form a statistically significant sample.


Report
Re: Is C++ the best language? Posted by AsmGuru62 on 27 Nov 2007 at 4:09 AM
Let me rephrase the famous quote:
Language does not produce bugs, bad programmers do.
In other words, C++ is fine, as long as one is a good programmer. Same can be said of all other languages as well.

..."continuous bug hunt" was not a good argument. There are simply too many mediocre programmers boomed into the profession, that's all. It will pass eventually.
Report
Re: Is C++ the best language? Posted by Lundin on 27 Nov 2007 at 5:56 AM
: 1. Does the language compile?
: Entirely beside the point. Whether a language is implemented as a
: compiler or an interpreter is not usually part of the language
: definition. Although BASIC is usually thought of as an interpreted
: language there are plenty of BASIC compilers out there. And while
: Pascal is usually compiled the book Oh! Pascal!
: comes with a disk that includes a Pascal interpreter. I'll bet if
: you looked hard enough you could find a C++ interpreter, or could
: write one yourself. This factor does not deserve to be considered
: let alone be worth two points.

I suppose the criteria could as well been written as "will the programs made in the language be fast or slow", since that is what the points are all about. Also, interpreted languages can never be used to write stand-alone applications such as operative systems or embedded applications.

It is worth to note that both C and C++ standards mentions compilers "between the lines", ie they implicitly assume the language will be compiled to binary files.


: 3. Does the language support multiple operating systems?
: Again beside the point. Popular languages get implemented on
: popular operating systems. It also seem to be sort of upside down.
: Languages do not support operating systems. Operating systems
: support languages. But I'll give you this one simply because most
: good languages get implemented on most OS.

It isn't beside the point. Some languages can't be implemented on multiple operating systems. Some examples are Visual Basic which can only be implemented in Windows, per definition of the language, and Java, which can only be implemented on systems with a virtual machine, ie there must be an OS.

I don't agree that systems support languages. I can come up with one or two systems designed to only support one specific high-level language. There are however thousands of systems (and I'm not exaggerating) without any language support at all, apart from machine code / assembler.


: 5. Does the language support object orientation?
: I'll give you this one.

OO is a fuzzy term though. As I for example (boldly) wrote in reply to that blog, ANSI C does support object orientation, while it does not support inheritage. C is excellent for writing module-based, highly maintainable programs with encapsulation of private variables.

: 6. Is the language commonly used to write device drivers and
: other low level software?

:
: 7. Does the language support pointers and direct memory
: allocation?

: I personally consider both 6 & 7 a negative, but I'll give you both.
: Nolo contendre.

If a language can't write every kind of application, it will have to depend on other languages to do the real work for it. Kind of like people who post on programming sites asking for someone to do their homework for them :), the program will work when executed, but not by its own effort.

: I'd like to add ...
: 11. Does the language have an annual "obfuscated code" contest
: and/or a best selling (fill in name of language here) puzzle
: book?

: If so, subtract three points. This is not a minor consideration.
: In any major programming effort, major meaning a minimum 2000 nccl,
: programming in C, instead of Cobol, Fortran, Pascal, etc, is a
: continuous bug hunt. I firmly believe that most of the bugs that
: plague the software buying public, the ones that got by both the
: programmers and the beta testers, would not exist were the dominant
: languages not C/C++ and their derivatives.

Hehe... well, the only reason there is one for C and C++ is that they are popular. I don't know of any single language where you can't screw up the code so that it is completely unreadable.

The majority of the bug plauge comes from the fact that a majority, not a minority, of the programmers in the world are incompetent, no matter language. In my opinion, you need a degree and 3 years of full-time programming experience as a minimum, before you can even claim to be a decent programmer. I see so many poor examples all the time from people that are supposed to be professional programmers, it makes me sick knowing that people actually pay money for their programs.

I think it is because various attitude problems. People who know the syntax of a programming language tend to claim to be programmers just because of it. Then there are people who refuse to use any programming standard and re-invent the wheel. And then there are people who write programs "in theory", who are clueless about what their programs actually do on a machine level.


: Personally, I don't care for the idea of a "best language" since it
: implies that some general purpose language exists that is a panacea
: for every programmer's ills. There just isn't any such animal. C
: was invented to write an operating system and by extension also
: serves to write drivers. That it was ever used to do anything more
: than that is an accident of history, a misfortune that computer has
: suffered from for over two decades with no end in sight. There are
: plenty of programming problems out there (most in fact) for which C
: is not the best answer, albiet (#10) it is an
: answer.

Agreed, it doesn't make much sense to nominate a programming language for "best language all categories". C/C++ is for example a rather poor choise for web/desktop programs. Java or C# are better choises there. But at the same time, that assumes that you will only make web/desktop programs and nothing else.

Though, the flexibility of C is a great advantage over other languages. You can take code you wrote as part of a program for an 8-bit microcontroller and put it inside your huge graphic PC video game.

And the other main advantage is efficiency. There is yet no other high level language which is as fast and memory efficient. None. Assuming that we are talking about the real implementation and practical usage of the language. On a fuzzy academic level without any connection to reality, then every language is equally fast/slow.


: I'd like to know what other languages you are familiar with. In my
: experience most C/C++ enthusiasts either started out as assembly
: language programmers or else were taught C/C++ as a first language
: (Bad choice for a first language). Those who started, as I did,
: with Fortran, Cobol and BASIC as first languages tend to not like
: it. I'll admit that I have not polled enough programmers to form a
: statistically significant sample.

I would count as a C/C++ enthusiast and I started out with Pascal. I liked C a whole lot better than Pascal when I learnt it. Suddenly you could do everything with the language.
Report
Re: Is C++ the best language? Posted by Actor on 31 Dec 2007 at 5:26 AM

: And the other main advantage is efficiency. There is yet no other
: high level language which is as fast and memory efficient. None.
: Assuming that we are talking about the real implementation and
: practical usage of the language. On a fuzzy academic level without
: any connection to reality, then every language is equally
: fast/slow.

:
"There is yet no other high level language which is as fast and memory efficient."

I seriously doubt that is true. Can you point to any study that has been done that will back up that contention? I don't know of any. I've done my own studies with small programs that indicate there is no significant difference. Coding the same algorithm with C++, Pascal, Fortran produced results where sometimes C++ was fastest/smallest, sometimes not. Of course my study was too small to be conclusive. A true study would have to involve bigger programs, a lot more programs and a lot of expense. There may be a study out there that proves the point one way or the other but finding one could be like the hunt for UFOs or Bigfoot. Just because you've never caught one does not prove that one doesn't exist. Still, until they do catch one, I don't believe in UFOs or Bigfoot and I don't believe that C++ produces faster/smaller programs.

Report
Re: Is C++ the best language? Posted by Csabi_B on 1 Dec 2007 at 5:50 AM
I think the Assembler is the only real language. Why is it not so popular? (1) Because operation systems tend to keep their secrets, so assembly programming has poor documentation support; (2) there are few written and ready procedures and functions to import for an assembly source. Pascal and C would be nothing without the official units and include files; (3) as you mentioned programmers' abilities, assembly takes a decent programmer. And who is the decent programmer? Who can keep certain numbers of steps and values in mind. Who cannot do that, they brand a difficult source "unreadable". It is very funny when programmers insert comments and tabulators (number of spaces) by "good programming practice", and you can see everything but the code they wrote... I think a decent programmer CAN read and does not need comments; (4) there are too many kind of PC and OS. If there was one standard PC to know well, writing applications would be easy even in machine language, because it would not take a decade of research how to call BIOS routines, read ports, handle the filesystem. Basically these jobs are like simple function calls and moving values and parameters like write(this) and read(that). It surprises me how easy could an inline statement be.

Does object oriented programming make a good language? Was OOP not invented because the language was not good enough for team work? If OOP was just a matter of syntax, it would solve the problems, but it is a matter of making a high level language more structured and farther from the real program code and results poor machine code. OOP provides programming security, but it creates new problems. (Your C++ and Java "few-line" examples demonstrate very well the thing: only ten lines in the source, but a thousand in the code. This is why I dropped OOP at once. You can never tell what the elegant statements do and at what cost...)

I think OOP can be replaced by the IDE Inking Techniques. (The source is of two files: the usual text and the mirror info-file and the team members write their things "in different ink". In the end the preprocessor sees the mirror info and warns by agreement, the compiler sees only the text).

The good high level language:
(1) uses only basic statements and no inclusive functions as write(), "GetEnvironmentStatusThreadErrorProcWhenReady()", because every interaction with the hardware and the OS is hardware and OS dependent. How could Pascal, for one, be a standard language when you cannot use the Write() procedure under Windows without emulation for instance;
(2) supports only the data types of the machine, which is all about size and not value interpretation;
(3) utilizes the instructions of the processor by enforcing the programmer to use clear and optimal statements;
(4) has a simple interface for import sources and binaries as well to fill the space of the lacking built in "standard" routines;
(5) has a strict ISO standard. I think the ISO standards allow too much, and sometimes they allow very ill protocol to interact with the environment;
(6) has compiler directives built in the syntax. Lots of statements and calls fail when a directive is not set properly. (Such directives regarding data alignment, calling protocol, optimatization, processor type, filesystem, etc.) As compiler directives were invented to create environment dependent code, the language must be environment dependent. Going round...

As the available operation systems and personal computers stink due to bad standardization, wrong policies, and commerce as top priority, it is hard to create a good language.
Report
Re: Is C++ the best language? Posted by Lundin on 2 Dec 2007 at 2:54 PM
Assembler is not so popular because it is extremely unportable. You will have to re-invent the wheel as soon as a new CPU is released or as soon as the program is moved to another system. Programming != PC, after all.
Report
Re: Is C++ the best language? Posted by Actor on 3 Dec 2007 at 12:16 PM
: I think the Assembler is the only real language. Why is it not so
: popular? (1) Because operation systems tend to keep their secrets,
: so assembly programming has poor documentation support; (2) there
: are few written and ready procedures and functions to import for an
: assembly source. Pascal and C would be nothing without the official
: units and include files; (3) as you mentioned programmers'
: abilities, assembly takes a decent programmer. And who is the decent
: programmer? Who can keep certain numbers of steps and values in
: mind. Who cannot do that, they brand a difficult source
: "unreadable". It is very funny when programmers insert comments and
: tabulators (number of spaces) by "good programming practice", and
: you can see everything but the code they wrote... I think a decent
: programmer CAN read and does not need comments; (4) there are too
: many kind of PC and OS. If there was one standard PC to know well,
: writing applications would be easy even in machine language, because
: it would not take a decade of research how to call BIOS routines,
: read ports, handle the filesystem. Basically these jobs are like
: simple function calls and moving values and parameters like
: write(this) and read(that). It surprises me how easy could an inline
: statement be.
:
: Does object oriented programming make a good language? Was OOP not
: invented because the language was not good enough for team work? If
: OOP was just a matter of syntax, it would solve the problems, but it
: is a matter of making a high level language more structured and
: farther from the real program code and results poor machine code.
: OOP provides programming security, but it creates new problems.
: (Your C++ and Java "few-line" examples demonstrate very well the
: thing: only ten lines in the source, but a thousand in the code.
: This is why I dropped OOP at once. You can never tell what the
: elegant statements do and at what cost...)
:
: I think OOP can be replaced by the IDE Inking Techniques. (The
: source is of two files: the usual text and the mirror info-file and
: the team members write their things "in different ink". In the end
: the preprocessor sees the mirror info and warns by agreement, the
: compiler sees only the text).
:
: The good high level language:
: (1) uses only basic statements and no inclusive functions as
: write(), "GetEnvironmentStatusThreadErrorProcWhenReady()", because
: every interaction with the hardware and the OS is hardware and OS
: dependent. How could Pascal, for one, be a standard language when
: you cannot use the Write() procedure under Windows without emulation
: for instance;
: (2) supports only the data types of the machine, which is all about
: size and not value interpretation;
: (3) utilizes the instructions of the processor by enforcing the
: programmer to use clear and optimal statements;
: (4) has a simple interface for import sources and binaries as well
: to fill the space of the lacking built in "standard" routines;
: (5) has a strict ISO standard. I think the ISO standards allow too
: much, and sometimes they allow very ill protocol to interact with
: the environment;
: (6) has compiler directives built in the syntax. Lots of statements
: and calls fail when a directive is not set properly. (Such
: directives regarding data alignment, calling protocol,
: optimatization, processor type, filesystem, etc.) As compiler
: directives were invented to create environment dependent code, the
: language must be environment dependent. Going round...
:
: As the available operation systems and personal computers stink due
: to bad standardization, wrong policies, and commerce as top
: priority, it is hard to create a good language.

You're right that assembler is the only real language. The problem is that every different CPU has its own assembly language. That means close to zero portability.

However, the primary reason it is unpopular is that a tremendous number of programmer hours are required to develop and maintain an application. Rapid Application Development it is not. The very purpose of a high level language is to trade machine time (which is cheap) for man hours (which are expensive).

In my early days I wrote a lot of quick and dirty programs for engineers. The request could come in at 9:00 a.m. and I'd have the program ready at noon. I did this in Fortran and BASIC. If I'd had to do this in assembler it would have probably taken a week and the engineer would probably have just done it by hand using a lot a paper and an adding machine.


Report
Re: Is C++ the best language? Posted by Csabi_B on 4 Dec 2007 at 9:25 AM
:
: You're right that assembler is the only real language. The problem
: is that every different CPU has its own assembly language. That
: means close to zero portability.
:
: However, the primary reason it is unpopular is that a tremendous
: number of programmer hours are required to develop and maintain an
: application. Rapid Application Development it is not. The very
: purpose of a high level language is to trade machine time (which is
: cheap) for man hours (which are expensive).

Expensive man hours and portability. Yes, that is true. I just answered the topic which was started rating the abilities of a language. I also prefer high level languages to assembler (I am really not an assembly programmer in any meaning), but I dare add some more:

Even the machine language has built-in functions and iterations (real iterations, not just the same old loops), and it happens that a machine code statement is even shorter and more readable than the high level language statement for the same result, let alone efficiency.

You mentioned portability and I mention weak standardization again. The manufacturers go directions they please (they have the right of course), but all in all they just ruin one other's business and, most importantly, the computer world.

I do not discriminate Pascal, C, and any other language. Each language can be put in practice right and wrong ways. In my opinion, Turbo Pascal was more decently put together than the ISO follower variants of Pascal.

(Personally the symbolist and case sensitive sytax of C left me with mixed feelings.)

A good high level language never leaves the assambly sense, its basic statements are almost equivalent to the assembly (the difference is usually that assembler uses registers, the high level language uses variables, because the contents of a register is uncertain and hidden and lost between the lines of the high level language syntax). The ability of time-sparingly writing a program in a language depends on how the supplied functions supports the cause of the programmer/user. But that is not the topic about languages; it would be a topic of how a language is supported by developers and hardware inventors, and if it is so, we have stated, as unified, that assembly language is not supported well, therefore writing in asm is a pain and means wheel inventions.

Oh, I must add this fine example: once upon a Turbo Pascal tool called Turbo Access. It could do everything (indexed and relative databases) Clipper and the like could do with less hardware expenses. When others wrote database handlers in Clipper I thought: you are crazy. All is about support. As Borland International Inc. (the supporter) died, Turbo Pascal died with it. Who could tell how far TP would have reached by now with support! There would not be Delphi, Kylix, GNU Pascal and such, for sure. (The Borland of today is a different company, it just holds the similar name.)
Report
Re: Is C++ the best language? Posted by Lundin on 4 Dec 2007 at 12:15 PM
: You mentioned portability and I mention weak standardization again.
: The manufacturers go directions they please (they have the right of
: course), but all in all they just ruin one other's business and,
: most importantly, the computer world.


It is not that simple. First there are 8-bit, 16-bit, 32-bit and 64-bit cpus. To make assembler portable between them isn't simple, especially not when going from a large address bus to a smaller one: that code can't be portable by definition, or it would be very ineffective. Plus, processors relying on external memory vs microcontrollers with memory and peripherals on-chip have very different needs.

Standardization is however taking place more and more. The big players in the cpu industry are all making their cpu families compatible from the range of 8 to 32 bit. Most of them also have an ARM version, which has turned into an industry standard. Intel/ADM made 64-bit cpus compatible with 32-bit ones, and so on.

Then there are architecture problems. Intel and Intel derivates in the whole range from 8 to 32 bit have always been odd in their core design, and have by tradition been rather code-inefficient. And then there is the old feud between little and big endian... or the feud between Intel and Motorola ways of thinking, where both camps believe their solution is the better. Intel side has its sheer size, while Motorola side is usually more code-efficient in most performance tests.
Report
Re: Is C++ the best language? Posted by Actor on 4 Dec 2007 at 12:54 PM
:
: You mentioned portability and I mention weak standardization again.
: The manufacturers go directions they please (they have the right of
: course), but all in all they just ruin one other's business and,
: most importantly, the computer world.
:
Unfortunately no standard can anticipate advances in technology. Standards are good for business but in many cases they must be ignored if progress is to be made. This is another reason for high level languages.


Report
Re: Is C++ the best language? Posted by HackmanC on 2 Dec 2007 at 5:37 PM

Sorry, I have to tell you. You CAN'T compare one with each other. Because each one was developed in different lines of work.

Try to build a regular expression parser in C++ ? Try to build a driver in Unix scripts ? A Database application in Fortran ? A graphical interface in PHP5 ? A 3D game in Perl ?

With ASM and C++ you can make everything other languages do, because (some of those) are created in C, C++. But those already has it done.

Each one has its own place in programming environment, you can't compare them because neither of them was designed to replace any of each others. Just to design different kind of applications.

Good luck!
Hackman
Report
Re: Is C++ the best language? Posted by Actor on 3 Dec 2007 at 11:55 AM
:
: Try to build ... A Database application in Fortran ?
:
I've done it.

Actor

Report
Re: Is C++ the best language? Posted by HackmanC on 3 Dec 2007 at 1:35 PM

I never said and I'm not saying it can't be done.
You can do everything you want with every language.

I'm saying that some languages already
has better support for some kind of tasks,
and that's why you shouldn't compare them.

Of course you can design database applications
in Fortran, but you need at least 3000% the time
you need to do the same thing in COBOL.

So, it's like comparing a Electrician against
a Salesman, both could be professionals, but each
one in his territory.

Good luck!
Hackman
Report
Re: Is C++ the best language? Posted by Actor on 4 Dec 2007 at 1:06 PM
:
: I never said and I'm not saying it can't be done.
: You can do everything you want with every language.
:
: I'm saying that some languages already
: has better support for some kind of tasks,
: and that's why you shouldn't compare them.
:
: Of course you can design database applications
: in Fortran, but you need at least 3000% the time
: you need to do the same thing in COBOL.
:
: So, it's like comparing a Electrician against
: a Salesman, both could be professionals, but each
: one in his territory.
:
: Good luck!
: Hackman
Actually I don't think writing it in COBOL would have saved that much time. The actual development time may have been cut in half. However, a COBOL version would probably have run faster in less memory. I know the storage of the actual data was very inefficient. We tried to find a COBOL compiler for our machine but were unsuccessful. I don't think management would have bought us one anyway. I think the Fortran compiler cost thousands (circa 1985).

Actor


Report
Re: Is C++ the best language? Posted by HackmanC on 8 Dec 2007 at 4:47 PM
Ok, I see I was clear enough.
And my example was the best one.

I give you another easier example to show
why you can't compare some languages.

Write a database application on FoxPro Lan 2.0
Write the SAME application on Borland C++ 3.0
Without downloading db lib's.

Yes, you can write it, and there are a lot of libraries
to do that, in less time, efficient, perfect!. But FoxPro
is a Database language, I'm not saying it is the best
language for DBMS, neither it will beat every other DBMS,
neither it has the worst "relational" database management.
Neither I said the same of C++.

Just that you can't compare them,
because those are two different worlds.

A database language has forms, reports, an easy open/close.
A generic language doesn't have it by design. You can link others.

Which one is the best?

DEPENDS ON YOUR NEEDS


Good luck!
Hackman
Report
Re: Is C++ the best language? Posted by Actor on 8 Dec 2007 at 1:09 AM
For what it's worth here's a quote and the link where I found it. I'm not a Lisp programmer.

"If you give someone Fortran, he has Fortran. If you give someone Lisp, he has any language he pleases."

Common Lisp is truly the Borg of programming languages!

http://bc.tech.coop/blog/040402.html
Report
Re: Is C++ the best language? Posted by Actor on 8 Dec 2007 at 11:32 PM
Another link with more food for thought.

http://c2.com/cgi/wiki?LittleLanguage
Report
Re: Is C++ the best language? Posted by Actor on 9 Dec 2007 at 3:11 PM
: For a long time I have debated with my friends/colleagues my reasons
: for thinking that C++ is the best all round programming language. I
: finally got round to posting this on my blog
: ([link=http://outofthetriangle.wordpress.com/2007/10/18/is-c-the-only
: -real-language/]Is C++ The Only Real Language?[/link]). I’d love to
: know what everyone else thinks. Is my assessment fair? Or should the
: program language crown be more deservingly allocated to another
: language?
:
Hey, I'd like to nominate Ada. I'm not an Ada programmer but from what I know about it, it seems to deserve an 11.

And how about Actor. I know little or nothing about the Actor language but I gotta support a language that has the same name as me.

Actor




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.