

Ask HN: A C compiler in a microkernel in a 406 line js CPU emulator.  What next? - robertelder

I made up a 14 instruction CPU specification:  http:&#x2F;&#x2F;recc.robertelder.org&#x2F;op-cpu.txt
I wrote a C compiler for a very large subset (not all) of C89 for this CPU:  https:&#x2F;&#x2F;github.com&#x2F;RobertElderSoftware&#x2F;recc
I wrote emulators for the CPU in 4 different languages: https:&#x2F;&#x2F;github.com&#x2F;RobertElderSoftware&#x2F;recc&#x2F;tree&#x2F;master&#x2F;emulators
I wrote bare bones microkernel:  https:&#x2F;&#x2F;github.com&#x2F;RobertElderSoftware&#x2F;recc&#x2F;tree&#x2F;master&#x2F;kernel
I can cross-compile the preprocessor, lexer, parser and code generator and run them inside a kernel task, which runs inside the CPU emulators for javascript, python, java, and C (but it is currently super slow): http:&#x2F;&#x2F;recc.robertelder.org&#x2F;compile-demo&#x2F;<p>I&#x27;m looking for feedback on what direction to go in next.  What would you like to see most?<p>Directions I can go in:<p>-  Fully client side C compiler and IDE
   - Full access to parse tree, static analysis with rich html annotations for errors
      -  For example, if a function call has arguments that don&#x27;t match the prototype, show a detailed graphic demonstrating that the arguments don&#x27;t fit into the function 
-  Write a proper shell for the kernel 
-  CPU Emulators for more languages
-  Make the compiler produce faster code (it is currently anti-optimized for code simplicity)
-  Implement currently unsupported C features (float, double, union, goto, K&amp;R C style functions, ...)
-  Work toward having better static analysis (warnings) than GCC or CLANG (but only for C89)
-  Write blog posts (about what?)
-  Work toward compiling the Linux Kernel
-  Create learning tools to help visualize the OS and program stack as the program executes (In addition to showing stack values, provide type annotations via background colours&#x2F;graphics eg. (0x10000 &lt;= unsigned int))
-  Static analysis for MISRA C 
-  A web based visual tool&#x2F;animation that shows you every step of how the C preprocessor works
-  Other ideas<p>Project Home: http:&#x2F;&#x2F;recc.robertelder.org&#x2F;
======
altruizine
Wow! Quite an achievement over a wide range of CS fields. :-)

The direction to go from here really depends on what you want to achieve for
yourself.

Do you want to maximize the breadth of your knowledge? Then how about an RTL
implementation of a CPU that implements your spec? Going for static analysis
or developing an IDE would also have that benefit.

Do you want your tools to be useful beyond being a toy / learning experience?
Then I would go for feature completeness in the C compiler. Also, a debugger
would be needed.

I quite like the minimalism of your approach. How about a single-page spec for
a CPU with an MMU? :-)

(Then you could actually tackle a real Linux port instead of being limited to
uClinux. But I'd refrain from trying to port any Linux kernel right now
because you'd have to extend your compiler and tool chain quite a bit; Linux
is written in GCC, not C.)

How about running your compiler as a JIT compiler?

