Ask HN: Which programming language for a first-time coder in 2022?
13 points by headmelted 3 years ago | 47 commentsCriteria I’m working on are:
1) Ease to get to “Hello World”.
2) Kid-friendly, easily available learning resources.
3) Low setup complexity.
It’s been so long since I’ve been there (VB6!) that it’s harder to know in 2022 what the right advice to give is for someone just starting out.
I also thought about steering them to HTML first, but I don’t think the open web as the same excitement factor for someone starting out in 2022 that it did for me back in the day (which is a shame).
What do you folks think?
- mikece 3 years agoJavaScript runs everywhere, and every web browser these days has really good JavaScript dev tools built into it (nothing to install). Python might be a bit easier in terms of syntax but if the kid has an interest in tinkering then learning how to search/parse the text of a website using the browser's Console, that can be the gateway into NodeJS programming.
- jfengel 3 years agoI concur, which I think is ironic since I think Javascript is a terrible language.
And I don't say that lightly, because I view most programming languages as being pretty much on par. They're all fine; the differences are more about framework and support than the language in itself. Javascript is one of the few languages so poorly thought out and so badly evolved that I actually say it's a bad language.
And yet it's ubiquitous, easy to learn, and (after decades) has reached a point where you can mostly step around the worst of the landmines. I'd even say that Typescript is pretty good, though it's probably best for a first-timer to be able to skip that.
- trinovantes 3 years agoJS is probably one of the worst languages for a beginner
Its execution model (single threaded, libuv callback scheduling) will be extremely difficult to understand without some OS background knowledge. It's also different than almost every other mainstream language so it's not even transferable
Its tooling beyond the browser console is still awful. Good luck explaining ESM/CJS and transpliers to a beginner
It has a non-existent stdlib compared to other libraries so you have to explain how to use npm/yarn/pnpm, how to pick the right package, how to resolve paths to them, and eventually bundle them with webpack/vite/snowpack/etc...
- ravi-delia 3 years agoI feel like all of that is secondary compared to the fact that JavaScript lets a kid immediately create something they can see. Sure, if you want to teach CS it's not my first choice, and if you want to interact with things you'll need a library, but once you add in that kind of stuff you're stepping up a complexity level anyway. Anything you need to build something simple is in the language, and along with HTML you can build things cool enough that there's time to learn before you outgrow it. Once you get around to making a real application those issues all apply, but I mean my first brush with programming was Minecraft mods and they're a million times more finicky. I stuck with it even though I was writing in notepad++ and taking 5 minutes to test each change because the end result was something a 12 year old wanted!
Obviously there are better purely pedagogical languages (I'm partial to Racket myself), but those are suited more for the classroom. In terms of getting a kid hooked, in this day and age the best option is JavaScript. Back in the day it was Basic, even though Basic sucks and sucked for anything complicated. For me it was a janky Java setup I downloaded off of a shady forum. The execution model or transpilers have nothing to do with it.
- trinovantes 3 years agoI agree that video game modding (Java for Minecraft or Lua for Roblox) is also a great introduction/motivator for learning programming. The key thing is even though these languages may also be as complex as JS, using them for modding usually have a "happy path" to getting started with many complexities abstracted away or completely disabled for obvious security reasons.
Alternatively if they do not play those games, then maybe a visual programming language like Scratch would be suitable.
- trinovantes 3 years ago
- eyelidlessness 3 years agoI program in JS/TS primarily. I’m quite proficient. There are a few little nitpicks I could offer here, but in good conscience I just can’t bring myself to do it. Because I can’t in good conscience recommend anyone start with JS in the current state of its ecosystem.
Part of the reason I’m so proficient in JS is because I’m really stubborn about learning why things break, and have had decades of practice to hone skills around that. But if I were new to programming today and started with web tech, I would have just given up. The amount of shit you have to know just to even start debugging a problem in a common setup is plain bonkers.
I’ll add one more thing to your “good luck” part: good luck building a mental model of client/server. Even if you’re just targeting client, you’re SOL because everything assumes you’re also running Node. Even the stuff that’s ostensibly compatible is either subtly not or built on additional complexities like polyfills with their own respective set of caveats.
I’m even pretty enthusiastic about the direction the ecosystem is going, I think these things are likely to get better over time. But I can’t imagine throwing someone into its current state and expecting anything but sadness and defeat.
- lmiller1990 3 years agoI disagree - when you start out, just seeing something happening is exciting - with JS, a tiny bit of CSS and HTML, you can have a real website deployed that does something in a few days of learning.
Any other language, you'll be stuck in the terminal/figuring out how to install things for days (as a beginner). For a website, you just need a `html` file with a <script> tag!
When learning new things, quick wins and feeling progress is really important, so I always recommend the easiest tool to get started with, not necessarily the one with the best model or fundamentals.
- trinovantes 3 years agoMost languages can be installed with `apt get` or `brew install` nowadays. You may not get the latest versions but it's not like the old days where you have to download and compile from source and then update your PATHs anymore. I think Ubuntu comes preinstalled with python too.
While it's true that you can get started quickly with a <script>, I think you'll encounter inexplicable walls much quicker than other languages.
If you limit yourself to WebAPIs, you'll have a even smaller toolset than node. Not to mention most tutorials are assuming you are executing in node and not a browser e.g. file system access which was only recently available in Chrome and not implemented in Firefox. You also can't interact with most of the web due to CORS (such a common problem that it's pretty much a rite of passage for any JS developer now).
- trinovantes 3 years ago
- postalrat 3 years agoYou seem to believe you need to teach a beginner every small detail from the start. You don't. You don't need to teach npm, yarn, pnpm, esm, cjs, transpilers, execution models, webpack, vite, snowpack. None of it.
Start with: console.log('hello')
- trinovantes 3 years agoBy that logic, any language is fine. The problem is how do you follow up to keep them interested after some simple stdin/stdout exercises? Trying to accomplish anything interesting beyond solving leetcode questions in JS requires going into the npm ecosystem.
- trinovantes 3 years ago
- ravi-delia 3 years ago
- Koshkin 3 years agoIndeed, the plain HTML plus JavaScript have been the best option for a kid to get a taste of programming ever since they became available.
I find Python to be more useful in general (should be taught in high school to everyone, in my opinion), but it is just less fun for a kid.
- 8bitsrule 3 years agoStart with a simple HTML template called with 'theirname.html'. Add a JS loader: <script src="theirname.js"></script>. Load that page in browser; bookmark it. (Easy access!) Now whatever they edit into theirname.js will 'run' when they reload the page. e.g. alert('Hello World!') When they're ready to add an image, time to learn a little HTML ;-O
- Koshkin 3 years agoA little interactivity helps to keep the kid engaged. It is amazing to see how much fun emulating a simple desk calculator in HTML can be.
- Koshkin 3 years ago
- 8bitsrule 3 years ago
- jfengel 3 years ago
- lholden 3 years agoLua on the Pico-8 Fantasy Console. It's easy to work with, has a built in editor, and it's very easy to make games in. I think it's a fantastic environment to learn programming with. What kid doesn't want to make a game? :)
Lazy Devs on youtube is currently producing a "Making a Shmup" tutorial that is very "from the basics" as well.
- wilsonnb3 3 years agoShout out to the TIC-80 as a FOSS alternative to PICO-8
- wilsonnb3 3 years ago
- jstx1 3 years agoScratch, C, Python
All 3 in that order, they don't need to go super deep on C, they can spend a couple of weeks on it - you go from programming on a very high level, to programming on a much lower level, and then to a language that takes care of lots of stuff for you (and you get to appreciate it more).
It's what CS50 does, and it's the best for complete beginners, including kids. The point is that they're learning about programming and software, they aren't learning a specifc language. I think that being exposed to more languages early helps with learning because it allows you to grasp overarching concepts instead of thinking that things are done only in the way your first language does them and then having to unlearn stuff much later on.
- ksaj 3 years agoC is harder than Python, and Scratch to C is quite a jump to make, so maybe those last two should be the other way around. But I do agree that they expose different aspects of programming.
- jstx1 3 years agoThe point isn't to order languages from easy to hard, it's to build up to Python with a bit more understanding about what's happening under the hood.
- ksaj 3 years agoI understand that. I was suggesting that Python would segway into C in terms of learning paths. Otherwise you go from C and then say "Okay, now forget half of what you learned" since Python has far simpler functions and structures, etc. For example, looping. Python's looping is really basic, and C greatly expands on it. Each level reinforces the next, instead of going from simple, to complex, right back to simple again.
Going from python to C, you can say "Remember those simple loops? Look at how much further you can go with that under C." Each level is additive from what you learned from the prior language, instead of putting low level stuff in the middle, just to return to high level again with limitations now imposed on what you'll learn in the next step.
I would argue that no aspect of python is "up" from C in terms of learning paths.
- ksaj 3 years ago
- jstx1 3 years ago
- ksaj 3 years ago
- kebsup 3 years agoOur university teaches C as the first language and even first time coders manage. The problem with python and most other languages is that you'll just end up confused about references while C forces you to understand them.
Just a recently my 14 yr old brother came to me super confused about why does his python code change all the values in the list when he is only changing one, and explaining that one object "lives" in some memory space and the list just points to it multiple times is quite difficult without more low level knowledge.
- Koshkin 3 years agoStill, C is probably the worst way to introduce someone to programming - even though (or maybe because) it looks like the middle road between learning the principles of how computers work and learning, say, JavaScript. It is much more enlightening if you start with a machine language (assembler) of a simple model of a computer or, at the other extreme, with a high-level (computer science-y) language like Scheme or JavaScript where you are not forced to think of details of the hardware.
- unsafecast 3 years agoBut then you'll be too far from a higher-level language like python to be able to make the connection, I think. It's quite easy to make analogies between python and C snippets, but to do that with assembly you have to understand calling conventions, system calls, stack frames, and so so much more.
- unsafecast 3 years ago
- Koshkin 3 years ago
- georgia_peach 3 years agoI like old Basic. Weak for writing real programs in, but unsurpassed as a crash-course in how computers work.
https://archive.org/details/simple-basic/mode/2up
- duffyjp 3 years agoAs a kid I had a hand me down 286 from my uncle with QBasic, and my only guide the terse help menu. I made so many cool things with that PC through trial and error. Unfortunately my curiosity was not limited to software and I disassembled it destroying it in the process. It's long gone.
I have a feeling my Minecraft infused 7 year old would be immediately bored of it anyway but I wish I still had it to give to him.
- duffyjp 3 years ago
- Qem 3 years agoI think Pharo fits the bill:
1) The "Hello World" is just to type "Transcript show: 'Hello World'" in the playground, and then see it printed to the transcript window;
2) It's a Smalltalk family language, with minimalistic syntax, and a environment that makes easy to learn it by exploring, initially developed as a means to teach children;
3) It adopts a image-based development approach, so everything you need in terms of tooling is contained inside the system image, and available out-of-the-box. There's no need to set up a complex set of interlocking dependencies to get proper environment and tooling.
There's a MOOC at https://mooc.pharo.org/ and free books at https://books.pharo.org/
Squeak, the Smalltalk dialect from where Pharo was forked also would be a good alternative.
- sanssoucis 3 years agoProcessing. It is oriented toward graphic applications, and having quickly a visual feedback was what hooked me on programming.
The documentation is excellent and filled with examples. https://processing.org/reference
It's one IDE to install and "play" button to press to execute code. "The coding train" provides a lot of videos for beginner or intermediate programmers to learn, and Daniel Shiffman is in my opinion an excellent teacher. https://thecodingtrain.com/
- ksaj 3 years agoI would recommend Python. If you install Thonny, you get pretty much everything you need right out of the (free) box. And because of its format, they can learn single commands in the REPL, then graduate to writing script-like programs, then progress onto increasingly complex GUI apps and whatever else they want from there, without having to change, install or update anything.
Then also if they get a Raspberry Pi Pico (which is only $4 or $5), Arduino, or just about any other microcontroller board, they're already set up to be able to control and program them, too. Lots of branching out potential, and a painless learning curve.
- mikewarot 3 years agoYou could show them Lazarus, they'll see 2 way tools for creating GUIs and be spoiled for life.
Python is pretty good if they have to handle hairy data structures, or just want to use the huge selection of libraries.
- juliendorra 3 years agoFrom my experience creating creative code workshops for children, design students and communication students, there’s not really a "good language for beginners", there’s nice and fun starting projects and from that, the language choice can follow. JavaScript as others mentioned is not a great language for beginners… but let say the beginners are into creating art with the computer? Then playing with p5js using the online editor is a great way to have fun while coding. It’s also easy to set up and to share. Even more accessible for someone visually-oriented would be livecodelab https://livecodelab.net/, a nice introduction to thinking in terms of a main loop and in 3D. But if the beginner want to program motors, for example, then the choices would be a whole other range of language, maybe the makecode playground from Adafruit is a good start. Maybe even the Arduino IDE (!! Ouch… ) For a pure beginner, I would dare to say that the choice of first language might be inconsequential. Everything is new, and everything is fuzzy. Give them the bare minimum to achieve the first goal they have. Don’t hesitate to switch the language and tooling for the next project they want to do.
- coward123 3 years agoMy son, also 13, just went through a program at school where they built a basic website from scratch, then did some python, then some java. They had some kind of teaching environment, a bit like a code.org or Swift Playground. When I would look over his shoulder to help, he was certainly coding an answer, but the way it was set up was so contrived that I can't really say he learned any of those languages. He learned a set of contrived functions nominally using those languages that he assembled in order to get the right answers.
I share this as preamble to why I recommend Swift Playground...it will get them going and be somewhat self directed. They will feel like they are actually achieving a goal rather than just typing text. And, if they take it to the next level they will be able to transfer their knowledge into "real" apps.
Second to this would be Python, because it's a great teaching language. That said, I think it's about the curriculum you put in front of them even more than the language.
- u8 3 years agoThis is timely, I just wrote about good first languages yesterday [1].
In short, Python / JS for quickest to pick up and make something cool. Rust if you’re interested in learning how computers work.
[1] https://blog.basedcount.com/choosing-your-first-language/
- krapp 3 years agoConsider that you can find online compilers and interpreters for many languages now, so in that regard, setup complexity would be zero.
for a kid, learning programming might be more compelling if filtered through something fun (just running code in a REPL isn't fun for most people.) I want to suggest Roblox because a lot of kids (like my nephew) apparently learn to code on that (in lua I believe) but I've also heard it's a bit exploitative. There is always also minecraft modding which I think uses java. Also Godot and GameMaker use simplistic programming languages.
Beyond that, I'd say either Javascript or Python, the first just because you need nothing more than a text editor, the second because of pygame.
- ravi-delia 3 years agoMinecraft modding is how I learned! It was a wonderfully formative experience, and suggesting it to a child should constitute abuse. Although I have heard things are better now than they were. And you're right that the important part was making something fun, little 12 year old me would not have stuck around without tangible mods to show my friends.
- ravi-delia 3 years ago
- kody 3 years agoChoose the best language for what the kid wants to learn.
Minecraft Education Edition - choose between Scratch, Python, and JS.
Battlesnake - any language with web server capabilities.
Electronics - C++, MicroPython, or Lua with NodeMCU
Love2d - Lua
PyGame - Python
etc.
I hesitate to recommend JS because it seems to introduce really bad habits, but it's hard to beat the feedback loop of writing code and seeing something in a web page. Lots of kids might be motivated to build an io game to share with their friends, for example -- JS on Replit or Glitch is perfect for that.
- citrin_ru 3 years agoLua is one more option to consider - simple syntax and environment like https://love2d.org/ look kid-friendly.
- BMc2020 3 years agoAutohotkey. It's also the language of choice for cheating at games (it's good for mouse clicking and button mashing) so by trying to cheat they will learn without realizing it.
On youtube, search for autohotkey and filter by new you'll see 75% of them are just that. Find a game he plays and start learning.
Very strong, very deep user community.
(FWIW, Rust seems to be a strong second. Don't know why, don't know anything about Rust).
- igouy 3 years agoWhat's the kid interested in?
Maybe there's some low-power device that would let them explore their interests, if only they could program the device.
And that would limit programming language choice to those available for the device.
- aristofun 3 years agoThe answer has been Ruby for at least 20 years now.
- Koshkin 3 years agoOOP is not the first thing I’d want to try and explain to a kid who is eager to see what programming is all about.
- aristofun 3 years agoOOP is the most natural way to introduce programming to a newbie. Tested on hundreds of my students. Even though oop is not a universal solution neither the best approach in many real world applicau.
- aristofun 3 years ago
- Koshkin 3 years ago
- PaulHoule 3 years agoPython.
- warrenm 3 years ago- Scratch
- Swift
- Python
- C[++]
- Javascript
- NetLogo (maybe)
- WheelsAtLarge 3 years agoJavascript is very handy since it's available in every browser but it's a horrible language to learn as your first. I would wait until he has an understanding of what a programming language is all about.
Go with python, it's very popular plus there are a lot of resources for it. And ultimately it's relatively easy to learn. Once he gets a handle of python then re-survey the situation and go from there.