|
|
Warp wrote:
> OTOH, I assume his code was something relatively simple. Something you
> would write when you are creating a simple and straightforward program.
It was "guess a number from 1 to 100, and I'll tell you if you're too
high or too low." I don't imagine it would be any more straightforward
in C or C++, really. Sure, there were a couple of somewhat odd lines
that you had to rely on English to understand, like
case compare number target of
But I found that pretty easy to understand given what the rest of the
program was doing. I might not have been able to write it or tell you if
it was wrong/buggy, but I could read it OK.
Throw in the syntax of printf() or "cout << std::eoln" or whatever, and
I think the syntax in something like C++ is certainly something you need
to learn to read.
There are some languages (like Ada, for example) that do all that C++
does and more, but which use spelled-out words. That doesn't help too
much when you don't know what the words mean. Telling you it's a limited
tagged access type doesn't really tell you what it means any more than
void xyz(void) = 0;
is comprehensible without knowing what it means.
> My reference counting pointer code uses rather advanced techniques
> (related to, among other things, how allocators are used and how templates
> behave) which are quite unusual in "normal" C++.
OK. Question: I think I've figured out what some of your advice means...
When you say "don't use new", are you really saying "use the calls to
new that are in the libraries, and you shouldn't have to do that
yourself"? Or are you really saying "C++ programs rarely need to execute
the 'new' operator"?
The former I can understand. The latter would seem really confusing to
me, and I've been interpreting it as the latter, methinks.
> One good thing in C++ is that usually you can *hide* all that overly
> complicated and advanced code behind a simple and nice public interface,
> so that the code which *uses* that code can be simple, straightforward
> and easy to understand.
Welll..... There's still a bunch of syntax. Template instantiation, <<
and >> for I/O, etc. I mean, compare Haskell add-up-a-list-of-numbers
to C++'s. Something like
fold (+) my_list
to something like
for (j = std::list.begin(); j != std::list.end(); j = j.next())
i += j.value;
or some such. :-)
> With the Haskell examples I often get the feeling that the code which
> I have hard time understanding is code which you write normally, when
> implementing your main code, not some advanced techniques you hide behind
> a nice module interface.
Agreed. I just think it's hard for you for a different reason than C++
is hard for Andrew. Haskell is hard to read because there's a lot of
powerful stuff going on without enough syntax. C++ is hard to read
because there's a lot of powerful stuff going on with too much syntax.
If you're used to a lot of syntax, C++ might be easier to read than
Haskell, and vice versa.
--
Darren New / San Diego, CA, USA (PST)
Post a reply to this message
|
|