IRC channel logs

2022-02-10.log

back to list of logs

<unmatched-paren>i was wondering, if rekado_'s ghc bootstrapping doesn't work out, could we write a translator from haskell to ocaml, since they're so similar? i don't know much haskell, so i'm not sure if it has some feature that's impossible to add to ocaml (ocaml does have a `lazy` keyword, btw)
<unmatched-paren>it would be way easier than writing a whole new compiler, at least
<unmatched-paren>we might even be able to reuse the ghc runtime with ocaml's ffi, idk
***ChanServ sets mode: +o rekado_
<rekado_>unmatched-paren: it would be easier to write a translator from non-standard haskell to haskell 98
<rekado_>ML and Haskell are only superficially similar.
<rekado_>GHC Haskell is again rather different from Haskell 98
***iridium.libera.chat sets mode: +o oriansj
<fossy>is ghc haskell the modern standard? or are there other dialects of haskell still used
<rekado_>there are newer versions of the standard, but there really is only GH
<rekado_>GHC*
<fossy>i see
<rekado_>other compilers exist, but they are written in the GHC dialect
<rekado_>so they are no viable targets for bootstrapping
<fossy>that's rather annoying
<rekado_>but I think we can make some progress here with STGHugs
<rekado_>the non-standard Argv.lhs may not be needed at all. This escape hatch to embed plain C in Haskell files may not be needed, because we *can* translate this to standard Haskell.
<rekado_>just looking at ``prog_argv'' – there is a pure Haskell way to access argv, so we could use that, I guess
<rekado_>it has a different type – IO String instead of FASTSTRING, but I think that with some newtype declarations we could work around that
<muurkha>GHC has pretty much eclipsed everything else yeah
<muurkha>janus__: seen the discussion here over the last few days?
<janus__>no, i will read it in the new few hours :)
***janus__ is now known as janus
***Noisytoot_ is now known as Noisytoot
<oriansj>unmatched-paren: well to your exact question, yes that could be done. Even if rekado's work is a success, anyone who feels that would be a fun project could certainly do that. To the more likely alternative bootstrap paths: blynn's Haskell compiler is trivial to bootstrap and appears to be actively developed. So once it reaches a large enough subset, it could be used to build GHC directly. But ultimately the solution will be decided by
<oriansj>people who are hacking on it with the right idea.
<slycelote_>can ocaml be bootstrapped?
<civodul>yes, see https://github.com/Ekdohibs/camlboot/
<civodul>roptat worked on it
<slycelote_>nice
<unmatched-paren>oriansj: even after we've _technically_ bootstrapped all the things that matter, we're still relying on all these gross hacks
<unmatched-paren>so that kind of thing would allow us to remove said gross hacks
<unmatched-paren>which is good either way :)
<unmatched-paren>muurkha: yes, though i am currently working on bootstrapping pascal myself; i'm in the early stages, tho, so i'm not really talking about it here much yet
<unmatched-paren>sadly none of the currently available pascal compilers will be adequate
<unmatched-paren>i'm not particularly knowledgable about C land, so although it _might_ be possible to use gpc with really old gcc, even rekado_ couldn't do it, so i don't fancy my chances
<unmatched-paren>so i'm in the early stages of writing one (with ocaml and llvm)...
<unmatched-paren>pascal is popular in that hellscape known as the commercial software industry, not so much in the libre world; however, the <https://nim-lang.org> compiler was originally written in Object Pascal, and i like nim :)
<roptat>slycelote_, the main limitation right now is that it targets ocaml 4.07
<roptat>but that's what we use for it in Guix, the later OCaml versions are still not bootstrapped
<unmatched-paren>...oh
<unmatched-paren>aaargh
<unmatched-paren>i thought it was completely bootstrapped :(
<roptat>at least we used it to perform DDC on ocaml 4.07 ;)
<roptat>we'd have to find the bootstrap commits starting from ocaml 4.07 to the current version, otherwise the plan was to port camlboot to the more recent versions
<roptat>it shouldn't be missing too much, but we have to implement the missing features
<unmatched-paren>i guess i'll try to find those bootstrap commits, because my pascal compiler will otherwise be pretty useless...
<roptat>one reason why we targetted 4.07 is that starting from 4.08, the compiler needs to use menhir to generate its parser, and menhir is written in ocaml
<unmatched-paren>does menhir not compile with 4.07?
<roptat>it does
<roptat>but that's why we needed 4.07
<unmatched-paren>right
<janus>what's DDC?
<Hagfish>diverse double compiling
<roptat>diverse double compiling
<roptat> https://dwheeler.com/trusting-trust/
<Hagfish>(sorry, i couldn't resist. i knew you must have been going to get a reference)
<roptat>:)
<unmatched-paren>...i'm really going down a rabbit hole with nim
<unmatched-paren>first, i try to bootstrap nim, and discover that it needs pascal
<unmatched-paren>then, i find out that pascal isn't bootstrapped and try to build it with existing stuff
<unmatched-paren>then i begin to write my own in ocaml
<unmatched-paren>and i discover that ocaml isn't quite bootstrapped yet...
<unmatched-paren>urgh, i'll rewrite it in rUsT then, since that's the only other language that i'm comfortable with...
<unmatched-paren>at least i wasn't too far on :P
<unmatched-paren>i could do it in scheme, but dynamic typing is the worst
<unmatched-paren>waitaminute... https://github.com/tylerlaberge/rascal
<unmatched-paren>i could extend this
<roptat>sounds fun :)
<unmatched-paren>it's a working interpreter written in a language i'm very comfortable working in, so why not :)
<unmatched-paren>hm, do i add my name to the license copyright, since i'm forking it?
<roptat>yes, once you do modifications, you own copyright on those modifications
<stikonas>yes, that might work since rust is bootstrapped
<stikonas>and right now mrustc can build rustc-1.54, so it's not even that far behind the latest version
<unmatched-paren>obviously rust is not the best idea re writing bootstrap programs, but i am not a good c programmer
<muurkha>pascal is popular in the commercial software industry?
<unmatched-paren>yes, it's pretty popular there afaik
<unmatched-paren> https://en.wikipedia.org/wiki/Delphi_(software)
<muurkha>unmatched-paren: you could write it in OCaml 4.07 too
<unmatched-paren>no sane free source developer would use an expensive proprietary ide/compiler like Delphi, but it still exists and is being developed, so it must be selling somehow
<unmatched-paren>apparently there's quite a lot of developers who refuse to learn anything else so they just produce commercial pascal programs
<muurkha> https://stackoverflow.com/questions/tagged/javascript 2,335,033 questions
<muurkha> https://stackoverflow.com/questions/tagged/delphi 49,205 questions
<unmatched-paren>muurkha: true, but i've found an existing tiny rust pascal interpreter which can do basic stuff, so i'd be better off forking that
<unmatched-paren>obviously not as popular as javascript :) and it's certainly getting less popular.
<unmatched-paren>i kind of meant 'more popular' in the commercial software industry, not 'very popular', sorry for the bad wording
<muurkha> https://stackoverflow.com/questions/tagged/sql-server 314,785 questions
<muurkha>oh, I'd believe "more popular" for sure
<muurkha>and ⅙ the popularity of SQL Server isn't that bad
<muurkha> https://stackoverflow.com/questions/tagged/vb6 10,541 questions
<unmatched-paren>there's only two free source programs (that are not part of the freepascal project itself) that i know that use pascal: double commander (gui file manager) and the old nim compiler
<unmatched-paren>the former i don't care about, the latter i do
<muurkha>yeah, bootstrapping nim could be pretty important
<unmatched-paren>it's a neat language, and i want to look into it more, but i have a rule where i won't use a non-bootstrappable language
<unmatched-paren>which is why i can't use haskell :(
<muurkha>:(
<unmatched-paren>most important changes first: change that blasphemous `README.md` to a beautiful `readme.org` :)
<muurkha>hahaha
<stikonas>hmm, looks like rascal is quite limited subset of pascal
<stikonas>but hopefully you can extend it
<unmatched-paren>stikonas: well, it's better than starting from scratch :)
<unmatched-paren>i had to make some minor modifications to make it compile when cargo's edition was set to 2021, but apart from that it works fine
<unmatched-paren> <https://codeberg.org/unmatched-paren/rascal-boot> the journey begins :)
<stikonas>well, I just tried some sample programs from tutorials and it almost always complains
<stikonas>but yes, that's much better than nothing
<unmatched-paren>it seems like it can't handle `char`s yet, which is a pretty gaping hole
<stikonas>probably more things are missing...
<unmatched-paren>they have the same syntax as strings in pascal, which makes it quite hard to tell when the programmer means a string and when they mean a char
<unmatched-paren>sorry, laptop died
<unmatched-paren>i really need to set up a low battery warning for mako :)
<unmatched-paren>as i said, you can't tell whether 'a' is a string or a char with just a parser
<unmatched-paren>you need to do type analysis on the functions and procs you're passing it to
<unmatched-paren>which is probably why there's no char
<unmatched-paren>i wonder if it would be worthwhile to change the home-grown parser to something like <https://lib.rs/nom>