POV-Ray : Newsgroups : povray.off-topic : Coding in ___ is like ___ : Re: Coding in ___ is like ___ Server Time
4 Sep 2024 21:20:53 EDT (-0400)
  Re: Coding in ___ is like ___  
From: Darren New
Date: 26 Feb 2010 13:08:26
Message: <4b880e1a$1@news.povray.org>
Warp wrote:
>   Why would a beginner need to deal with constructors, destructors,
> exceptions and the like?

Because they'll be using libraries that require such.  Even in your example, 
you'd have to talk about the std::string constructor and how it creates an 
empty string if you don't pass it arguments. As opposed to (say) integers, 
that don't get initialized to zero. And what happens if you run out of 
memory in your concatenate function.

>   No, C is a lot more complicated for the beginner precisely because it's
> less powerful.

I disagree. It's more complicated to get things done, but easier to understand.

> std::string concatenate(const std::vector<std::string>& strings)
> {
>     std::string result:
>     for(int i = 0; i < strings.size(); ++i)
>         result += strings[i];
>     return result;
> }



>   Show me the same function implemented in C and explain how it would be
> easier for a beginner (especially without any danger of memory leaks).

It would be easier to explain what's happening. I don't have to explain the 
syntax for method invocation, const, references, the difference between 
references and pointers, the differences between method invocations on 
references and pointers, overloaded operators, or what namespaces are. The 
function will be longer and more dangerous, but the only "unusual" things to 
be explained are pointers and strings. Basically, in the C equivalent, the 
only *confusing* part is that C doesn't allocate multi-word objects for you.

I take it you've never actually taught beginner computer programming 
classes, yes?

It's not "how much power do you have."  It's "how much do you have to 
dismiss as magic before you have a full understanding of the entire language."

-- 
Darren New, San Diego CA, USA (PST)
   The question in today's corporate environment is not
   so much "what color is your parachute?" as it is
   "what color is your nose?"


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.