5 ms·
Honestly, from the title, I expected something that gave actual 'insights' into the compiler, rather than the code. For example, indicating applied and potentia
by ColonelPhantom 2y ago
Honestly, from the title, I expected something that gave actual 'insights' into the compiler, rather than the code. For example, indicating applied and potential (missed) optimizations. But seeing what it was, I was definitely not unpleasantly surprised :)
Being able to cut through abstraction is very nice and quite important when you want to understand WHAT you are writing from the machine's perspective (or even in general when you don't know the abstraction yet). I love using Haskell, but have no idea what kind of machine code GHC spits out at the end (something based on the spineless tagless G-machine, an abstraction I barely understand by itself).
- jaredwy 2y agocompiler explorer/clang can do this. https://clang.llvm.org/docs/UsersManual.html#options-to-emit-optimization-reports https://clang.llvm.org/docs/UsersManual.html#options-to-emit... Gcc also has similar options
- ColonelPhantom 2y agoOoh nice, I completely forgot that that existed. When you say the compiler explorer can do it, do you mean that it will 'inline' the output in a similar way to the assembly i.e. you can view the results 'within' the source code?
- linhns 2y agoI think Haskell creators never meant to have users care about those abstractions. It's more about what, not how, and given its terseness and power, I'd be happy to be a normal user.
- ReleaseCandidat 2y ago> I love using Haskell, but have no idea what kind of machine code GHC spits out at the end There is GHC's core, an indermediate representation of your code (mostly "just" desugared Haskell), which is comparable to Andreas' C++ Insights. Which you can get by passing `-ddump-simpl` with additional flags to disable displaying everything. A list of other internal GHC data to dump is https://downloads.haskell.org/~ghc/7.8.4/docs/html/users_guide/options-debugging.html https://downloads.haskell.org/~ghc/7.8.4/docs/html/users_gui... But getting an idea what assembly is finally generated is still hard (at least for mé). Or, to rephrase, to know if "everything" is finally unpacked and strict or not, and if not: why not. Btw. IMHO still the best book to read (of course not up-to-date, but to get the basic concepts of GHC) is https://www.microsoft.com/en-us/research/publication/the-implementation-of-functional-programming-languages-2/ https://www.microsoft.com/en-us/research/publication/the-imp... https://www.microsoft.com/en-us/research/uploads/prod/1987/01/slpj-book-1987-r90.pdf https://www.microsoft.com/en-us/research/uploads/prod/1987/0...
- pkkm 2y agoYeah, I like this, but the tool I wish existed the most is some kind of pointer aliasing checker. Something that would tell me when I've violated strict aliasing or, conversely, when I've forgotten to put in a restrict and now the compiler is reloading things from memory unnecessarily.