r/learnpython • • 9d ago

Making my own golfing language in python

Im not that active on reddit, but the moment I came into the osdev subreddit (I tried making my own OS with a python shell) and I INSTANTLY got my inbox filled with hate comments.

I heard from one reddit post that this subreddit is much friendlier and more helpful, thats why I switched to this subreddit.

So I started making my own golfing language, array-oriented ofcourse, where data and code are seperated.

As of now I haven't really done anything except plan on what instructions to make, I have a total of 20 letters and symbols on board.

So, I'd like to hear some tips about making interpreters/compilers that I should keep in mind.

0 Upvotes

28 comments sorted by

View all comments

Show parent comment

1

u/fallenreaper 9d ago edited 9d ago

This reminds me of a programming exercise i give to new engineers where you need to intake a string and then parse it with a variety of rules, not unlike your example. That said, its literally a nonissue and is easy to implement within an hour or so.

So im trying to understand broadstrokes, like what is this shorthand going to provide to someone other than solving math with shorthand? How does it handle strings, floats, binaries, unicode, etc? Typically a language has a purpose. If this is a business layer on top of python, it is inherantly going to be slower because youre adding complexity and string interpolation prior to mathematical functionality.

So from respect of code golf, youre making shorthand to use less characters, but still potentially needs to be run through an interpretor and then executed; In this case, a business layer on python ( given that youre in this sub ). So youre solving smaller code which will have a slower runtime? I am not saying it is good or bad, maybe it is more about the concept of learning the language as opposed to making something functional, which im all about ( given the sub ).

1

u/keepandroidopen 8d ago

Well, for now I'm just trying to make it functional and lightweight.

After which I will probably import pypy for big performance gains, pypy is a JIT compiler for python which is why it makes things faster.

Tho honestly, I will probably rewrite all of this in C later, because I'm forced to learn C for one of my python projects which means that rewriting this in C wont be as hard as it woudlve been (and it would make the performance crazy fast).