289. Stronger Strong Types (Replay)

Today on The Rabbit Hole we are talking about strongly typed and loosely typed languages. There is very little industry consensus about what these terms mean and it is not uncommon to find often contradictory definitions, so we take it upon ourselves to uncover the truth and what we find is rather surprising! Languages that we initially thought of as strong proved not to be as iron-clad as we thought and our previous thinking about loosely typed language also had some holes. We also talk about some of the type checkers that we have used in our work and which ones we think are best. Finally, we look to the future and explore the trajectory of strongly and loosely typed languages as well as dynamic and compiled ones. For all this and more, join us today!


Key Points From This Episode:

  • Definitions of strongly and loosely typed languages are subjective based on perceptions of capabilities.
  • How implicit versus explicit type factors into the capability and strength of a language.
  • Although Python and Java are different, they are both strongly typed languages.
  • How Python’s type hinting works.
  • Javascript’s type checker does not work in the same way as a conventional type checker.
  • The most loosely typed programing language in our opinion.
  • Who would win in an arm wrestle between Python and Ruby?
  • How static typing relates to strong and loosely typed language.
  • Why transpiling and compiling affects the checking of a language
  • Flow is difficult to use for several reasons.
  • The future of dynamic and compiled languages.


Transcript for Episode 289. Stronger Strong Types (Replay)


[0:00:01.7] DA: Would you say that as a person, you’re strongly or weakly typed?

[0:00:05.5] MN: I don’t know.

[0:00:07.0] WJ: This is a good intro for the episode. Are we rolling?

[0:00:10.3] DA: I’m sorry, yeah. Hold it.

[0:00:11.4] WJ: Wait, no, I think let’s just let it roll, we’re in the episode now.

[0:00:15.3] MN: Yeah, let’s do it. We’re at the podcast at the Rabbit Hole Podcast. Dave just asked me if I was a strongly type or weakly type, is that what it was?

[0:00:24.6] DA: No, if you're strongly or weakly type person.

[0:00:26.8] MN: As a person.

[0:00:27.5] DA: yeah, you know, in situations.

[0:00:30.2] MN: I think I could be like loosely typed, I don’t know, it’s just like, you know, I could walk like a duck and talk like a duck.

[0:00:40.8] DA: Looks like a duck.

[0:00:42.0] MN: Yeah. I think I could mesh with whatever group is thrown at me.

[0:00:46.6] DA: Duck is also wearing this Yankees hat that has a Dominican flag on it.

[0:00:52.0] MN: Hey, I’m just letting everyone know the types that they can communicate with me in –

[0:00:55.8] DA: That’s true.

[0:00:57.8] MN: Not that I have to conform to them, but hey, doubles and integers, that’s me, don’t worry about it. I could deal with numbers, okay? Well, do you have, are you strongly type person or weakly type person, how do you feel? Do I have to approach you a certain way when you respond?

[0:01:16.2] WJ: I’m type non-binary. I’m type fluid.

[0:01:18.7] MN: Okay.

[0:01:19.8] WJ: I don’t think you know — typing is a spectrum.

[0:01:22.2] MN: I see.

[0:01:22.9] DA: Right, okay.

[0:01:24.7] WJ: It depends on the day, depends on my mood. Sometimes, I will type catch for you, sometimes I won’t.

[0:01:30.6] MN: yeah, someone yells at me.

[0:01:32.2] DA: That just sounds fickle.

[0:01:35.4] MN: Dave, yourself? Did you have one as you were asking?

[0:01:40.7] DA: Dude, I’m just so strong.

[0:01:43.4] MN: Mega strong bro.

[0:01:46.3] DA: I’m just very strict.

[0:01:47.5] WJ: There you go.

[0:01:48.1] DA: So, OCD.

[0:01:49.9] MN: There you go, someone comes at you the wrong way, you’re just like no. Try again.

[0:01:54.3] DA: This milk is supposed to be on this shelf, not that shelf. This is breaking the interface.

[0:02:02.7] MN: I like my beans on the rice, not on the side, you flip the table.

[0:02:07.3] DA: Flip the table, compiler error. Get out of here. It’s over.

[0:02:12.4] MN: There you go. Hello, welcome to the rabbit hole, the definitive developers podcast in Fantabulous Chelsea Manhattan. I’m your host Michael Nunez, our cohost today.

[0:02:22.1] DA: Dave Anderson

[0:02:23.0] MN: And our producer

[0:02:20.7] WJ: William Jeffries.

[0:02:25.0] MN: we’re talking about strongly typed and loosely typed languages. Earlier in life, Me and William came, you know, to the office and we dive down the rabbit hole to talk about strongly type and loosely type languages.

[0:02:38.2] WJ: We were so sure we had radio gold and then I went back to the office and I told Dave about it and he was like, wait, you said that Python is a loosely typed language, it’s a strongly typed language.

[0:02:50.0] MN: We’re like what?

[0:02:51.1] WJ: Wait.

[0:02:53.0] DA: I was like, I’m sorry, I think you’re wrong and I’m like, then II looked it up online and I’m like, “I think I’m wrong too.” I think we’re all wrong.

[0:03:01.9] MN: We’re all right. Guys, maybe I don’t know, so let’s talk about that. I think we discussed, when we were discussing this strongly type versus loosely type, I think it’s safe to say that Java is a strongly type language. Maybe we need to define what it is.

[0:03:19.7] WJ: Yeah, let’s do a definition.

[0:03:21.1] DA: Yeah. I’m looking at something right now, it says, you know, strong or weak type is like very subjective and like this thing, there’s a spectrum. So, there’s like different capabilities that people think about as being stronger or weaker. So, like static type checking. You got to write the types before you compile the code, that’s Java.

[0:03:47.3] MN: Yeah, for sure. I think we mentioned, I mentioned before in life, and then I know we also got into the explicit and implicit type checking. Java 11 allows you to write ‘var’ and then whatever you want to name it and you equal to whatever you want it to be. Let’s say we do ‘var,’ name, equals Michael, it would imply that that’s a string because it looks at whatever the type is on the right for Java 11. Java eight, you would have to write string name equals Michael, in that sense. That was another thing we may have overlooked, the implicit versus explicit type.

[0:04:26.9] DA: Right, even then in Java 11, I think you have to define the balance of the method. To find your inputs and your outputs and your outputs so that way you can be a bad cop if you’re like not doing it right.

[0:04:38.7] MN: Right, even if you use vars in a method, your method definition has to return the right type or the type that you want it to be as you go forward with the rest of your application.

[0:04:52.3] DA: It will flip the table if you get it wrong.

[0:04:53.9] MN: Yeah, exactly. You know, you have a different method, that’s returning a string name and then you multiply, it will tell you that the multiplication is just not going to happen because it’s a string, “What are you doing? Stop that.” There was that but then like – Python is strongly typed but dynamic as well is the idea?

[0:05:14.6] DA: Yeah, if you try to add the number two in the word hello together then it’s going to be like –

[0:05:21.3] WJ: Type error, can’t do that type error is the way that those operations are defined is that it does a type check.

[0:05:29.0] MN: But that would not happen until you did it in run time.

[0:05:34.0] DA: Yeah, run time, exactly.

[0:05:36.6] MN: That’s like a huge – one is compilation time and then one is run time. That’s a different way of checking for types.

[0:05:44.1] DA: Yeah, dynamic type checking, right? And when you’re actually writing your own types of Python, if you want to have that kind of type safety, you just got to write an if statement like, “If it’s the right type then do the thing and if isn’t the right type then you know, either return not implemented or raise an error or do whatever.”

[0:06:06.0] MN: Okay. You could also introduce type checking in Python though. I think we also had a discussion about that.

[0:06:14.0] WJ: We can do type hinting.

[0:06:16.0] MN: Hinting, there’s a hint here.

[0:06:17.8] DA: Annotation, little note.

[0:06:21.5] MN: How does that work, that just makes it more strongly type or it checks the types earlier than python would normally check them by giving you hints when you try to do the wrong things with types.

[0:06:37.5] WJ: Yeah, actually, I don’t know at what point in program execution it actually runs to see if any of your type hints show that something shouldn’t compile. I mean, the main thing that’s nice about type hinting in Python to me is that it allows you to use your editor more effectively. Like the same way that in a strongly type language like Java, you’re able to hop around quickly based off of knowing the type you give the editor that same functionality but for Python.

[0:07:09.1] DA: Yeah, also like finding instances where you're referencing a certain thing, you know, that’s easier refactoring tools.  Telling like you can look at the things that you’re passing around and be like, “Oh, god, I’m just passing around a dictionary or like a bunch of hashes everywhere, this is embarrassing, we should have a value object or something like that.”

It makes you think about the things that you’re doing a little bit more. You can kind of like, ignore the broken windows if they’re not like – they don’t have a light shine on them. Yeah, a lot of dynamic languages are kind of going in that direction where now you have some kind of like nice little type hinting or annotation you can bolt on to it like Ruby has that now too with Sorbet. I think they’re working on building something more into the core of Ruby with a future release but Python has mypy

JavaScript has Flow or Typescript. I guess there’s a different thing but like –

[0:08:11.1] MN: I actually want to go into – Typescript all is a framework you would call it or it just make your JavaScript more type like, is that the idea?

[0:08:25.5] DA: Yeah, I guess. I don’t know how you describe it, its own language, I could just compiles down to JavaScript, it’s like – like Elm or something like that like closure but it just looks like JavaScript.

[0:08:38.8] MN: Yeah, you mentioned, I believe William did mention in the episode in our conversation before that you can just throw [inaudible 0:08:47] anywhere and that will be fine kind of, you could –

[0:08:48.0] WJ: Yeah, I think you can sort of sabotage your own efforts to use types effectively in your type script by using the any type which allows you to use whatever type happens to be returned.

[0:09:02.3] MN: Just like that, bam, use any.

[0:09:04.6] WJ: Which kind of defeats the purpose.

[0:09:06.3] DA: Right. You should feel a deep shame whenever you use any.

[0:09:12.4] WJ: Unless you're like working with a third-party library where you don’t have control of what type they were turning maybe.

[0:09:18.9] DA: Still a deep shame.

[0:09:22.5] MN: That would be more strongly typed type script and our definition because it will give you errors on compilation or will that give you a result run time?

[0:09:33.4] WJ: Typescript will throw errors at compilation time, really transpiration time because it’s transpiring into JavaScript.

[0:09:39.6] MN: Got it.

[0:09:40.2] DA: Yeah. That’s an interesting thing because like, with other tools like we were talking about like mypy and Sorbet, those can live in your code and you can run the code and it will be fine. It’s perfectly valid code. It’s just that if you run the type one tier then the entire will be like, that bad thing.

[0:10:04.8] MN: And then, JavaScript is just not loosely typed all around. It’s very, I mean, what are your thoughts? Because you have to kind of use types.

[0:10:18.0] WJ: I think if you want an example of a loosely typed language, JavaScript seems like maybe the loosest of the popular programming languages. No, not like in the mean way.

[0:10:30.3] DA: It just has some quirks. It’s not picky.

[0:10:39.3] MN: You can add numbers and then define as not a function but your code compile is just fine which is way too late to that method.

[0:10:47.5] DA: I love that tweet that you found where what was it like? Creator of JavaScript is just like, “It’s non type,” and I was like, “Wait, that blew my mind.”

[0:10:58.4] WJ: Actual language.

[0:10:59.3] DA: That’s a very strong stance.

[0:11:02.7] MN: It has no types, none of them.

[0:11:05.3] WJ: I was really surprised to see how little consensus there is in industry about what all these terms mean. How easy it is to find really contradictory definitions.

[0:11:18.4] MN: Bro, we came here like knowing –

[0:11:20.7] WJ: I thought I knew what was up. I was very wrong.

[0:11:24.4] MN: One hundo p, we were like, “Yo, Java, Strong, Python, dynamic, weak sauce. No, wrong.”

[0:11:32.7] DA: I think dynamic like people have an agreement on but then you start talking about strength then it’s like, well, I don’t know, it’s all relative when you think about it. It could be stronger you know? It could be a little beefier snake.

[0:11:49.9] MN: With little arms.

[0:11:51.3] WJ: Bit more of an anaconda.

[0:11:52.3] DA: Exactly. No arms, can’t be that strong.

[0:11:57.3] MN: Would you say that Ruby is a weaker lead type language than Python? I mean we are discussing like doing arithmetic on string and you can get away with some of that in Ruby like you do hello times three –

[0:12:10.8] WJ: And then you get the string hello three times.

[0:12:14.3] DA: Python does that too though, but if you do hello plus three then Ruby is like, “Nah.”

[0:12:21.2] WJ: And so, is Python, right? Python is also like no.

[0:12:24.3] DA: Yeah, right they have pretty similar behaviors.

[0:12:26.4] WJ: So, if Python and Ruby were to get into like an arm-wrestling match who would be stronger?

[0:12:35.9] DA: I think they’re equally matched yeah. I mean they are both compiled onto C, right? Or they’re both based on C core, which from what I was reading hardly before this podcast is like pretty weekly type in some ways where you can like just do math on memory addresses and end up in all kinds of funky states.

[0:12:59.9] WJ: Yeah you just have no idea.

[0:13:01.9] DA: It’s like I didn’t even think about that being a thing because like Java don’t let you do that. That is like this is my pointer. You can’t touch it. And you know Python and Ruby like also are like, “We are going to take that away from you.”

[0:13:17.7] MN: Wait. So, I mean you have to execute this really quick Dave. What would Java Script do if you did hello times three? Do you get like “Hello N-A-N” it is going to be so wild. What do you think William go ahead real quick! Got a few question.

[0:13:36.5] WJ: NAN maybe?

[0:13:38.0] DA: Yeah since it’s NAN.

[0:13:40.3] MN: You just get a NAN, yeah Java is bit weird.

[0:13:43.1] WJ: I mean technically true.

[0:13:45.2] MN: Yeah, it is not a number, but like Java Script will let you have that in your code and then you’re like, “Wait, why am I getting this NAN?” and they did have to look through it.

[0:13:52.7] DA: But plus three is hello three.

[0:13:55.1] WJ: Oh, all right, what is three plus hello?

[0:13:58.8] MN: Uh-oh there you go. It’s going down.

[0:14:03.5] DA: It’s three hello.

[0:14:04.8] MN: Three hello, what is three times hello? NAN.

[0:14:09.5] DA: NAN yes, just NAN.

[0:14:11.1] MN: Oh man, Java Script what is wrong with you. You are truly un-typed, aren’t you?

[0:14:16.8] WJ: Those ones aren’t even that bad though like if you watch the Watt video, he’s got some pretty surprising release.

[0:14:22.1] MN: Oh yeah no, that one is great, who is the person we should put in on the show notes?

[0:14:26.6] WJ: Gosh a great video.

[0:14:27.8] MN: That is a great video like just to show people how ridiculous JavaScript could be, it is a pretty good video.


[0:14:34.5] WJ: Apparently, they can’t fix it because it going to be backwards compatible.

[0:14:37.6] DA: Oh yeah, that is Gary Bernheardt’s talk Watt.

[0:14:42.2] MN: Yeah, I remember friend of the show, Kevin Thomas put me onto this video and it is quite the laugh.

[0:14:49.4] WJ: Yeah, really hysterical.

[0:14:51.2] DA: Yeah because JavaScript does all kinds of helpful things for you like just on math the course types into different things.

[0:14:58.4] WJ: Right, it doesn’t always do it quite of what you would expect it to though.

[0:15:03.1] DA: Yeah but that is why we had the triple equal sign because it is just like, you know that much beefier than the double equals.

[0:15:10.9] MN: Just make it longer or just tons of equals.

[0:15:13.6] DA: Four equals please.

[0:15:15.3] MN: There you go. Yeah, I mean the term strongly and loosely typed is much bigger than we thought when we first had this conversation and dynamic –

[0:15:26.3] WJ: So, do we figure out what static typing is and how that is different? I guess that is just static versus dynamic.

[0:15:32.0] DA: Yes, static is like before.

[0:15:33.7] WJ: It is like whether or not it is compiled.

[0:15:35.2] DA: Yeah exactly.

[0:15:36.6] MN: Right, so we could say Java is a static strong typed language.

[0:15:43.5] DA: Static meaning like you have all the code on the page and it is not moving. It is just sitting there. Someone just looks at it.

[0:15:51.5] MN: Let’s add then you described Java perfectly like that.

[0:15:55.9] DA: It doesn’t go anywhere.

[0:15:56.7] MN: Meanwhile Ruby is a strong, dynamic typed language, right? Because it does –

[0:16:07.3] WJ: Yeah, I mean it sounds like what we have landed on is that strength and weakness in programming languages is the spectrum and Ruby is stronger than average, but not as strong as say Java because they don’t have explicit types.

[0:16:25.5] MN: Right and then Typescript that can also be a strong typed but not as strong as Java because you used the word transpiler not compiler.

[0:16:37.6] WJ: So, would that count as a statically typed language? Because it is technically compiled. Well sort of, it is transpiled.

[0:16:46.2] MN: Yeah that is what I am saying. So, it is not as strong as Java but it is still stronger than Ruby, right? Because it would yell at you if you got something wrong but once it transpiles to do that.

[0:16:56.1] WJ: So, it will transpile into Java Script and you will get transpilation errors, which makes it seem strongly typed but then it’s going to run as Java Script and that’s dynamic and you can have runtime errors at that point.

[0:17:12.2] MN: Typescript sounds hard. Have you guys ever used Flow before?

[0:17:16.1] DA: Oh, I use it all but.

[0:17:18.3] MN: I don’t. Flow is so hard to use and the errors weren’t that great. That was another thing we spoke about was how some strong or static typed languages actually help you with those errors, those type errors that will allow you to fix the code or ensure that things are running correctly and because you had these strongly typed languages, you are less likely to write tests to test those types because you know exactly what you are expecting in a given type.

But Flow is just hard and the errors don’t really help me at least unless they fixed it. I don’t know, I haven’t used it since 2016? I am not sure, it was hard.

[0:17:58.9] DA: Yeah, I haven’t used it in a while too. Like type script they may seem alike but it is more loved for whatever reason.

[0:18:07.7] MN: Yeah, I mean Flow is something else. Not a fan. Flow is not a friend of the show I am just going to say that in person. Flow is not invited into the chamber that is what we have here. I just don’t like Flow.

[0:18:20.6] WJ: Throwing down the gauntlet.

[0:18:21.8] MN: Oh yeah, I am being – I will put my foot down on this one guys, I’m sorry.

[0:18:25.0] WJ: All right, hot stuff.

[0:18:27.3] MN: And then as we discussed as we were going through all of these languages, JavaScript is just something completely out there not strongly typed and dynamic-ish.

[0:18:40.5] WJ: I think it is pretty solid, dynamic great.

[0:18:43.8] MN: So, it is a solid dynamic.

[0:18:44.8] WJ: Solidly dynamic. I feel like it would be hard to argue that Java Script is static, yeah?

[0:18:50.4] MN: Yeah, I think so. I think so you get a lot of those weird runtime errors. It is tough.

[0:18:56.9] WJ: Because it’s what? It is the V8 engine that processes it and that happens at runtime.

[0:19:03.2] MN: Yeah, whoa! Man, I am so glad we had this episode, we were like fools if you released that last episode hopefully –

[0:19:12.9] WJ: I am a little worried we are going to release this one and get just as PONED.

[0:19:18.3] MN: Well, we’ll find out and hopefully we will also release the one we had recorded before.

[0:19:23.4] WJ: Please no, no, please no.

[0:19:26.2] MN: And I am sure it will happen. I won’t let that one out. Do you all think that we’ll see more type languages in the future or is that all going to go away and everything is going to be dynamic?

[0:19:38.1] WJ: I think that – oh wait, you are talking about strongly typed versus weakly typed? Are you talking about dynamic versus static? I think that strong and weak typing are increasing becoming options that you can have no matter what language you’re in.

[0:19:53.3] MN: Right.

[0:19:54.0] DA: Right like Java just kind of –

[0:19:56.7] MN: Using Vars, yeah, all day.

[0:20:00.5] WJ: It’s just weakening, it’s not even really weak because it’s not like I can see where you could actually get a real [inaudible 0:20:07] exception because you're doing an operation on a location in memory that contains a completely different data type than what you were expecting.

[0:20:15.5] MN: Right.

[0:20:17.5] WJ: Whether we see more dynamic or more compiled languages I think is a tougher thing to predict. I mean, it seems like a compiled language will always be performant than dynamic languages, that’s just the reality.

[0:20:32.3] MN: The use of the compiler, right? If everything is already been compiled into machine code then it doesn’t have to do that at run time. You save that part but having it static or dynamic, or rather having it strongly typed and loosely typed, there will be an option when you want to –

[0:20:51.4] WJ: You’ll be able to start too loosen it, you know, you could tweak it.

[0:20:55.5] DA: Just lay your hair down every now and then.

[0:20:57.6] MN: Yeah, exactly. Or strengthen it you know? Get some –

[0:21:01.1] WJ: Tiny bells.

[0:21:02.7] DA: Do some reps, yeah. I mean, yeah. I heard about how Dropbox is applying mypy for doing type checking on their code base of Python code and they didn’t start with that, but now, they’re fully invested in it because you know, their code base has grown to a point where it’s millions of lines of code. Like just tens of millions of lines of code and no one can understand what it is and so they kind of decided that this is a tool that is helpful for them to better understand the code and verify that it’s correct.

[0:21:44.4] MN: Right, so that you get the – you understand the types that are currently being used in parts of the code base?

[0:21:51.1] DA: Right, exactly. You know, it’s there for you if you need it.

[0:21:56.0] MN: If you need it. That’s awesome. I imagine we’ll see more of those types of additions to programming languages in the future or that programming languages that get created in the future would have this feature readily available out of the box. Till then, we’ll deal with the current strength and versatility over a language that we’re currently using. Whether it’s Java, Typescript, Ruby, Python or JavaScript.

[0:22:25.9] DA: All the things.

[0:22:27.3] MN: All the things.


[0:22:27.7] MN: Follow us now on Twitter @radiofreerabbit so we can keep the conversation going. Like what you hear? Give us a five-star review and help developers like you find their way into The Rabbit Hole and never miss an episode, subscribe now however you listen to your favorite podcast. On behalf of our producer extraordinaire, William Jeffries and my amazing co-host, Dave Anderson and me, your host, Michael Nunez, thanks for listening to The Rabbit Hole.



Links and Resources:

The Rabbit Hole on Twitter

Quentin Watt on YouTube

Gary Bernheardt on Twitter