Jeena
link
fedilink
English
191Y

At university the by far coolest and most fun course was compiler construction. We had to write something which would compile a small subset of Java (Javalette) into the Java Virtual Machine instruction set.

I wrote my compiler in Haskell because it seemed that it’d be much less hassle compared to do it in a object oriented or procedual language.

It ain’t pretty but it’s honest work: https://github.com/jeena/CC/blob/master/Compiler.hs

I wrote my compiler in Haskell because it seemed that it’d be much less hassle compared to do it in a object oriented or procedual language.

That is not a feeling I’d associate with Haskell!!

Jeena
link
fedilink
English
51Y

But it definitely was, oh and when you compared the results, I don’t remember the exact number anymore but compared to especially the solutions in Java and C++ the haskell ones used around 1/10 of the lines of code to solve this particular problem. Because in the end this problem really has a recursive nature.

I have an idea for a Rust-like language with total functional methods bouncing around in my head. Lord knows when I’ll get around to building it.

@pewpew@feddit.it
link
fedilink
English
121Y

The programmer who made the OS

@nychtelios@rlyeh.icu
link
fedilink
English
171Y

Actually compilers are more complex than operative systems, and incredibly they are built using compilers.

@cdnalsi@lemmy.world
link
fedilink
English
41Y

Compilers are built using compilers?

@nychtelios@rlyeh.icu
link
fedilink
English
21Y

gcc and clang are open source, you can read their source code whenever you want!

@phorq@lemmy.ml
link
fedilink
English
101Y

Yup, C is written in C. You bootstrap using a compiler written in another language until your language is complete enough to write its own compiler.

Alright, that’s kinda crazy lol.

@pewpew@feddit.it
link
fedilink
English
31Y

I belive you. I made a basic OS in around a month and now i’m starting a C compiler, I think I underestimated it a bit

@joyjoy@lemmy.world
link
fedilink
English
61Y

When you write a compiler, you eventually have to write it twice. Once in a pre-existing language, then again in the language it compiles.

Just say no to bootstrapping.

@Lemminary@lemmy.ml
link
fedilink
English
1
edit-2
1Y

Just say no to bootstrapping

*Boostrap 5 sad noises*

print(“Hello World!”)

Create a post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 1 user online
  • 120 users / day
  • 257 users / week
  • 744 users / month
  • 3.72K users / 6 months
  • 1 subscriber
  • 1.48K Posts
  • 32.7K Comments
  • Modlog