← Back to context

Comment by jokoon

15 hours ago

I started making a language, and I took many shortcuts.

I just parse my language, translate it to C, and use C compiler errors.

I don't add new semantics, I just add many things like strings, map, etc to make it usable and fast.

I don't know if it's a good idea and how difficult this will be.

You're in good company. The original C++ compiler translated to C. Haskell translates to C--.

That sounds like a good approach, concentrate on the things you want to do/learn and let the C compiler pick up the rest. You can then be finished, add to your front end, or start replacing the backend.

My language compiles to Javascript. I wanted to concentrate on the frontend tasks like type checking and elaboration, and I wanted a web playground (the language is now self-hosted). Javascript got me a runtime with closures and garbage collection for free.

Chicken Scheme compiles to C, using a method that ended up as a maths paper (Cheney on the MTA).

Its a valid approach.

  • One day I aspire to be able to fully comprehend Cheney on the MTA. I kinda get it? But I've never learned C, and never had to slog through manual memory management, so it's a little lost on me

"I don't know if it's a good idea and how difficult this will be."

It is a great idea, if you want to learn about languages!

(But if money is your goal, you may want to reconsider)

I am also doing this. Like you i guess I want a nicer C. I produce my own errors though because it's better for the user.

Nothing wrong with that - some others do it too. You can even use TCC to do quick test builds and only use Clang/GCC for release builds.