Share your repls and programming experiences

← Back to all posts
🌕 Night - My Programming Language 🌑
DynamicSquid (4914)

Night

I feel like my logo is a little too fancy. I'm working on something simpler. Any suggestions?

Hey guys! This is my language I'm currently working on. It's still in early development, so it can't do much yet, but I still have a long way to go.

Also thanks to @ChezCoder and @targetfanttthat for helping me out in the early stages of my language. And thanks to @mathiasaboye as well for the logo idea.

You can also view my language on GitHub as well for more details and an inside look at future plans, and the code! And don't forget to leave star :)

Anyway, I modified it a bit here, so you can run the repl and code directly. All you have to do is run the repl, write your code in the console, and then, type in RUN, and hit ENTER to run the code.

Like this:

print "Hello World!\n";

RUN

Try it out!

Note: To paste text in the console, use Ctrl + Shift + V.

Another Note: The RUN command actually isn't part of my language, but I added it in so it's easy for you guys to run the code here.


Documentation

Standard input:

print "Hello World!\n";

// this is a comment

RUN

It can basically print any expression (you'll see later).

Variables:

// variable initialization
bit a = true && false; // bool
syb b = 's'; // char
int c = 2 + 3;
dec d = 3.14 * 2.73; // float
str e = "squid";

int f; // variable declaration
f = 10; // variable assignment

RUN

Expressions:

Note: operator precedence follows C++ style.

int a = 2 + 3; // supports '+ - / * % ( )' all of those
print a % (2 + 1);
print "\n";

bit b = !true && false; // supports `! && || == != ( )` all of those
print true && ("Squid" == "smart");
print "\n";

str c = "dynamic " + "squid"; // supports string concatenation
c = c + " is smart";
print c + "\n";

RUN

If Statements:

This is the good part :)

int numberOfLegs = 10;
bit isSmart = true;

if (isSmart && (numberOfLegs == 8 || numberOfLegs == 10))
{
	// nested if statements work fine!
	if (numberOfLegs == 8)
	{
		print "You're an octopus!\n";
	}
	else
	{
		print "You're a squid!\n";
	}
}
else if (!isSmart && numberOfLegs == 2)
{
	print "You're a human!\n";
}
else if (isSmart && numberOfLegs == 4)
{
	print "Hi pet!\n";

	if (true)
	{
		print "Dogs are better than cats\n";
	}
	else
	{
		print "Cats are better than dogs\n";
	}
}
else
{
	print "Who are you??\n";
}

RUN

And that's it! Make sure to check out my GitHub page for more info! And feel free to leave any feedback or questions in the comments below.

Enjoy :)

Comments
hotnewtop
pr0p3rno0b10 (33)

How did you make your logo? Did you use a website?

DynamicSquid (4914)

@pr0p3rno0b10 it's a coding language that let's you create graphics easily

HenryZelonka1 (91)

@DynamicSquid
That's pretty good for processing. Nice!

BobTheTomatoPie (3361)

Its awesome! The code is so out of my mental range it is frightening

StringentDev (229)

How did you create the programming language?
good job btw

DynamicSquid (4914)

@Lethdev2019 oh you can check out my github page for more info on the code. also thanks!!

StringentDev (229)

i cannot keep this in anymore:
can i help build and refine the website?

I have been building a css library called "Flightcss" which is fully customisable in theme. (even MarcusWeinberger likes it)

If i am able to help - i will need a nodejs repl (also, if you create a team called "night" you can get a url like "web.night.repl.co") called "web" (if you have a team called Night). that is literally it.

also, the current website violates one design recommendation (google even recommends this) - do not use black and white.
this is due to eyestrain so it is better if you use #222 and #eee or #222 #ddd.

still though great work so far! :)

@DynamicSquid

DynamicSquid (4914)

@Lethdev2019 hmm... sure I guess. I'm not that good with html (the only html I know is from w3schools lol) so I probably won't be of much help. want me to invite you?

also about the url, I'm just coding on repl.it, but i'll definitely switch over to another domain name once i'm done

StringentDev (229)

Hi dynamic squid - can i ask you to come look at the webpage. sadly, i could not accept the changes made as they would cramp the page on mobile and having search on references is not a good idea as the search is for the entire site. but search now works. search for "display" and then "hghhdgfj" (you need to press enter.) @DynamicSquid

StringentDev (229)

@DynamicSquid we also, we have 17 results so far, come on to the night repl so we can talk further.
thanks,
lethdev2019.

CuriousMonkey (48)

can you give me a link i cant find it [email protected]

CuriousMonkey (48)

can you give me a link to your github page where it shows you how to make a [email protected]

DynamicSquid (4914)

@CuriousMonkey you mean a tutorial on how to make a language?

CuriousMonkey (48)

ye you said it was on your github page but i couldn't find it there @DynamicSquid

CuriousMonkey (48)

@DynamicSquid OOF well can you make one in the future i wanna get 5000$ dollars for the jam xD

DynamicSquid (4914)

@CuriousMonkey too lazy lol. really busy with actually making the language. maybe once it's done idk

viraatvv (147)

it's built around c# and python, right?

DynamicSquid (4914)

@viraatvv kind of yes. I tried to combine the simplicity of python with the type concepts of the C family

viraatvv (147)

@DynamicSquid wow. also, this is unbelievable. I think your language could actually be successful when you release it

HenryZelonka1 (91)


Hey! Humans are smart.

Barry123 (350)


It seems like octopuses and squids are smarter

HenryZelonka1 (91)

@Barry123
Hmmmm... So strange considering that @DynamicSquid should not be biased at all.

DynamicSquid (4914)

@Codemonkey51

print "Monkeys are good too!\n";

RUN
firefish (948)

@DynamicSquid You should make it into a REPL... also Shift+Insert is another way to paste in console

[deleted]

Nice! Btw, You should add loops

DynamicSquid (4914)

@CarlosRosiles thank you!! also, you can take a look at my github page to see what I'm working on next. right now, I'm doing functions, but loops are coming after

[deleted]

@DynamicSquid All right. Keep up the good work!

Codemonkey51 (1057)

this looks amazing it could be added to repl. if you want to do that go here: https://github.com/replit/polygott and look thru some files in languages/ to see how it works and how you could add ur lang in a pr

DynamicSquid (4914)

@Codemonkey51 oh wow! I never knew I could add my language to repl. I'll take a look at it, thanks!!

Codemonkey51 (1057)

thats just backend btw they would still have to add it to frontend @DynamicSquid

Codemonkey51 (1057)

thats the base docker image it will be on replservers but not a language makeable thru the new repl button @DynamicSquid

DynamicSquid (4914)

@Codemonkey51 oh, I see. is there a way to do the front end?

TheForArkLD (770)

@DynamicSquid ill help you
1. make github account
2. fork polygott
3. open languages/
4. add night.toml
5. ill give you toml file to you by discord ( teach your discord name to me pls )

TheForArkLD (770)

@DynamicSquid and you forgot add run program by file

DynamicSquid (4914)

@TheForArkLD I did steps 1-5, but I don't have discord. but I forked it though. could you send the info through like a pull request or something? https://github.com/DynamicSquid/polygott/tree/master/languages

DynamicSquid (4914)

@TheForArkLD also what do you mean when you say run by file? like when i coded my language I wrote the code in a file, but for this post, I changed it so you can write code in the condole

TheForArkLD (770)

@DynamicSquid i want run program by file
example : ./night main.night

TheForArkLD (770)

@DynamicSquid no, i send toml file for you.
and oh, ill send link here

TheForArkLD (770)

@DynamicSquid nvm i sended pr to you
(./night is for boot repl, ./night file is for run program by file)

Codemonkey51 (1057)

check the circleci errors bc those need to pass for it to be merged @DynamicSquid

DynamicSquid (4914)

@Codemonkey51 what is circleci? I can see it building and testing, but what does that mean?

TheForArkLD (770)

@DynamicSquid i want run program by file...

DynamicSquid (4914)

@TheForArkLD couldn't you type in ./night?

TheForArkLD (770)

@DynamicSquid HEY WE DID IT
TEST SUCCESS!!!!

TheForArkLD (770)

@DynamicSquid BUILD_AND_TEST_CHANGED SUCCESS
BUILD_AND_TEST WILL SUCCESS!!!

DynamicSquid (4914)

@TheForArkLD YAY!!! wait, but what does that mean? like what do the tests actually do?

TheForArkLD (770)

@DynamicSquid uhhh build_and_test failed
bc not night error

TheForArkLD (770)

@DynamicSquid that fail means you cant add that

TheForArkLD (770)

@DynamicSquid sorry type miss i fixed comment

DynamicSquid (4914)

@TheForArkLD oh, aw.. is there a way to fix it?

DynamicSquid (4914)

@TheForArkLD oh, it's fine anyway. thanks for trying though!

Codemonkey51 (1057)

well if you guys fix the error circle ci is throwing they can merge it :/ @DynamicSquid

DynamicSquid (4914)

@TheForArkLD oh, so, it turns out there was a bug preventing people from merging successfully. the updates are in the pr. but they said that it's better to just create a template with a binary of your language since they're not at that point yet where you can add languages easily

MocaCDeveloper (651)

I LOVE the fact that you're taking it easy and making it simple since it is your first go at making a programming language. I should've done that. It is way easier to just make a copied version of a language then adapt the copied version of a language into your own as time goes on.
I, on the other-hand, tend to get myself caught up on a whole bunch of useless stuff(that probably don't even have a use) and waist my time when I could be fixing the hundreds of bugs my programming language has, lol.

But good job man! You're by far wayy smarter and wayy more advanced than me. Keep it up you're doing great!!

DynamicSquid (4914)

@targetfanttthat Oh thanks! I've learned the hard way that when trying something new, go the easy route first to learn what you're actually doing. Trust me, I've fell down that rabbit hole many times before and it was a pain. But thanks! You're going great with your language as well!

KimiTian08 (11)
int numberOfLegs = 2;
bit isSmart = true;

if (isSmart && (numberOfLegs == 8 || numberOfLegs == 10))
{
    // nested if statements work fine!
    if (numberOfLegs == 8)
    {
        print "You're an octopus!\n";
    }
    else
    {
        print "You're a squid!\n";
    }
}
else if (!isSmart && numberOfLegs == 2)
{
    print "You're a human!\n";
}
else if (isSmart && numberOfLegs == 4)
{
    print "Hi pet!\n";

    if (true)
    {
        print "Dogs are better than cats\n";
    }
    else
    {
        print "Cats are better than dogs\n";
    }
}
else
{
    print "Who are you??\n";
}

RUN
OUTPUT:

Who are you??

umm

a smart human?
mathiasaboye (86)


I think it could look nice if you removed the "N"

and maybe add more stars?
DynamicSquid (4914)

@mathiasaboye oh interesting... thanks for the idea!

hhbo64 (4)

How do you make a Lang?

DynamicSquid (4914)

@hhbo64 Okay, so first you pass code input through something called the lexer. And what the lexer does is it tokenizes the input into tokens, like this:

print "Hello World!";

[lexer]

KEYWORD: (print)
STRING:  (Hello World!)
SYMBOL:  (;)

  |
  |
  V

array_of_tokens = {
  Token{ KEYWORD, "print"       },
  Token{ STRING,  "hello world" },
  Token{ SYMBOL,  ";"           },
}

A token is a struct/class. The type is an enum and the actual token is a string.

Then you pass that through a parser. There are many different types of parsers around, but mine looks like this:

array_of_tokens = { "int", "a", "=", "2", "+", "3" }

Variable declaration? Check
Int variable? Check

Extract Expression:

"2 + 3"

Send off to Math Parser.

Math Parser:

2 + 3 = 5
return 5;

So now we have a value. Then we do the runtime:

int a = 5;

Create int variable with value of 5

And that's it :) Let me know if there's parts in which you're confused. Check out the GitHub page for more info

hhbo64 (4)

Thanks! Any good tutorials you [email protected]

DynamicSquid (4914)

@hhbo64 umm... there really aren't any great tutorials out there for making a language. I just started coding and learning through trial and error, and I'm still learning a lot. You can try this tutorial to get started, but my best advice is to just start coding. Start with the lexer :)

hhbo64 (4)

K’@DynamicSquid

skiscratcher (3)

@hhbo64 Crafting Interpreters is good. It's a full ebook, and it makes two different interpreters for a toy language. It's even freely available at craftinginterpreters.com

SwaroopBappanad (240)

I visited your page a couple days ago and saw this. But when I looked at it, it had a bunch of folders. Right now it looks like a bunch of binary. How did you change this? (And how did you write and understand that gibberish?)

DynamicSquid (4914)

@SwaroopBappanad oh, that's just the .exe ELF file. I coded this in c++, and when you run a C++ program, it generates a .exe ELF file. the actual code can be found on my github page :)

AmazingMech2418 (1085)

@DynamicSquid ELF, not .exe! This is Linux, not Windows.

DynamicSquid (4914)

@AmazingMech2418 wait, is there an actual difference between the two?

AmazingMech2418 (1085)

@DynamicSquid Yeah. LOL! ELF is on Linux and EXE is on Windows.

DynamicSquid (4914)

@AmazingMech2418 well, yes lol, but I meant other than that

AmazingMech2418 (1085)

@DynamicSquid Well, they are both binary files on their respective systems, so not much other than that EXE files don't have as low-level control (i.e. you can't make an OS with an EXE file, but can with ELF)

StringentDev (229)

It's also the way they are encoded, if they were endoed the same, you would have been able to just directly change the extension from .exe to .elf and back. @DynamicSquid

@AmazingMech2418 wouldn't low level access also allow you to create a really dangerous virus.

AmazingMech2418 (1085)

@Lethdev2019 Yes, but access to certain parts of the memory storage device on Linux is restricted. Though, if someone could get root privileges, they could completely change the OS and that could cause a huge ransomware attack...

theangryepicbanana (1697)

Always nice to see real languages here :)

rediar (518)

@theangryepicbanana I mean.. “real languages”? That’s pretty subjective, but I would agree if you said this was a higher quality language

[deleted]


Cool

StringentDev (229)

@DynamicSquid That kinda makes me think of a commodore in which you would type the code and then type run.

Don't use goto 0 alone on a commodore, it creates an infinite loop that goes on forever.

Jakman (449)

I like the way your recent projects have been heading lately. Also would you like to give me some programming advice on a project i have been building lately?

DynamicSquid (4914)

@Jakman oh yeah thanks! every since summer rolled around, I've been spending much more time programming. and sure, what's the project?

Jakman (449)

@DynamicSquid A File corrupter. It uses both Rust and python. Are you up for it?

DynamicSquid (4914)

@Jakman that sounds interesting, but I'm not that familiar with rust or python

Jakman (449)

@DynamicSquid I think i just need advice with my thought process. As I haven't used anything as a glue language before.

DynamicSquid (4914)

@Jakman oh sure I guess, I can help

AphixDev (213)

How did you do this? The file is heavily encrypted lol

DynamicSquid (4914)

@nt998302 oh, that's an .exe file. the actual code can be found on GitHub: https://github.com/DynamicSquid/Night

[deleted]

guys upvote this its purely amazing

CodeLongAndPros (1624)

This feels like BAPy++L:
BASIC + Python + C++.

(Not a thing.)

DynamicSquid (4914)

@CodeLongAndPros kinda of. I tried to combine the simplicity of Python, with the type concepts of C++. notice how there is no main function/class like in C++ or Java, but it's still statically typed

CodeLongAndPros (1624)

@DynamicSquid The next thing is to make it golfable.
for example:
int x = 0; == ix0

DynamicSquid (4914)

@CodeLongAndPros umm... I don't think I want to do that lol

CodingRobot12 (182)

This is a cool language. Do you want me to add this to my upcoming search engine?

PizzaisGood (30)

@DynamicSquid I can't wait to learn (or try to anyways)your new language! :)

DynamicSquid (4914)

@PizzaisGood oh thanks!! I'll also make a website and everything once I'm done

ELDER054 (29)

How does Night turn tokens into an AST?

programmeruser (596)

@DynamicSquid is there a way to make syscalls in the current version? I can build File I/O and other things from there

DynamicSquid (4914)

@programmeruser no, I'm working on v4 which will be able to support file IO though

programmeruser (596)

@DynamicSquid with syscalls you can have access to the linux kernel

DynamicSquid (4914)

@programmeruser Yeah, but im trying not to complicate things yet. Im definitly going to add those later though

DynamicSquid (4914)

@programmeruser Hey, if you don't mind, could you create an issue on the GitHub repo about sys calls with the label feature? I'm going to start working on them, and it would be nice to have an issue to keep track of it

CuriousMonkey (48)

did you put this in the jam cuz its not there

CuriousMonkey (48)

@DynamicSquid ohh ok i got confused cuz there was a programin glanguage here on share not jam

StringentDev (229)

@DynamicSquid the repl has stopped working.

firefish (948)

@Lethdev2019 It's a REPL, you type in raw night code and it evaluates it, prints it, and starts again, that's what a REPL is, Read Evaluate Print Loop.

firefish (948)

@Lethdev2019 type your code, then type RUN to execute it, bear in mind it's an ancient version, so prints are done print "a"; not print("a");

fuzzyastrocat (1841)

Is Night compiled or intepreted? If it's compiled what does it compile to?
(And, if it happens to be compiled to x86, mind giving suggestions for Sea?)

fuzzyastrocat (1841)

@DynamicSquid Wow thanks for the quick reply. Just realizing how stupid I am for not looking at the github, where the first sentence is "An interpreted programming language".