Skip to content
← Back to Community
πŸ”² Mirror πŸ”³ - My Other Programming Language!
Profile icon
h
has Hacker Plan
DynamicSquid

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 :)

Voters
Profile icon
N3rdL0rd
Profile icon
maxina
Profile icon
zplusfour
Profile icon
figglediggle
Profile icon
LoganSpong
Profile icon
ninja2k11
Profile icon
KeironTravis
Profile icon
TheOceanFace
Profile icon
mkhoi
Profile icon
BotsBoots
Comments
hotnewtop
Profile icon
Bookie0

Mirror mirror on the wall...

Who's the fairest of them all?

me

Screen Shot 2020-11-14 at 3.20.25 PM

Profile icon
DynamicSquid

@Bookie0 lol nice!

Profile icon
Bookie0

yay thx :) @DynamicSquid

Profile icon
RayhanADev

@Bookie0

Insert Bookie0’s β€œfair” face

lmao, I’m sure you look fair xD.

Profile icon
Bookie0
Profile icon
RayhanADev

@Bookie0 (^_βˆ’)βˆ’β˜†

Profile icon
elburg

@Bookie0 that's a nice face

Profile icon
Bookie0

yay thxxx ;) @elburg

Profile icon
Wilke000

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

Profile icon
Bookie0
Profile icon
realTronsi

impressive for 10 hours

Profile icon
DynamicSquid

@realTronsi Thanks!

Profile icon
RayhanADev

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

Profile icon
DynamicSquid

@RayhanADev wdym by "release this"?

Profile icon
RayhanADev

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

Profile icon
DynamicSquid

@RayhanADev huh? when did I say that?

Profile icon
RayhanADev

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

Profile icon
DynamicSquid

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

Profile icon
RayhanADev

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

Profile icon
DynamicSquid

@RayhanADev ahhhhhhhhhhhhhhhhhh I get it now lol xD

Profile icon
DynamicSquid

@RayhanADev sorry I'm slow sometimes

Profile icon
RayhanADev

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

Profile icon
RayhanADev
Profile icon
DynamicSquid
Profile icon
LoganSpong

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

Profile icon
DynamicSquid

@LoganSpong lol thank you!!

Profile icon
LoganSpong

@DynamicSquid night tho

Profile icon
LoganSpong

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

Profile icon
DynamicSquid

@LoganSpong ik! it's so cool!

Profile icon
LoganSpong

@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

Profile icon
DynamicSquid

@LoganSpong Try making a lexer

Profile icon
LoganSpong
Profile icon
code913

In conclusion,
squids can now develop programming languages

Profile icon
DynamicSquid
Profile icon
JBloves27

NICE! it seems like it has python syntax!

Profile icon
DynamicSquid

@JBYT27 thanks!

Profile icon
JBloves27
Profile icon
AmazingMech2418

Yay! Python but better!

Profile icon
DynamicSquid

@AmazingMech2418 yay thanks!

Profile icon
AmazingMech2418

@DynamicSquid You're welcome!

Profile icon
AmazingMech2418

@DynamicSquid By the way, in Python, type

from __future__ import braces

Why Mirror is better. LOL!

Profile icon
DynamicSquid

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

Profile icon
fuzzyastrocat

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

Profile icon
DynamicSquid

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

Profile icon
fuzzyastrocat

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

from __future__ import dynamic_whitespace => SyntaxError: Not a Chance

Profile icon
DynamicSquid
Profile icon
DynamicSquid

@fuzzyastrocat from future import dynamic_whitesquid

Profile icon
fuzzyastrocat

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

Profile icon
Coder100

Nice! !eciN

Profile icon
DynamicSquid

@Coder100 thanks!

Profile icon
Coder100
Profile icon
Coder100

wait hold up why does your compiler use namespace std @DynamicSquid

Profile icon
Coder100

seems like a lot of unnecessary overhead @DynamicSquid

Profile icon
DynamicSquid
Profile icon
firefish

mirror gut

night better

Profile icon
DynamicSquid
Profile icon
DungeonMaster00

oh cool rust

Profile icon
DynamicSquid

@DungeonMaster00 Yeah, it's a pretty cool language

Profile icon
DungeonMaster00

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

it may or may not transpile to rust and bye

Profile icon
fuzzyastrocat

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

Profile icon
DynamicSquid

@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

Profile icon
19wintersp

Reminds me of python with curly braces :)

Profile icon
DynamicSquid

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

Profile icon
19wintersp

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

Profile icon
DynamicSquid

@19wintersp Yup lol!

Profile icon
samfierycreeper

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

Profile icon
zplusfour

some lil project :)
https://mirror.zdev1.repl.co/

Profile icon
firefish

@ZDev1 haha palindrome go brrr

Profile icon
zplusfour

@firefish indeed

Profile icon
DynamicSquid

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

Profile icon
firefish

@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?)

Profile icon
firefish

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

Profile icon
DynamicSquid

@firefish what no

Profile icon
firefish

@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

Profile icon
DynamicSquid

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

Profile icon
firefish

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

Profile icon
DynamicSquid

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

Profile icon
firefish

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

Profile icon
MatthewADev
Profile icon
zplusfour

@MatthewADev this project is too old smh

Profile icon
MatthewADev

@zplusfour ik just cuz i am bored

Profile icon
zplusfour

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++?

Profile icon
DynamicSquid

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

Profile icon
zplusfour

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

Profile icon
DynamicSquid

@ZDev1 trial and error :)

Profile icon
zplusfour
Profile icon
firefish

@ZDev1 you learn from craftinginterpreters.com

Profile icon
xxpertHacker

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") }
Profile icon
DynamicSquid

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

Profile icon
DynamicSquid

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

Profile icon
xxpertHacker

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

Profile icon
xxpertHacker

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

std::shared_ptr<int> x = nullptr;
Profile icon
xxpertHacker

@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.

Profile icon
code913

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

Profile icon
DynamicSquid

@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

Profile icon
code913

@DynamicSquid ight imma head out gtg attend zoom online classes

Profile icon
ThisUserTaken
Profile icon
ThisUserTaken

:O

Profile icon
elipie

teach me your sorcery now.

Profile icon
DynamicSquid
Profile icon
elipie

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

Profile icon
firefish

@elipie craftinginterpreters.com, what sorcery

Profile icon
HarperframeInc

Another language!?

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

Profile icon
DynamicSquid

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

Profile icon
HarperframeInc
Profile icon
firefish

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:
image

foo()? is short hand for

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

Hope that clears things up

Profile icon
realTronsi

@firefish

here you go spreading your eye rape syntax highlighting again
Profile icon
Coder100
Profile icon
DynamicSquid

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

Profile icon
firefish

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

Profile icon
DynamicSquid

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

Profile icon
firefish

@DynamicSquid er better check

Profile icon
Code1Tech

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

Profile icon
DynamicSquid

@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

Profile icon
Code1Tech

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

Profile icon
DynamicSquid

@Code1Tech Oh thank you!!

Profile icon
NoNameByProgram

Screen Shot 2020-11-14 at 10.44.54 PM
electronics don't work underwater

Profile icon
DynamicSquid
Profile icon
Codemonkey51

Python + cpp + js?

Profile icon
DynamicSquid

@Codemonkey51 + i don't really know what I'm doing

Profile icon
Codemonkey51