r/shittyprogramming • • 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
>tfw

Let me know what you guys think :^)

463 Upvotes

67 comments sorted by

99

u/SkaKri Nov 11 '15

System exit: thank, with exit code thank 1

69

u/SkaKri Nov 11 '15

GOTO: >>line_number, for example >>615321

98

u/AsianFeng Nov 11 '15

Of course what's a shitty language without gotos

60

u/SkaKri Nov 11 '15
  >implying :^)
    >mfw "no new memes"
    >>1
  >done implying
  >thank # mr skeltal

16

u/[deleted] Nov 12 '15

> implying assembly languages are shitty <#

13

u/[deleted] Nov 12 '15
> :^)

0

u/[deleted] Nov 13 '15

[deleted]

1

u/[deleted] Nov 25 '15

I hate goto: it makes you your codes so unclear.

17

u/seiyria Nov 12 '15

#define mr_skeltal 1

9

u/hypervelocityvomit Nov 12 '15

#define is not a hashtag

5

u/immibis Nov 12 '15

It is now that he's used it. That's how hashtags work.

1

u/A00841554 Feb 28 '16

Yeah, it's called an octothorpe

1

u/hypervelocityvomit Feb 29 '16
#ifndef __STDC__
    long time; //NOP unintended
#endif

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

u/DonkeyTeeth2013 Nov 12 '15

return -> thank mr skeltal

NOP -> doot

try -> spook

catch -> triggered

5

u/dudemaaan Nov 12 '15

TW: (exception e) { ... } triggered { ... }

98

u/Coloneljesus Nov 12 '15

Should be

>be me = main

25

u/egasimus Nov 12 '15

And >dank memes should be an include/import/require thing.

44

u/Deathyr Nov 11 '15

return -> rekt

23

u/JDN3 Nov 12 '15

break -> rekt

39

u/[deleted] 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

29

u/piefge Nov 12 '15

wrap every exception that it returns an error stating it couldn't find adobe reader.

https://imgur.com/a/iJD8f

1

u/[deleted] Nov 12 '15

Yessssssssss

10

u/hestoelena Nov 12 '15

Comments should be:

tldr op's mom
tldr zero fucks

7

u/Scaliwag Nov 12 '15

I have yet to understand why seems to be a trend to enjoy wet stuff.

14

u/myhf Nov 12 '15

damp meme brah

2

u/Jafit Nov 12 '15

if you add support for regular expressions, you could have: REEEEEEE!

2

u/RenaKunisaki Nov 12 '15

DAE le dank may mays!?

Not complaining, just shitposting.

3

u/jantari Nov 12 '15

Needs more john cena

1

u/oneofthefewproliving Nov 12 '15

You should create a sub for this

1

u/[deleted] Nov 12 '15

Oh my, memes in my codes! What a time to be alive

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

u/[deleted] Nov 18 '15

This is my favorite thing ever.

1

u/[deleted] Nov 18 '15

> done implying really did it for me.

1

u/[deleted] Nov 19 '15

I fucking love you

1

u/-victorisawesome- Nov 21 '15

You ever head of LOLCODE? http://lolcode.org/

1

u/[deleted] Mar 01 '16

You should ask /u/SeaCowVengeance to let CompileBot use this amazing language

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

u/I-baLL Nov 12 '15

...but we're talking about greentext?

1

u/wormania Nov 12 '15

And the parser is pretty clearly written in python

0

u/[deleted] 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 SyntaxError or TypeError because it will allow the following to silently fail:

try:
   import something
   1 + object + []
except (SyntaxError, TypeError):
   pass 

where something.py is:

python?!?!!? TOP KEK

define 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

u/[deleted] 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

Source

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 start

a branch is sufficient to build a loop.

1

u/benzrf Nov 14 '15

That's goto, not if. if is 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

u/[deleted] 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

u/capitalsigma Nov 12 '15

it looks like it supports recursion and a conditional so yes

0

u/[deleted] Nov 12 '15

[deleted]

1

u/hypervelocityvomit Nov 12 '15

ExitProcess() : fuck(this.shit);