:: not my type
[Typing is a way of assigning a data type to variables, functions, objects and other constructs of programs. A way of saying that the function "add two numbers" will always result in an Integer, for example.]
On Discord, rubyists kicked off a converstaion while Matz was talking. One person explained what static typing was. "A type checker," said one, "can check your program without running it" and that's the "'static' part of 'static typing'." Someone else emphasized how static typing reduces the cognitive load associated with programming by preventing silly mistakes and bugs that a type checker can easile catch. Other people focused on what we may describe as animal welfare concerns: they were worried that type checker would end up killing duck typing. Poor ducks.
"Duck typing" is trying to infer what type a function or object has by looking at its behaviour. A way of performing the "duck test" in the context of computing: if it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck. This is a test you often have to perform when using dynamically typed languages like Ruby. You often have to think about how to better interact with certain objects and functions. You need to keep an eye out for rogue types. Geese, for instance.
Writing code without specifying types sounds dangerous and ill-fated for a lot of programmers. But there is a flip side. If most of the time you can predict or guess what type functions and objects have, then you can write code faster. If you don't need to worry about types, you'll have a better programming experience. Thinking about types is a terrible task. No one likes to think about types - you only do it if you have to. As one conference goer explained: "I felt liberated from having to think about types when I switched to Ruby."
Packed into this opposition between static and dynamic typing, there is a political philosophy. Dynamic typing is about freedom, it's about giving the programmer the responsibility to handle things by themselves. Contrary to the paternalism inherent in static typing, free languages treat the programmer as an adult.
"That's what Ruby is for me: it has always been about freedom, about freedom to express yourself in different forms. […] Programmers should be allowed to make mistakes. Ruby is not a language that will tell you 'Come here my son, hold my hand, let's cross the road and nothing will happen to you." (a ruby programmer)
Does that mean Ruby encourages children to cross the road on their own? Forget about type safety… is Ruby road safe?
"Ruby has no paternalism whatsoever and, of course, there will be people who will do loads of shit and you will get really angry at the pile of crap that these people do. But, at the same time, you are able to do amazing things if you know how to do the right thing. […] Ruby is not a paternalistic language, while Python and Java are very paternalistic." (a rubyist)
Where does this idea of freedom comes from and what kind of paternalism is this? How do they relate to wider socio-political contexts and debates about freedom and its restriction?
Ruby has come a long way since the days of wimsiness and fun that characterized the code written by people like "why the lucky stiff". Ruby now runs in billion dollar's worth of production code sustaining thousands of applications. The question, then, is this: is the move towards static typing related to the fact that Ruby now generates a lot of money and needs "safer" production code? Are rubyists getting scared of being free?
No need to be so dramatic, but that tension is certainly felt by some developers. There is a politics to typing that we can feel inside our brain. The battle between ducks and geese.
"I feel this as an internal conflict. I have within me this notion that freedom is paramount and that having this sort of paternalism is not something I want in my language. However, working in the same company for 6 years, I can also see the other side of it, how a lack of paternalism can lead to certain situations. So I have this internal conflict today, in which I have to accept certain paternalism even though I hate to have them. It's quite funny, because sometimes I have to impose certain rules to all the people [developers], rules that I don't want to follow. I end up following them, but I don't want to. A clear example of this is types." (the ruby dev)
They went on to tell me that their team implemented type checking a few years ago. No one was really fond of it at the beginning, but eventually, as most production errors started to disappear, people changed their minds. Perhaps that will happen with the Ruby community at large as well.
What the future will hold for the community as Ruby code gains more importance and generates more money is hard to predict. But it seems that the community is evolving towards the desire to control and restrict its objects. Today, the latest version of the language adds the ability to declare the types of objects, classes, and functions by adding additional files. As such, it is still not a built in syntactic feature of the language. But maybe Ruby 4 will have syntax for types. The question is will we see the ruby core-team move towards more and more static typing, perhaps even considering adding syntax that would allow for it. If that happens, there will be no more ducks in the ruby ecosystem.
The good thing is that ducks are not swans and we do not have swan typing. If that were the case, Queen Elizabeth might not like it - given that she owns all swans. As a static sovereign, ducks are not her type.