this post was submitted on 01 Sep 2023
327 points (96.1% liked)

Programming

16781 readers
116 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 4 points 11 months ago (19 children)

Types and unit tests are bloat that increase the maintenance cost of whatever code they are involved in. Most types force premature design/optimization. Most unit tests lock up some specific implementation (increasing cost of inevitable refactors) rather than prevent actual bugs.

Nil-punning in clojure has spoiled me rotten, and now every other language is annoyingly verbose and pedantic.

[–] [email protected] 21 points 11 months ago (5 children)

Definitely a hot take. Wow.

I do get where you're coming from, however. Dynamically typed languages are great for prototyping and if you're dealing with a small codebase, it can stay that way, but IMO large codebases without typing are not fun to navigate and understand.

"Which class am I dealing with now?" is such a common problem that I'd rather have it explicitly written than guessing or assuming to know.

[–] [email protected] 1 points 11 months ago (4 children)

Very happy to share this hot-take :) Definitely code-base and team-size are a huge factor, and I mostly work on my own projects, so each project is very different. still, I expect to get downvoted into oblivion by the last decade's influx of typey-langs and -devs.

I think most love for types is folks being happy they don't need to assert on the input to every function, i.e. static analysis and reduced unit-tests. It's hard for me to not see types as asking folks to pre-design their entire system (by defining types first!), before you've even started writing a few functions, which are actually what the system should codify (behaviors, integration tests). It's also frustrating b/c types don't guarantee that the system does-the-thing, only that the type-system and compiler are happy, so it's like pleasing the wrong boss, or some metaphor like that.

I like to work with behavior directly in functions, which should be the same regardless of the type passed in. Unfortunately most dynamic languages have their flaws (js,python,etc), so this kind of opinion suffers b/c of those languages... similar to type-favoring opinions suffering b/c of langs like typescript.

Nil-punning makes me very happy - that's a hill I will actually die on. Almost every project i've worked on, there's no reason to go out of the way to specifically handle every case of not the right input or oh-no-it's-null! Whenever you have null, you just return null from this function too, and guess what, everything's fine - no need to crash and blow up b/c one thing wasn't there. Mostly this is a complaint about things completely crashing for no reason, rather than being incomplete (i.e. some data missing) but still working for the user.

Anyway, lots of different use-cases, and use the right tool for the job, etc etc. types and unit tests are useful for some things.

[–] [email protected] 6 points 11 months ago (1 children)

and I mostly work on my own projects

Then your opinion is absolutely understandable.

It’s also frustrating b/c types don’t guarantee that the system does-the-thing, only that the type-system and compiler are happy, so it’s like pleasing the wrong boss, or some metaphor like that.

Types help you refactoring and communicating with other team members about expected inputs/outputs. Did you ever try debugging a number that should've been a string in a codebase that you didn't write? Example from today: jsforce will throw an exception when you pass a number instead of string due to the fact that the Salesforce server will complain that the type is incorrect. If the method had correct typing of "string", it would save me a few hours of debugging a huge library without visibility inside of it...

[–] [email protected] 0 points 11 months ago

Sounds like a frustrating issue - feels like salesforce shouldn’t be enforcing that number vs string in the first place, because it could just get coerced later on. But, it’s out of your hands for sure, and there are tradeoffs for them making their API “easier” to work with.

And yeah I’m being a bit obstinate in this hot take - it’s easy to get away without types when working on smaller projects and in more modern languages, especially for low-stakes dev tooling. In larger projects, types can help improve confidence during large refactors.

I just want less code to maintain in general…

load more comments (2 replies)
load more comments (2 replies)
load more comments (15 replies)