lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, Apr 26, 2017 at 3:56 PM, Jay Carlson <nop@nop.com> wrote:
> On Apr 26, 2017, at 12:21 PM, Coda Highland <chighland@gmail.com> wrote:
>>
>> "Good idiomatic modern C++" != "good didactic C++". The stuff you're
>> talking about is a complete non-issue for a beginning programmer.
>>
>> Templates: You don't need to know how to WRITE templates in order to
>> USE them. Beginners should be getting vector<> instead of arrays.
>
> Beginners should be getting tables instead of arrays.

I disagree. It's convenient to make linear containers, associative
containers, and fixed structures all use the same implementation in
terms of language design; there's definitely a certain elegance to
that. But those ARE in fact three distinct concepts, and blurring the
distinction between them seems unwise to me.

>> Smart pointers: Smart pointers are beautiful things, but
>> beginner-level C++ won't be doing the kinds of memory management that
>> needs it. This is going to come AFTER iterators, probably.
>
> Smart pointers? What are pointers?

Then you agree with me! Beginner C++ should be passing things by value
or by reference instead of by pointer as much as possible, and
idiomatic C++ reflects this. (There's a reason that move semantics
were such a big deal in the discussions leading up to C++11; that's
what allows pass-by-value to operate efficiently.)

>> You're right that learning C++ to a level that you can write
>> enterprise-grade software is a long and arduous education, but that
>> doesn't mean that you have to jump in with both feet.
>
> I guess I don't see the point of teaching C++ except as an elective. If you're a CS/EE major, you need to deal with the metal eventually[1], so you might as well go Python/Lua/Scheme then C then assembly. If you're not a CS/EE major, study Python/numpy and Excel, and run circles around the EEs.

As mentioned upthread, there's no point in teaching C when you could
be teaching C++. C++ can do literally everything C can, and it can do
it with syntax that's much friendlier and much less error-prone. Even
the argument about being better in restricted environments is proven
to not hold water, because Arduino's primary language is C++. (That's
not to say that the C++ STL is suitable for restricted environments.
That's a separate argument.) In fact, learning C before learning C++
I've found tends to HURT your ability to write good C++ until you've
unlearned some habits.

High level language -> C -> assembly is really a pretty bad path
nowadays. The demand for assembly skill is ridiculously small. I'm a
CS major myself, and I've only ever written assembly for the fun of it
on retro systems (and an attempt to write a C++ compiler, which got
aborted due to the instructor vanishing). I've never had demand to
write so much as a single line of assembly code in a professional
context. If you're going to teach assembler in school, you should be
teaching it on a toy model as a didactic tool for understanding the
low-level functioning of the CPU instead of teaching it as an actual
programming language.

Meanwhile, modern C++ is a sufficiently high-level language that if
you come at it with an open mind (instead of with prejudices derived
from the disaster that was pre-C++11 in a world that had to support
Visual Studio 6 long past its obsolescence) you'll find a much more
modern and comfortable experience than you might have expected.
There's nothing wrong with Python, and Scheme is a FANTASTIC teaching
language -- but as a SECOND language, where the significance of its
paradigm can be fully appreciated -- but it's not a necessary step in
the process.

That said, I already said upthread that I think that there are
possibly better choices than C++. C# is closer, even though I'd rather
use C++ for real work.

Lua is a good lightweight general-purpose language, don't get me
wrong, and there's probably nothing wrong with exposing fledgling
programmers to it. But in terms of actually building engineering
skill, I think starting off with a statically-typed object-oriented
language is a better choice.

/s/ Adam