I am planning to write an improved GolfScript for even shorter programs that can do more things. This is not a challenge; it is a request for feedback and tips on what I should do. (see tags)
I'm not sure if this should be Community Wiki. If you think so, just flag for a moderator to convert it :)
This language will be very similar to GolfScript. It is still written in Ruby. However, it has a few differences:
- Using
`
as a string delimiter, because it's an uncommon character, so less escaping will be needed. (Another character can replace its function, like#
(more on that later)).\`
to escape a backtick,\\
to escape a backslash, and there are no other escape sequences. If you need a newline, just stick an actual literal newline in the string. - Using Ruby's
Rational
s for arbitrary precision floating point, one of GolfScript's major flaws. - The ability to convert types to other types. For example, you can convert a block to a string.
- Regular expressions. Probably created with
"..."
. Operators will be overloaded for them as well. For example,"\W"~{`Invalid: non-word character`}{`OK`}if
. Will automatically execute when pushed from a variable, like blocks. - File and Date objects, to do more stuff that was impossible in GolfScript. These will not have literals, but will have functions for initializing them, such as
`file.txt`fl
(name of the file-making-function may change). - Hashes maybe, but I'm not sure on that one. Should I?
- Helper functions to do even more. For example,
`http://example.com`net
for network access (again,net
operator may be renamed).rb
to execute a string as Ruby code. There will be many more of these; suggestions welcome. - No comments, so that
#
can be used for something else. If you want a comment,`comment here`;
will work fine. (Maybe#
can replace`
's function) - It will be completely rewritten in a way that it will be much easier to add functions. Basically, the code will be more readable. (Have you seen the GolfScript source?
:/
) - It will be on Github so it can be collaboratively worked on. I'll license it under MIT or something.
- No final newline, so cheaty quines work :P
And I'm setting these apart because I think they're the most drastic and helpful changes (except maybe adding floating point):
- It will have many Ruby functions built-in. For example,
shuffle
(which may be abbreviated tosf
) (previously took 9 characters),tr
(previously 14 chars),sample
(sm
, previously.,rand=
),flatten
(fl
, previously ???), etc. - It will be mushed, like Rebmu. For example, now you can do
~:a0<{0a-}aIF
(using a letter variable name) instead of~:$0<{0$-}$if
(overwriting the sort function). (example from here). Note that this way, it is case-insensitive, and numbers are not allowed in variable names. This is okay in my opinion since it's a golfing language :P - It will have debugging. I will add the ability to supply a flag specifying array delimiters, element delimiters, etc., number output (rational, float, or int?), stepping through instructions one at a time, tokenizing and outputting each token instead of running the program, etc.
So, my question is: what is there to improve? What do you think I should add?
Any other ideas for this, before I start coding it?