Saturday 14 January 2017

Expressive types, not oppressive types

Uncle Bob wrote a recent post in which he warns programmers against the "dark path" some modern languages have taken - that is to "double down" on static typing. He cites Swift and Kotlin as examples, though his argument is meant to be interpreted more generally.
I share many points of view in common with Uncle Bob. I find the dynamically typed Clojure programming language beautiful and expressive - most of my personal projects are written in Clojure. I think that TDD (test-driven design) is a valuable and important discipline - I work for an agile consulting company where most of our projects include helping clients to get better at testing.

But I disagree strongly with the way Uncle Bob frames this discussion on static types.

Uncle Bob looks at advanced type systems and sees them as more oppressive rather than more expressive. Being able to describe whether or not a function can return null is an opportunity, not a constraint. Being able to use types to describe your code's intent is an opportunity, not a constraint. Being able to reason about the behaviour of a function based on its type signature is an opportunity, not a constraint.
The kicker is that this is almost exactly the fallacy about TDD that we have railed against for years. We call it "test-driven design" because we know that evolving code in response to examples is a great way to inform a design. Folks who have not learnt to listen to their unit tests see them as nagging constraints that prevents them from writing code in the way they'd like. A master of TDD uses tests as feedback for their design.

Anyone who sees unit test as mere "checks" that make changing code needlessly difficult isn't getting the most out of test-driven design. Anyone who sees static types as mere "checks" that make changing code needlessly difficult isn't getting the most out of type-driven design.
Based on his post Uncle Bob falls into the latter category. He sees types as ad hoc antidotes for specific mistakes rather than tools for thought - "Every time there’s a new kind of bug, we add a language feature to prevent that kind of bug."
If that's Uncle Bob's experience of Swift and Kotlin, he should try Elm. Or F#. Or Haskell. If his experience is anything like mine, he would find that more sophisticated types lead to less ad hockery, not more.

In a follow-up post, Uncle Bob is explicit about what he wants in a programming language - "There is a balance point after which every step down The Dark Path increases the cost over the benefit. I think Java and C# have done a reasonable job at hovering near the balance point."
I couldn't disagree more. Java and C# have two of the most onerous and least beneficial type systems. Their complexity and absence of type inference force excessive bookkeeping on the programmer. They lack of basic features like sum types, which denies the programmer an important expressive idiom.
Java and C# represent the nadir of the type system trade-off, not the zenith. Type systems are tools. Better tools help us write better code. We should welcome each and every advance in the tools we use to do our job, because frankly we could do a lot better than what we have now.

To argue that employing more expressive types is a "dark path" that leads developers away from personal responsibility isn't accurate or helpful.

66 comments:

  1. Why do you say C# lacks of type inference? It supports years ago. And by the way, don't say thing like "Java and C# " anymore since they are completely different now, they are just similar in the key C/C++ syntax.

    ReplyDelete
    Replies
    1. Java and C# are still quite similar, paradigm-wise. Garbage-collected, object-oriented, class-based, simple polymorphism, managed runtime. When talking about the type systems you can consider them to be one and the same.

      Delete
    2. Once you learn Haskell, you find out that C# doesn't have anything like type inference.

      Delete
  2. Try F# and you'll see what real type inference is on .Net

    C#'s inference at the level of a single expression is a toy in comparison.

    ReplyDelete
  3. I agree with you. I've read similar responses to Uncle Bob's post:

    http://blog.zdsmith.com/posts/the-dark-path-or-what-if-i-dont-want-to-quit-my-job.html

    And frankly it strikes me very strangely to have such a strong opinion about the badness of types. I certainly like to have control over how strict I want my compiler/interpreter to be with me, but I really like using types to be expressive about my intent.

    ReplyDelete
  4. Great blog.you put Good stuff.All the topics were explained briefly.so quickly understand for me.I am waiting for your next fantastic blog.Thanks for sharing.Full Stack Training in Hyderabad

    ReplyDelete
  5. Really you have done great job,There are may person searching about that now they will find enough resources by your post

    Java training in Chennai

    Java training in Bangalore

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete

  8. Thank you for sharing the article. The data that you provided in the blog is informative and effective. Best Devops Training Institute

    ReplyDelete
  9. Thanks for explanation about the literate programmer
    Sanjary Kids is one of the best play school and preschool in Hyderabad,India. Give your child the best preschool experience by choosing the best playschool of Hyderabad in Abids. we provide programs like Play group,Nursery,Junior KG,Senior KG,and provides Teacher Training Program.
    pre and primary teacher training course in hyderabad

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...

    digital marketing course in hubli

    ReplyDelete
  12. Thanks for the blog but If your looking to switch your career to the Airline Industry we the Fusion is the best place to pursue. It is one of the best Air Hostess course

    ReplyDelete
  13. We’re a group of volunteers and opening a new scheme in our community 야동 . Your web site provided us with valuable info to work on 오피헌터. You’ve done an impressive job and our entire community will be thankful to you 외국인출장.마사지,카지노사이트존

    ReplyDelete
  14. I think this is a really good article. You make this information interesting and engaging. You give readers a lot to think about and I appreciate that kind of writing. 토토사이트

    ReplyDelete
  15. It is a good site post without fail. Not too many people would actually, the way you just did. I am impressed that there is so much information about this subject that has been uncovered and you’ve defeated yourself this time, with so much quality. Good Works!.
    경마사이트
    경마

    ReplyDelete
  16. The writer has outdone himself this time. It is not at all enough; the website is also utmost perfect. I will never forget to visit your site again and again. 사설토토

    ReplyDelete
  17. This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck.
    data science course in malaysia

    ReplyDelete
  18. Happy to visit your blog, I am by all accounts forward to more solid articles and I figure we as a whole wish to thank such huge numbers of good articles, blog to impart to us.

    ReplyDelete
  19. 360DigiTMG, the top-rated organisation among the most prestigious industries around the world, is an educational destination for those looking to pursue their dreams around the globe. The company is changing careers of many people through constant improvement, 360DigiTMG provides an outstanding learning experience and distinguishes itself from the pack. 360DigiTMG is a prominent global presence by offering world-class training. Its main office is in India and subsidiaries across Malaysia, USA, East Asia, Australia, Uk, Netherlands, and the Middle East.

    ReplyDelete
  20. First You got a great blog. I will be interested in more similar topics. I see you got really very useful topics, I will be always checking your blog thanks.

    BCA 1st 2nd 3rd Year time table

    ReplyDelete
  21. This post is so useful and informative.Keep updating with more information.....
    Python Training In Bangalore
    Python Course In Bangalore

    ReplyDelete
  22. I'm really impressed about the info you provide in your articles. I must say am highly overwhelmed by your whole story. It’s not easy to get such quality information online nowadays. I look forward to staying here for a long time.

    UOK BCom 2nd Year Exam Result | UOK BCom Exam Result | UOK BCom 3rd Year Exam Result.

    ReplyDelete
  23. Very helpful and Great information 경마

    ReplyDelete
  24. Hey Nice Blog Post Please Check Out This Link for purchase 토토사이트

    ReplyDelete
  25. very pleasant say. I just found your weblog and needed to pitch that i've beyond question appreciated perusing your weblog posts. After each wiped out buy in on your feed and that I dream you compose inside a similar way as again rapidly! Wifi Password Hacker Online

    ReplyDelete
  26. You have accomplished an inescapable interaction upon this article. Its completely legitimate and strongly subjective. you have even figured out how to make it comprehensible and clean to get to. you have a couple of legitimate composing capability. much thanks to you subsequently much. Windows 10 Pro Key

    ReplyDelete
  27. Get the import export data for Vietnam Import Export Data at Importglobals. Vietnam mostly import export telephones, mobile phones and parts thereof (21 percent of total shipments) and textiles (12 percent), and computers. Visit importglobals for more information in details.
    Vietnam Import Data

    ReplyDelete
  28. I was hundreds of miles away on your special day. I hope you enjoyed your day with a big cake. Late Birthday Wishes

    ReplyDelete
  29. React JS Training in Hyderabad

    ReplyDelete
  30. useful Information, thanks for sharing

    ReplyDelete
  31. Thank you for the infomation
    I concur that this is the most thorough description of the subject. I'm so glad I found your blog and am looking forward to reading your future posts. And I have referred to related content in the link below.

    At Login360, you may get the best training in android Training in Chennai
    . We provide a variety of software-related courses along with complete placement assistance.

    Excellent IT instruction has been given to our pupils in a number of methods by our teachers and subject-matter specialists.

    We offer top-notch instruction in Android technologies, and we frequently update our curricula to include the most recent IT trends.

    We provide placement help for recent grads (recent graduates). We will offer support to all eligible applicants.

    Contact Details:
    Name: Login360 Software Training Institute
    Address: No-06, Ground Floor, 5th Main Road, Vijaya Nagar Velachery, Chennai – 600042.
    Phone: 6385872810

    ReplyDelete
  32. Nice detailed blog. Thank you for sharing such nice blog.
    We also provide online professional courses. Do check our website.
    Best IT Training Institute in Kolkata - Instaily Academy

    ReplyDelete
  33. Lot of information. Keep posted and keep us updated.

    IT Training Institute in Kolkata

    ReplyDelete
  34. I'm quite impressed with the information you present in your writings. I must say that your entire story has left me speechless. Nowadays, finding such high-quality material online is difficult. I intend to stay here for a long time.
    api testing course in hyderabad

    ReplyDelete
  35. https://literateprogrammer.blogspot.com/2017/01/expressive-types-not-oppressive-types.html?sc=1691576543263#c9008738630579773301

    ReplyDelete
  36. This is a great post. I like this topic.This site has lots of advantage.I found many interesting things from this site. It helps me in many ways.Thanks for posting.our sclinbio.com 🙂

    ReplyDelete
  37. A React course is a training program that teaches you how to use React, a JavaScript library for building user interfaces. React is one of the most popular JavaScript libraries in the world, and it is used by many large companies, such as Facebook, Airbnb, and Netflix.

    A React course typically covers the following topics:

    The basics of React, including components, state, and props
    Advanced React topics, such as routing, Redux, and testing
    How to build real-world applications with React
    React training in Hyderabad

    ReplyDelete
  38. nice article
    https://careergearup.com/clat-coaching-in-hyderabad/
    https://careergearup.com/sociology-optional-syllabus/
    https://careergearup.com/sociology-optional-coaching-online/
    https://careergearup.com/clat-coaching-in-hyderabad/


    https://careergearup.com/top-10-csat-coaching-institutes-in-hyderabad/

    ReplyDelete
  39. Nice blog "I'm impressed with the quality of your posts." Keep posting more
    Data science training institute in KPHB

    ReplyDelete
  40. This post is so useful and informative.Keep updating with more information.
    javafullstack training in kukatpally hyderabad

    ReplyDelete
  41. Hi, ho letto il suo blog di tanto in tanto e ne sono proprietario e mi chiedo se riceverà molti commenti per spam. In caso affermativo, come fermarlo, qualsiasi plugin o qualsiasi altra cosa che si possa suggerire? I recenti tempi mi hanno fatto prendere la pazza, e quindi qualsiasi sostegno è molto apprezzato.

    ReplyDelete
  42. nice post
    internship for eee students

    ReplyDelete