In Scala it's bad practice to use implicit parameters for summoning traits that aren't type classes. Not all traits required via implicit parameters are type classes, usage via "implicit" isn't what defines a type class, the trait's signature is. Stop using "implicit" for DI.
-
Show this thread
-
A lot of the "tagless final" in Scala is basically "passing all OOP dependencies at the call site as implicit parameters", the so called "algebra", in this context a fancy term describing OOP classes w/ state. The things people do to avoid giving plain arguments to functions
4 replies 0 retweets 13 likesShow this thread -
Using implicits for DI is bad b/c reading code requires more context. It's why the Linux kernel has never adopted C++, b/c kernel devs want to reason about pieces of code in isolation, C making everything explicit. Reading code is more important than writing it, always.
2 replies 1 retweet 27 likesShow this thread -
Replying to @alexelcu
But shouldn't that be what context is? It's the things that the reader can take for granted, and every additional explicit parameter that ought to be taken for granted instead has to be present, diluting the parameters that are actually significant to the method.
2 replies 0 retweets 1 like -
Replying to @propensive
Seeing that a method interacts w/ the database, or can potentially fire missiles, is as important at the call-site, as its definition. And if we want context, if we want DI, Scala also has a true and tried way of doing it, which is OOP classes, closures on steroids.
2 replies 0 retweets 2 likes -
Replying to @alexelcu
This is less true in Scala 3 where context (i.e. givens) must be explicitly imported. You do that once for a particular scope, and that sets your context, which you accept for every method call in that scope.
1 reply 1 retweet 4 likes -
Replying to @propensive @alexelcu
Let's ignore firing nuclear missiles for now, but a beginner learning the language who doesn't care how many calls are being make to the database would benefit from being able to read the code without worrying about when the database connection is used. The code is more readable.
1 reply 0 retweets 0 likes
Or consider a logger parameter. If you have to explicitly pass a logger object to every method that uses it (probably all of them) that's a death-by-a-thousand-papercuts level of distraction in every expression making the important parameters harder to see.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.