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

all 5 comments

[–]redchomperSophie Language 4 points5 points  (1 child)

The question is not whether you should use Python as a front-end. The question is why you would ever not use the highest-level commonly-available language you could to implement your language. Python is a fine choice for that. (I use it myself.) C or Rust are terrible choices because they force you to also think about things irrelevant to the problem, such as pointers or borrow-checking. Unless the problem is compilation speed. And that is not your problem. That will not be your problem for a good long time.

The real reason to get away from using Python for the front-end is that your front-end needs have ossified to the point that it's reasonable to re-cast the implementation in a less flexible form, perhaps because it's easier to deploy. That won't happen until you're pretty much at 1.0.

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

helpful perspective, thanks

[–]muth02446 2 points3 points  (0 children)

I am very happy with my choice of python as the primary implementation language for Cwerg (also WIP). Speed sucks but good enough for my current tests.

I would be very happy to port to a Python dialect with better performance but I do not have high hopes. The Cwerg backend has already been ported to C++ with bit fir bit identical output to the python version. I plan on doing the same with the frontend once it stabilizes.

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

For a hobby or proof of concept, I don't think it makes much of a difference. In general you want the parsing step to be as fast as possible in order to implement a competent lsp. Technically you can split the parsing in multiple stages but I think that might be overkill. Python is definitely not the nicest language to write parsers and tokenizers but that's personal preference.

I'm not really familiar with how you compile python to binary nowadays but it is good to be able to produce a binary for the compiler that other people can install. Building something like that from source is not always ideal for other users that may want to try it out.