1. 10

  2. 8

    The more I read about statically typed languages, the more I feel like Python isn’t giving me the guarantees it could. My issue is that I know a hell of a lot more Django than any other framework. Are there web frameworks in statically typed languages that have a similar (or better) level of framework maturity?

    1. 7

      I’ve worked in a large number of statically typed code bases. Static typing doesn’t help if you don’t take advantage of it. I’ve seen tons of statically typed code that operates just like the ruby code in the posting this is in response to. Here’s a basic problem. Most “OO” is just bad code. But it’s bad because its procedural spaghetti code with objects. OO in a dynamic language or a statically typed one provides you tons of ways to be safer than the aforementioned ruby example. I think there are core ideas that lead to good code. You can follow these ideas in ANY language. Each can provide you with different tools around those ideas.

      My work is primarily a JVM shop and from that, a Java shop. Most Java developers write code that ages poorly and is hell to maintain. In order to try and counteract that, we have all our incoming developers do our variation on Object Calisthenics (https://github.com/TheLadders/object-calisthenics). Some of the particulars therein don’t apply to “FP” languages but the overarching principles do.

      I’d stop thinking in terms of static/dynamic,fp/op and any other way you can break it down and start looking for the common larger ideas that lead to code that is easy to maintain no matter what the language. I see large amounts of Haskell code that reminds me of ideas from Smalltalk. Yet according to most, they are polar opposites. How is that? Because their core ideas of what makes a maintainable program is the same.

      I know many people who poo-hoo tooling around a language, but it’s important. Static analysis, via the compiler or via something like dialyzer for erlang is an amazing tool to have. Take advantage of it. At this point, you’d be hard pressed to get me to give up static typing for day to day code I write however, I recognize its just a tool and in the end, its the principles I put into play that matter. Trust me, you can write impossible to maintain code in any language, including statically typed ones. Here’s an entire standard built around hard to maintain code:


      All of this aside, if your only experience is with dynamically typed languages; reach out, see what static typing can provide you, but don’t stop with one language. Keep going, find language ecosystems that provide different tools. And after that, keep going some more. Never stop.

      1. 2

        Thanks for the great response; sounds like I just need to get my hands dirty! Only statically typed languages I’ve used are Java (for algs and infosec in undergrad) and C (for networking and OS in undergrad). Sounds like the web dev world is very different.

        1. 1

          Really, I’d just learn a new language like Haskell or F#, and then investigate web frameworks. I’d suggest Haskell first. And here’s the thing, take a guess at how much you needed to know to go from 0 to Django. You’ll need to learn roughly that much again. I think Haskell (and to a lesser extent F# and Scala) provides more safety than Python, but as you travel down the hierarchy you’ll get less and less compiler “help”. In that area, I’d wager: Haskell > F# > Typed Clojure > Scala >>>>>>>>> Java > Python. I found Java to only have the tinest bit more compiler “help” than PHP’s runtime errors. Pretty much all it can do is tell you if you are smashing a round peg into a square hole, but give no valuable other insights or warnings. It’ll be a breeze to pick up the lower languages if you understand the higher ones.

          I started this year by saying “this year’s project will be rewriting my small Mint clone in Haskell”. I’ve yet to write a line on that, and I put in about 20 minutes a day. I am not trying to scare you, but letting you have realistic expectations. I am normally the guy who is a programming polymath, doing Python, PHP, Ruby, Java, C#, Clojure, and Racket in a single day, but the semantics of Haskell are pretty foreign, and will take effort to learn to read.

          Good news is: I think it’s the most rewarding study I’ve undertaken. I’m just finishing bitemyapp’s tutorial, either this week or the next, and I’m feeling confident I could sit down now with yesod (the framework I picked) and knock out that app rewrite. Even better news, I think Haskell qualifies as a language that’ll “forever make you a better developer in every language[1]”, so it’s worth the journey regardless of if you use it or not in production (but you’ll want to!).

          [1] http://norvig.com/21-days.html

      2. 3

        I’m a long time Python and Clojure user. I finally made the switch and now teach others.


        Yesod is the most mature framework in Haskell, but it’s going to be the most alien. There are alternatives.

        If by maturity you mean having a plugin for everything on the planet, you may be out of luck. Depends on where you think you stand the most to gain in your choice of tools. I find slapping together JS widgets or pagination aren’t the time-consuming part.

        1. 3

          I definitely recommend Scotty:


          Supposedly it’s modelled a little after Ruby Sinatra. It’s very small and extensible.

        2. 1

          One real-world example of this technique is Ruby on Rails’s HTML escaping. Rails monkey-patches Strings to have an html_safe? method that returns false, and right before any string is output, it is escaped if html_safe? is false. A pre-escaped String can be marked so by calling html_safe (no ?), which returns a string of type SafeBuffer whose html_safe? returns true.