12
6
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?
Questions like this are no longer considered a good fit for the site, so I'm closing this.
– Martin Ender – 2015-10-18T09:04:23.000@MartinBüttner Good call. Think we should lock it as well? – Doorknob – 2015-10-18T12:03:37.090
Do realize that if you add mushing you lose case sensitivity. – marinus – 2013-12-31T19:03:19.617
@marinus I realize that. I should have made that clear; editing... – Doorknob – 2013-12-31T19:04:23.977
Also what it really needs is a way to do explicit I/O (for interactive programs). The interpreter could check beforehand if the program uses explicit I/O, and only do implicit I/O if it doesn't. – marinus – 2013-12-31T19:05:40.410
@marinus Great, you should add that as an answer then :) – Doorknob – 2013-12-31T19:06:09.060
` is already a quite important operator, thus not good as string delimiter. – Howard – 2013-12-31T19:10:18.260
@Howard I was planning on replacing
\`` with
#` or some other character. I'll edit that also – Doorknob – 2013-12-31T19:13:17.883But I still have a need for comments! Otherwise you cannot save comments with your code. – Howard – 2013-12-31T19:14:22.057
@Howard
\
comment here`;` will work. I just don't see the need for comments in a golfing language... – Doorknob – 2013-12-31T19:15:39.680``comment here
;
will be interpreted while comments are not. What about strings in the comment? Or#{}
? – Howard – 2013-12-31T19:18:37.423Related: Language idea for golfing purposes
– Peter Taylor – 2013-12-31T19:19:15.957@Howard Good point. I could add a
rb
command instead of#{}
, and I guess you'll just have to escape\``. (Use
`\``` for backtick in comments :-P) – Doorknob – 2013-12-31T19:19:46.103Escaping inside comments? That sounds very strange. What's wrong with
"
as string delimiter? – Howard – 2013-12-31T19:20:52.683@Howard, I sometimes do multi-line comments as
'comment';
, but it is slightly fragile because it's possible to use'
in the comment unintentionally. – Peter Taylor – 2013-12-31T19:21:04.947@Howard
"
is used more often, and would require an extra char to escape. Yes escaping in comments is odd, but it is a golfing language :-P – Doorknob – 2013-12-31T19:22:28.773No no no ;-) If you'd post the first one as answer I'd downvote it. – Howard – 2013-12-31T19:38:10.973
Ok, I have to go on a plane so I'll not comment for a while. Looking forward to ideas when I land! :-) – Doorknob – 2013-12-31T19:44:46.400
Any updates on this? I've thought about upgrading Golfscript myself. Will try to remember some ideas I had and post them. – Claudiu – 2014-03-30T02:55:34.887
1@Claudiu My development on my new language is quite alive, although I've recently been fairly busy so I haven't done much with it for a little while. Some of these ideas are just not good ideas though, which I am not using :P – Doorknob – 2014-03-30T03:01:44.113