News for hackers. Stuff that matters.
Re:Chibicc – A Small C Compiler by rui314 on Sunday November 13, 2022 @06:49AM (#33582179)
Author here. I'm amused that I opened HN thinking that https://docs.google.com/document/d/1kiW9qmNlJ9oQZM6r5o4_N54s... (which I posted today) might come to the front page and found this post instead.

So the chibicc book is not available yet. I'm busy working on the other project (the mold linker) and don't have time to work on it. That being said, I believe the repo is still very valuable for those who want to learn how easy it is to implement a simple C compiler. chibicc's each commit was carefully written so that you can read one commit at a time. I'd recommend starting from the initial commit and observe how each feature (`if`, `for`, local variables, global variables, etc.) is implemented by following each commit.

Re:Chibicc – A Small C Compiler by samatman on Sunday November 13, 2022 @07:20AM (#33582392)
I'm charmed by projects like this, thanks for sharing.

What I want to see is a program like this, with very simple assembly/object code, and very fast compilation, and uses DynASM to build the executable in-memory.

Then use a tracing JIT to make it fast.

Having good, tiny, reference C compilers is a prerequisite for that, so I'm always happy to see work in that field.

Re:Chibicc – A Small C Compiler by samsquire on Sunday November 13, 2022 @08:31AM (#33582866)
I am interested in this too. I would do different tradeoffs. I am more interested in optional garbage collection, the parallelism and async story in the language such as threading and coroutines or both together.

I suspect combining garbage collection, exceptions, closures, tail call optimisation, parallelism, JIT compilation and coroutines is difficult to do orthogonally.

On eatonphil's discord someone recently shared this link: This is a framework for building high performance language runtimes

https://github.com/eclipse/omr

I am currently implementing a programming language and compiler and interpreter in my multiversion-concurrency-control repository.

https://github.com/samsquire/multiversion-concurrency-contro...

I am doing codegen that is interpreted by my imaginary interpreter. My assembly has primitives for thread safe multithreading.

Re:Chibicc – A Small C Compiler by foonathan on Sunday November 13, 2022 @12:45PM (#33585323)
I'm currently writing an interpreter for C, I plan on adding a JIT at some point as well: https://github.com/foonathan/clauf
Re:Chibicc – A Small C Compiler by Rochus on Sunday November 13, 2022 @06:55AM (#33582231)
> If they need to buy a license, that's fine, that's part of their usual business

Why not release mold linker under a dual license (open source and commercial) and sell them a commercial license?

Re:Chibicc – A Small C Compiler by rui314 on Sunday November 13, 2022 @06:58AM (#33582252)
It didn't work. If it is available as open-source, they don't _need_ a different license. Anyway, it's off-topic.
Re:Chibicc – A Small C Compiler by enriquto on Sunday November 13, 2022 @07:18AM (#33582380)
> It didn't work. If it is available as open-source, they don't _need_ a different license.

Don't they? I'm surprised to hear that. I have sold a few proprietary versions of my AGPL codes (which were identical to the original one, but with the license stripped). Not enough to make a living, but I can buy some fancy bikes with the money.

In some cases, they even paid --separately-- for support and a few features of the software that were of particular interest to them. For some reason, many companies are extremely frightened of the AGPL, but a dual AGPL/commercial licensing seems to fit them very well. This is a nice model for free software distribution, but it only suits small projects that do not get external contributors.

Re:Chibicc – A Small C Compiler by rui314 on Sunday November 13, 2022 @07:38AM (#33582501)
I could buy bikes too, but as you wrote that's not enough to make a living. This is my full time project. I could earn a mid 6 figure salary if I work for a big tech, and I think I'm creating a more valuable program than I did when I was working for a big tech, and in return I make money that counts in "fancy bicycle" unit... I think it's not wrong to say it didn't work quite well.
Re:Chibicc – A Small C Compiler by gavinray on Sunday November 13, 2022 @09:21AM (#33583316)
I might get shit on for saying this here, but I agree with you that it's very difficult to make a decent living on fully "free" software.

I've had orgs not bat at an eye paying a few thousand for a software license if there are justifiable productivity returns and the license is required for us to continue to use the software.

If that license is not required, we would never give you a dime. It's sad, but true. Those few thousand, to many companies, are pennies on the dollar. Just price it graciously so you don't leave the little guys out.

You'll get grumbles but do what you need to survive if you want to do this full time and for a living. God knows you, of all people, have earned it.

Re:Chibicc – A Small C Compiler by Rochus on Sunday November 13, 2022 @07:09AM (#33582326)
Did you have a look at Qt (https://www.qt.io/, https://www.qt.io/terms-conditions/) how they do it? They sell a lot of licenses e.g. to car industry.
Re:Chibicc – A Small C Compiler by ngcc_hk on Sunday November 13, 2022 @07:49PM (#33588997)
Pygt did it and gt did it. Just they like to buy into maintenance as some company need to do this.
Re:Chibicc – A Small C Compiler by svnpenn on Sunday November 13, 2022 @09:30AM (#33583390)
> Business Source License

I am using this one:

https://polyformproject.org/licenses/noncommercial/1.0.0

Re:Chibicc – A Small C Compiler by stefanos82 on Sunday November 13, 2022 @09:53AM (#33583569)
Rui, can you open a new Discussions thread at https://github.com/rui314/mold so we can transfer the whole conversation there?

We could ask for advice from other project developers that have succeeded on their own journey.

Re:Chibicc – A Small C Compiler by carapace on Sunday November 13, 2022 @11:10AM (#33584334)
I think I recall you saying that you elided the bugs, yeah? (Am I under-caffeinated this morning?) If so, you could write a second book about the bugs and issues you encountered while implementing chibicc and, uh, that would be awesome too! (I'd buy a copy.)

- - - -

Fantastic work, congrats and thank you!