Hacker News new | past | comments | ask | show | jobs | submit login

Yes, but it isn't the core way the language works -- you don't need to approach asynchronicity very early on as you do with JS, and it's not all closures. At some point someone learning Python will have to do something async. But what they can do up until then is just not do anything async, and that's fine (just wait for stuff to complete...). That's not really an option in JS: the great benefit of the language from a learner perspective is that it just runs straightaway in the browser, everywhere. But to actually do anything interesting (click a button, make something happen), that's async.

Re. the syntax, anecdata but I've helped beginners through their initial steps for about 6 years now in JS (and Python) and C-type syntax is just not an issue that slows down learning or causes issues. There are only so many different ways syntax can be structured so it's sane for a compiler to parse, they all work basically the same way, and people get used to a syntax really quickly




Hey there, I've also taught lots of students online!

In my JS courses, I actually don't touch upon async things until I get to rather advanced/intermediate courses. Universally, I think the fundamentals of programming languages can be taught without too many drawbacks and agnostic of language choice unless the language is super verbose.

For example, all the things with closures, this, and asynchronous programming probably aren't relevant until a student runs into them/their gotchas while making web applications. By that point, I think framing it as event driven programming makes a lot of sense and gives context without being forced to deal with the details.

I think doing anything cool in other languages is also almost similar. A while loop/game loop in Python or other languages is pretty similar to the event loop which where the asynchronous nature of JS comes from. This becomes really apparent when working with games like Roblox/Lua and Minecraft/Minecraft plugins+mods.


Yes, yes, it is similar, and I maybe didn't get that across as well as I could have. JS is the default (for good reasons!), but IME if we're talking about game engines aimed at beginners that are suitable for getting programming concepts across, I feel a [synchronous] game loop is often easier to get across conceptually, to build on. And then yes, definitely framing it in the same way works really well because when they get stuck, you can point them at that and say "well you've already done something really similar here, here's the comparison, {unpack how the async stuff is working by framing it in the same way}, you should be able to now link these concepts together"

(Apologies to other commenters as well! I got a little bit salty when people mentioned async in relation to beginner programmers because it's not a simple thing. It's abstract and doesn't really make a bunch of sense until the beginner has built a floor of very basic programming to stand on)


I’m sure you know about async/await in JavaScript? It sounds like the issue you have is not so much with the traditional paradigm of using callbacks, but the fact that the “default” environment in JavaScript is a GUI rather than a CLI, meaning that you need to figure out things like event handlers pretty early on?


Yes, default environment is the browser, that's a given and that's fine: if you are a beginner, making stuff happen there is easy and rewarding. Everyone has easy access to it

[I apologise for being a little snippy here]. I don't have an issue here: I don't think you & sibling commenters are really getting that these are beginners I'm talking about. Yes, I am aware of async/await. With the browser being the default environment, a beginner has to understand callback-related programming with JS quickly: they need to be able to say "I want to do this then this". You have do this via callbacks. You can write JS synchronously, but IME this isn't practical.

Using async/await isn't some magic bullet here. You can write synchronous-looking asynchronous code, but the level I'm talking about is: what does asynchronous mean? What does synchronous mean? Once they've got that (which is not simple), what's a Promise? That one's fun because you need to explain the concept and how they work first, and generally that's gibberish. Async/await helps, so say I ignore Promises and go straight to that. At which point the learner starts getting errors to do with unresolved values. And back to Promises we go. And so on.

I would say that I don't think there's any magic language that makes things easy for learners, and JS has many advantages over any other one, mainly to do with its general accessibility. But it's a fairly weird language in how it works, it isn't the simplest.


I fully respect that these things are not easy for a complete beginner! I might not have expressed it very clearly but that’s what I tried to say; the browser environment requires you to deal with asynchronicity to do almost anything other than log to the console, so that makes it a tough place to start.


In node, nearly all of the stuff has sync versions and global await is around the corner.

For every other saner environment (read: browser consoles), global await is a thing already, and you get immediate feedback, and have a canvas (with sync APIs!).

That being said, I do think that the best programming language to start learning is the one your parents/friends speak.


Great. I have no idea what "global await" means, but anyway, what's Node?

[shows them Node]

Oh, It's a calculator. Wow. I mean, wow. That's emm, really impressive.

[No, it's a runtime environment for JavaScript]

It's a what? So how does that help me move things around on the screen?

[It doesn't]

So explain what the point of Node is?

[etc]


Sorry, you need to be less cryptic for me to understand what you mean :)


When you're teaching beginners: what you're talking about won't really make any sense. It's an implementation detail (and a complex one at that).

A beginner at basic level, that's "what's a variable", "what's a function", "I don't see what the point of a function is". And something like Node -- it's just not a great environment to explain that: it doesn't do much that's interesting, like move stuff around on a screen. You can type stuff into the REPL, and it will spit things back, but that's just going to look like a calculator. Something like Processing, or a simple game engine aimed at beginners, or even making things happen on a web page using JS: that's good, it holds interest.


Its been a while that I did somehing with python - but shouldn't event handlers work pretty much the same? Or in other words, how can eventhandlers work any other way than asynchronous?

And you need eventhandlers for games.


in python you would do a loop for a game, unless you're using an event driven framework that does the loop for you.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: