Inspired by a reddit discussion, I decided to create short blog post to ask two questions:
- Is static typing winning?
- Is functional programming winning?
In other words, are we at a turning point where most modern languages are moving towards static typing and functional programming? Let’s consider the evidence.
Static typing
Some of the most popular dynamic languages are considering some form of static typing:
- Ruby: Matz announced that Ruby 3.0 may have type annotations.
- Python: Guido van Rossum sent out a proposal to add type annotations to Python.
- PHP: Facebook has released Hack, which supports type annotations on top of the PHP syntax. Moreover, PHP itself already has Type Hinting and may add return type declarations.
- JavaScript: Facebook has released Flow, Microsoft has released TypeScript, Google has released Dart and AtScript, and there are many statically typed languages that compile to JavaScript, including GWT (Java to JavaScript), Scala.js (Scala to JavaScript), Haste (Haskell to JavaScript), and purescript (Haskell-ish to JavaScript).
Of course, most of these type systems are not as strict as, say, Haskell, but whether you call it static typing, gradual typing, type hinting, type inference, or type annotations, the goal everywhere seems to be the same: try to catch more errors at compile time instead of run time.
Functional programming
Similarly, some of the most popular imperative languages are adding features from functional programming:
- Java: version 8 added lambdas, functional interfaces (i.e. functions, almost), method references (i.e. first class functions, almost), and the stream API.
- C++: version 11 and version 14 added support for functional programming features.
- C#: there is a book and several guides on functional programming in C#.
- Swift: Apple’s new language for iOS and OS X has many functional programming features.
- JavaScript: I’m seeing more and more functional JavaScript these days thanks to things like underscore.js, promises (ie, monads), react.js, bacon.js, and compile-to-JS languages like ClojureScript.
Of course, tossing in a few functional features does not a functional programming language make, but still, the trend is encouraging. Moreover, languages that are functional at their core seem to be growing in popularity too:
- Haskell: Facebook, Bump, Google, Microsoft, NY Times.
- Clojure: Amazon, Netflix, Groupon, Heroku, and Twitter.
- Erlang: WhatsApp, Facebook, Amazon, Riak, CouchDB, Yahoo.
- Scala: LinkedIn, Twitter, Box, Foursquare, Coursera, Nest, Quora, Tumblr, VMWare.
What’s the future?
There is some research that shows that static typing and functional programming are modestly better than dynamic typing and imperative programming, respectively (albeit it’s far from air tight). That said, I’ve been hearing this sort of hype for a long time, and only in the last year or two do I feel like it’s finally starting to make a noticeable dent in the industry.
Are you noticing the same trends? Do you like seeing more static typing and functional programming? Will we all be Haskell programmers soon?
Leave your thoughts as a comment or discuss this post on reddit and Hacker News.
Herman van der Veer
If you enjoyed this post, you may also like my books, Hello, Startup and Terraform: Up & Running. If you need help with DevOps or infrastructure, reach out to me at Gruntwork.