Hacker News new | past | comments | ask | show | jobs | submit login
Stgi: A visual STG implementation to understand GHC/Haskell's execution model (github.com/quchen)
84 points by kelseyfrog on Oct 8, 2021 | hide | past | favorite | 5 comments



Spinless Tagless G-Machine is my DJ name and I'm miffed that SPJ and his Glasgow thugs stole it for their intermediate language/abstract machine that Haskell eventually compiles down to.

But really, that's not a TLA that most people know, and a little explanation upfront is useful to the unenlightened.


I was also expecting at least a one sentence explanation to what STG is. A link to https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compil... could help.

Also, I think it is spineless, not spinless


is there something like this for node? sorry if this is an obvious q; i'm relatively new


Super offtopic question, but I'll give you two answers: The literal one, and the one I know you're asking for.

1. The literal answer is yes. Node uses V8 as the execution engine. V8 uses something called "TurboFan" as one of the compiler + IR passes:

  https://v8.dev/docs/turbofan
  https://v8.dev/blog/turbofan-jit
There's a tool that displays input JS code, and then visualizes the TurboFan IR node output. It's called Turbolizer. That would likely be the closest equivalent:

  https://github.com/v8/v8/tree/main/tools/turbolizer
2. The answer you want is you can just use a regular Node.js debugger and attach it to whatever it is you want to look at. The scope context will show all of this info.

For things like "unused variables", etc, the TypeScript-for-JavaScript integration that I think is turned on by default in VS Code should catch this. So should Webstorm.

So should any linting tool, like ESLint.

At least I think this is what you're asking. Hope that helps.


Just the README alone is a great read if you want to know how Haskell's lazy evaluation works in detail on the actual machine.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: