Type Systems

Type Systems

This issue is going to deviate a tiny bit from the more theoretical format. Instead, we're going to dig into why I prefer static type checking and strongly typed languages. I've been asked about this a lot recently and figured that this would be a good one to fossilize as a Read Only Memory.

Typing in regards to a programming language is not the same thing as typing as in a keyboard. Typing is the idea of assigning a type from a logical type system to data in a program. There are lots of forms of typing and many different forms of type systems as well. Different type systems support different ideas and concepts.

Two of the biggest differences between type systems are whether they are loosely typed or strongly typed. A very clear example of the difference is JavaScript and it's (almost) superset language TypeScript. Indeed, the name TypeScript came from adding strong Typing to JavaScript. In JavaScript, we dont have to declare that our data is a number or a list, in fact, there's not really a good way to effectively do that outside of code comments. On the contrary, TypeScript allows us to specify the type that our data represents.

TypeScript is considered a flexible type system as you technically do not need to specify any types, although with those approach you're removing many of the benefits of the language by doing so. However, this allows you to gradually add types to existing JavaScript codebases, which eases with adoption.

Haskell is another language that is often complimented on it's rich type system. Every expression in Haskell has a type. Because of this, the compiler is able to be extremely helpful by ensuring that the code should works as written (you may still have logical bugs though!). This helps avoid an entire class of problems where code is shipped to a user down that exists behind an uncommonly accessed page or flow of logic and then months later when its accessed, the code breaks. With stricter classifications of languages, they can help eliminate entire classes and styles of bugs. Rust is another great example of a language that leverages a rich (and strict) type system to help heavily optimize and check code at the compilation layer.

There are also dynamically typed languages that can be either strongly typed or loosely typed. Dynamically typed languages have their types determined at runtime. A commonly used dynamically typed language is PHP, as an example. Because PHP implements this philosophy, you can still get some of the same benefits of strictly and statically typed languages even when not using a language that requires you to declare types.

You may have picked up on my bias at this point. I prefer stricter languages with strong types. You generally get better IDE support and avoid a large class of bugs simply by choosing to use a tool with that type system paradigm. However, these languages and tools can be difficult for people to use, too. If you're the type of person that likes to see gradual progression as you fix issues and likes to explore your running application in real-time, JavaScript is probably going to feel better to you than Rust. I've often joked that I'm "bartering with the compiler" when writing Rust for that very reason. However, once you get used to bartering with the compiler, it can actually provide just as great of an experience and ultimately help you produce safer code.

Ruby is another interesting example. Ruby is a dynamically typed language that, to me, feels extremely flexible. Flexibility is extremely nice when it works, but when something is wrong that flexibility manifests as a "This variable could be anything. I have no idea what it is in this path but it looks like its supposed to be a map." For me, this ruins my peace of mind about the code I ship, and for this reason, I generally try to spend less time coding in this class of languages.

Type Systems are way, way more in depth than I've covered here. If you're interested in learning more Types and Programming Languages is a really educational read. Additionally, a lot of the languages mentioned have type systems that fit into multiple categories -- Please don't come at me with a torch and pitchfork. I understand that a language's type system can fall into multiple categories ??

Learn you some new tech for great good!

Flutter is an open source framework by Google for building beautiful, natively compiled, multi-platform applications from a single codebase. Flutter uses the Dart programming language (remember 2013?) which was built for client-centric development. Flutter supports building for iOS, Android, Web, and native desktop applications. I really, really love this technology and hope that you will too!

Shoutouts

  • Shoutout to you! Yeah, you! Thanks for reading and supporting me!
  • Shoutout to Gophercon! This year was virtual but it was a fun and educational experience. If you want to learn more about the Go programming language, check out this conference next year and some of the talks from this year when they go up on YouTube.

Thanks again for reading! Enjoy your week!



要查看或添加评论,请登录

Brad Cypert的更多文章

  • Modern times call for modern languages

    Modern times call for modern languages

    Computing has only been around for roughly 70 years. While that may seem like a long time, it's actually an extremely…

  • Communicating in Code

    Communicating in Code

    Writing elegant code is an extremely difficult task. In some sense, you can think of it as writing a paper in a mix of…

    1 条评论
  • Dart all the way down

    Dart all the way down

    If you're using an app and it's built with a cross-platform framework, chances are high that it's either built with…

    1 条评论
  • The one on burnout

    The one on burnout

    I really, really enjoy writing code. It's both my hobby and my career, and in that sense I am extremely fortunate to be…

  • How to write less code without losing your mind

    How to write less code without losing your mind

    Today's issue is near and dear to my heart. As I've moved up in my career (in the "away from code" sense, not the…

  • Shortening the SDLC

    Shortening the SDLC

    One thing that has been on my mind a lot, recently, is how the SDLC is effected by modern development practices like…

    4 条评论
  • Read Only Memories: Optimizing Software

    Read Only Memories: Optimizing Software

    Hi! I wanted to give you some insight into what exactly Read Only Memories is. The goal with Read Only Memories is to…

    4 条评论
  • Boxing things in Rust

    Boxing things in Rust

    Rust's memory management can feel a bit intimidating for most developers. Rust gives you some control over whether…

  • Understanding Clojure's map and pmap

    Understanding Clojure's map and pmap

    Let's be honest - Part of the reason you're using Clojure is the higher order functions like . They're great…

  • Introduction to Asynchronous Processes in Clojure

    Introduction to Asynchronous Processes in Clojure

    I've been writing about Clojure for a while now, and after some requests, decided to write about Core.Async.

社区洞察

其他会员也浏览了