Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Any reason to use C?

Author: Robert Hyatt

Date: 16:41:27 07/31/03

Go up one level in this thread


On July 31, 2003 at 18:20:47, Matthew White wrote:

>On July 31, 2003 at 11:21:58, Robert Hyatt wrote:
>
>>On July 30, 2003 at 18:07:07, Matthew White wrote:
>>
>>>On July 30, 2003 at 00:00:54, Robert Hyatt wrote:
>>>
>>>>On July 29, 2003 at 22:10:11, Matthew White wrote:
>>>>
>>>>>On July 29, 2003 at 22:08:13, Robert Hyatt wrote:
>>>>>
>>>>>>On July 29, 2003 at 20:16:59, Matthew White wrote:
>>>>>>
>>>>>>>On July 29, 2003 at 16:53:05, Vincent Diepeveen wrote:
>>>>>>>
>>>>>>>>On July 29, 2003 at 03:15:54, Hristo wrote:
>>>>>>>>
>>>>>>>>>On July 28, 2003 at 19:12:56, Vincent Diepeveen wrote:
>>>>>>>>>
>>>>>>>>>>On July 28, 2003 at 17:34:46, Russell Reagan wrote:
>>>>>>>>>>
>>>>>>>>>>>Is there any reason to start new projects with C anymore? It seems like most (if
>>>>>>>>>>>not all) of the drawbacks of C++ have faded away with modern compilers.
>>>>>>>>>>>
>>>>>>>>>>>Note that I am talking about new projects, and maintaining old projects is
>>>>>>>>>>>obviously a good reason to still use C.
>>>>>>>>>>
>>>>>>>>>>If i would learn coding today i would prefer C++.
>>>>>>>>>>
>>>>>>>>>>However let's be clear, for good programmers there is not much diff between C
>>>>>>>>>>and C++. Every complex problem which you can solve in 10000 lines of C++ you can
>>>>>>>>>>solve in 10000 lines C too.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>Vincent,
>>>>>>>>>with all due respect I must disagree. In 10K lines of C++ code one can solve a
>>>>>>>>>much more general or larger set of problem(s) or cram in more features. :)
>>>>>>>>>(think templates, exceptions, and often inheritance ... all of which can shorten
>>>>>>>>>your code)
>>>>>>>>
>>>>>>>>I do not know about you, but i program both in C and C++.
>>>>>>>>
>>>>>>>>Do you?
>>>>>>>>
>>>>>>>>Not a single program where you can use all the nice toys you can also make a few
>>>>>>>>functions for in C.
>>>>>>>>
>>>>>>>>In general the average programmed C++ program you program more compact in C.
>>>>>>>>
>>>>>>>>That's not what i'm talking about.
>>>>>>>>
>>>>>>>>If you do not know how to program in C, then just say it loud instead of writing
>>>>>>>>it down like this.
>>>>>>>>
>>>>>>>>the advantages of what you mention here (assuming 1 man products) you can show
>>>>>>>>great in 50 line examples or even 200 line examples.
>>>>>>>>
>>>>>>>>But as soon as you write a 10000 line product then it doesn't matter what you do
>>>>>>>>in C++. I can do the same in C too. No problem!
>>>>>>>>
>>>>>>>>>In your post, latter, you indicate that C++ offers some advantages over C,
>>>>>>>>>especially for large projects. In my experience this is %100 true, so we are in
>>>>>>>>
>>>>>>>>I see no other advantages to C++ than for big projects in fact.
>>>>>>>>
>>>>>>>>The advantage is *really* huge there for companies.
>>>>>>>>
>>>>>>>>Given the importance of those companies for the world, the choice to teach
>>>>>>>>students C++ instead of C is a logical choice.
>>>>>>>>
>>>>>>>>teaching them Java, delphi i find a bad idea.
>>>>>>>>
>>>>>>>The best reason that I see to teach students using Java is that Java gives you
>>>>>>>useful information when an error occurs (remember the first time you saw a
>>>>>>>segmentation fault how lost you felt?). Java has strong typing and it FORCES
>>>>>>>object orientedness. C and C++ are too frustrating for new programmers...
>>>>>>>
>>>>>>>Matt
>>>>>>
>>>>>>
>>>>>>Strong typing was also Pascal's claim to fame.  Thankfully it died a
>>>>>>graceful death.
>>>>>
>>>>>It was good for teaching, though...
>>>>>
>>>>>Matt
>>>>
>>>>
>>>>Depends on your ultimate goal.  If you are going to be a programmer, it is
>>>>not the best way to go.  If you program in Java for 4 years, then leave and
>>>>go to work where they use C, you have a _long_ learning curve.  You've never
>>>>seen pointers, for example.
>>>>
>>>>We took a _lot_ of heat about that from companies like BellSouth.
>>>
>>>I see what you mean. However, for intro-type classes, Java makes a lot of sense.
>>>When a student is first learning syntax, Java is far easier than C++. Once a
>>>student has a fairly good command of syntax, then C/C++ could be used for
>>>development in more advanced classes. It seems to me that the learning curve
>>>will be easier to overcome once syntax is no longer an issue...
>>
>>I'm not sure how Java is "easier".  Omit C's pointers.  The loops, declarations,
>>etc are the same.  You have to learn to use some imported class stuff for I/O
>>and the like.  In C you use a run-time library.
>>
>>However, omitting pointers is a serious problem for those that are going to
>>use C/C++ professionally.  I've taught classes for BellSouth to remedy this.
>>They get kids that simply haven't been exposed to pointers, yet all their
>>applications at BellSouth depend on them, because you can't even use the
>>normal library stuff without pointers.
>
>I realize that they are essentially the same. The reason why I lean towards Java
>is the fact that if you read past the end of an array in Java, you get an
>ArrayOutOfBounds exception with the line number where the exception occurred. In
>C/C++ you get the obscure "Segmentation Fault (core dumped)." That scared the
>hell out of me as a student, having no clue what a core was... I just think that
>Java is a friendlier intro...
>
>Matt


The real problem is that C has never had "arrays".  It has always had pointers,
but arrays were implemented on top of pointers as a kludge.  As a result, bounds
don't mean anything at run-time.

There are tools that help here, of course, but it would be nice to have a
compiler option to check array bounds, although for chess it would not work
for things that are dynamically created like the hash table.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.