5 ms·
If I had to choose a language to teach programmers to absolute beginners, I think I'd actually go with Go. I understand the predilection for Python but there a
by cletus 6y ago
If I had to choose a language to teach programmers to absolute beginners, I think I'd actually go with Go.
I understand the predilection for Python but there are some parts of Python that are just... odd.
- hguant 6y agoPython is great fun, and you can be really productive with it, but for people first coming into programming, a language with an explicit and strict type system is invaluable. I used to think that everyone should be taught python first, because it lets you focus on the meat of computer science - algorithms, data manipulation, actually _doing_ something - but after helping my girlfriend out with some comp sci 101-104 projects, I really think Go, Java, or Rust should be everyone's first language. It's hard for someone new to the field to understand the nuances that come with python's corner cutting. You can work yourself into some weird corners because of how permissive the language is, where in a (strongly) typed language, the complier just says no.
- kab_al_ashraf 6y ago> You can work yourself into some weird corners because of how permissive the language is, where in a (strongly) typed language, the complier just says no. Could you share an example?
- blahedo 6y agoHere's one my (intro programming, non-major) students have just been tripping over this week: if word == "this" or "that": ... Not an error, always runs. Very mysterious to a beginner. (Shared with C/C++) Another one: counter = "0" for thing in things: if matches(thing): counter += 1 The error is in the init, by someone who is overzealous with their quoting, but the error is reported, as a runtime error, on the attempted increment, which throws a TypeError and helpfully tells them "must be str, not int", and of course I know exactly why it's reporting the problem there and why it's giving that error, but it's a bit confusing to the newbie programmer and it doesn't even turn up until they actually test their code effectively, which they are also still just learning how to do.
- deleted 6y ago[deleted]
- harpiaharpyja 6y agoI use Python a lot professionally these days, after having been a C#/Java developer for a while (and some experience with C and Free Pascal). I absolutely love the language. I always feel a little iffy when people talk about Python like it's a language ideally suited to beginners. Dynamic typing puts so much power in your hands to create expressive structures. But it requires discipline to use properly. It's a great trade off for me but I don't think it would be for beginners.
- InvOfSmallC 6y agoMy reasons for suggesting Python compared to Java for example is due to the fact that I teach to Electrotechnical engineers and there are plenty of libraries to experiment with Raspberry and stuff and it's a little bit higher level than C. Every language has its own difficulty to teach but the fact the companies have a banned.h it's basically saying "well C gives you functions for C, but don't use them". It makes it unecessary harder to explain something to people with no experience.
- int_19h 6y agoThere are parts of Go that are similarly odd. Arrays and slices, and the hoops you have to jump through to do something as simple as adding a new item to a list, are very unlike anything else, for example. In Python, the weird stuff is generally easy to avoid/ignore until it's actually needed.
- ericbarrett 6y agoVery true, but if you're teaching CS then this also exposes students to the topic of ownership-versus-reference in a much gentler way than C.
- int_19h 6y agoIf I remember correctly, slices in Go also have ownership semantics, in a sense that so long as any slice exists, the array is kept alive by the garbage collector. Or do you mean value vs reference semantics? In that case, I think C pointers are simpler as a fundamental concept, and slices are best defined in terms of pointer + size.
- wbl 6y agoIn Java you do the exact same reallocation dance as append does behind the scenes when using arrays.
- int_19h 6y agoJava standard library does that, not you directly. The issue here is not performance, but rather ergonomics. For example, in Go, you can forget to assign the result of append to the variable, and it'll even work most of the time (because there was still some unused capacity in the array, so there was no need for reallocation).
- wbl 6y agoWhich method? Note im talking about the language level array, not ArrayList. Also this was years ago.