lua-users home
lua-l archive

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


On Wed, Apr 26, 2017 at 5:44 PM, Andrew Starks <andrew@starksfam.org> wrote:
> On Wed, Apr 26, 2017 at 7:07 PM, Sean Conner <sean@conman.org> wrote:
>> It was thus said that the Great Coda Highland once stated:
>>> 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.
>>
>>   Remove "object oriented" and I would probably agree.
>>
>>   -spc (At the very least, come up with some better examples of OOP than
>>         animals, vehicles or shapes)
>
> I think I'm weird or something or I'm not seeing your particular
> forest for the trees that I've stared at. I think I'd pox both of your
> houses.
>
> Static types: When learning how to program, I don't know that static
> typing is a net positive. To me, it tends to push problems elsewhere
> and cause a whole lot of code to be generated, just to get around the
> strong typing. When you're first starting out, is it necessary to
> teach this or is it a concept that can be added later?
>
> Early on, I want to learn about the basic structures of programming
> and how they're composed. I want to learn about:
>
>  - Values
>  - References
>  - Variables
>  - Scope (and thus globals and locals and upvalues)
>  - Functions
>  - Branch statements
>  - Loops
>  - Structures
>  - Using libraries
>  - Breaking things into components / files
>  - Testing
>  - How to organize projects, comments, etc.
>
> When I was first learning to program, the #1 word that I wanted to
> avoid was "except", as in, "...works like this except sometimes, which
> we'll cover 7 chapters from now, but try not to think about that right
> now..." That sort of phrasing kills confidence.
>
> To me, with the right curriculum, Lua is excellent for teaching
> someone how to program. Simple is beautiful and the fact that you have
> to create most of the more advanced structures and concepts is a win.
>
>  - start by teaching structured programming
>  - demonstrate C-style objects (functions with a state structure)
>  - ease into object oriented programming using tables with properties
> and methods and the ":" operator.
>  - Maybe show some craziness with metatables and operator overloading
>  - Then make them do another object model, using closures.
>
> Make me construct my own object model in two different ways and I can
> assure you that I'll understand the concept better than if you just
> hand it to me.
>
> Same thing is true with arrays: in Lua, I have to implement them with
> tables. If I want to make sure that I don't have holes, then I have to
> learn how to do that too.
>
> There may be data that proves me wrong, but when I'm learning, I want
> to have a feeling for what is going on and a sense that I can hold
> everything in my head.
>
> --
> Andrew Starks
> 612 840 2939
> andrew@starksfam.org
>

On the whole I actually agree with you here. The content of the
curriculum and its means of presentation are far more important than
the language itself. A class presented as you give it would certainly
be successful. I'd take it, if it wouldn't bore me to tears because
I'm 20 years past that in my career. ;)

But in terms of the problems with static typing... I'm only aware of
three that come up at that level.

The first is the distinction between integers and floating-point
numbers. This is basically unavoidable, and I'd rather teach students
to be aware of it as early as possible because it's pretty fundamental
to computer programming.

The second is typecasting, and that's really more of a strong typing
issue than a static typing issue -- and Lua's typing is fairly strong.
Beginners tend to run into this more directly when it comes to wanting
to coerce strings and numbers back and forth to each other. The other
issues that come up in this regard I actually consider to be part of
the teaching process, because understanding the difference between
different kinds of object and why they're not interchangeable and what
you need to do to MAKE them interchangeable is very instructive.

The third is trying to store heterogeneous values in a container, and
the biggest lesson of that one is "don't do that."

/s/ Adam