🌕 Night - My Programming Language 🌑
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 :)
Its awesome! The code is so out of my mental range it is frightening
@BobTheTomatoPie lol, thanks!!
How did you create the programming language?
good job btw
@Lethdev2019 oh you can check out my github page for more info on the code. also thanks!!
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! :)
@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
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
@DynamicSquid we also, we have 17 results so far, come on to the night repl so we can talk further.
thanks,
lethdev2019.
can you give me a link i cant find it [email protected]
can you give me a link to your github page where it shows you how to make a [email protected]
@CuriousMonkey you mean a tutorial on how to make a language?
ye you said it was on your github page but i couldn't find it there @DynamicSquid
@CuriousMonkey what no I didn't lol?
@DynamicSquid OOF well can you make one in the future i wanna get 5000$ dollars for the jam xD
@CuriousMonkey too lazy lol. really busy with actually making the language. maybe once it's done idk
ok thx :) @DynamicSquid
it's built around c# and python, right?
@viraatvv kind of yes. I tried to combine the simplicity of python with the type concepts of the C family
@DynamicSquid wow. also, this is unbelievable. I think your language could actually be successful when you release it
@viraatvv oh thanks!!
@HenryZelonka1 huh? lol XD
great job @DynamicSquid
@Barry123
Hmmmm... So strange considering that @DynamicSquid should not be biased at all.
Hey you forgot monkeys @DynamicSquid
print "Monkeys are good too!\n";
RUN
@DynamicSquid
What about humans?
@DynamicSquid You should make it into a REPL... also Shift+Insert is another way to paste in console
Nice! Btw, You should add loops
@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
@DynamicSquid All right. Keep up the good work!
Cool!
@AdCharityTester thanks!!
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
@Codemonkey51 oh wow! I never knew I could add my language to repl. I'll take a look at it, thanks!!
thats just backend btw they would still have to add it to frontend @DynamicSquid
@Codemonkey51 wait I'm confused
thats the base docker image it will be on replservers but not a language makeable thru the new repl button @DynamicSquid
@Codemonkey51 oh, I see. is there a way to do the front end?
@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 )
@DynamicSquid and you forgot add run program by file
@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
@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
@DynamicSquid i want run program by file
example : ./night main.night
@DynamicSquid no, i send toml file for you.
and oh, ill send link here
@TheForArkLD oh okay
@DynamicSquid nvm i sended pr to you
(./night
is for boot repl, ./night file
is for run program by file)
@TheForArkLD okay, so now I wait?
check the circleci errors bc those need to pass for it to be merged @DynamicSquid
@DynamicSquid did you add ./night file
?
@TheForArkLD wdym by that?
@Codemonkey51 what is circleci? I can see it building and testing, but what does that mean?
@DynamicSquid i want run program by file...
@TheForArkLD couldn't you type in ./night
?
@DynamicSquid fixed bug, merge pls :)
@DynamicSquid HEY WE DID IT
TEST SUCCESS!!!!
@DynamicSquid BUILD_AND_TEST_CHANGED SUCCESS
BUILD_AND_TEST WILL SUCCESS!!!
@TheForArkLD YAY!!! wait, but what does that mean? like what do the tests actually do?
@TheForArkLD aw.. it failed
@DynamicSquid uhhh build_and_test failed
bc not night error
@TheForArkLD what do you mean by that?
@DynamicSquid that fail means you cant add that
@TheForArkLD oh, YAY! thank you!
@DynamicSquid sorry type miss i fixed comment
@TheForArkLD oh, aw.. is there a way to fix it?
@TheForArkLD oh, it's fine anyway. thanks for trying though!
well if you guys fix the error circle ci is throwing they can merge it :/ @DynamicSquid
@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
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!!
@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!
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?
@KimiTian08 umm.... uh.... lol
@mathiasaboye oh interesting... thanks for the idea!
How do you make a Lang?
@hhbo64 long or short answer?
@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
Thanks! Any good tutorials you [email protected]
@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 :)
K’@DynamicSquid
@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
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?)
@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 :)
@DynamicSquid ELF, not .exe! This is Linux, not Windows.
@AmazingMech2418 I knew that lol
@AmazingMech2418 wait, is there an actual difference between the two?
@DynamicSquid Yeah. LOL! ELF is on Linux and EXE is on Windows.
@AmazingMech2418 well, yes lol, but I meant other than that
@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)
@AmazingMech2418 oh, okay
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.
@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...
Always nice to see real languages here :)
@theangryepicbanana I mean.. “real languages”? That’s pretty subjective, but I would agree if you said this was a higher quality language
@GoofyGus thanks!!
@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.
This is amazing man!
@VulcanWM thank you!!!
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?
@Jakman oh yeah thanks! every since summer rolled around, I've been spending much more time programming. and sure, what's the project?
@DynamicSquid A File corrupter. It uses both Rust and python. Are you up for it?
@Jakman that sounds interesting, but I'm not that familiar with rust or python
@DynamicSquid I think i just need advice with my thought process. As I haven't used anything as a glue language before.
@Jakman oh sure I guess, I can help
@DynamicSquid alright cool
@Jakman multiplayer repl?
How did you do this? The file is heavily encrypted lol
@nt998302 oh, that's an .exe
file. the actual code can be found on GitHub: https://github.com/DynamicSquid/Night
@DynamicSquid Ohhhhhhh. COOL
@NullVoidxA thank you!!!
This feels like BAPy++L:
BASIC + Python + C++.
(Not a thing.)
@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
@DynamicSquid The next thing is to make it golfable.
for example:int x = 0;
== ix0
@CodeLongAndPros umm... I don't think I want to do that lol
@DynamicSquid For golfing!
@CodeLongAndPros For actual readable code! lol
yay I got pinged!
This is a cool language. Do you want me to add this to my upcoming search engine?
@CodingRobot12 oh sure! and thanks!!
ok added you and the repl @DynamicSquid
@DynamicSquid I can't wait to learn (or try to anyways)your new language! :)
@PizzaisGood oh thanks!! I'll also make a website and everything once I'm done
How does Night turn tokens into an AST?
@DynamicSquid is there a way to make syscalls in the current version? I can build File I/O and other things from there
@programmeruser no, I'm working on v4 which will be able to support file IO though
@DynamicSquid with syscalls you can have access to the linux kernel
@programmeruser Yeah, but im trying not to complicate things yet. Im definitly going to add those later though
did you put this in the jam cuz its not there
@DynamicSquid ohh ok i got confused cuz there was a programin glanguage here on share not jam
@DynamicSquid the repl has stopped working.
@Lethdev2019 What do you mean?
it does not load up. @firefish
@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.
@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");
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 interpreted
@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".
How did you make your logo? Did you use a website?
@pr0p3rno0b10 oh I use Processing
@pr0p3rno0b10 it's a coding language that let's you create graphics easily
@DynamicSquid Cool, I like it.
@pr0p3rno0b10 thanks!!
@DynamicSquid
That's pretty good for processing. Nice!
@HenryZelonka1 oh thanks!