7 ms·
Ask HN: Which programming language for a first-time coder in 2022?
I’ve been asked recently by a buddy who’s kid (13) wants to learn programming but isn’t sure where is best to start. My gut feeling is something like Python might make the most sense, but wanted to ask the room.
Criteria 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?
- WheelsAtLarge 4y 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.
- mikece 4y 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.
- Koshkin 4y 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 4y 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 4y 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.
- jfengel 4y 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 4y 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...
- postalrat 4y 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 4y 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.
- ravi-delia 4y 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.
- PaulHoule 4y agoPython.
- georgia_peach 4y 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 https://archive.org/details/simple-basic/mode/2up https://www.bbcbasic.co.uk/index.html https://www.bbcbasic.co.uk/index.html https://basic256.org/ https://basic256.org/
- duffyjp 4y 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.
- Qem 4y 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/ https://mooc.pharo.org/ and free books at https://books.pharo.org/ https://books.pharo.org/ Squeak, the Smalltalk dialect from where Pharo was forked also would be a good alternative.
- krapp 4y 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 4y 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.
- jstx1 4y 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 4y 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 4y 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 4y 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 4y 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.
- warrenm 4y ago- Scratch - Swift - Python - C[++] - Javascript - NetLogo (maybe)
- u8 4y 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/ https://blog.basedcount.com/choosing-your-first-language/
- citrin_ru 4y agoLua is one more option to consider - simple syntax and environment like https://love2d.org/ https://love2d.org/ look kid-friendly.
- lholden 4y 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 4y agoShout out to the TIC-80 as a FOSS alternative to PICO-8
- sanssoucis 4y 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 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/ https://thecodingtrain.com/
- igouy 4y 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 4y agoThe answer has been Ruby for at least 20 years now.
- Koshkin 4y 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 4y 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.
- coward123 4y 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.
- kebsup 4y 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 4y 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 4y 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.
- BMc2020 4y 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).
- mikewarot 4y 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 4y 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/ 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.
- kody 4y 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.