<d_bot>
<salt rock lamp> Can someone help me understand the relationship between OCaml, Reason, Bucklescript, and Rescript? I tried reading through https://rescript-lang.org/blog/bucklescript-is-rebranding but it doesn't provide a clear picture for an outsider. Apologies if this is considered off-topic for this server
<companion_cube>
soooooo
<d_bot>
<carmysilna> As far as I understand: OCaml is an older programming language that compiles to bytecode and native. js_of_ocaml is an alternative backend to OCaml that produces javascript from OCaml instead of bytecode or native. Bucklescript is an OCaml fork for Javascript programmers to use the existing OCaml typed frontend and a new backend to produce javascript, similar to js_of_ocaml. Reason is a newer frontend/syntax over both Bucklesc
<companion_cube>
reason is a alternative syntax for OCaml
<companion_cube>
which compiles to native and JS (via js_of_ocaml)
<companion_cube>
bucklescript is ocaml->js in a different way
<companion_cube>
and rescript is… its own thing, now (deriving from reason+BS)
<d_bot>
<salt rock lamp> So reason is/was "just" alternative syntax for bucklescript?
<d_bot>
<salt rock lamp> And rescript is... a fork/remix of parts of reason and bucklescript that only targets js?
<d_bot>
<salt rock lamp> Man this is so confusing
<companion_cube>
yes
<companion_cube>
alas
kevinsjoberg has quit [Ping timeout: 256 seconds]
<d_bot>
<salt rock lamp> But reason is still active right? It's going to remain supported and has its own devs?
kevinsjoberg has joined #ocaml
<companion_cube>
I'm not sure
elf_fortrez has quit [Ping timeout: 246 seconds]
<d_bot>
<salt rock lamp> Hm
<d_bot>
<salt rock lamp> Reason's site is confusing too
<d_bot>
<salt rock lamp> It looks like they don't use buckescript anymore
<d_bot>
<RegularSpatula> Bucklescript is no more afaik. It’s ReScript now
<d_bot>
<RegularSpatula> ReScript is another new syntax. Looks like reason but supposed to be more readable for JS deva
<d_bot>
<salt rock lamp> So Bucklescript made its own frontend and renamed itself to Rescript?
<companion_cube>
yeah
<companion_cube>
the BS people decided to make their own syntax/frontend, instead of using reason
<companion_cube>
and to move further away from OCaml
<d_bot>
<salt rock lamp> Where does that leave Reason? As a JS-like frontend to Ocaml without a JS backend? Does Reason no longer interoperate with JS?
<d_bot>
<RegularSpatula> Essentially yeah. Bucklescript (BS) was a compiler. Worked with Ocaml and reason. Now there is also a syntax so go along with BS and the two are sorta one now: ReScript
<d_bot>
<RegularSpatula> I read that reason will be focusing more on native (not sure never used reason, but have used BS and ReScript). BS core devs and Reason core devs are not the same ones
<d_bot>
<RegularSpatula> to make things more confusing, ReScript compiler can *also* compile OCaml syntax. But only if you use simpler stuff, an older compiler version (like 4.08 or 4.07 iirc) and not much ppx
<d_bot>
<salt rock lamp> Gah
<companion_cube>
I think in 2021 there's only 2 things, in practice
<companion_cube>
OCaml, compiling to native or JS (via js_of_ocaml)
<companion_cube>
and ReScript, which targets JS in a different way, and is much more targeted as JS devs
<d_bot>
<RegularSpatula> that's also what i gather from spending much time on the ReScript discuss
<d_bot>
<salt rock lamp> And Reason just transpiles to Ocaml? That's what the 2016 forum post suggests but apparently a lot has changed
<d_bot>
<salt rock lamp> I watched one talk which suggested that Rescript is more like a standalone language that reuses Ocaml's semantics and type system
<d_bot>
<Skid> What about F# :Sadge:
<d_bot>
<salt rock lamp> Stuck in .Net purgatory
<d_bot>
<Skid> True
<d_bot>
<RegularSpatula> That is true...ReScript should be considered its own language now, according to the core devs
<d_bot>
<salt rock lamp> Ngl that is quite a value prop
<d_bot>
<salt rock lamp> Looks not-scary to JS devs, uses the "good parts" of OCaml
<d_bot>
<RegularSpatula> I have to say...ReScript is awesome
<d_bot>
<salt rock lamp> The Rescript announcement post suggested that supporting both backends was cumbersome and impeding development
<d_bot>
<RegularSpatula> the compilation is like lightening fast...and you get JS that is like nice basic stuff you can read (like really actually read)
<d_bot>
<salt rock lamp> And it feels Ocaml-ish to use?
<d_bot>
<RegularSpatula> Well, ocaml-ish yeah. It depends how much of the "advanced" ocaml stuff you use on the regular
<d_bot>
<salt rock lamp> I thought part of the appeal of Reason was the ability to write browser and server code in the same language; same data types etc
<d_bot>
<salt rock lamp> Like with Kotlin and the various other languages that compile to JS
<d_bot>
<RegularSpatula> you can actually still do that to an extent with rescript
<d_bot>
<salt rock lamp> By running on Node in the backend? Or something else
<d_bot>
<RegularSpatula> that's the easiest way yeah...i can't remember where off the top of my head but I think I saw some more about it (using native on backend, plus rescript on front)
<d_bot>
<RegularSpatula> It's pretty straightforward to wrap Node though for backend stuff
<d_bot>
<RegularSpatula> Actually, there are 3 fullstack examples here...JSOO, ReScript, and Melange
<companion_cube>
ahhh forgot that
<companion_cube>
Melange is, well, a fork of bucklescript that plays nice with OCaml
<companion_cube>
sort of going the other direction than ReScript
<companion_cube>
(so, basically, it's an alternative to js_of_ocaml for OCaml->JS compilation)
<d_bot>
<RegularSpatula> that's how i understand it as well
<d_bot>
<RegularSpatula> salt rock lamp: are you a JS dev or "native"-ish dev that dabbles in JS?
<d_bot>
<salt rock lamp> Interesting... ty for all this
<d_bot>
<salt rock lamp> I'm a python dev actually, and a data scientist by training and trade for several years
<d_bot>
<salt rock lamp> I know enough JS to be productive in a Node codebase and have dabbled in... a lot
<d_bot>
<RegularSpatula> the only reason i ask is that I sort of remember someone saying if you're a JS dev, just use ReScript and be done with it...if you're already an ocaml dev, just use JSOO and be done with it (haha)
<d_bot>
<salt rock lamp> Hah, noted
<d_bot>
<salt rock lamp> I tend to go for the weird and interesting
<d_bot>
<salt rock lamp> I feel more comfortable in common lisp and idris 2 than in java
<d_bot>
<salt rock lamp> And i know more crystal than ruby
<d_bot>
<salt rock lamp> Work code is boring, I don't want to write boring code for my hobby stuff 😛
<d_bot>
<RegularSpatula> In that case...just compile Idris to JS and be done with it! lolol
<d_bot>
<salt rock lamp> Yes! I have been meaning to try it
<d_bot>
<salt rock lamp> I also really really don't like web dev
<d_bot>
<salt rock lamp> * frontend web dev
<d_bot>
<RegularSpatula> if part of your webdev dislike is due to the JS ecosystem, then definitely you won't like rescript. it leverages that whole ecosytem. Makes it very easy to wrap JS libs and uses all the build tools JS devs would use
<d_bot>
<salt rock lamp> Heh no, i dislike all the fiddling with css and browser apis
waleee has quit [Ping timeout: 250 seconds]
<d_bot>
<salt rock lamp> It's 2021 and I still can't center a div or make an accessible sidebar or footnotes
<d_bot>
<RegularSpatula> Pretty sure centering a div is like a meme at this point lol
<d_bot>
<salt rock lamp> That was the joke but yes
<d_bot>
<salt rock lamp> It will be a meme until it isn't
<d_bot>
<RegularSpatula> just never center anything...problem solved
<d_bot>
<samwell> TIL about Idris 2. Pretty cool stuff
<d_bot>
<salt rock lamp> Has anyone made a lisp that compiles to OCaml? Or with PPX is it kind of unnecessary?
wilfred has joined #ocaml
<d_bot>
<EduardoRFS> @salt rock lamp well it's just a parser, but why would you want it?
gravicappa has joined #ocaml
<d_bot>
<salt rock lamp> i like macros/homoiconicity and the uniform syntax
<d_bot>
<salt rock lamp> but i don't know enough about ppx to know if it's equivalent
favonia has quit [Ping timeout: 250 seconds]
<d_bot>
<EduardoRFS> macros can be done, but homiconicity will be really hard
<d_bot>
<EduardoRFS> I did macros recently but still thinking through a way to encode data
<d_bot>
<EduardoRFS> it works across module boundary, it's just annoying because it's abusing of a bunch of things in the OCaml ecossystem
<d_bot>
<salt rock lamp> i think a lot of lisps-that-compile-to-X use the host language's list type (or some equivalent sequence type), and some kind of opaque data structure to represent symbols
<d_bot>
<salt rock lamp> i admittedly don't know what this does
<d_bot>
<EduardoRFS> it's a macro, it expands to the code defined on the right
<d_bot>
<salt rock lamp> neat
<d_bot>
<salt rock lamp> i see how this would get you pretty far
<d_bot>
<salt rock lamp> it looks like you can't really build literal source code to be eval'ed, but you can do a lot with a system like this
<d_bot>
<EduardoRFS> like, assuming your macro had a valid AST yes you can, it's literally expanded
<d_bot>
<EduardoRFS> it's not a C like macro, so to do things like concating identifiers is a little bit annoying
<d_bot>
<salt rock lamp> does ocaml have some "ast object" that you can operate on?
<d_bot>
<EduardoRFS> what do you mean by "ast object"? Like, do you have access to the AST to operate on? In this implementation not yet, I want to have it tho. https://astexplorer.net/
<d_bot>
<EduardoRFS> was thinking on something like
<d_bot>
<salt rock lamp> yeah that is what i was wondering
<d_bot>
<salt rock lamp> so even if you can't operate on lists, you can still have a first-class language construct to operate on for generating code with the "full power" of the language
<d_bot>
<EduardoRFS> would you be willing to make your build time roughly 2x worse on development?
<d_bot>
<EduardoRFS> that's currently the tradeoff of typed ppx
xd1le has joined #ocaml
<d_bot>
<salt rock lamp> that's pretty good considering a lot of people say statically typed macros aren't feasible at all
zebrag has quit [Remote host closed the connection]
bartholin has joined #ocaml
<d_bot>
<EduardoRFS> they're not typed, I just expand the code
gravicappa has quit [Ping timeout: 240 seconds]
bartholin has quit [Quit: Leaving]
wilfred has quit [Quit: Connection closed for inactivity]
<d_bot>
<octachron> The feature is mostly for debugging purpose (it helps naming existential types). Why are you commuting the two decoders?
<d_bot>
<bikal> so that if I do `/: int /: string` then I want `int` first then `string` second.
<d_bot>
<bikal> in the resulting `('a, 'b) uri`.
<d_bot>
<bikal> Mostly I want to achieve a combinator approach to doing below:
<d_bot>
<bikal> ```
<d_bot>
<bikal> utop # let u = Decode(int_d, Decode(string_d, End));;
<d_bot>
<bikal> val u : (int -> string -> 'a, 'a) uri = Decode (<abstr>, Decode (<abstr>, End))
<d_bot>
<bikal> ```
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
<d_bot>
<bikal> with the `/:` operator
<d_bot>
<octachron> This doesn't match the type that you have written.
<d_bot>
<bikal> the `decode` function?
<d_bot>
<bikal> `let decode : type a b c. (b, c) uri -> a decoder -> (a -> b, c) uri`
mro has quit [Quit: Leaving...]
<d_bot>
<octachron> Yes, the type of the `decode` function is adding the last decoder to the front
<d_bot>
<bikal> indeed, which is what I want to achieve
<d_bot>
<octachron> No, you are saying that you want the reverse
<d_bot>
<bikal> Basically these two should be equivalent: `Decode(int_d, Decode(string_d, End))`
<d_bot>
<bikal> and `let ( /: ) = decode`
<d_bot>
<bikal> and `End /: int /: string`
<d_bot>
<bikal> if I do `let decode uri d = Decode(d, uri)` then the ordering is not maintained, i.e. with the latter definition of decode, ` End /: int /: string` ends up being equivalent to `Decode(string_d, Decode(int_d, End)`
<d_bot>
<octachron> First, your example probably should contain three case, because your implementation is wrong even in the untyped setting.
<d_bot>
<octachron> Second, this is quite inefficient, because `((End /: a) /: b) /: c` end up being quadratic because you need to reverse the application order.
<d_bot>
<octachron> It might be simpler to just have something akin to `End @@@ a /: b /: c`
<d_bot>
<bikal> hmm .. okay let me give that a try
<d_bot>
<bikal> thanks
xd1le has quit [Quit: xd1le]
Anarchos has joined #ocaml
nfc_ has quit [Ping timeout: 252 seconds]
nfc_ has joined #ocaml
gravicappa has joined #ocaml
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]