7 ms·
I agree on all points, especially the idea of using Lua as a first language. It has so few features that you're really forced to focus on fundamental concepts l
by widdershins 2y ago
I agree on all points, especially the idea of using Lua as a first language. It has so few features that you're really forced to focus on fundamental concepts like functions and (simple) data structures. And its flexibility to be used in an imperative or functional manner is great too. It's almost like a stripped back Javascript, and anyone who learns it will find jumping to JS easy.
I guess one might argue that 1-based indexing could cause beginners to get confused when they move to another language. But maybe it's good for them to get used to the idea that things like this can be different across languages.
- sitkack 2y agoThe other great thing about Lua is the utter sparsity of the standard library, it teaches one to think for themselves instead of only taking goods off the shelf.
- vascocosta 2y agoThis point made me think for a while... We're so used to languages with batteries included, like for instance Python which I often compare to Lua, that we assume it's always a good feature to have. It can be, but it's not for free. We definitely become a bit lazy and often turn more into "library users" than coders. It's convenient at first sight, nevertheless a bad habit. There's so much we can learn by implementing our own versions of even the most simple algorithms. In addition to that, our solution is probably going to be leaner, even if not as feature-rich, than the library next door. But then again, we probably don't need most of those features.
- tugberkk 2y agoI believe we can still do them for fun, for practice. But having them readily available (also, tested) when you are trying to build something is much better.
- vascocosta 2y agoBoth views have valid points. I guess it depends on how quickly you need to get something up and running. Battle-tested libraries definitely have their pros, but then again the surface area for possible bugs is also greater. For sure, most of my code in Rust for instance is quite complex and I wouldn't be able to do it without external crates. That said, in most projects I end up with 300+ indirect dependencies, most of which I don't even know anything about. It adds to compile time, final binary size and most importantly, I'm building my software on top of a huge stack of stuff I don't really know. I guess the higher level we go, the less we can avoid this anyway. Nevertheless some of my points don't necessarily apply to interpreted languages.
- vascocosta 2y agoYour analogy to a stripped back version of JavaScript is really on point. I feel that way about Lua too. Through time Lua kept its simplicity, whereas ECMAScript kept accreting stuff which most of the times makes life easier, but also gives way too many choices for how to do the same thing. Indeed the 1-based indexing, which often generates heated discussions, could be a source of confusion later on. However, like you mentioned, it can also prompt the beginner to quickly understand the languages are just tools, which have slightly different ways to be used, depending on what they're trying to solve. In fact, this 1-based indexing is by convention (although everyone uses it), once again showing how flexible and "hackable" Lua is.
- pierrec 2y agoI often hear this (probably because PIL is so optimistic about it), but I would say that 1-based indexing is not just a convention, it's a default that's baked into the language: > array = {"A", "B", "C"} > array[1] A And there's more: built-in functions like ipairs will not work with hacked-up zero indices (which you would have to specify every time you create an array). Overall, straying from the default is not a great idea unless you really need to (like in LuaJIT).
- vascocosta 2y agoYes, it's technically possible, but indeed it's such a default that no one really tries to fight it.
- giraffe_lady 2y agoI've taught programming to beginners, both children and adults, and lua is the worst of the languages I've done it with. It's an amazing technical accomplishment, and CS students should study its implementation. But for actual beginners its "focus on fundamental concepts" and flexibility are liabilities. The main struggle people have learning to code is getting over the initial frustration hurdle where they can't actually accomplish anything yet. What they have to get them through this is excitement about their actual goals. With lua you burn too much goodwill and beginner spark on debugging string manipulation functions that don't seem important to the actual interest or goal that brought them to programming. Or figuring out how to use luarocks so you can make http requests, or regex, or whatever. > 1-based indexing could cause beginners to get confused when they move to another language. This is so far from the problems that beginners actually have. You should teach some programming, it's a really fascinating experience that will mess with your intuitions about how people learn this skill, and what's hard about it.
- vascocosta 2y agoInteresting viewpoint. It is my belief that Lua would be nice as a first language, but maybe this opinion is tainted by all my years of experience in programming. Lua definitely wasn't my first language, I started out with C/C++ and Java, long ago. Nothing beats having first-hand experience as a teacher and thus I'll accept your opinion as something more substantiated than my gut feeling. I'm quite interested in this topic, since I would like to write a good book to introduce absolute beginners into the world of programming. I have a good and encompassing knowledge about many different languages, nevertheless I lack teaching experience. In your opinion, which languages are good candidates as a first choice and what do you think about using a Lua game framework, like for instance Love2D to teach programming (instead of raw standalone Lua)? The idea being that instead of clunky low level awkwardness, like string manipulation, students would instead see geometrical shapes moving on a screen with just a bunch of simple and imperative statements. Would that provide a better motivation?
- giraffe_lady 2y agoI think if you were going to design a rigorous approach to programming from the ground up as part of a like new quadrivium or something, lua could have a place in it. But when people decide to learn programming now, they usually have a goal in mind so the best language is the one that lets them keep that objective in focus as they learn. Not necessarily do it most easily: love is good because while making a game with it is a huge undertaking for a novice, they can see the whole time that game-making is what they're building up to. But for example I've seen rank beginners get really fascinated with data visualization, or interacting with their local government's API, or text generation, or audio stuff. All things that are going to be out of reach for a novice in lua. And a lot of people will show up saying they want to make games, but it's because video games are the one programming artifact they have positive experiences with. Once they start to see the broader possibilities other interests develop. Anyway I have had a lot of success introducing programming with roblox scripting. It adds a lot of the "missing" lua library features and the script editor is a decent basic IDE that simplifies tooling, another huge pain point for novices. For non-game focused beginners I've had the best results in ruby. Python works as well once you get going but the whitespace is a frustrating time sink in a classroom environment. In these the strength is being able to grab a library for any API they'd want to work with, and build something that feels like an actual useful tool to them.
- lucasoshiro 2y ago> I guess one might argue that 1-based indexing could cause beginners to get confused when they move to another language. The creator of Lua once visited my university, he told us about the 1-indexing (it looked like this is the thing that everybody asks him). Lua was created in a time that 0-indexed languages wasn't so dominant over the 1-based languages. Lua is older than Java and JS, and a few years newer than Perl and Python. Before those, as far as I remember about more popular languages: C and C++ are 0-indexed; COBOL, MATLAB and FORTRAN are 1-indexed; Pascal can be 0 or 1 indexed, but its for loop is better suited for 1-indexed. This way, there wasn't a strong bias to use 0-index in a new language as we have today, they could use what made more sense. Since it was created for engineers used to math notation (sum, products and matrices generally are 1-indexed) and without background in programming, they have chosen to start in 1. *However*, about using Lua for studying algorithms and data structures, some books use 1-indexed arrays in their pseudocode, notably CLRS' Introduction to Algorithms. When I was studying algorithm analysis using CLRS I used Lua to implement them. I still prefer 0-indexed languages, though.