🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #2026

Re: Should I learn C or C++ first?

#2026
From: vancleef
Date: Wed, 30 Aug 1995 06:28
47 lines
2226 bytes
In article <41vlgv$q33@druid.borland.com>, pete@borland.com (Pete Becker) writes:
> In article <41tjep$2hn@deyke3.fc.hp.com>, rainer@deyke3.fc.hp.com says...
>>
>>Pete Becker (pete@borland.com) wrote:
>>: In article <41kici$p4t@deyke3.fc.hp.com>, rainer@deyke3.fc.hp.com says...
>>: >: TApplication* MyApp;
>>: >: MyApp = new TApplication("My Application");
>>: >
>>: >: without new and delete?
>>: >
>>: >Why bother with doing both at the same time?
>>: >
>>: >MyApp = (TApplication *)malloc(sizeof(TApplication));
>>: >create_TApplication(MyApp, "My Application");
>>
>>: The difference is in the gap between the two lines, where you have 
> something 
>>: that claims to be a pointer to a TApplication object, but isn't. C++ makes 
> it 
>>: very hard to perform operations on objects that have not been initialized. 
>>: Separating memory allocation from initalization makes it much easier to 
>>: accidentally do things like this, as we have all done at one time or 
> another.
>>
>>Real programmers don't "accidentally" forget to initialize objects.
>>
> 
> Real programmers are human and make mistakes.
> 
>>:       Or, to turn the question around the other way, why separate them?
>>
>>Obviously when using an array where each object is initialized to a
>>different value.  Especially a resizable array.
> 
> That's not the example you posted, which allocated a single object. So, let me 
> ask again: in the code you posted, what benefit is there in separating 
> allocation from initialization?
> 

Pete, this example is so beautiful it isn't even funny. The fact that
you can have a pointer to unitialized data lying around at
all is a source of bugs in its own right.

Obviously Raynier is wasting alot of company time reinventing the wheel
40 hours a week :)

-Garrett
Technical Details
Message-ID: <1995Aug30.022846.8049@ohstpy>
Path: arc1-ca.pugleaf.net!ohstpy.mps.ohio-state.edu!vancleef
References: <DDJ2Lp.3DG@pentagon-ai.army.mil> <41vlgv$q33@druid.borland.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!ohstpy.mps.ohio-state.edu!vancleef
From: vancleef@ohstpy.mps.ohio-state.edu
Newsgroups: rec.games.programmer,comp.lang.c++
Subject: Re: Should I learn C or C++ first?
Message-ID: <1995Aug30.022846.8049@ohstpy>
Date: 30 Aug 95 02:28:46 -0400
References: <DDJ2Lp.3DG@pentagon-ai.army.mil> <41vlgv$q33@druid.borland.com>
Organization: The Ohio State University, Department of Physics