Show HN: Build your own programming language in C++
github.com
github.com
It's like my early Fortran code looked like Basic, my early C code looked like Fortran, my C++ code looked like C, and my D code looked like C++.
It takes a while to write code idiomatic to the language your using.
As for C++: I have zero clue about it. Occasionally a student who learns C++ comes to me for help and I end up being useful and help her (by RTFM), but other than that, nothing much really.
I like how down to earth human being you are; that's the type of people I want to be around as much as possible.
There are so many things I could be taught from you.
Keep up the good work mate! +1
Don't let your employer into your GitHub account, kids; it will never be the same.
The linked project is an example of how to do just what it claims using the project you linked as a foundation.
The two main styles I've seen are (1) the classic full-fledged OOP-y C++ classes with methods, and (2) POD structs with functions that work on them defined in namespaces, in a more C-like style.
Your style seems to be a mix. You don't seem to get the big downsides of OOP, as you're grouping functions per namespace instead of having to make everything a class and ending up with a contrived architecture. At the same time, you're still going to be using many C++-isms due to your use of non-POD structs, which some people may appreciate (for uniform initialisation and memory management), and some people may enjoy less (due to the limitations and complexities of constructors, being forced to use exceptions etc.).
I apologise for my extremely superficial description, but I think it's enough background for my question, namely: could you speak a bit about this programming style, what led you to choose it, and what you enjoy/don't enjoy about it? Thank you! :)
[0]: https://github.com/codr7/liblgpp/blob/main/src/lgpp/parser.h...
That's correct, I tend to drift towards the same style when the language allows it.
This is the result of 35 years of trial and error, not so much careful planning. I've found that structuring my code like this makes it more enjoyable to deal with.
C++ being C++, simplifying and cutting it down to its core is essential from my experience. But I like constructors and destructors, and the standard library is pretty nice these days.
Why on earth would someone seriously want to use C++ for the compiler, when you created a much better language? Bootstrap it once and your problems are gone. Memory safety, tree management, proper matching, high level. All extremely important for a compiler.
Translating that into sane Java takes some experience but it's totally doable.
I don't know why you'd post a Show HN and then being so dismissive of someone chiming in asking if it's possible to use your project to do something they'd be interested in!
The constructive answer to the original question is - yes both this system and Java bytecode are fundamentally stack-based languages, so they should match up well.
If you're reimplementing Java, this project isn't going to take you very far and it's probably not the optimal approach.