Sunday Thought: Embracing the Type System

I had a lot of fun talking with all of you on the benefits of dynamic languages on the previous post. Definitely getting a better picture of what working with a language like that is like listening to your stories, so thank you for sharing. I also was given a killer link to an over view of type systems that I want to share with you incase you missed it in the comments or when I tweeted about it.

What to know before debating type systems

Yup, I liked it that much. Easy to understand and gave me a fresh perspective.

Also during my read of the above link, was lead to this guy which blew my mind:

A type based solution to the strings problem

Damn, I need to spend more time in haskell. Interestingly, the little languages that he talks about in the post, and how we usually just use strings to represent them. That problem is one of the reasons why I love the little library called HtmlTags (although built by the Fubu guys has no dependencies on FubuMVC) - makes working with fragments of HTML so much easier. I need one of these for everything that I currently use strings for. :)

Which goes back to another thought of mine which is that we as developers depend far too heavily on primitives in our languages. We use strings to represent everything. Instead of taking the time to write a few app level primitives to wrap up these strings inside type’d goodness, we are content to just let them get passed around as anonymous objects. In .Net at the very least we could be using the BCL’s ‘SecureString’ when we need to lock strings down. You can also read an older post of mine on Business Primitives. And if you work with code that loves types as much as your compiler does you can get some really bad ass code to work with (my favorite is the way I can extend things in FubuMVC).

Do you have to write more code? Yes. Do you get value from doing so? Yes. Do you get enough value to make it worth it? That’s up to you, but I know that I do.

I would say that over the past year I have been looking at python and ruby and I just don’t get the same buzz out of those languages that I do out of languages like C# and Haskell. For my larger projects that is. I still maintain a few small sites and scripts in python (and I LOVE IT). but as my projects get bigger my brain is just wired into the type systems provided to me in a more static language. I love it, I can bend C#’s type system to my will in ways that crush my brain, much like the Haskell type system is currently crushing my brain.

Anyways, just my thoughts on this chill Sunday.

About Dru Sellers

Sr. Software Engineer at Dovetail Software.
This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • http://www.icu-india.com http://www.icu-india.com

    really a amazing and fabulous 

  • Anonymous

    I agree that more often than not C# can get in your way. But I believe that if you work at it you can really cover a lot of this up. In MassTransit we try to wrap a lot of the primitives into our own classes. Then in our exposed methods that lib users interact with we provide an override that takes a string or number and then quickly wraps it up. Its worked well for us, and puts less burden on the user. I do wish I had boo, not going to lie. 

  • Kevin Berridge

    I love the concept of making the type system work for you.  But at least in C#, I often find the type system just requires more syntax noise, making solutions less elegant and enjoyable and readable.  I loved the look of the Haskell Templates the article you linked to leveraged.  C# needs more compile-time-dynamic magic like that, similar in someways to what Boo can do.  So we can build elegant DSLs but still leverage the type system.