Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jul 19 20:37
    @SethTisue banned @tonyobanon
  • 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
Klas Segeljakt
@segeljakt
ownership + move = affine?
but then you also have copy
and borrow
Ichoran
@Ichoran
It's affine-like, but there's the whole single-mutable-borrow-or-arbitrary-immutable-borrow thing.
Affine means "may use it at most once".
OlegYch
@OlegYch
borrow checking is pretty central to rust and i'd guess whatever flavor of substructural typing it has just naturally flows from that
Ichoran
@Ichoran
Linear, strictly speaking, means "must use it exactly once"
Klas Segeljakt
@segeljakt
I have tried to understand the “Region inference” for determining lifetimes
but I don’t get it
or, I get the general concept
Ichoran
@Ichoran
You really shouldn't, unless you're working on implementing the lifetime system. Just like you shouldn't try to understand explicitly all the steps the Scala compiler uses to do type inference.
Having a practical knowledge of how to get the languages to do what you want, or close enough, is fine.
Klas Segeljakt
@segeljakt
I am working on a master thesis for embedding Rust as a DSL in Scala
Ichoran
@Ichoran
In each case, the implementation details encompass enough tricky subcases that just hoping that....ah...you...what?!
Fabio Labella
@SystemFw
:)
Klas Segeljakt
@segeljakt
but I skipped the ownership system entirely
Ichoran
@Ichoran
Oh man. Well, you have your work cut out for you. For starters, the basic syntax is irreconcilably incompatible.
Klas Segeljakt
@segeljakt
xD
Ichoran
@Ichoran
So you'll need to write a compiler plugin to even get off the ground.
Klas Segeljakt
@segeljakt
I wrote a DSL for building an AST with GADT encoding
Fabio Labella
@SystemFw
or macros, no?
I think it really depends on what you mean by dsl
Ichoran
@Ichoran
Rust's if p { bar(); } else { foo(); } just won't work in Scala.
Fabio Labella
@SystemFw
rust"""
  rust code
"""
could be an option
Ichoran
@Ichoran
You could build a Scala DSL to generate Rust MIR, I'm sure. Or a Rust DSL to generate Scala TASTY (from Dotty).
Klas Segeljakt
@segeljakt
I explored quasiquotes a bit but never tried it
these might be interesting
Klas Segeljakt
@segeljakt
ok
Fabio Labella
@SystemFw
they embed java in haskell with quasiquotes
Klas Segeljakt
@segeljakt
there is also IntelliJ language injection if you have heard about it
// language=Rust
val code = “”"
rust code
“”"
Ichoran
@Ichoran
I would think that would be waaaay more relevant for embedding Rust in Haskell?
Klas Segeljakt
@segeljakt
the language injection has some static checks, but only up until name-resolution it seems like
Fabio Labella
@SystemFw
@ichoran I mean, it's not like you are going to find a million blog posts that are related... you'll have to make do with that :P
Ichoran
@Ichoran
Honestly I'm rather puzzled by why this is an interesting thing to do. Rust as a DSL hardly makes sense, since aside from its superior ability to infer types, and its lifetime/ownership system, its syntactic capabilities are basically a subset of Scala's.
Usually you want DSLs because they can express something that the original language can't easily express.
Klas Segeljakt
@segeljakt
the DSL is only meant to generate Rust code
Ichoran
@Ichoran
Ah, okay.
I am not sure why you would want to generate Rust code from a Scala DSL (as opposed to from a Rust DSL, for instance), but at least it sounds possible :)
Having a Rust backend to the Scala compiler would be interesting. Weird, but interesting.
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