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.

86 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. very useful info, and please keep updating........
    Best Online Software Training

    ReplyDelete
  5. 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
  6. 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
  7. This comment has been removed by the author.

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

    ReplyDelete
  9. Outstanding blog thanks for sharing such wonderful blog with us ,after long time came across such knowlegeble blog. keep sharing such informative blog with us.

    Check out : big data training in velachery
    big data hadoop training cost in chennai
    big data training in chennai omr
    big data training in chennai velachery

    ReplyDelete
  10. Great Post,really it was very helpful for us.
    Thanks a lot for sharing!
    I found this blog to be very useful!!
    JAVA training in Bangalore

    ReplyDelete

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

    ReplyDelete
  12. 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
  13. This comment has been removed by the author.

    ReplyDelete
  14. Effective blog with a lot of information. I just Shared you the link below for Courses .They really provide good level of training and Placement,I just Had Web Design Classes in this institute , Just Check This Link You can get it more information about the Web Design course.


    Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

    ReplyDelete
  15. 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
  16. Thanks for Sharing a Very Informative Post & I read Your Article & I must say that is very helpful post for us.
    Data Science
    Selenium
    ETL Testing
    AWS
    Python Online Classes

    ReplyDelete
  17. Hi thanks for sharing nice information.
    if you are lookingpersonal trainervisit my site.

    ReplyDelete
  18. That's really impressive and helpful information you have given, very valuable content.
    We are also into education and you also can take advantage really awesome job oriented courses

    ReplyDelete
  19. Thank you so much for sharing all this amazing information, keep it up.
    are you want to make a career in UI Development. check this UI Development Course in Bangalore.
    Attend The Best Front-end Certification Training In India From AchieversIT. Practical Front-end Training Sessions With Assured Placement Support From Experienced Faculty. and also proving live projects
    AchieversIT Training Institution

    ReplyDelete
  20. This site helps to clear your all query.
    This is really worth reading. nice informative article.
    bu bhopal ba final year result
    mp bhoj ba 3rd year result

    ReplyDelete
  21. great post ! This was actually what i was looking for and i am glad to came here!
    F5 Load balancer Training
    SAP Ariba Training
    MuleSoft Training

    ReplyDelete
  22. I read this post,Thanks for sharing this information.

    Machine learning classes in Pune

    ReplyDelete
  23. Very awesome!!! When I seek for this I found this website at the top of all blogs in search engine.
    data science course in malaysia

    ReplyDelete
  24. Nice to be visiting your blog once more, it has been months for me. Well this article that ive been waited for therefore long. i want this article to finish my assignment within the faculty, and it has same topic together with your article. Thanks, nice share.
    data scientist course in hyderabad

    ReplyDelete
  25. I see some amazingly important and kept up to length of your strength searching for in your on the site
    data scientist course in malaysia

    ReplyDelete
  26. Online Training | Classroom | Virtual Classes
    SQL Server Training with 100% placement assistance
    1860 testers placed in 600 companies in last 8 years
    Real time expert trainers
    Indutry oriented training with corporate casestudies
    Free Aptitude classes & Mock interviews

    ReplyDelete
  27. 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
  28. Very Nice Blog…Thanks for sharing this information with us. Here am sharing some information about training institute.
    devops training in hyderabad

    ReplyDelete
  29. I am sure it will help many people. Keep up the good work. It's very compelling and I enjoyed browsing the entire blog. We are also providing the best services click on below links to visit our website.
    Snowflake Training
    Workday Training
    Okta Training
    AEM Training
    CyberArk Training

    ReplyDelete
  30. 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
  31. 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
  32. 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
  33. This is a good tip particularly to those fresh to the blogosphere. Brief but very accurate information… Many thanks for sharing this one. 바카라사이트

    ReplyDelete
  34. 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
  35. Simply desire to say your article is as amazing. The clearness on your post is simply spectacular and that i could assume you are a professional on this subject.
    카지노사이트

    ReplyDelete
  36. It’s so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also.
    바카라사이트

    ReplyDelete
  37. Your blog is really nice. Its sound really good
    스포츠토토

    ReplyDelete
  38. I finally found great post here. Thanks for the information. Please keep sharing more articles.
    온라인카지노

    ReplyDelete
  39. .Sometimes I feel like I don’t belong anywhere
    .I just feel like no one can actually understand me
    .But then I remember that I have you
    .I honestly don’t know what would I do without you. Thank you for being the best human being in the world. دانلود آهنگ محمد علیزاده لطفا

    ReplyDelete
  40. 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
  41. I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.
    cyber security course

    ReplyDelete
  42. 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
  43. 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
  44. 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
  45. Extremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one.
    Continue posting. A debt of gratitude is in order for sharing.
    data analytics course in warangal

    ReplyDelete
  46. I was just examining through the web looking for certain information and ran over your blog.It shows how well you understand this subject. Bookmarked this page, will return for extra.https://360digitmg.com/course/project-management-professional-pmp

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

    ReplyDelete
  48. The blog which you have shared is more creative... Waiting for your upcoming data...
    Python Course in Chennai
    Python Online Course
    Python Course in Coimbatore

    ReplyDelete
  49. Tableau training institute in Hyderabad can be a ticket to your fortunate tableau career.Dashboards, tableau desktop, Tableau online,charts,and many other key features of tableau this is best for you have interest visit my website link http://tableautrainings.in/

    ReplyDelete
  50. 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
  51. Very helpful and Great information 경마

    ReplyDelete
  52. Your information was very useful to me. That's exactly what I've been looking for 릴게임

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

    ReplyDelete
  54. Thanks for such a fantastic blog. Where else could anyone get that kind of info written in such a perfect way? I have a presentation that I am presently writhing on, and I have been on the look out for such great information. 먹튀검증사이트

    ReplyDelete
  55. Are you looking for a Data Science training institute that will not only train you but also aid you in bagging a job, 360DigiTMG is the right place for you. data science institute in chennai

    ReplyDelete
  56. Get dual certification from IBM and UTM, Malaysia with a single Data Science Course at 360DigiTMG. Enroll now for a successful tomorrow! best data science courses in chennai

    ReplyDelete
  57. What a nice post! I'm so happy to read this. 안전놀이터모음 What you wrote was very helpful to me. Thank you. Actually, I run a site similar to you. If you have time, could you visit my site? Please leave your comments after reading what I wrote. If you do so, I will actively reflect your opinion. I think it will be a great help to run my site. Have a good day.

    ReplyDelete
  58. Hello, I'm happy to see some great articles on your site. Would you like to come to my site later? My site also has posts, comments and communities similar to yours. Please visit and take a look 토토사이트

    ReplyDelete
  59. Thanks for sharing the useful and amazing information.you are also read morehttps://salesforcemasters.in/

    ReplyDelete
  60. 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
  61. 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