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
Klas Segeljakt
@segeljakt
it will be for a stream processing engine, when it gets an incoming query it will generate Rust code for it and execute
Ichoran
@Ichoran
Okay, but why not write it all in Rust?
Klas Segeljakt
@segeljakt
Rust is not as good as Scala for meta-programming in I think
Ichoran
@Ichoran
Having to keep two nontrivial languages deeply in mind simultaneously to complete the project is not going to be easy.
Klas Segeljakt
@segeljakt
true
Ichoran
@Ichoran
I guess I'd agree with that. If all else was equal I'd use Scala.
Klas Segeljakt
@segeljakt
the code generator is a small part of the project
Ichoran
@Ichoran
Okay. Well, I guess if the project is already irrevocably committed to using both Scala and Rust, may as well charge ahead.
Klas Segeljakt
@segeljakt
the driver will be written in Scala and do most of the coordination, then the workers do the work in Rust
Ichoran
@Ichoran
Wouldn't be my first choice, but there are other choices that people make all the time that would be waaaaaay lower down on my list (like using Java to create and execute Java).
Klas Segeljakt
@segeljakt
lol
They put a JVM in the JVM?
Rob Norris
@tpolecat
Hm I think Scala is not very good for metaprogramming, depending on how you define it I guess.
The Scala macro system is a garbage fire.
I think it's pretty good for embedded DSLs though.
Seth Tisue
@SethTisue
What metaprogramming support exists in Rust?
Long Cao
@longcao
Rust has macros and derivation, not sure how that lines up with what's available in Scala https://doc.rust-lang.org/book/second-edition/appendix-04-macros.html
Gabriel Claramunt
@gclaramunt
give me a collapsing tower of interpreters :)
Klas Segeljakt
@segeljakt
Rust’s macros are not on the same level as Scala’s I think
the macros define meta-variables which can be substituted for token-trees
Separators, like (), {}, [] create token trees
Rob Norris
@tpolecat
@gclaramunt o/
Harrison Houghton
@hrhino
Sounds kinda like Dotty LMS, then?
Elikar Ibn Mtsouko
@mtsouko_twitter
What is a good rule of thumb to follow when creating a trait vs abstract class? It seems there is a good amount of overlap in functionality ...
Li Haoyi
@lihaoyi
Python’s metaprogramming is the best :D
it even has hygienic quasiquotes
i think ichoran was talking about runtime java source code generation and compilation
although i have put a jvm inside a jvm and it’s awesome(ly slow)
Li Haoyi
@lihaoyi
spark does runtime java source generation and it’s not bad; compiles fast enough, JITs down to fast assembly and is easier for most people to debug than malformed blobs of bytecode
Klas Segeljakt
@segeljakt
What does hygienic mean?
with quasiquotes :D
Li Haoyi
@lihaoyi
it means when you call a function foo in a quasiquote, the macro generated code calls the function foo that is lexically in scope where the quasiquote was defined, not whatever random foo may be in scope at the macro callsite
Gabriel Claramunt
@gclaramunt
@mtsouko_twitter since you can only mix one abstract class and many traits as you want, I try to use traits as much as I can... abstract classes is for when you really want OO and is a reasonable hierarchy
Justin du Coeur, AKA Mark Waks
@jducoeur
Yeah -- I tend to favor traits by default, unless I want constructor parameters or have some other reason to specifically want a class.
Fabio Labella
@SystemFw
abstract classes can have parameters, that's a big point (it will change though). They are also better for bincompat in 2.11, if you're writing a library
Rob Norris
@tpolecat
Once trait parameters exist get ready for "why do we even have classes?"
Elikar Ibn Mtsouko
@mtsouko_twitter
What were the design reasons behind not giving traits parameters in the first place?
Rob Norris
@tpolecat
Same reasoning as class/interface in Java I imagine.
nafg
@nafg
@klassegeljakt if the reason is JVM startup time, you may want to look into scala-native or Graal VM
Klas Segeljakt
@segeljakt
Ok I'll take a look
If you know any more libs please let me know 🙏
Rob Norris
@tpolecat
I guess I should own up to writing a cursed DSL. Take it as a warning https://github.com/tpolecat/basic-dsl
Miguel Pérez Pasalodos
@mpasa
That is just great :smile:
Hanns Holger Rutz
@Sciss

Is there a way to constrain a Double to "just smaller than 1.0" such that (aDouble * aPositiveInt).toInt < aPositiveInt is guaranteed to hold? I.e. I don't want to perform that check after each multiplication. Like I can empircally get a very long literal:

assert (0.999999999999999944488848768742172978818416595 < 1)

assert ((0.999999999999999944488848768742172978818416595 * Int.MaxValue).toInt < Int.MaxValue)

But I wasn't patient enough to keep looking for the digits (seems there are more)

(Plus I'm afraid this might rely on the particular JVM, OS, or something)
Hanns Holger Rutz
@Sciss
This looks better: java.lang.Double.longBitsToDouble(0x3fefffffffffffffL) - comments?
Otto Chrons
@ochrons
yea, use longBitsToDouble, that's what I would use :)
Martijn Hoekstra
@martijnhoekstra
I think what you're asking is equivalent to the largest double smaller than 1.0. That's java.lang.Math.nextAfter(1.0, -1.0)
Otto Chrons
@ochrons
funny enough, I had exactly the same concern in my scheduling algorithm yesterday as it takes in 0.0 <= x < 1.0
and I needed to scale that to 0..N-1 where N is the number of input elements