Share your repls and programming experiences

← Back to all posts
🔲 Mirror 🔳 - My Other Programming Language!
DynamicSquid (5022)

Hi!

I made another language. It's called Mirror.

It's statically typed and riddled with bugs. It's coded using Rust and transpiles down to C++.

I only had like 10 hours to make this so it isn't much. And this is also my first time coding in Rust so the code is really bad.

I'll probably revisit this sometime in the future though.

Check out its GitHub repo!


Here's Mirror's syntax.

Mirror has a built in print function that acts as standard output.

print("Hello Mirror!\n")

Variables are created using the set keyword. Their type is automagically deduced.

set name = "squid"

Conditionals are as expected.

if "squid" == "smart" {
  print("squid is smart")
}
else if "squid" == "octopus" {
  print("no")
}
else {
  print("squid")
}

Functions are defined using the def keyword.

def become_squid(string name) {
  print(name)
  print(" is now a squid")
}

become_squid("octopus")

Ranged based for loops are also supported.

set name = "squid"
for ch in name {
  print(ch)
  print(' ')
}

And arrays.

set arr = [ 5, 6, 7 ]
for num in arr {
  print(num)
}

And that's it!


Write code in the source.mir file. Here's some code to reverse your name. Try it out!

print("Enter your name: ")

set name = input()
set reverse = ""

for ch in name {
  reverse = ch + reverse
}

for ch in reverse {
  print(ch)
  print(' ')
}

print("\n")

Enjoy :)

Comments
hotnewtop
Bookie0 (6358)

Mirror mirror on the wall...

Who's the fairest of them all?

me

RayhanADev (2595)

@Bookie0

Insert Bookie0’s “fair” face

lmao, I’m sure you look fair xD.

Wilke000 (636)

You @Bookie0... maybe... or maybe not, it depends on what mirror it is, the good one, or the bad one.
That is the good one

RayhanADev (2595)

Ahhh I couldn’t wait for you to release this! Awesome language @DynamicSquid!

RayhanADev (2595)

@DynamicSquid ‘when you made it public‘. You’ve talked about and I was waiting for you to post it!

RayhanADev (2595)

@DynamicSquid mhh sometime within the last week. You mentioned Mirror (and I think gave the Github link I’m pretty sure).

DynamicSquid (5022)

@RayhanADev I'm not sure what I meant by that. But this language is public, anyone can use it...

RayhanADev (2595)

@DynamicSquid sigh. I mean you told me about it (a project you were working on) before you made the post xD.

DynamicSquid (5022)

@RayhanADev ahhhhhhhhhhhhhhhhhh I get it now lol xD

RayhanADev (2595)

@DynamicSquid (°▽°) yay finally. If you still didn’t I’d have to resort to more extreme methods.

LoganSpong (57)

Me: creates test programming language with regex and stuff

if a=6
print "a"
else
print "b"

You:
Me: WHAT THE HOW DOES HE MAKE THIS HOW JUST HOW THIS IS AMAZING

LoganSpong (57)

also if you look up "night programming language" on google, your github repository is the first result! Congrats!

LoganSpong (57)

@DynamicSquid i want to make a pl but whenever i do, it always breaks down at the if, while and for statements. and operation parsing is impossible for me

code913 (17)

In conclusion,
squids can now develop programming languages

AmazingMech2418 (1102)

Yay! Python but better!

AmazingMech2418 (1102)

@DynamicSquid By the way, in Python, type

from __future__ import braces

Why Mirror is better. LOL!

DynamicSquid (5022)

@AmazingMech2418 lol! I never realized Python had that easter egg built it, that's pretty cool!

fuzzyastrocat (1867)

@DynamicSquid Python has 50 billion easter eggs hidden around... try import this or import antigravity.

DynamicSquid (5022)

@fuzzyastrocat I need some eastwr eggs. What about import squid it'll summon an ascii squid

fuzzyastrocat (1867)

@DynamicSquid Should be squod so that it's harder to find.

from __future__ import dynamic_whitespace => SyntaxError: Not a Chance

DynamicSquid (5022)

@fuzzyastrocat from future import dynamic_whitesquid

fuzzyastrocat (1867)

@DynamicSquid ImportError: Cannot find requisitioned squod in the current directory

DynamicSquid (5022)

@DungeonMaster00 Yeah, it's a pretty cool language

DungeonMaster00 (190)

@DynamicSquid yeah im thinking about making one of my own.

it may or may not transpile to rust and bye

fuzzyastrocat (1867)

Nice! Though transpilation to C++ for this kind of language feels a bit cheaty :)

DynamicSquid (5022)

@fuzzyastrocat Yeah I thought that too. But I really wanted to practice making a transpiled language, but yeah I probably should of done it differently. I was thinking of making Mirror a functional language actually but I never got around to it for some reason

19wintersp (1142)

Reminds me of python with curly braces :)

DynamicSquid (5022)

@19wintersp Yeah lol. But it's statically typed and transpiled so that's different

19wintersp (1142)

@DynamicSquid Nice! Finally, Python's readability with type safety and without indentation!

samfierycreeper (1)

Lol for 10 hours still looks 500% nicer that JavaScript.

firefish (953)

@ZDev1 haha palindrome go brrr

DynamicSquid (5022)

@firefish oh, how's the pkg manger going?

firefish (953)

@DynamicSquid wut i'm too busy working on slicelang to do really anything (wanna join the project? we are currently working on a garbage transpiler. considering you've made one, do you consent to us (me) ransacking Mirror?)

firefish (953)

@DynamicSquid I'll take that as permission to copy mirror for our trash transpiler.

firefish (953)

@DynamicSquid

wut i'm too busy working on slicelang to do really anything (wanna join the project? we are currently working on a garbage transpiler. considering you've made one, do you consent to us (me) ransacking Mirror?)

read the previous comment

DynamicSquid (5022)

@firefish I would, but I'm way to busy :( I barely have enough time to code Night

firefish (953)

@DynamicSquid hm... sad :(
but if I erm... were to slightly change mirror's source to make slicelang transpile down?

DynamicSquid (5022)

@firefish sure, I'm fine with that. just don't copy everything lol

firefish (953)

@DynamicSquid well we are only doing the bad transpiler to get the number of slice repos to 200 before the real thing comes out

zplusfour (916)

um hi squid
can you tell me how can i go into language design and development?
thanks

edit: and plz answer me, shud i use Rust or C++?

DynamicSquid (5022)

@ZDev1 C++. Try to make a lexer first

zplusfour (916)

@DynamicSquid yeah!
but can you tell where did you learnt?

firefish (953)

@ZDev1 you learn from craftinginterpreters.com

xxpertHacker (931)

How do you disambiguate between the condition and body of if statements?

Are brackets optional in if statements?
If not, you would have to change your example:

if "squid" == "smart" {
    print("squid is smart")
} else if "squid" == "octopus" {
    print("no")
} else {
    print("squid")
}

to

if "squid" == "smart" {
    print("squid is smart")
} else {
    if "squid" == "octopus" {
        print("no")
    } else {
        print("squid")
    }
}

To keep it more consistent in its rules ^.

To remedy this, I suggest introducing an keyword that combines both, the if and the else keywords. I call it elif.

You could use it like so:

if "squid" == "smart" {
    print("squid is smart")
} elif "squid" == "octopus" {
    print("no")
} else {
    print("squid")
}
DynamicSquid (5022)

@xxpertHacker Yeah, I was definitely thinking of an elif to keep it simpler. But it separates condition from body by the curly braces.

DynamicSquid (5022)

@xxpertHacker Oh quick question, how do you initialize a shared_ptr with NULL? Does the default constructor initialize it will NULL?

xxpertHacker (931)

@DynamicSquid Why would you want to initialize a shared_ptr with null? That sounds... counterintuitive?

xxpertHacker (931)

@DynamicSquid Just tried it in a Repl, this works fine:

std::shared_ptr<int> x = nullptr;
xxpertHacker (931)

@DynamicSquid Sorry for the third ping to your question, but they're null by default.

#include <iostream>
#include <memory>

int main() {
	std::shared_ptr<int> x;

	std::wcout
	<< std::boolalpha
	<< (x.get() == nullptr); // true
}

Unless you need the literal C macro NULL, which is an integer, not a pointer.

code913 (17)

Are you just converting it to C++ then running it?

DynamicSquid (5022)

@code913 yup, that's what a transpiled lang is. But like Fuzzy said I kinda cheated since the syntax is so similar and there aren't a lot of differences, but i didnt have much time to do this

code913 (17)

@DynamicSquid ight imma head out gtg attend zoom online classes

ThisUserTaken (245)


squids takin over repl.it

elipie (355)

teach me your sorcery now.

elipie (355)

@DynamicSquid i need help again can you get on the PieC++Main repl or do you not have time...

firefish (953)

@elipie craftinginterpreters.com, what sorcery

HarperframeInc (456)

Another language!?

What's going to happen to Night?
Are you going to merge languages?

DynamicSquid (5022)

@HarperframeInc What no. I did this for a school project. Night is still actively developed

firefish (953)

ew include! macro
if you want to try cargo maybe you can try an old enemy friend @Coder100's template known as RUST PACKAGES POG POG CRATE MOMENT or something like that. I'll make a flipping tutorial on the grammatical implications of pog, it's waiting to happen

Hope you know about the early return operator:

foo()? is short hand for

if let Err(e) = foo() {
    e
} else {}

Hope that clears things up

realTronsi (923)

@firefish

here you go spreading your eye rape syntax highlighting again
DynamicSquid (5022)

@firefish didn't have time to learn cargo, and yes, I know what the ? does

firefish (953)

@DynamicSquid i can er teach you lol
it need no learning

DynamicSquid (5022)

@firefish it's fine lol. oh, how's mat1's pinger? is it keeping the cdn alive?

Code1Tech (106)

Syntax is like python, why did you choose it to be like that?

DynamicSquid (5022)

@Code1Tech Cause I only had 10 hours and I couldn't think of anything else :)

But it's nothing like Python. It's transpiled and statically typed

Code1Tech (106)

K. Also, nice! For 10 hours, I'd say that is very good!
I could never write a language in 10 hours or under.
Correction: I would never be able to make a language (xD)
tl;dr, Good job!
@DynamicSquid