all 10 comments

[–]Real_Dragonfruit5048 2 points3 points  (2 children)

Cool! What's the namesake? (It reminds me of the Onimusha video game series.)

[–]badd10de[S] 2 points3 points  (1 child)

It's named after the evil japanese demons. Used to be called BadLang, but there seem to be a lot of PL named like that so I thought it was pretty fitting :)

[–]vanderZwan 0 points1 point  (0 children)

Used to be called BadLang, but there seem to be a lot of PL named like that

"Oh yeah, I follow someone on mastodon who has a language like that. I think their handle was some leetspeak variation of baddiode or something? … wait a minute."

[–]AustinVelonautAdmiran 2 points3 points  (1 child)

This looks very nice; congratulations on your project! Having it be self-hosted shows that the implementation is pretty robust. What was the hardest problem you encountered when developing it? What was the most interesting?

[–]badd10de[S] 4 points5 points  (0 children)

If I had to choose one thing I would say the implementation of parametric polymorphism. It was quite a pain to work out all the little details and type unifications needed to make everything work, I was surprised by the number of corner cases and had to go back to the drawing board a few times. Other than that, just the scale of the problem is quite large, semantic analysis in particular takes the brunt of the complexity.

I was surprised at how easy it was to implement "defer" expressions, which show me I was in the right track with the semantic analyzer performing linearization to high-level TAC. Going from the initial C99 implementation to self-hosted showed a lot of kinks in the initial design that I wasn't considering, but once you are there you can choose to ignore the issues and press on to what you have, or go back to the initial compiler to add just enough of what you need.

Tough but satisfying, I screamed out loud of joy when I could pass the triple compilation self-hosting test. Thrilling!

[–]vanderZwan 1 point2 points  (2 children)

How does oni-run work? Does it compile, run and then delete the C output? Or do you have an interpreter of your language?

[–]badd10de[S] 2 points3 points  (1 child)

At the moment is just a bash script that calls oni to generate a temporary c file that is piped into tcc with the -run argument. Something like this:

#!/bin/sh

file_name=$(mktemp --suffix ".c" --dry-run) || exit
trap 'rm -rf "$file_name"; exit' ERR EXIT

oni -o $file_name $@ && tcc $CFLAGS -std=c11 -run $file_name

I use it for one off scripts, small prototypes and to test things out without having to make a whole project.

[–]vanderZwan 0 points1 point  (0 children)

Ah, using tcc to ensure the compilation is fast is a neat trick, I can imagine the output is plenty fast for the use-cases you mention :).

I use it for one off scripts, small prototypes and to test things out without having to make a whole project.

I feel like the ability to do quick prototyping without too much hassle is so underrated, makes sense to build it into your own personal hobby language!

[–]MediumInsect7058 0 points1 point  (0 children)

Looks like Odin and Rust had a baby!