Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yep. Building a working C compiler that compiles Linux is an impossible task for all but the top 1% of developers. And the ones that could do it have better things to do, plus they’d want a lot more than 20K for the trouble.




What's so hard about it? Compiler construction is well researched topic and taught in the universities. I made toy language compiler as a student. May be I'm underestimating this task, but I think that I can build some simple C compiler which will output trivial assembly. Given my salary of $2500, that would probably take me around a year, so that's pretty close LoL.

You can one shot prompt a toy C compiler. Getting one that can compile Linux in a bootable way is significantly harder.

Everybody talks as Linux is the most difficult thing to compile in the world. The reality is that linux is well written and designed with portability with crappy compilers in mind from the beginning.

Also, the booting part, as stated some times, is discutable.


The reality is you can build Linux with gcc and clang. And that’s it. Years ago you could use Intel’s icc compiler, but that stopped being supported. Let’s stop pretending it’s an undergrad project.

Just writing a non-toy C preprocessor is non-trivial.

It's a bit more nuanced. You can build a simple compiler without too many issues. But once you want it to do optimisations, flow control protection, good and fast register allocation, inling, autovectoriasation, etc. that's going to take a multiples of the original time.

Some of the hardest parts of the compiler are optimization and clear error handling/reporting. If you forego those - because you're testing against a codebase that is already free of things that break compilation and have no particular performance requirements for the generated code - it's a substantially simpler task.

Making a basic C compiler, without much error/warn detection and/or optimizations, is as a matter if fact no so difficult. In many Universities is a semester project for 2 to 3 students.

> Building a working C compiler ... is an impossible task

I think you might be thinking of C++


I’m not. I’ve been working with C on and off for 30 years. Linux requires GNU extensions beyond standard C. Once you get the basics done, there’s still a lot more work to do. Compiling a trivial program might work. But you’ll hit an edge case or 50 in the millions of lines in Linux.

I also should’ve qualified my message with “in 2 weeks”, or even “in 2 months.” Given more time it’s obviously possible for more people.


Interesting, why impossible? We studied compiler construction at uni. I might have to dig out a few books, but I’m confident I could write one. I can’t imagine anyone on my course of 120 nerds being unable to do this.

You are underestimating the complexity of the task so do other people on the thread. It's not trivial to implement a working C compiler very much so to implement the one that proves its worth by successfully compiling one of the largest open-source code repositories ever, which btw is not even a plain ISO C dialect.

They did bot compile the whole linux, mind you, just an absolute minimal kernel.

Doing a real compiler to be used by humans is difficult. Doing a compiler that “gets the thing done” is a different thing.


Nowhere did I imply it is production-ready. I said "working compiler" and by definition Claude built one since they booted up the kernel.

I didn’t say it was trivial. Just that I thought my course mates would be able to do it.

You thought your course mates would be able to write a C compiler that builds the Linux?

Huh. Interesting. Like the other guy pointed out, compiler classes often get students to write toy C compilers. I think a lot of students don't understand the meaning of the word "toy". I think this thread is FULL of people like that.


I took a compilers course 30 years ago. I have near zero confidence anyone (including myself) could do it. The final project was some sort of toy language for programming robots with an API we were given. Lots of yacc, bison, etc.

Lots of segfaults, too.


If it helps, I did a PhD in computer science and went to plenty of seminars on languages, fuzz testing compilers, reviewed for conferences like PLDI. I’m not an expert but I think I know enough to say - this is conceptually within reach if a PITA.

Hey! I built a Lego technic car once 20 years ago. I am fully confident that I can build an actual road worthy electric vehicle. It's just a couple of edge cases and a bit bigger right? /s

That's really helpful, actually, as you may be able to give me some other ideas for projects.

So, things you don't think I or my coursemates could do include writing a C compiler that builds a Linux kernel.

What else do you think we couldn't do? I ask because there are various projects I'll probably get to at some point.

Things on that list include (a) writing an OS microkernel and some of the other components of an OS. Don't know how far I'll take it, but certainly a working microkernel for one machine, if I have time I'll build most of the stack up to a window manager. (b) implementing an LLM training and inference stack. I don't know how close to the metal I'd go, I've done some low level CUDA a long time ago when it was very new and low-level, depends on time. I'll probably start the LLM stuff pretty soon as I'm keen to learn.

Are these also impossible? What other things would you add to the impossible list?


Building a microkernel based OS feels feasible because it’s actually quite open ended. An “OS” could be anything from single user DOS to a full blown Unix implementation, with plenty in between.

Amiga OS is basically a microkernel and that was built 40 years ago. There are also many other examples, like Minix. Do I think most people could build a full microkernel based mini Unix? No. But they could get “something” working that would qualify as an OS.

On the other hand, there are not many C compilers that build Linux. There are many implementations of C compilers, however. The goal of “build Linux” is much more specific.


Minix is a fair example, or Herd. Something like that.

So what other projects are impossible? That was my question.



I’ll be shocked if they are able to do it in 4 months, never mind 4 weeks.

Have you ever seen Tsoding youtube channel? I’m sure Mr Zosin can very much do it in one week. And considering russian salaries, it will be like an order of magnitude cheaper.



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

Search: