r/shittyprogramming • u/AsianFeng • Nov 11 '15
The dankest programming language: greentext
Hello shitty programmers, a few weeks ago I was inspired by this thread and decided to take it to the next level and make a memearrow-based language a real thing. (Shout outs to everyone in that thread for all those ideas ayy lmaoI swear I didn't steal them ) So here it is, my new programming language called greentext. Code and docs on Github
A basic rundown:
:^) = true, :^( = false
>mfw = print
>be foo like 1234 = variable assignment
>implying = if statement
>inb4 = for loop
>dank memes = main function
>wewlad foobar = function declaration
Yes you can write actual code in this language. Here's fizzbuzz:
>dank memes
>inb4 i from 0 to 100 by 1
>implying i % 15 is 0
>mfw "fizzbuzz", i
>or not
>implying i % 3 is 0
>mfw "fizz", i
>done implying
>implying i % 5 is 0
>mfw "buzz", i
>done implying
>done implying
>done inb4
>tfwLet me know what you guys think :^)
11
u/dersand Nov 12 '15
What about something with "thank Mr skeltal". Return false? NOP?
8
u/AsianFeng Nov 12 '15
Yes I need to bring Mr skeltal into this somehow. Needs more dooting
13
98
44
39
Nov 12 '15
You need the "is" comparison operator like python has
>dank memes
>be op like "Fag"
>mfw op is "Fag"?
#Returns " :^) "Oh Myyyyyy
49
29
u/piefge Nov 12 '15
wrap every exception that it returns an error stating it couldn't find adobe reader.
1
10
7
2
2
3
1
1
1
u/silentclowd Nov 12 '15
Forgive me for being a fucking idiot but how do I actually compile something with this? Say I have a file called HelloWorld.gt and want to run it. The command I type is python parser.py helloWorld.gt. What am I doing wrong?
Oh I also went ahead and made you an Esolangs wiki page. You're welcome. http://esolangs.org/wiki/Greentext
1
1
1
1
1
1
u/I-baLL Nov 12 '15
you realize that if you remove the "implying i % 15" conditional, you'll still have a full fizzbuzz program? all you have to do is remove the "done implying" part after the fizz test.
1
u/SBareS Nov 12 '15
Not really. He would need to print Fizz and Buzz on the same line.
1
u/I-baLL Nov 12 '15
I don't see a newline character after Fizz
1
u/wormania Nov 12 '15
Python newlines on print by default, you have to end your print statement with
,in order to stop it newlining.1
0
Nov 12 '15
[deleted]
4
u/capitalsigma Nov 12 '15
try: ... except (SyntaxError, TypeError): ...wat
i can't tell if the code is ironically bad for this sub or what
8
u/AsianFeng Nov 12 '15
It's a miracle that I put in any error checking at all :^)
9
u/capitalsigma Nov 12 '15 edited Nov 12 '15
<realz>
never ever ever even ironically catch
SyntaxErrororTypeErrorbecause it will allow the following to silently fail:try: import something 1 + object + [] except (SyntaxError, TypeError): passwhere
something.pyis:python?!?!!? TOP KEKdefine your own GreenTextSyntaxException inheriting from Exception and raise that
</realz>
exception game on fleek brah
2
u/AsianFeng Nov 12 '15
Thanks man, pretty new with Python so I haven't got the best practices down. Advice noted.
3
u/AsianFeng Nov 12 '15
Wrote it pretty much from scratch. But it helps that I'm taking a course on compilers in school right now
0
Nov 11 '15
[deleted]
38
u/lurking_bishop Nov 11 '15
jup, an if clause is enough. The deeper you dive into the matter the more surprised you are what simple things are actually turing complete
30
u/timeforpajamas Nov 12 '15
Close!
an imperative language is Turing complete if it has conditional branching (e.g., "if" and "goto" statements, or a "branch if zero" instruction
4
u/FearTheCron Nov 13 '15 edited Nov 13 '15
and the ability to change an arbitrary amount of memory locations
I would argue that this language does not have this property. An easy counterexample is the turing machine that takes a number encoded in binary and tells me if it has an even or odd number of bits. The turing machine would be very simple to write, it simply toggle between even and odd as you go over the number and accept or reject on the first empty space. However with this language you cannot even take a number with more digits than a float can hold. There are many solutions to this, the easiest probably being to include arrays with a runtime allocation.
The easiest for the language developer, and most difficult for the programmer using the language, would just be to switch the numbers over to big integer types. Then you could simply encode the entire tape of the turing machine using Gödel numbering into a single variable.
1
u/timeforpajamas Nov 13 '15
greentext has variables, so isn't that condition satisfied?
5
u/FearTheCron Nov 13 '15
No because you can only have a finite number of variables. This means when I write a program I can only have a predefined amount of memory. For example if I wrote the program to span the number across 20,000 floats (this would be tediously spelled out such that x1 = ...; x2 = ...; x3 = ... ;x20000 = ... ) then I could potentially give the program a number that needs 20,001 floats worth of space and it wouldn't be able to store it.
1
u/timeforpajamas Nov 14 '15
sorry, I'm missing something. where do you see that only 20000 variables are allowed?
4
u/FearTheCron Nov 14 '15
It's not the language, it's the program you write in it. You are limited to the variables you explicitly declare. The point of that is to say you can't write a program that operates over any finite amount of information. With the even odd example your program is limited by the amount of space in your declared variables.
1
u/benzrf Nov 12 '15
actually, you also need some means of looping. in particular, any language in which all programs halt cannot be turing complete, and conditional branching alone still generally terminates
1
u/timeforpajamas Nov 13 '15
LABEL: start goto starta branch is sufficient to build a loop.
1
u/benzrf Nov 14 '15
That's
goto, notif.ifis considerably less powerful in many languages.1
u/timeforpajamas Nov 14 '15
goto is the branch
if is the conditional
for a turing-complete language, you need both. as described in the link I shared earlier.
1
u/benzrf Nov 14 '15
ah, I see. I misread
if it has conditional branching (e.g., "if" and "goto" statements
as giving "if" and "goto" as two examples of "conditional branching", not as giving them jointly as a single example.
0
Nov 13 '15
[deleted]
1
u/benzrf Nov 14 '15
That's not a property of if statements; that's a property of procedure definitions. The conditionals there are irrelevant to the looping behavior. What you're demonstrating is unrestricted mutually recursive definitions.
2
0
99
u/SkaKri Nov 11 '15
System exit:
thank, with exit codethank 1