3 ms·
I always recommend Lua as a first language. It's about as straightforward to learn as Python, but it's smaller and simpler, with fewer "gotchas". Once you've le
by enkiv2 10y ago
I always recommend Lua as a first language. It's about as straightforward to learn as Python, but it's smaller and simpler, with fewer "gotchas". Once you've learned Lua, moving to Python is about as easy as moving to Javascript.
I don't recommend Python or Javascript because while having a rich set of third party modules is great for actual development, it's a detriment and distraction for beginners. When you're learning the nuts and bolts of programming, it's easy to be misled by how easy some common task is to perform via API call and think you understand it when you haven't really been exposed to it. This becomes a big problem when moving to some other language, where library functions work in a different but equally straightforward way. When it comes to things outside the core standard library, you should really learn to implement them yourself before becoming accustomed to using third party libraries.
Python is a great second language, but the way you write things for a beginner programmer is very different from the way you write things when you're trying to be clever and squeeze a lot of behavior out of a few characters or a few cycles, and python has too much of a mixture: searching for information on how to solve a problem in python will get you equal numbers of people who don't know how a for loop works and people who prefer to do everything by passing lambdas around.
- Avshalom 10y agoLua is not a bad choice: the docs are good and once you get the basics down https://love2d.org/ https://love2d.org/ is great for writing Tetris and having having something you can point to and go "I did that"
- allemagne 10y agoI don't know that hiding complex ideas is necessarily helpful for a beginner. Admitting "by the way we're writing 'public static void' every time for a reason, but we won't worry about it yet" or "yes technically you could complete this assignment on one line, but trying to learn that right now is not useful" don't seem like bad ways of confronting the idea that programmers don't always know everything and that's okay. Keeping them completely insulated from those kinds of things could make them seem scarier than they really are. Of course learning is complex and the "best" way totally depends on who is learning and their goals.
- striking 10y agoI disagree with some of these points. Specifically, programmers should necessarily be left unable to understand everything they use. Packaging systems are excellent for providing you with functionality without the mental cost of having to understand how that functionality works. They're not a distraction, they're how people get things done. And Lua is not a great first language. If you know how to use it, it's a great language; but its 1-indexing, tiny standard library, inability to distinguish between hashmaps and arrays, confusing "metatables", and lack of external libraries really make it tough for me to recommend as a first lang. This comes from someone who used LuaJIT often with Love2D to prototype games.
- enkiv2 10y agoAnything that's trivial to write (think "left pad" and 90% of what's in NPM & PIP) shouldn't be used by people who can't conceive of how those things might be written, if their goal is to learn to write things. I'm not suggesting that beginners should start with writing bootloaders in machine code or anything; I'm suggesting that beginners should master things like loops and functions and variables before they start plugging together big chunks of other people's code, lest they overestimate their abilities and take a major blow to their self-esteem when they realize that they are completely incapable of doing simple things in another environment because they never really learned how to do things. Some of the biggest and most important hurdles to clear when learning to code are related to learning to master things you've never considered; convenient API calls are convenient to avoid considering. In this way, a tiny standard library is useful: all of the things in Lua's standard library are things that a beginner can afford to put off learning for a little while. Lua has a handful of strange attributes that distinguish it from most programming languages -- 1-indexing, lack of a distinction between integer and fractional numeric types, lack of a distinction between integer-keyed and non-integer-keyed arrays (and lack of distinction between arrays and objects), and the use of tilde rather than exclamation point in comparison. The number of idiosyncracies is comparable to those in python and javascript. I don't think that distinguishing between arrays and objects is useful for a beginner, nor do I think that the fact that in most languages integer-keyed arrays are special for optimization reasons is terribly important for a beginner. And, metatables are an advanced feature -- they are similar to mechanisms in python and C++ and aren't all that weird, but they won't even come up until long after our hypothetical student is ready for their second and third language. A first language is for learning. Whether or not it's useful for real work is totally irrelevant; someone who doesn't know ten languages inside-out isn't qualified for real work in any of them. Lua is a good candidate because although it can be used for real work, it's not optimized for that. Instead, it's a simple language that combines ideas that have historically been separated for reasons related to ease-of-implementation and separates ideas that have historically been combined to make ugly hacks possible. In other words, it's a fairly internally coherent and conceptually pure language that is easy to pick up because it lacks "gotchas" (except to people who come from other languages, and are offended by Lua's improvements).