Hacker Newsnew | past | comments | ask | show | jobs | submit | frogfish's commentslogin

Genuinely curious and willing to learn: what are the different inference approaches broadly? Is there any difference in the approach between Cerebras and simplismart.ai which claims to be the fastest?


Genuinely curious about the last sentence and would like to learn more on the Gentoo approach. Could you please provide a link or a little more details?


By "the Gentoo approach", I think pjmlp is referring to the fact that Cargo crates are usually compiled from source for each project, rather than simply distributing binaries. See [the Wikipedia article for Gentoo](https://en.wikipedia.org/wiki/Gentoo_Linux):

> Unlike a binary software distribution, the source code is compiled locally according to the user's preferences and is often optimized for the specific type of computer.


What I instantly liked is, how literally it starts from scratch and builds a couple of lines at a time.

Can anybody refer to a similar step by step guide to building a compiler?


Niklaus Wirth's "Compiler Construction", which teaches how to build an Oberon subset compiler.

https://inf.ethz.ch/personal/wirth/

Afterwards you can follow up with building an workstation OS on a systems programming language with GC, all the way from the boot sector loading code to the graphical UI, by reading and implementing "Project Oberon".

The 2013 edition uses an FPGA instead of the original Ceres hardware.

A̶n̶d̶ ̶s̶i̶n̶c̶e̶ ̶W̶i̶r̶t̶h̶ ̶d̶o̶e̶s̶ ̶n̶o̶t̶ ̶f̶e̶e̶l̶ ̶i̶t̶ ̶i̶s̶ ̶t̶i̶m̶e̶ ̶t̶o̶ ̶a̶c̶t̶u̶a̶l̶l̶y̶ ̶r̶e̶t̶i̶r̶e̶,̶ ̶h̶e̶ ̶h̶a̶s̶ ̶u̶p̶d̶a̶t̶e̶d̶ ̶t̶h̶e̶ ̶b̶a̶c̶k̶e̶n̶d̶ ̶t̶o̶ ̶t̶a̶r̶g̶e̶t̶ ̶R̶I̶S̶C̶ ̶V̶ ̶a̶s̶ ̶w̶e̶l̶l̶.̶


> And since Wirth does not feel it is time to actually retire, he has updated the backend to target RISC V as well.

Are you confusing RISC-V with RISC5 [1]?

[1] https://en.wikipedia.org/wiki/RISC5


Apparently yes, thanks for the correction.


http://www.penguin.cz/~radek/book/lets_build_a_compiler.pdf PDF form of "let's build a compiler" as mentioned by others (Haven't read it fully myself but I hear it's a very good introduction)

I haven't got a copy, but as far as I know Andrew Appel's book is structured in that manner, i.e. basic steps first then more advanced topics like garbage collection later.

"Engineering a compiler" is not step by step but very readable and contained if you want to skip the discussion of (say) various scanner implementations.

There is a decent sized gap between any real compiler and a related toy or book implementation (In general), so take a look at a compiler for a language you know (that isn't C++).

http://www.drdobbs.com/architecture-and-design/so-you-want-t... Walter Bright (of Digital Mars C++ and D fame) wrote an article about language implementation e.g. how to write a good compiler rather than a toy one.


It's not finished yet, but you probably want https://craftinginterpreters.com/

I loved his "Game Programming Patterns" book, and this new book is looking totes spiffy


>> step by step guide to building a compiler?

I haven't found any better resource than nand2tetris, see Projects 6 to 12 where you start with an assembler and end up with a compiler [1]. There is the accompanying books [2] and coursera courses [3]. Hope this helps, best!

[1] https://www.nand2tetris.org/course

[2] https://www.nand2tetris.org/book

[3]https://www.coursera.org/courses?query=from%20nand%20to%20te...

[4]


There are several super long (8+ hr) live coding videos of building an assembler and compiler for CP/M here: http://cowlark.com/2019-07-15-cowgol-prototype/index.html

I haven't had the stamina to go through one but have watched some sizable chunks and it's pretty cool, even with me not really knowing much about low-level stuff like that.

There's also a session where he live codes a vi-like text editor here: http://cowlark.com/2019-06-28-cpm-vi/index.html


Thanks a lot for sharing this video! This is absolutely the kind of thing that I hope to find on HN. Plan to spend all of tomorrow on this.


Another notable video series, Handmade Hero: https://www.youtube.com/user/handmadeheroarchive


I enjoyed Kyle James' "The Super Tiny Compiler."

https://github.com/jamiebuilds/the-super-tiny-compiler


Shameless self-plug, but I specificities wrote interpreterbook.com and compilerbook.com because I’m also a huge fan of start from scratch and build it line-by-line tutorials and couldn’t find such a thing for interpreters/compilers that wasn’t about a toy language. You might like it too.



I've been considering making a video tutorial on how to make a compiler from scratch. I'll try to keep it very concise yet include the very basics for anyone who isn't a computer scientist. (I am one by education).

Would you be willing to pay for it (how much)? And what would be a good platform for this?

I'm doing this to pay bills while I work on something of my own. I will use C myself (might include a couple of 'parallel' videos for Rust too wherever applicable) but the way I explain, one would be able to use any programming language.

The contents would roughtly go like this-

1) Explaining the 'theory of computation', theoretical and not really necessary for learning how to build compilers but I love this topic and it does give you formal insight in the 'power' of computers and if you're going to build non-toy compilers, may help you write more efficient algorithms.

2) Tokenization and parsing.

3) Type system

4) Symbol table

5) Assembly

6) Brief introduction to some basic optimization techniques.

I want to hear if people here have ideas on how to go about doing this. Is there a good platform for interactive online coding+slides class?


"written in C" is not compatible with "basics for anyone who isn't a computer scientist", IMO. It just gets you so bogged down with low level details which is not necessary for an introductory course.

I still haven't found a better introductory text than Appel's "Modern Compiler Implementation in ML". I also like pairing this with "Language Implementation Patterns", which uses ANTLR.


Video makes it easy to ramble about design-choices, etc. But I'd rather read content. Seeing snippets of text on-screen, at my own pace, is much better than seeing shots of a monitor or slides. Much like this story.

That said there are a couple of great books out there already, interpreterbook.com, compilerbook.com, and craftinginterpreters.com - all recommended. If you're doin g this for money you'll struggle, unless you have a lot of clarity / something new to offer.


Game scripting mastery, pretty much line by line, and you have the source code for each chapter.


Eugene Wallingford at the University of Northern Iowa recommends "My First Fifteen Compilers"

http://composition.al/blog/2017/07/31/my-first-fifteen-compi...

I haven't tried it yet, but it's on my list of "someday" projects


There is an old one on compilers called "Let's build a compiler by Jack Crenshaw" Its in Pascal but I think there are modern rewrites of it (like C on an x86)


Here it is, https://compilers.iecc.com/crenshaw/

As for modern, one can follow along using Free Pascal.


Compilers have a lot of relatively independent pieces, unlike a text editor. Better luck at looking at those pieces instead (Lexing, parsing, type checking, etc...)


For your information, even a simple a text editor (like much of user-facing software) too is comprised of several logically independent pieces, in the spirit of the model-view-controller paradigm.


It depends on how you implement it. I tend to implement mine as part of a compiler/run time, so it’s just another stage for me.

But my point was that any of those editor parts aren’t really identifiable as it’s own thing outside of editing.


Same request but for ACID compliant database engine :)


Previous discussions: with [1] 67 comments, [2] 23 comments.

[1] https://news.ycombinator.com/item?id=4367933 [2] https://news.ycombinator.com/item?id=10865568


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

Search: