Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 02 23:58
    @SethTisue banned @fakubishes:nerdsin.space
  • Dec 15 2021 05:01
    som-snytt commented #12516
  • Dec 15 2021 04:38
    SethTisue edited #1312
  • Dec 15 2021 04:38
    SethTisue opened #2273
  • Dec 15 2021 04:31
    jackkoenig opened #12516
  • Dec 15 2021 04:29
    SethTisue edited #1312
  • Dec 15 2021 04:28
    SethTisue edited #1312
  • Dec 15 2021 04:27
    SethTisue labeled #9831
  • Dec 15 2021 04:27
    scala-jenkins milestoned #9831
  • Dec 15 2021 04:27
    SethTisue labeled #9831
  • Dec 15 2021 04:27
    SethTisue opened #9831
  • Dec 15 2021 03:35
    som-snytt commented #11339
  • Dec 15 2021 03:27
    som-snytt labeled #12494
  • Dec 15 2021 03:07
    SethTisue edited #1312
  • Dec 15 2021 03:07
    SethTisue edited #1312
  • Dec 15 2021 03:05
    SethTisue edited #1312
  • Dec 15 2021 03:05
    SethTisue edited #1312
  • Dec 15 2021 03:05
    SethTisue edited #1312
  • Dec 15 2021 02:58
    SethTisue edited #1312
  • Dec 15 2021 02:58
    SethTisue synchronize #1312
PsyfireX
@PsyfireX
What is in the category of etc?
By "none" I meant no framework, which usually means "plain old parameters" or structuring your code in a way where you don't have many dependencies
Martijn Hoekstra
@martijnhoekstra
I don't know
PsyfireX
@PsyfireX
Exactly
:)
Martijn Hoekstra
@martijnhoekstra
maybe global variables? that's sort of implicits
it's a relatively broard category
Dominic Egger
@GrafBlutwurst
the only correct choice is "refuse to write code that 'requires' DI"
PsyfireX
@PsyfireX
^ Agreed
Martijn Hoekstra
@martijnhoekstra
what, and not have any dependencies?
Fabio Labella
@SystemFw
I think you're just disagreeing on the meaning of "DI"
Martijn Hoekstra
@martijnhoekstra
or construct them yourself in the bodies of your methods -- destroying any chance of parametricity?
Fabio Labella
@SystemFw
if by "DI" you include passing dependencies manually
then "avoid DI" is pretty nonsensical
if by "DI" you mean "magic frameworks"
then I agree
Martijn Hoekstra
@martijnhoekstra
If "manual (e.g. passing constructor parameters)" is given as an option on what DI you use, I think it should be obvious that it's not limited to magic frameworks in this context
Fabio Labella
@SystemFw
I agree :)
the question of whether this should be called DI or not is probably a separate conversation
Dominic Egger
@GrafBlutwurst
code that actually does anything is impure and evil :D
Martijn Hoekstra
@martijnhoekstra
fun fact: code doesn't actually do anything at all
Josh
@joshlemer
code doesn't do side effects, people do side effects
Martijn Hoekstra
@martijnhoekstra
CPUs may do stuff with code that a compiler generated from the code you wrote, but if that's "close enough" to the code doing things, then I'd argue pure effects in an IOApp runtime is "close enough" as well
PsyfireX
@PsyfireX
The CPU was just following orders.
vijendra singh
@viju0731_twitter
image.png
value current is not a member of object java.sql.SQLException
not found: value JDBCConnectionException
Getting this error any help
PsyfireX
@PsyfireX
Could you copy a larger code-snippet?
Harrison Houghton
@hrhino
also, that's Java...
Josh
@joshlemer

Also I feel like it's so easy to "sneak in" mutability, if that makes sense. For example:

Seq[(String, Int)](
  "x" -> 1,
  "y" -> 2,
  "z" -> 3,
  "x" -> 2
).foldLeft(Map.empty[String, Int])(_ + _)

In a sense, we're reassigning a value to "x" here, right?

Harrison Houghton
@hrhino
... no? not any more than using updated on a map
Josh
@joshlemer
If you kinda squint at it and pretend that each line is binding to a variable then it's as if we have invented var out of purely functional constructs
PsyfireX
@PsyfireX
I don't get it, how are you assigning anything to "x"
"x" isn't mutable, nor is "x".->(2)
Martijn Hoekstra
@martijnhoekstra
@joshlemer sure, if you consider a Map[String, Int] as the runtime of your programming environment, with the strings as identifiers, updating values in that map can be seen as mutating values pointed to by identifiers
Josh
@joshlemer
Exactly @martijnhoekstra gets it
Martijn Hoekstra
@martijnhoekstra
but that's not scala, that's the Map[String, Int] language
Josh
@joshlemer
so if you aren't careful, mutability can "foam up" from beneath you
or rather, emerge would be the verb
Fabio Labella
@SystemFw
mutability is not a problem, lack of referential transparency is
also, that Map is a common technique to implement environments for closures when doing e.g. an interpreter :)
Josh
@joshlemer
a more flushed out example
sealed trait AssignmentTo 
case class Constant(c: Int) extends AssignmentTo
case class Variable(varName: String) extends AssignmentTo


Seq[(String, AssignmentTo)](
  "x" -> Constant(1),
  "y" -> Constant(2),
  "z" -> Constant(3),

  "uhoh" -> Variable("x"),

  "x" -> Constant(1),

  "uhoh" -> Variable("x")

).foldLeft(Map.empty[String, Int]) { case (acc, (ident, assign)) =>
  val newValue = assign match { 
    case Constant(c) => c
    case Variable(varName) => acc(varName)
  }
  acc + ((ident, newValue))
}
Martijn Hoekstra
@martijnhoekstra
The mutability there is in the interpreted language of AssignmentTo, not in scala
Josh
@joshlemer
like, aside from throwing exceptions, this is as pure as it gets.Yet, it is starting to look a lot like imperative programming
PsyfireX
@PsyfireX
I don't see the mutability
It seems like you're trying to prove a point by starting with "squint very hard"
Amit Prasad
@amitprasad01_twitter
Hi Guys
anyone familiar here of scalamock