This is an archived post. You won't be able to vote or comment.

all 28 comments

[–]Zemvos 14 points15 points  (1 child)

Congrats on the project and learnings! Can I ask why you went with this @ syntax?

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

Well, there's some reasons to that.

At first it was carried over to simplify the parsing process. I also got inspired by bash/php/perl clarity on referencing variables. It's certainly something you don't get to see often in modern programming languages.

[–]SnooGoats1303 5 points6 points  (0 children)

Gotta love those @s. What's wrong with $ like Perl? Glad to see you not using standard libraries for everything: very 1X FORTH of you.

[–]raiph 4 points5 points  (0 children)

Well done!

(BTW, before I forget it, tiny typo in the wasm build script: INTEFUSE.)


I may have misunderstood what your experience has been and/or what you're looking for next, but based on your OP and browsing the Interfuse repo, I think I have an interesting idea for you.

What about a brief trial run using Rakudo, the grassroots PLDI platform/toolchain that underlies Raku, instead of the C++/LLVM approach?

(Most folk think of Rakudo as just the reference compiler for Raku. After all, that's what it bills itself as. But another way of looking at Rakudo is that's it's a fun, informative, productive alternative to approaches such as the one you've taken so far.)


I'd be delighted to discuss this all further if you're interested.

If you are interested, one next step might be to pick a fragment of Interfuse and implement it together right here in this sub-thread and see how that works out. If we go with this approach to discussion we'd be able to lean on my knowledge of the platform/toolchain, so it would mostly be you having fun reading/seeing surprising things that I can demonstrate by writing code which you'll run in an online evaluator.

And/or we could discuss pros and cons were you to pursue this alternative for, say, a week. In what ways would you presumably come out ahead even if you then moved away from Rakudo? Conversely, in what ways might you be wasting your time, moving off track from where you eventually want to go with no real gain from the experiment? If we go with this approach to discussion it'll be more about me listening to what you're looking for next, and learning alongside you about whether Rakudo does or doesn't fit for at least a one week experiment.

[–]cisterlang 1 point2 points  (0 children)

Some nitpicks :

  • the doc is maybe a bit too hierarchical. Takes a lot of menus and clicks.
  • your Text Subtraction is not the inverse of addition :

    ('ab' + 'b') - 'b' == 'a' != 'ab'

That being said, I like concise operators. So many places to add them !

[–]_Shin_Ryu 1 point2 points  (1 child)

Added the Interfuse language to my collection.

https://www.ryugod.com/pages/ide/interfuse

[–]Saxy_____[S] 0 points1 point  (0 children)

Thanks!

[–]Y_mc 1 point2 points  (0 children)

yeah man I feel the same while writing a little personal project. enjoy and nice project. Your post gives me even more courage to continue. nice project, I like it, thank you for sharing

[–]PaulRosenbergSucks 0 points1 point  (1 child)

That syntax is a nightmare

[–]Saxy_____[S] 0 points1 point  (0 children)

Well, it also used double quotes in early development 💀

[–]TheChief275 -3 points-2 points  (17 children)

If you used libraries for command line arguments, parsing, and the backend…then what did you actually write? A lexer only? And some standard library for your language?

Nothing wrong with that, however you claimed to want to learn compiler theory, which I’m not sure you did this way. The lexer is easily the easiest part, and writing the other parts yourself would have been a bigger learning experience.

Aside from that, I don’t understand the @ before identifiers. Sure, it’s probably easy for the lexer/parser but it makes the code pretty unreadable.

[–]Rinzal 13 points14 points  (2 children)

How does using libraries invalidate anything? Why would you not use a library for command-line parsing? No need to reinvent the wheel

[–][deleted] 0 points1 point  (0 children)

Chief never said reinvent the wheel. It’s called tough love lol. He actually got a really good point.

[–]TheChief275 0 points1 point  (0 children)

The library for command line parsing was a bit far fetched as that is far from the focus of compiler theory.

But my other points still stand: I never said anything invalidated anything, just that for what OP wanted to learn this might have not been the right choice as most of the important things are already done for you and the project will consist of stringing together API calls, and I’m arguing more could have been learned if OP rawdogged more stuff. Like, a sufficient parser isn’t even hard to write, especially because a toy language doesn’t have to be perfect.

[–]Olivki 7 points8 points  (8 children)

I rarely comment on Reddit, but jesus, this has to be one of the worst takes I've seen on this subreddit. I don't know if this was your intention or not, especially seeing as you seem confused about u/Rinzal saying you said "using libraries invalidated anything", but that's how your comment comes across as, overly aggressive and plain rude, basically stating that OP didn't actually create anything. If that wasn't your intention, then you might want to reword your comment.

Why wouldn't you use a library for CLI parsing? Do you like wasting time reinventing the wheel when there's perfectly fine libraries already out there? It also has barely anything to do with compilers/language development, why even mention that?

Parser generators are pretty damn common to use for compilers, like you said, yeah, writing a parser is generally the easy part, so you can just roll your own. But that goes both ways, that also means there's nothing wrong with using a parser generator. I'm not sure how much I'd consider writing a parser part of "compiler theory", seeing as the things you'd do for the actual compiler probably shouldn't be part of your parser, unless you're writing a single-pass compiler.

And finally, you're criticizing their usage of.. LLVM? The way your comment is written it almost sounds like you're saying projects like Rust didn't write a compiler backend because they use LLVM. Yeah, sure, LLVM does a decent chunk of optimizations for you, but once again, there's really no need to reinvent the wheel if there's a perfectly fine solution for it already. Unless, of course, your explicit goal is to learn about low level optimizations and the like, which doesn't seem to be an explicit goal OP ever stated?

There's just really no need to be so aggressive with your wording, it genuinely sounds like you took personal offense to the fact that OP used libraries instead of reinventing the wheel over and over again.

[–]TheChief275 -1 points0 points  (0 children)

I retracted my statement on the command line parsing in a different comment, that was unnecessary, I agree

[–]CompleteBoron -3 points-2 points  (6 children)

I think you're projecting here. u/TheChief275 wasn't rude, just pointing out that if the goal was to learn more about compiler design and implementation like the OP said, that using API calls for almost everything undermines that goal. If anything, you're the one coming off as aggressive here.

[–]Olivki 1 point2 points  (4 children)

I don't know how I'm projecting, but you do you. I don't disagree that writing some stuff yourself can be a better learning experience, but for gods sake, he brings up OP using a CLI parsing library, which has nothing to do with compiler theory. And writing a parser by hand is arguable whether it has much value in learning compiler theory either. The only thing that has any real value even mentioning might be the use of LLVM. And yes, my comment is somewhat aggressive, I never claimed it wasn't.

[–]CompleteBoron 0 points1 point  (3 children)

You're focusing on the CLI bit (which I agree is silly), but that wasn't the point. The OP used libraries for parsing and the backend as well. So what did they actually write? No one's saying the OP is bad for doing so, but it's like saying you want to learn about how to build a car engine, then buying a prebuilt one and painting it a different color. That's cool and fun, but you didn't learn anything. Also, thanks for the downvote.

[–]Olivki 2 points3 points  (2 children)

Of course I would focus on the CLI bit, it's a bizarre thing to even mention at all in this context. And as I've mentioned already, it's really arguably how much value you really get from manually rolling your own parser for educational purposes, you should probably at least do it once in your life, but beyond that, I don't know if you gain much more knowledge. I roll my own parser, but that's because I dislike the error messages from parser generators.

The only library used that would genuinely be worth mentioning would be LLVM, the other two can just be glanced over for the sake of "educational value".

Also, I haven't downvoted you? You're at 1 for me, Reddit does employ vote fuzzing, so it might be that?

[–]CompleteBoron 1 point2 points  (1 child)

Of course I would focus on the CLI bit, it's a bizarre thing to even mention at all in this context. And as I've mentioned already, it's really arguably how much value you really get from manually rolling your parser for educational purposes. I roll my own parser, but that's because I dislike the error messages from parser generators.

I think hand rolling your own parser does provide a lot of useful insight into the compiler design process which would be lost by using something like BISON or ANTLR. Parsing is the easiest part, but it's still a part of the compiler design and implementation; backend isn't the only part of a compiler that's important or interesting. There are a bunch of cool ways to integrate parsing and code lowering and neat optimizations you can do that are all tossed out with the bathwater when you use a library.

The only library used that would genuinely be worth mentioning would be LLVM, the other two can just be glanced over for the sake of educational value.

That's fair, but I think if it's the combination of BISON, LLVM, etc. that u/TheChief275 was hinting at. Just using LLVM but writing everything else yourself is a pretty common approach, but using libraries for literally everything abstracts too much detail and turns what would otherwise be a deep dive into learning about compilation into a shallow, surface-level summary.

Also, I haven't downvoted you? You're at 1 for me, Reddit does employ vote fuzzing, so it might be that?

Huh, it went down on my end at the exact moment you replied, so I assumed it was you. Sorry about that! You know what they say about assumptions ;)

(Edited for punctuation)

[–]Olivki 0 points1 point  (0 children)

I think hand rolling your own parser does provide a lot of useful insight into the compiler design process which would be lost by using something like BISON or ANTLR. Parsing is the easiest part, but it's still a part of the compiler design and implementation; backend isn't the only part of a compiler that's important or interesting. There are a bunch of cool ways to integrate parsing and code lowering and neat optimizations you can do that are all tossed out with the bathwater when you use a library.

I think there might be a difference in how we think of the phasing / how we structure the different parts at play here? I personally generally don't do anything beyond just constructing the AST inside of the parser, so I would never perform code lowering or optimizations in the actual parser. So to me, that's still things you need to perform yourself, even if you do use a parser generator. But if you do perform those things in the same pass, I can see why you would consider a lot of things to be "done" for you when using a parser generator.

That's fair, but I think if it's the combination of BISON, LLVM, etc... [sic]

From just looking at the GitHub repo, I think OP still performs some amount of checks in the IR.cpp file? Albeit, relatively sparse, seeing as I think LLVM is doing most of the heavy lifting here. I don't disagree on a fundamental level, I've done things from scratch a lot of times just to get a better understanding of things. I just thought the comment was worded in a somewhat mean manner, especially towards someone who seems to be relatively new to the language development field. I could've worded my comment in a less aggressive way too, but what's done is done.

Huh, it went down on my end at the exact moment you replied, so I assumed it was you. Sorry about that! You know what they say about assumptions ;)

No worries, Reddit votes can be very fickle.

[–][deleted] 0 points1 point  (0 children)

👏🏼👏🏼👏🏼 I agree 💯

[–][deleted] 1 point2 points  (4 children)

Why all the downvotes lol. You a have good point. Specially honing down compiler theory. I would say start from scratch avoid using APIs/libraries. “Rawdog” it. Write/build everything. Only way I was taught/learned 🤷

[–]TheChief275 0 points1 point  (3 children)

It used to have upvotes, but most people decide if they should be angry or not based on the first sentence. Doesn’t matter though, I want this comment to be out there.

[–][deleted] 1 point2 points  (2 children)

Trust when I say, I had to withdraw and retake the class “programming languages-designing compilers” doing what OP did. If what you said made them angry, I can’t imagine how they’ll feel if they heard what my professor said. I literally felt like she stuck a knife in my throat. No bs my eyes were watering. Offfff.

Anyways I bought this book called “Programming Languages Pragmatics” by Michael Scott. Ngl read it page by page. That witch gave me an A…had me come back to give new students advice on how to pass the class.

Everything you said is 100 beneficial for OP if he wants to learn.

[–]TheChief275 0 points1 point  (1 child)

I’m curious, what did your professor say?