Share your repls and programming experiences

← Back to all posts
SIMP! The language
developer1001 (26)

SIMP

Intro

Simp is a simple layer on top of python (considered a language on its own by some). It is easy to understand and write: its small keywords and easy to access characters were written with the keyboard in mind. It is interpreted and as of right now quite complete.

Features

  • Input/Output
  • Numerous data types:
    • Strings
    • Numbers - equivalent to ints
    • Floats
    • Lists
    • Sets
    • Tuples
    • Hash Maps
  • Datatype manipulation
  • File handling
  • Graphics
  • Functions
  • Classes
  • Polymorphism
  • Support for many libraries
    • SIMP standard libraries:
      • TIME
      • DATETIME
      • RANDOM
      • MATH
      • SYSTEM
      • OS
    • These libraries are still under development:
      • MATPLOTLIB (display graphs)
      • PANDAS (work with data files)
      • REQUESTS (mostly functional)
      • NLIB (Number library)
      • BS4 (BeautifulSoup implementation)
      • SIL (SIMP imaging library)
      • SVL (SIMP video library)
      • TENSORFLOW (SIMP implementation of tensorflow)
      • QUANTUM (SIMP library for Quantum circuits)
      • SIMPGAME (SIMP library specifically for games)
      • NEAT (NEAT implementation in SIMP)
    • MUCH MUCH MORE!

Examples

SIMPle FizzBuzz example

!! FizzBuzz test
!! Write numbers from 1 to 100, but for multiples of 3 write Fizz and for multiples of 5 write Buzz. For multiples of both write FizzBuzz

FOR i @ RANGE[1, 101] -> 
	IF i % 3 == 0 AND i % 5 == 0 ->
		OUT["FizzBuzz"]
	ELSIF i % 3 == 0 ->
		OUT[“Fizz"]
	ELSIF i % 5 == 0 ->
		OUT["Buzz"]
	ELSE ->
		OUT[i]

Following code solves code forces problem 4A

!! solving codeforces problem 4A using SIMP
Input = IN['']
IF NUM[Input] % 2 != 0 OR NUM[Input] != 2 ->
	OUT["YES"]
ELSE ->
	OUT["NO”]

Following code solves code forces problem 71A

!! solving codeforces problem 71A using simp
n = NUM[IN[""]]
words = {}
FOR i @ RANGE[n] ->
	words::ADD[IN[""]]
FOR word @ words ->
	IF LENGTH[word] > 10 ->
		OUT[word{0} + STR[LENGTH(word)-2] + word{LENGTH[word]-1}]
	ELSE ->
		OUT[word]

Following code grabs all a tags from google.com

!! You must run simp install bs4 for it to work
FROM BS4 IMPORT BeautifulSoup & bs
IMPORT REQUESTS

url = 'http://www.google.com'
page = REQUESTS::get[url]
html = page::text
soup = bs[html, 'html.parser']
ps = soup::find_all['a']
FOR p @ ps ->
	OUT[p::string]

SIMPle class example

!! this is a comment
IMPORT RANDOM
OBJ Person ->
	FUNC CONSTRUCT[THIS, name, age] ->
		THIS::name = name
		THIS::age = age
	FUNC REPRESENT[THIS] ->
		RETURN 'My name is ' + THIS::name + ' and my age is ' + STR[THIS::age]
people = {}
names = {"Anton", "Margaret", "John", "Steve", "Sive", "Dave"}
FOR i @ RANGE[50] ->
	people::ADD[Person[RANDOM::choice[names], RANDOM::RANDINT[30,75]]]
	OUT[people{i}]

SIMPle polymorphism example

OBJ Animal ->
	FUNC CONSTRUCT[THIS, name=''] ->
		THIS::name = name
	FUNC talk[] ->
		PASS
OBJ Cat[Animal] ->
	FUNC CONSTRUCT[THIS, name='Cat'] ->
		super[]::CONSTRUCT[name]
	FUNC talk[THIS] ->
		OUT[THIS::name, "says meow"]
OBJ Dog[Animal] ->
	FUNC CONSTRUCT[THIS, name='Dog'] ->
		super[]::CONSTRUCT[name]
	FUNC talk[THIS] ->
		OUT[THIS::name, "says woof"]
OBJ Cow[Animal] ->
	FUNC CONSTRUCT[THIS, name='Cow'] ->
		super[]::CONSTRUCT[name]
	FUNC talk[THIS] ->
		OUT[THIS::name, "says moo"]
noNames = {
	Cat[],
	Dog[],
	Cow[]
}
specials = {
	Cat['Shelly'],
	Dog['Rutherford'],
	Cow['Hayford']
}
FOR noName @ noNames -> noName::talk[]
FOR special @ specials -> special::talk[]

Graphics example

!! FFX is only needed for Mac users, otherwise, just use GFX::
FROM GFX IMPORT FFX
IMPORT GFX
GLOBAL screen
screen = GFX::GRF[]
screen::geometry["500x500"]
screen::title["Graphics are cool"]
FFX::Label[text="This is a label"]::pack[]
FFX::Button[text="Login"]::pack[]
FFX::Label[text="This is another label"]::pack[]
FFX::Button[text="Register"]::pack[]
screen::mainloop[]

Usage

You too can use SIMP lang, and forever stop simping!
Click here to launch the interactive simp terminal! Once there, you can run the example.simp file by using simp example.simp, or access its code by using vim example.simp. If you want to try the graphics, refer to the examples above, and download this zip file. Open it, and add any simp files to the “files” folder. Once that is done, just run the python scrip and from there just run simp [name of file] without the previous files dir.

Notes

  • First off, this language works best with FiraCode font in my opinion due to the large usage of arrows
  • Second, I know there are a couple of things I may have not covered in the examples or the documentation... If you have any questions, post them below.

Credits

All the code and ideas behind this was created by me, @developer1001. If you want to, check out my team (with only one member) here: @RayBoat

Comments
hotnewtop
Coder100 (17010)

mad why are you using exec @developer1001

developer1001 (26)

A true magician never reveals his secrets :) @Coder100
edit: or a coder ;)
edit2: Look below for an answer...

sugarfi (626)

@developer1001 exec is a huge security risk for XSS and code injection - never use it if you have a choice

HahaYes (1913)

@sugarfi lol who would use exec

AmazingMech2418 (1044)

@sugarfi Well, not XSS, but still code injection. (XSS is only JS and is eval, not exec)

sugarfi (626)

@AmazingMech2418
1. my bad, thought this was JS lol
2. exec can do XSS as well, if the JS runtime has it.

AmazingMech2418 (1044)

@sugarfi LOL! The repl included is just the documentation repl.

DaLiteralPanda (11)

I am a simp for your humor

THISISATEST2389 (11)

You guys did not create a language, you just changed python to make it seem like you did. You convert OUT --> print and [] --> () and have python run "print()". You made a layer to python, not a language.

For anyone that does not know 'exec' converts a string to python code

developer1001 (26)

It doesn’t say anywhere in the rules that we can’t do that @THISISATEST2389
edit: plus, it’s not about how the language is created but about the language itself

generationXcode (329)

@THISISATEST2389 oh my egg... that is sad but ig it wasnt written in the rules or anything so i dont really know... EGG RULEZ

Leroy01010 (419)

thats what your supposed to do @THISISATEST2389

sugarfi (626)

@Leroy01010 no it isn't. They are right; this is not a language, and it is most definitely not how you are supposed to make a language.

developer1001 (26)

m8, I don’t mean to be rude, but who are you to decide what is and isn’t a language and how you’re supposed to make one? It said in the rules you where allowed to modify an existing language. Also, it’s me who decides how I code my own language (or an adaptation of one if it makes you happier) @sugarfi

CodeLongAndPros (1591)

@THISISATEST2389 That is called a transpiler. It's not really good for python, but a lot of simple languages are transpiled to ones with compilers.

You made a layer to python, not a language.
Python is a layer to C
C is a layer to ASM
ASM is a layer to machine code
Machine code is a layer to logic gates
Logic gates are a layer to electrons.

In computing, EVERYTHING is an abstraction over something.

I would look a little more into what they are doing before saying "Oh no, it uses python!". Python calls into C. Using wrappers is fine, they might not get full marks, but they obviously spent a lot of time on this.
So, even if they didn't write a full stack for everything, just keep an open mind and don't scream IT'S TRANSPILED

THISISATEST2389 (11)

@CodeLongAndPros It is not using a built parser, it is taking key words and turning them into python tokens. OUT becomes print, and so on. I can see the point in finding the out token and finding what args it has. The syntax is no different from python, just the key words are. When you make a language you are trying to do something different, not the exact same.

Python is not using C syntax or it would look like this

import["lib.h"]

INT MAIN {
print("Hello world") $

}

#include <"file.h">

int main() {
printf("Hello world");
}

sugarfi (626)

@CodeLongAndPros I get that, and I'm not saying that you need a full ecosystem and vm or anything
but in my opinion submitting a language that is literally .replace with lists of tokens, and more seriously passing off python libraries and functions (matplotlib, bs4, literally the whole stdlib) as their own is not acceptable in my opinion.

THISISATEST2389 (11)

@CodeLongAndPros Also I think you should have a look at their code before you post defending them.

CodeLongAndPros (1591)

@THISISATEST2389 Python takes symbols and coverts them to c symbols.

CodeLongAndPros (1591)

@THISISATEST2389 Oh, it's not that I endorse it. But the fact that it's transpiled is what I'm defending.

sugarfi (626)

@CodeLongAndPros no? the only way python can interface with c is through ctypes - internally it uses a vm.

CodeLongAndPros (1591)

@sugarfi The Python interpreter calls C.

sugarfi (626)

@CodeLongAndPros it's written in C, it doesn't call it...

THISISATEST2389 (11)

@CodeLongAndPros just because it uses C does not mean python is just C's keywords changed. Python is not typed and has different way of handling memory.

THISISATEST2389 (11)

@CodeLongAndPros anyway C is a compiled language, you can not convert a string to c/c++ without using tiny-cc or something to do the work for you.

THISISATEST2389 (11)

@CodeLongAndPros Lets say they did put a lot of work into this project, their entire code base is 76 lines. 76! Just to implement sockets to do https requests would need more then that (edit: I am talking without using a library to handle everything for you). You get my point, they are just changing the words to python not the syntax. 'OUT' = 'print' and so on.

THISISATEST2389 (11)

@developer1001 Think about this contest as writing a paper, you on the other hand has taken a paper from python and changed all the fancy words to different words. Nothing is new here, it is just python with different words. Using exec is not how you make a language, its how you copy one. I could see if you were using it for calculations or something (those are really hard). But to use it for all your syntax :(

developer1001 (26)

If it makes you happier, I added “a layer on top of python” in the intro
Also, I will have to respectfully disagree with you on that, @THISISATEST2389 since this is not the same as writing a paper. In coding, nobody cares about how you did something; they just care about the result. In my opinion, it is important to write good and neat code and whatnot but the reason is so that in large projects you don’t get lost, and it is easier to find bugs.
Look, truth is, I saw this jam two days ago and really wanted to submit something, anything! I started building a lexer and parser objects and whatnot, and after a lot of lines of code, I had gotten nowhere(just simple mathematical and logical expressions). Thinking I wasn’t going to make it in time, an idea struck me. What if I could just transpile the written code into python and run it as is. And so that’s what I did.
So, if you don’t mind, could you at least look at the language and syntax, and the practicality of the language, without having to think what is going on behind the scenes? Otherwise, I would appreciate it if you just let it be, as in no moment I cheated or didn’t follow the rules of the jam. If you have a problem with the ruleset, it is not me you have to contact.
Thanks.

developer1001 (26)

@developer1001 I also thought it was quite clever as it fulfilled all the steps: It tokenised the elements like a lexer would, but then instead of having a thousand if statements, I just had python do the parser and interpreter for me. This not only resulted in a shorter codebase, but also in a more efficient 'language' with a few working libraries. I still had to make changes to these, though not many, just for the GFX library mostly...Anyway, I think the comment above is more than a sufficient explanation for anyone who is coming back to attack....

sugarfi (626)

@developer1001 people care a lot about how you do something actually.

Mainmenu (12)

@developer1001 first of all, you don't need 1000s of statements. Your language is nothing more then python. Readability or not, it's python. Nothing is different. I agree with @THISISATEST2389.

Mainmenu (12)

@developer1001 why would I look at the practically. I know what python can do. Look at some of the other languages and see how they did it. In my eyes you cheated if it was in the roles or not. We came here to see new ways of doing things, not literally python with different key words. I see you did not have time to finish. I would have liked to see what you were working on first. I had to stay up until 3 am with work in the morning for days to get were I was at. (I also had no time)

developer1001 (26)

a) Congratulations for being so dedicated @Mainmenu
b) What part of 'I would appreciate it if you just let it be,’ and ‘it is not me you have to contact' do you not understand? I mean, I’m not trying to be rude, but I’m tired of people coming here to make the same statement, when I already explained myself above. Have you stopped to think that people may have different lives and live in different places than you, leaving them with less time to complete the jam? Get off my back, and if you have a problem, I repeat, it’s not me you have to talk to.
c) My original work was on my desktop. If you want to see it, I will upload a repl and post a link here.

TheDrone7 (1775)

Moving to share since, 1 member teams are not allowed. This was already specified in the FAQ on the blog post.

PetryshynVlad (1)

My wife's boyfriend liked this

ironblockhd (425)

By life's moyfriend wiked mhis

VulcanWM (2338)

Is your wife cheating on you? lol @PetryshynVlad

DannyIsCoding (695)

Does SIMP have an acronym?

developer1001 (26)

“Squirrels in my pants” XD @DannyIsCoding

developer1001 (26)

Haven’t you seen the memes? @DannyIsCoding

DannyIsCoding (695)

@developer1001 Ummmm... Yes of course.
But i thought it had another meaning idk ¯_(ツ)_/¯

developer1001 (26)

Well it also means its SIMPle but you know... I thought the wordplay would be funny @DannyIsCoding

HahaYes (1913)

oh cool you do codeforces too!