Discuss Scratch

Saiid
Scratcher
1000+ posts

PigeonScript - a Golfing Language

jokebookservice1 wrote:

Saiid wrote:

jokebookservice1 wrote:

Ok, I envision a hello world program to look like this (if we use prefix notation)
d"gsS1p
The “d” decompresses the next parameter.

The "gsS1p does not require a closing quote because that is implicitely done at the end of the program. I just made up gsS1p but it would be a compressed version of Hello World.
Interesting. I was more thinking it would look like this
log Hello World
And in this case it assumes it's a string, since it's A) two words and B) not a number. Also, any ideas for a name?

Saiid
“log” is too long – make it “l”. And it should be implicit output so no need for the “l” at all. It could be a variable so we should have one quote atthe start I think.
We could have one quote at the beginning, but, correct me if I'm wrong, aren't variables supposed to be only one word anyway?

Saiid
jokebookservice1
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Saiid wrote:

jokebookservice1 wrote:

Saiid wrote:

jokebookservice1 wrote:

Ok, I envision a hello world program to look like this (if we use prefix notation)
d"gsS1p
The “d” decompresses the next parameter.

The "gsS1p does not require a closing quote because that is implicitely done at the end of the program. I just made up gsS1p but it would be a compressed version of Hello World.
Interesting. I was more thinking it would look like this
log Hello World
And in this case it assumes it's a string, since it's A) two words and B) not a number. Also, any ideas for a name?

Saiid
“log” is too long – make it “l”. And it should be implicit output so no need for the “l” at all. It could be a variable so we should have one quote atthe start I think.
We could have one quote at the beginning, but, correct me if I'm wrong, aren't variables supposed to be only one word anyway?

Saiid
But what if you want two variables?
Saiid
Scratcher
1000+ posts

PigeonScript - a Golfing Language

jokebookservice1 wrote:

Saiid wrote:

jokebookservice1 wrote:

Saiid wrote:

jokebookservice1 wrote:

Ok, I envision a hello world program to look like this (if we use prefix notation)
d"gsS1p
The “d” decompresses the next parameter.

The "gsS1p does not require a closing quote because that is implicitely done at the end of the program. I just made up gsS1p but it would be a compressed version of Hello World.
Interesting. I was more thinking it would look like this
log Hello World
And in this case it assumes it's a string, since it's A) two words and B) not a number. Also, any ideas for a name?

Saiid
“log” is too long – make it “l”. And it should be implicit output so no need for the “l” at all. It could be a variable so we should have one quote atthe start I think.
We could have one quote at the beginning, but, correct me if I'm wrong, aren't variables supposed to be only one word anyway?

Saiid
But what if you want two variables?
Hello+World
would be interpreted as the output of the variables “Hello” and “World”.
Hello World
would be interpreted as the output of the string, “Hello World”.

Saiid
jokebookservice1
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Anyway, we'll want a built in compressed for the hello world
Saiid
Scratcher
1000+ posts

PigeonScript - a Golfing Language

jokebookservice1 wrote:

Anyway, we'll want a built in compressed for the hello world
You mean have the function
print "Hello world"
built in? something like
hw
would print “Hello World” you mean?

Saiid

Last edited by Saiid (Oct. 25, 2016 16:05:12)

Sigton
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Saiid wrote:

jokebookservice1 wrote:

Anyway, we'll want a built in compressed for the hello world
You mean have the function
print "Hello world"
built in? something like
hw
would print “Hello World” you mean?

Saiid
He means compressing the string itself into fewer bytes, so the program will still effectively read
print "Hello world"
but the string “hello world” will itself be shortened.

I like the idea of implicit output, kinda like Python shell. it means we don't need a command to print, and once everything is executed and evaluated the result will be printed (that would make it a very functional language… everything would eventually need to return something).

Sigton
jokebookservice1
Scratcher
1000+ posts

PigeonScript - a Golfing Language

(We still need a command to print, we just don't always need to use it)
Anyway, yes, I mean instead of “Hello World” we can put
d"ghD15
Because “Hello” and “World” are common words they can be easily compressed. The “d” calls the “decompress” function
Saiid
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Sigton wrote:

Saiid wrote:

jokebookservice1 wrote:

Anyway, we'll want a built in compressed for the hello world
You mean have the function
print "Hello world"
built in? something like
hw
would print “Hello World” you mean?

Saiid
He means compressing the string itself into fewer bytes, so the program will still effectively read
print "Hello world"
but the string “hello world” will itself be shortened.

I like the idea of implicit output, kinda like Python shell. it means we don't need a command to print, and once everything is executed and evaluated the result will be printed (that would make it a very functional language… everything would eventually need to return something).

Sigton
I think compressing the string would be confusing. It still should be relatively easy to write in and understand. I do agree with the implicit output. So, to confirm. Is this relatively acceptable to everyone?

To print:
Hello World prints "Hello World"
var prints the value of that variable
3.1415 works the same as the first and prints "3.1415"

Also, I thought that for variables, instead of having, for example
var x = 1;
we could just write
x|1
Please, share your thoughts

Saiid
IcyCoder
Scratcher
1000+ posts

PigeonScript - a Golfing Language

x|1

To save a byte
1x
Saiid
Scratcher
1000+ posts

PigeonScript - a Golfing Language

IcyCoder wrote:

x|1

To save a byte
1x
But then we would still need to include something that tells it that we're assigning a variable and not printing a string
Also, is everyone fine with having the command “l” for when something needs to be specifically told to log itself? For example,
x|1
might assign a variable, but if we wanted to print “x|1”, we could do
l x|1

Saiid

Last edited by Saiid (Oct. 25, 2016 18:03:18)

jokebookservice1
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Saiid wrote:

IcyCoder wrote:

x|1

To save a byte
1x
But then we would still need to include something that tells it that we're assigning a variable and not printing a string
Also, is everyone fine with having the command “l” for when something needs to be specifically told to log itself? For example,
x|1
might assign a variable, but if we wanted to print “x|1”, we could do
l x|1

Saiid
Just put quotes around strings.
Saiid
Scratcher
1000+ posts

PigeonScript - a Golfing Language

jokebookservice1 wrote:

Saiid wrote:

IcyCoder wrote:

x|1

To save a byte
1x
But then we would still need to include something that tells it that we're assigning a variable and not printing a string
Also, is everyone fine with having the command “l” for when something needs to be specifically told to log itself? For example,
x|1
might assign a variable, but if we wanted to print “x|1”, we could do
l x|1

Saiid
Just put quotes around strings.
That adds unnecessary and unneeded bytes that could be saved

Saiid
jokebookservice1
Scratcher
1000+ posts

PigeonScript - a Golfing Language

Saiid wrote:

jokebookservice1 wrote:

Saiid wrote:

IcyCoder wrote:

x|1

To save a byte
1x
But then we would still need to include something that tells it that we're assigning a variable and not printing a string
Also, is everyone fine with having the command “l” for when something needs to be specifically told to log itself? For example,
x|1
might assign a variable, but if we wanted to print “x|1”, we could do
l x|1

Saiid
Just put quotes around strings.
That adds unnecessary and unneeded bytes that could be saved

Saiid
Variables are more commonly used than strings. It moves bytes from variables to strings.
Saiid
Scratcher
1000+ posts

PigeonScript - a Golfing Language

jokebookservice1 wrote:

Saiid wrote:

jokebookservice1 wrote:

Saiid wrote:

IcyCoder wrote:

x|1

To save a byte
1x
But then we would still need to include something that tells it that we're assigning a variable and not printing a string
Also, is everyone fine with having the command “l” for when something needs to be specifically told to log itself? For example,
x|1
might assign a variable, but if we wanted to print “x|1”, we could do
l x|1

Saiid
Just put quotes around strings.
That adds unnecessary and unneeded bytes that could be saved

Saiid
Variables are more commonly used than strings. It moves bytes from variables to strings.
It's still unnecessary. It takes less bytes to write out
l x|1
Hello World
012345
Than it does to write out
'x|1'
'Hello World'
012345

Saiid
CodeLegend
Scratcher
500+ posts

PigeonScript - a Golfing Language

Saiid, I suggest you take a look at ATC#5. Be sure to open the shortened link, it has roughly 100 examples of golfed programs that run in Scratch languages.

If you're going for simplicity (which you've stated), variables and loops are not the way to go as a ‘first step’. Your first step should be basic math; the language doesn't need to be Turing-complete until later in development. That being said, here are some tips:

  • Use postfix notation. It makes the architecture so much simpler, which means that you're less likely to make mistakes.
  • Once you've chosen an architecture, choose which data types your program will be able to manipulate. This list will probably consist of booleans, numbers, strings, possibly lists, and maybe a few more. (for instance, you could have a ‘coordinate’ data type (x,y), and corresponding commands that make geometry easier)
  • Once you are sure of the data types you'll be using, start brainstorming the commands that the language will have. Obviously you'll have things like + and =, but the number of commands is unlimited. Often, more is better. Prioritize which commands will be a single character long, and which ones will be subsets of other characters. (see: “.” in pyth) Keep in mind that while some commands are useless on their own, they can be incredibly useful when other ‘useless’ commands are present. For instance, if your program won't ever need to input or output lists, it can still be useful to process first-class lists internally. List commands would be useless on their own, but useful when put together.
Mostly irrelevant, but back to variables and loops: you don't actually need them. You probably should have them, but a language with strong stack manipulation abilities and a simple ‘goto’ can be Turing-complete.
CodeLegend
Scratcher
500+ posts

PigeonScript - a Golfing Language

jokebookservice1 wrote:

Saiid wrote:

jokebookservice1 wrote:

Saiid wrote:

IcyCoder wrote:

x|1

To save a byte
1x
But then we would still need to include something that tells it that we're assigning a variable and not printing a string
Also, is everyone fine with having the command “l” for when something needs to be specifically told to log itself? For example,
x|1
might assign a variable, but if we wanted to print “x|1”, we could do
l x|1

Saiid
Just put quotes around strings.
That adds unnecessary and unneeded bytes that could be saved

Saiid
Variables are more commonly used than strings. It moves bytes from variables to strings.
Sorry, but I have to specifically call you out on this one - you're wrong. How is this:
l x|1
shorter than this?
l"x|1
It's not. Your space character is serving the same function as a quotation mark, except that it's less discrete.

Plus, this:
Hello World
Should NOT output “Hello World”. That's a waste of 8 whole characters that could serve useful functions!

EDIT: I'm sorry if I'm coming across as mean; that's not my intent. But most of the people in this thread have successfully created codegolfing languages, so you should listen to their advice.

Last edited by CodeLegend (Oct. 25, 2016 22:14:16)

Saiid
Scratcher
1000+ posts

PigeonScript - a Golfing Language

CodeLegend wrote:

Saiid, I suggest you take a look at ATC#5. Be sure to open the shortened link, it has roughly 100 examples of golfed programs that run in Scratch languages.

If you're going for simplicity (which you've stated), variables and loops are not the way to go as a ‘first step’. Your first step should be basic math; the language doesn't need to be Turing-complete until later in development. That being said, here are some tips:

  • Use postfix notation. It makes the architecture so much simpler, which means that you're less likely to make mistakes.
  • Once you've chosen an architecture, choose which data types your program will be able to manipulate. This list will probably consist of booleans, numbers, strings, possibly lists, and maybe a few more. (for instance, you could have a ‘coordinate’ data type (x,y), and corresponding commands that make geometry easier)
  • Once you are sure of the data types you'll be using, start brainstorming the commands that the language will have. Obviously you'll have things like + and =, but the number of commands is unlimited. Often, more is better. Prioritize which commands will be a single character long, and which ones will be subsets of other characters. (see: “.” in pyth) Keep in mind that while some commands are useless on their own, they can be incredibly useful when other ‘useless’ commands are present. For instance, if your program won't ever need to input or output lists, it can still be useful to process first-class lists internally. List commands would be useless on their own, but useful when put together.
Mostly irrelevant, but back to variables and loops: you don't actually need them. You probably should have them, but a language with strong stack manipulation abilities and a simple ‘goto’ can be Turing-complete.
Simplicity, yes, but some simplicity can be sacrificed to aid codegolfing. In addition, I was more trying to start with an output command.

Saiid
CodeLegend
Scratcher
500+ posts

PigeonScript - a Golfing Language

Saiid wrote:

CodeLegend wrote:

-snip-
Simplicity, yes, but some simplicity can be sacrificed to aid codegolfing. In addition, I was more trying to start with an output command.

Saiid
There is no aid to using prefix notation over postfix notation. They are the exact same length.

An output command is the last thing you need. First implement a stack.
jokebookservice1
Scratcher
1000+ posts

PigeonScript - a Golfing Language

CodeLegend wrote:

Saiid wrote:

CodeLegend wrote:

-snip-
Simplicity, yes, but some simplicity can be sacrificed to aid codegolfing. In addition, I was more trying to start with an output command.

Saiid
There is no aid to using prefix notation over postfix notation. They are the exact same length.

An output command is the last thing you need. First implement a stack.
I disagree, when you have implicit closing quotes at the end of the program, then
d"abc
is shorter than
"abc"d
CodeLegend
Scratcher
500+ posts

PigeonScript - a Golfing Language

jokebookservice1 wrote:

CodeLegend wrote:

Saiid wrote:

CodeLegend wrote:

-snip-
Simplicity, yes, but some simplicity can be sacrificed to aid codegolfing. In addition, I was more trying to start with an output command.

Saiid
There is no aid to using prefix notation over postfix notation. They are the exact same length.

An output command is the last thing you need. First implement a stack.
I disagree, when you have implicit closing quotes at the end of the program, then
d"abc
is shorter than
"abc"d
That's just one specific situation. Besides that, they are isomorphic.

Powered by DjangoBB