DEV Community

Discussion on: Why You Should Learn Java First: Part 1, Basic Typing

Collapse
 
peerreynders profile image
peerreynders • Edited
  • I like types. Even in a dynamically typed language I try to practice Type Driven Development. Once upon a time, I even liked Java exactly because of the (false) sense of security of compilation (static type checking) - to the point it put me off learning JavaScript (I got over it). However once I had a chance to use OCaml and Haskell, I finally got a taste of what a real type system could accomplish - but those benefits come with a learning curve.

  • I don't share the mainstream enthusiasm for Python as a first language [1].

On the surface the argument to start with a statically typed language for the sake of "safety" makes sense but people who have dedicated their career to computer science education have come to a different conclusion; The Structure and Interpretation of the Computer Science Curriculum:

The lack of a type system means that we don’t have to spend energy on finding and explaining type errors with the same care with which we explain syntax errors. Better yet, when we use Scheme to teach design principles we can informally superimpose a type system and use the types for program design. In particular, it is easy to define and use sets and subsets of Scheme values. This comes close to students’ intuitions about classes and subclasses in object-oriented programs and thus provides a good transition for the second course.

As it is How to Design Programs 2e (HtDP) uses 5 student languages each one relaxing the constraints on capabilities more than the previous one but none include static type checking - even though Typed Racket exists.

That said, "those pesky parentheses" did turn out to be a real obstacle for some students - which is why Pyret was created. It's used in Programming and Programming Languages (PAPL). And Pyret has an optional static type checker.

The real issue is that educational institutions often feel compelled to teach programming with a résumé-friendly programming language, i.e. a one that a significant number of employers actually use. Perhaps if that was less of an issue it wouldn't matter if programming was taught without static type checking because that can be added next time.

The issue is that when dynamic typed languages like Python or JavaScript are used as first languages the student may not venture beyond that first experience and miss out on capabilities that other languages have to offer. Similarly one shouldn't get overly fixated on "static type checking" as an essential language feature - there are dynamically (but strongly) typed languages that have other things to offer (e.g. Erlang, Elixir).

[1]:

It is not only the violin that shapes the violinist, we are all shaped by the tools we train ourselves to use, and in this respect programming languages have a devious influence: they shape our thinking habits. This circumstance makes the choice of first programming language so important.

Austin, 12 April 2001
Edsger W.Dijkstra
To the Budget Council concerning Haskell