Ephera
link
fedilink
English
93M

Yeah, the alternative to static typing is to write tons of unit tests, which definitely adds a lot more code to your codebase.

That’s not an alternative, you always need tests

Ephera
link
fedilink
English
23M

Right, so this is the part where I get to sound like a smart ass, because I snuck a “tons of” into there.

What you do always need, is tests serving as a specification of the intended behavior, to document it for your team members and your future self.
But the thing that static typing is an alternative to, is integration tests for many code paths. For example, in dynamic languages you have no reassurance that a call to your database library still works, unless you have an integration test which actually calls into the database. Similarly, you hardly know whether the many error-handling code paths are working, unless you write tests for those, too.
In static languages, we don’t test this stuff outside of the specification-like integration tests, because the database library and the error handling library are already separately tested, and the type system ensures that we interface with them correctly.

Create a post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 1 user online
  • 46 users / day
  • 93 users / week
  • 414 users / month
  • 2.18K users / 6 months
  • 1 subscriber
  • 1.69K Posts
  • 37.3K Comments
  • Modlog