Re:Ask HN: What programming language should I teach my child?
by karmakaze on Thursday January 13, 2022 @12:08AM
(#29917088)
Historically, I would have suggested starting with lower-level languages such as C and a bit of assembly, then building up from there as the added expressiveness is much appreciated and understandably less direct. This all made sense when hardware was many orders of magnitude slower than it is now, even a phone running on a battery is more powerful than workstations of those days.
I would say the question isn't exactly which language to learn first, but rather which programming style. After a long career developing software, my opinion for new developers is to learn programming in a functional style. Not necessarily with a proper functional language, but one where it's natural to use immutable datastructures, only assign to local variables once per scope, and for longevity support concurrency. One element that could be deferred until later is static typing. Another important element is that there shouldn't be a main concept of fine-grained execution steps. By this I mean the typical for-loop or iteration variables. This whole premise is forcing humans to 'play computer'. We have powerful computers now, we can have computers, 'play logic' at a higher level without thinking in what amounts to be higher-level-machine language. A good example is using map/reduce/takeWhile/etc forms rather than for/if constructs. With those we can write one-liners that are one-level higher replacing entire block-control structures, and they can be chained on the same one-line, or over multiple lines in a flat, not nested structure.
The great thing about thinking this way, is that you can apply the same thinking and writing even when using procedural languages resulting in cleaner code without off-by-one and other edge case errors. Two languages that could fit this bill and be relatively mainstream are Elixir and Clojure. I think Elixir would be a great choice, as it together with the Phoenix framework is a reimagining of Ruby/Rails. Clojure is fundamentally small, but its usage can quickly become esoteric.
I also wouldn't go heavy on the js/css and learn just enough to get stuff done. When ready try to get exposed to using static types via TypeScript or a functional language like F# to see what they're about. Java, Kotlin, or Dart (with Flutter) might also be good mainstream choices but they tend to be less functional. You can try but the ecosystem (especially jvm) tends toward more OO and mutable data/state.
One completely different good candidate is Go. It has static types, is lowish-level like a C of today with garbage collection. There isn't a full framework though so you'd be pulling together a collection of libraries to make a web app. Having something opinionated leaves you with fewer questions when starting out. Still great if making command-line utilities, networking, or text (not graphical) apps is of interest.
I would say the question isn't exactly which language to learn first, but rather which programming style. After a long career developing software, my opinion for new developers is to learn programming in a functional style. Not necessarily with a proper functional language, but one where it's natural to use immutable datastructures, only assign to local variables once per scope, and for longevity support concurrency. One element that could be deferred until later is static typing. Another important element is that there shouldn't be a main concept of fine-grained execution steps. By this I mean the typical for-loop or iteration variables. This whole premise is forcing humans to 'play computer'. We have powerful computers now, we can have computers, 'play logic' at a higher level without thinking in what amounts to be higher-level-machine language. A good example is using map/reduce/takeWhile/etc forms rather than for/if constructs. With those we can write one-liners that are one-level higher replacing entire block-control structures, and they can be chained on the same one-line, or over multiple lines in a flat, not nested structure.
The great thing about thinking this way, is that you can apply the same thinking and writing even when using procedural languages resulting in cleaner code without off-by-one and other edge case errors. Two languages that could fit this bill and be relatively mainstream are Elixir and Clojure. I think Elixir would be a great choice, as it together with the Phoenix framework is a reimagining of Ruby/Rails. Clojure is fundamentally small, but its usage can quickly become esoteric.
I also wouldn't go heavy on the js/css and learn just enough to get stuff done. When ready try to get exposed to using static types via TypeScript or a functional language like F# to see what they're about. Java, Kotlin, or Dart (with Flutter) might also be good mainstream choices but they tend to be less functional. You can try but the ecosystem (especially jvm) tends toward more OO and mutable data/state.
One completely different good candidate is Go. It has static types, is lowish-level like a C of today with garbage collection. There isn't a full framework though so you'd be pulling together a collection of libraries to make a web app. Having something opinionated leaves you with fewer questions when starting out. Still great if making command-line utilities, networking, or text (not graphical) apps is of interest.