this post was submitted on 26 Jun 2023
180 points (96.9% liked)

Programmer Humor

32054 readers
1591 users here now

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

Rules:

founded 5 years ago
MODERATORS
 
top 14 comments
sorted by: hot top controversial new old
[–] [email protected] 19 points 1 year ago (2 children)

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

[–] [email protected] 4 points 1 year ago (1 children)

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!!

[–] [email protected] 6 points 1 year ago

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.

[–] [email protected] 3 points 1 year ago

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.

[–] [email protected] 12 points 1 year ago (1 children)

The programmer who made the OS

[–] [email protected] 18 points 1 year ago (2 children)

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

[–] [email protected] 4 points 1 year ago (2 children)

Compilers are built using compilers?

[–] [email protected] 12 points 1 year ago (1 children)

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.

[–] [email protected] 3 points 1 year ago

Alright, that's kinda crazy lol.

[–] [email protected] 2 points 1 year ago

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

[–] [email protected] 3 points 1 year ago

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

[–] [email protected] 6 points 1 year ago (1 children)

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.

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago)

Just say no to bootstrapping

*Boostrap 5 sad noises*

[–] [email protected] 1 points 1 year ago

print("Hello World!")

load more comments
view more: next ›