🔲 Mirror 🔳 - My Other Programming Language!
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 :)
impressive for 10 hours
@realTronsi Thanks!
Ahhh I couldn’t wait for you to release this! Awesome language @DynamicSquid!
@RayhanADev wdym by "release this"?
@DynamicSquid ‘when you made it public‘. You’ve talked about and I was waiting for you to post it!
@RayhanADev huh? when did I say that?
@DynamicSquid mhh sometime within the last week. You mentioned Mirror (and I think gave the Github link I’m pretty sure).
@RayhanADev I'm not sure what I meant by that. But this language is public, anyone can use it...
@DynamicSquid sigh. I mean you told me about it (a project you were working on) before you made the post xD.
@RayhanADev ahhhhhhhhhhhhhhhhhh I get it now lol xD
@RayhanADev sorry I'm slow sometimes
@DynamicSquid (°▽°) yay finally. If you still didn’t I’d have to resort to more extreme methods.
@DynamicSquid lmao.
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 lol thank you!!
@DynamicSquid night tho
also if you look up "night programming language" on google, your github repository is the first result! Congrats!
@LoganSpong ik! it's so cool!
@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
@LoganSpong Try making a lexer
In conclusion,
squids can now develop programming languages
NICE! it seems like it has python syntax!
@JBYT27 thanks!
np :) @DynamicSquid
Yay! Python but better!
@AmazingMech2418 yay thanks!
@DynamicSquid You're welcome!
@AmazingMech2418 lol! I never realized Python had that easter egg built it, that's pretty cool!
@DynamicSquid Python has 50 billion easter eggs hidden around... try import this
or import antigravity
.
@fuzzyastrocat I need some eastwr eggs. What about import squid
it'll summon an ascii squid
@DynamicSquid Should be squod
so that it's harder to find.
from __future__ import dynamic_whitespace
=> SyntaxError: Not a Chance
@fuzzyastrocat from future import dynamic_whitesquid
@DynamicSquid ImportError: Cannot find requisitioned squod in the current directory
Nice! !eciN
@Coder100 thanks!
wait hold up why does your compiler use namespace std @DynamicSquid
seems like a lot of unnecessary overhead @DynamicSquid
oh cool rust
@DungeonMaster00 Yeah, it's a pretty cool language
@DynamicSquid yeah im thinking about making one of my own.
it may or may not transpile to rust and bye
Nice! Though transpilation to C++ for this kind of language feels a bit cheaty :)
@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
Reminds me of python with curly braces :)
@19wintersp Yeah lol. But it's statically typed and transpiled so that's different
@DynamicSquid Nice! Finally, Python's readability with type safety and without indentation!
@19wintersp Yup lol!
Lol for 10 hours still looks 500% nicer that JavaScript.
some lil project :)
https://mirror.zdev1.repl.co/
@firefish oh, how's the pkg manger going?
@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?)
@DynamicSquid I'll take that as permission to copy mirror for our trash transpiler.
@firefish what no
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
@firefish I would, but I'm way to busy :( I barely have enough time to code Night
@DynamicSquid hm... sad :(
but if I erm... were to slightly change mirror's source to make slicelang transpile down?
@firefish sure, I'm fine with that. just don't copy everything lol
@DynamicSquid well we are only doing the bad transpiler to get the number of slice repos to 200 before the real thing comes out
@MatthewADev this project is too old smh
@zplusfour ik just cuz i am bored
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++?
@ZDev1 C++. Try to make a lexer first
@DynamicSquid yeah!
but can you tell where did you learnt?
@ZDev1 trial and error :)
@DynamicSquid oh lol
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") }
@xxpertHacker Yeah, I was definitely thinking of an elif
to keep it simpler. But it separates condition from body by the curly braces.
@xxpertHacker Oh quick question, how do you initialize a shared_ptr with NULL? Does the default constructor initialize it will NULL?
@DynamicSquid Why would you want to initialize a shared_ptr with null? That sounds... counterintuitive?
@DynamicSquid Just tried it in a Repl, this works fine:
std::shared_ptr<int> x = nullptr;
@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 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
@DynamicSquid ight imma head out gtg attend zoom online classes
teach me your sorcery now.
@DynamicSquid i need help again can you get on the PieC++Main
repl or do you not have time...
Another language!?
What's going to happen to Night?
Are you going to merge languages?
@HarperframeInc What no. I did this for a school project. Night is still actively developed
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
here you go spreading your eye rape syntax highlighting again
@firefish didn't have time to learn cargo, and yes, I know what the ?
does
@DynamicSquid i can er teach you lol
it need no learning
@firefish it's fine lol. oh, how's mat1's pinger? is it keeping the cdn alive?
@DynamicSquid er better check
Syntax is like python, why did you choose it to be like that?
@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
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
@Code1Tech Oh thank you!!
Python + cpp + js?
@Codemonkey51 + i don't really know what I'm doing
Lmao cool @DynamicSquid
Mirror mirror on the wall...
Who's the fairest of them all?
me@Bookie0 lol nice!
yay thx :) @DynamicSquid
@Bookie0
lmao, I’m sure you look fair xD.
@RayhanADev yaaaay
@Bookie0 (^_−)−☆
@Bookie0 that's a nice face
yay thxxx ;) @elburg
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
@Wilke000 lol