c vs c++

Discussion of chess software programming and technical issues.

Moderator: Ras

c or c++ ?

c
24
48%
c++
26
52%
 
Total votes: 50

ethanara
Posts: 134
Joined: Mon May 16, 2011 6:58 pm
Location: Denmark

Re: c vs c++

Post by ethanara »

Actually, The language I understand best is c++ , but im still a beginner (from a 1-10 scale i would say im 2-3).
I will start making a pawn chess engine tomorrow, today i plan how to make it.

I like c++ , I remember two years ago, when i was 11 I learned HTML and a friend of mine said that c++ is one of the most used languages.
BTW, c++ was made by a dane (Bjarne Stroustrup)

Regards
Ethan
rbarreira
Posts: 900
Joined: Tue Apr 27, 2010 3:48 pm

Re: c vs c++

Post by rbarreira »

SuneF wrote:
rbarreira wrote:
SuneF wrote:
rbarreira wrote:
SuneF wrote: If you stick to just ansi C it is fairly portable but still in need of special native assemblies as opposed to eg Java. Once you begin with threads or anything requirering 3rd party libs it gets messy.
Java which doesn't even run on all mobile platforms (last I checked, due to licensing reasons), is that what you call a portable language?
Yes Java is extremly portable, that was also one of its key design goals.
Nothing is portable to ALL platforms, so not sure what your point is.
My point is that Java is not as portable as C/C++, that simple. If you have a Java program and want to get it running across several kinds of mobile phones (a quite important platform these days), you're out of luck.
You must be referring to Apple platform? If so you are out of luck with C too, it's call Objective-C and is something different entirely. Of course if you jail-break it works. It's more of a business decision than a limitation of the Java language. Apple wants to fight everyone for some reason.

Windows Mobile and Android supports Java just fine of course, Android _is_ java.
The Apple one is the most important one which doesn't run Java, but it's not the only one I believe.

Objective-C is a superset of C, so no portability worries there. And you can run C++ on the iPhone too...
SuneF
Posts: 127
Joined: Thu Sep 17, 2009 11:19 am

Re: c vs c++

Post by SuneF »

ethanara wrote:Actually, The language I understand best is c++ , but im still a beginner (from a 1-10 scale i would say im 2-3).
I will start making a pawn chess engine tomorrow, today i plan how to make it.
Good luck, C++ is not a bad place to start - OOP is fun! :)
I like c++ , I remember two years ago, when i was 11 I learned HTML and a friend of mine said that c++ is one of the most used languages.
BTW, c++ was made by a dane (Bjarne Stroustrup)

Regards
Ethan
Yes and C# was also invented by a dane, Anders Hejlsbjerg. You can catch some great lectures by him on channel 9, eg. this one:

http://channel9.msdn.com/Blogs/matthijs ... -Hejlsberg


He goes crazy near the end.. trying coding that in C! ;-)
SuneF
Posts: 127
Joined: Thu Sep 17, 2009 11:19 am

Re: c vs c++

Post by SuneF »

rbarreira wrote:
SuneF wrote:
rbarreira wrote:
SuneF wrote:
rbarreira wrote:
SuneF wrote: If you stick to just ansi C it is fairly portable but still in need of special native assemblies as opposed to eg Java. Once you begin with threads or anything requirering 3rd party libs it gets messy.
Java which doesn't even run on all mobile platforms (last I checked, due to licensing reasons), is that what you call a portable language?
Yes Java is extremly portable, that was also one of its key design goals.
Nothing is portable to ALL platforms, so not sure what your point is.
My point is that Java is not as portable as C/C++, that simple. If you have a Java program and want to get it running across several kinds of mobile phones (a quite important platform these days), you're out of luck.
You must be referring to Apple platform? If so you are out of luck with C too, it's call Objective-C and is something different entirely. Of course if you jail-break it works. It's more of a business decision than a limitation of the Java language. Apple wants to fight everyone for some reason.

Windows Mobile and Android supports Java just fine of course, Android _is_ java.
The Apple one is the most important one which doesn't run Java, but it's not the only one I believe.

Objective-C is a superset of C, so no portability worries there. And you can run C++ on the iPhone too...
Ah well I have an Android, HTC Incredible S - which is far superior to iPhone 4 of course :P

But I seriously doubt you can compile that C-code with all it's 3rd party libraries to Objective-C without any problems. A java machine or .Net runtime would solve all those problems.
rbarreira
Posts: 900
Joined: Tue Apr 27, 2010 3:48 pm

Re: c vs c++

Post by rbarreira »

SuneF wrote:
rbarreira wrote:
SuneF wrote:
rbarreira wrote:
SuneF wrote:
rbarreira wrote:
SuneF wrote: If you stick to just ansi C it is fairly portable but still in need of special native assemblies as opposed to eg Java. Once you begin with threads or anything requirering 3rd party libs it gets messy.
Java which doesn't even run on all mobile platforms (last I checked, due to licensing reasons), is that what you call a portable language?
Yes Java is extremly portable, that was also one of its key design goals.
Nothing is portable to ALL platforms, so not sure what your point is.
My point is that Java is not as portable as C/C++, that simple. If you have a Java program and want to get it running across several kinds of mobile phones (a quite important platform these days), you're out of luck.
You must be referring to Apple platform? If so you are out of luck with C too, it's call Objective-C and is something different entirely. Of course if you jail-break it works. It's more of a business decision than a limitation of the Java language. Apple wants to fight everyone for some reason.

Windows Mobile and Android supports Java just fine of course, Android _is_ java.
The Apple one is the most important one which doesn't run Java, but it's not the only one I believe.

Objective-C is a superset of C, so no portability worries there. And you can run C++ on the iPhone too...
Ah well I have an Android, HTC Incredible S - which is far superior to iPhone 4 of course :P

But I seriously doubt you can compile that C-code with all it's 3rd party libraries to Objective-C without any problems. A java machine or .Net runtime would solve all those problems.
The only reason you doubt it is that you don't know the fact that an Objective-C compiler can compile any legal C code, that's the way Objective-C is designed. It's OK not to know things, it's not so OK to keep repeating wrong information which can easily be checked to be wrong...
SuneF
Posts: 127
Joined: Thu Sep 17, 2009 11:19 am

Re: c vs c++

Post by SuneF »

rbarreira wrote:
SuneF wrote:
rbarreira wrote:
SuneF wrote:
rbarreira wrote:
SuneF wrote:
rbarreira wrote:
SuneF wrote: If you stick to just ansi C it is fairly portable but still in need of special native assemblies as opposed to eg Java. Once you begin with threads or anything requirering 3rd party libs it gets messy.
Java which doesn't even run on all mobile platforms (last I checked, due to licensing reasons), is that what you call a portable language?
Yes Java is extremly portable, that was also one of its key design goals.
Nothing is portable to ALL platforms, so not sure what your point is.
My point is that Java is not as portable as C/C++, that simple. If you have a Java program and want to get it running across several kinds of mobile phones (a quite important platform these days), you're out of luck.
You must be referring to Apple platform? If so you are out of luck with C too, it's call Objective-C and is something different entirely. Of course if you jail-break it works. It's more of a business decision than a limitation of the Java language. Apple wants to fight everyone for some reason.

Windows Mobile and Android supports Java just fine of course, Android _is_ java.
The Apple one is the most important one which doesn't run Java, but it's not the only one I believe.

Objective-C is a superset of C, so no portability worries there. And you can run C++ on the iPhone too...
Ah well I have an Android, HTC Incredible S - which is far superior to iPhone 4 of course :P

But I seriously doubt you can compile that C-code with all it's 3rd party libraries to Objective-C without any problems. A java machine or .Net runtime would solve all those problems.
The only reason you doubt it is that you don't know the fact that an Objective-C compiler can compile any legal C code, that's the way Objective-C is designed. It's OK not to know things, it's not so OK to keep repeating wrong information which can easily be checked to be wrong...
Please point out one single thing I said that was wrong. C has never given me anything but a world of pain whenever I tried to port stuff back and forth between windows and linux. The threads didn't work the same, the headers weren't called the same, the timers were broken, I needed macros scattered all over the code to get something to work half decent. Been there done that and if this is what you call portability then you haven't got a clue what the word means.
So chill Einstein, don't try and lecture me, you ain't got the skills.
rbarreira
Posts: 900
Joined: Tue Apr 27, 2010 3:48 pm

Re: c vs c++

Post by rbarreira »

SuneF wrote:
rbarreira wrote:
SuneF wrote:
rbarreira wrote:
SuneF wrote:
rbarreira wrote:
SuneF wrote:
rbarreira wrote:
SuneF wrote: If you stick to just ansi C it is fairly portable but still in need of special native assemblies as opposed to eg Java. Once you begin with threads or anything requirering 3rd party libs it gets messy.
Java which doesn't even run on all mobile platforms (last I checked, due to licensing reasons), is that what you call a portable language?
Yes Java is extremly portable, that was also one of its key design goals.
Nothing is portable to ALL platforms, so not sure what your point is.
My point is that Java is not as portable as C/C++, that simple. If you have a Java program and want to get it running across several kinds of mobile phones (a quite important platform these days), you're out of luck.
You must be referring to Apple platform? If so you are out of luck with C too, it's call Objective-C and is something different entirely. Of course if you jail-break it works. It's more of a business decision than a limitation of the Java language. Apple wants to fight everyone for some reason.

Windows Mobile and Android supports Java just fine of course, Android _is_ java.
The Apple one is the most important one which doesn't run Java, but it's not the only one I believe.

Objective-C is a superset of C, so no portability worries there. And you can run C++ on the iPhone too...
Ah well I have an Android, HTC Incredible S - which is far superior to iPhone 4 of course :P

But I seriously doubt you can compile that C-code with all it's 3rd party libraries to Objective-C without any problems. A java machine or .Net runtime would solve all those problems.
The only reason you doubt it is that you don't know the fact that an Objective-C compiler can compile any legal C code, that's the way Objective-C is designed. It's OK not to know things, it's not so OK to keep repeating wrong information which can easily be checked to be wrong...
Please point out one single thing I said that was wrong. C has never given me anything but a world of pain whenever I tried to port stuff back and forth between windows and linux. The threads didn't work the same, the headers weren't called the same, the timers were broken, I needed macros scattered all over the code to get something to work half decent. Been there done that and if this is what you call portability then you haven't got a clue what the word means.
So chill Einstein, don't try and lecture me, you ain't got the skills.
I don't see why I should point it out again, just read earlier posts.

Sure, you have to adapt some of the code which deals with system-specific stuff, but C itself is portable. The real joke is when you start mixing C# into a discussion of portability and ignoring the fact that Java does not run at all on some important platforms.
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: c vs c++

Post by Don »

Ron Murawski wrote:
rbarreira wrote: Where did you read about GCC including a D compiler soon? AFAIK it had one but it was not maintained in a while.
The GDC front end for GCC is being maintained once again
https://bitbucket.org/goshawk/gdc/wiki/Home
https://bitbucket.org/goshawk/gdc/downloads (download)

Ron
Yes, and it's designed to be more portable than even C. It has multi-processing support also which makes it even more portable.

If I can get within about 5-7% of the speed of GCC I am going to switch over. It may already be there but I have not tested it with a substantial chess-like benchmark in a long time. What is gained will offset a small slowdown - and I would be betting on the future because I think it will end up faster than C once it is integrated into GCC and gets more attention. It's very actively developed.
SuneF
Posts: 127
Joined: Thu Sep 17, 2009 11:19 am

Re: c vs c++

Post by SuneF »

rbarreira wrote: I don't see why I should point it out again, just read earlier posts.

Sure, you have to adapt some of the code which deals with system-specific stuff, but C itself is portable. The real joke is when you start mixing C# into a discussion of portability and ignoring the fact that Java does not run at all on some important platforms.
You're being very vague, specifics is what I ask for.

You want Java on your iPhone, here:
http://iphoneroot.com/tutorial-install- ... he-iphone/

C# is like Java, only more advanced but sadly not quite as portable in practice.
Though like java it has an asp.net equivalent and that is taking into a hole new dimension that C/C++ can't take you. The possibilities are endless :-)
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: c vs c++

Post by Don »

For chess, Java is a poor choice if you want performance. It does not have the low level support you need. It's also a memory pig but there may be ways to work around that. For many types of applications it is not much slower than C or C++ but for the low level bit-twiddling attention to detail and memory management you need for a really high performance chess program, it's a terrible choice.

If you want a pretty good chess program (but not great program) that is portable, then it's probably a reasonable choice.

I honestly don't think C is that portable. It you stick with some specific dialect of C such as ansii C it is portable, but in a real world program you cannot do that. You still have to deal with platform differences in the real world.

My code is peppered with #ifdef's to deal with difference between compilers and platforms and it's annoying.

My experience is that Java really is much more portable. I do not know if this applies to the hand-held devices which use subsets or variations of java.







SuneF wrote:
rbarreira wrote: I don't see why I should point it out again, just read earlier posts.

Sure, you have to adapt some of the code which deals with system-specific stuff, but C itself is portable. The real joke is when you start mixing C# into a discussion of portability and ignoring the fact that Java does not run at all on some important platforms.
You're being very vague, specifics is what I ask for.

You want Java on your iPhone, here:
http://iphoneroot.com/tutorial-install- ... he-iphone/

C# is like Java, only more advanced but sadly not quite as portable in practice.
Though like java it has an asp.net equivalent and that is taking into a hole new dimension that C/C++ can't take you. The possibilities are endless :-)