r/learnpython • • 8d 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

4

u/tlor2 8d ago

my own golfing language, array-oriented ofcourse

Ow sure ofcourse that would be array orientend............... :?

0

u/keepandroidopen 8d ago

Array-oriented means it mostly operates on arrays/lists instead of normal, singular numbers.

In a normal language, adding 5 numbers looks like this: 5 + 4 + 3 + 2 + 1

In array-oriented languages, adding 5 numbers looks like this: +[5, 4, 3, 2, 1]

1

u/fallenreaper 8d ago edited 8d 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 7d 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).

1

u/xplosm 7d ago

So, like a LISP? What you didn’t like about the many LISP variants?

-1

u/keepandroidopen 7d ago

I dont know much about LISP except that code can be edited at runtime, and that its used for AI. And I'm not really interested in LISP, I'm making something closer to APL.