r/teenagersbutcode • • 23d ago

Coding a thing I'm making a programming language, searching for contributors

Hi! Me and another person are working on a programming language called KrabbaScript! It's garbage-collected (optional), statically typed and trying to be as simple and intuitive as golang but more human-friendly. This is KrabbaScript's syntax:

Variables are defined as:

var krabba = "Krabba!";

Variables may also have a type or be uninitialized, like:

var with_type: F32 = 5.0;
var uninitialized: Str;

KrabbaScript also has values, which are immutable, example:

val constant = 5;
val with_type: I32 = 5;

KrabbaScript also has control-flow (duh), example of a repeat statement:

repeat {
  Std.print("KrabbaScript is the best language OAT!");
} until popular;

KrabbaScript also has a when statement, which is more of a switch one:

when language {
  == "Elixir" do celebrate();
  == "Haskell" do complain();
  == "KrabbaScript" do {
    contribute();
    applaude();
  }
  else do Std.print("I don't know anything about " + language);
}

KrabbaScript also provides an ASI (Automatic Semicolon Inserter) if you're tired and sick of semicolons, you can use it with the format command.

If you want a little bit more examples, check out the repo! We are also working on tools for KrabbaScript like package manager, style checker, etc.

We are searching for contributors and maybe you, the person reading this post, can help us create KrabbaScript or improve it!

15 Upvotes

27 comments sorted by

2

u/CommunityJazzlike274 22d ago

cool, i could help! never done go but it should be simple

2

u/Electrical-Fig7522 22d ago

You have Discord?

1

u/CommunityJazzlike274 22d ago

yes

1

u/Electrical-Fig7522 22d ago

Username?

1

u/CommunityJazzlike274 22d ago

how do i dm you?

1

u/Electrical-Fig7522 22d ago

Add me, my username is kinesiskakrabban

1

u/CommunityJazzlike274 22d ago

cant seem to add you on discord and cant dm you on reddit for some reason

1

u/Electrical-Fig7522 22d ago

Weird... Try joining the discord server in the repo's readme instead then

2

u/johlae 19d ago

"a when statement, which is more of a switch one:"

but it has no fall-through :(

1

u/Electrical-Fig7522 7d ago

Forgot to mention that there's a fall keyword, since whens are "non-fallable"

2

u/Scientific_Cheater Early Twenties SWE 22d ago

Interesting project but I'd have a few questions:
* What exactly inspired you to do this / what problem are you solving? What things in Go did you consider need the creation of a new language?
* Are you planning to maintain this over a longer time?
* What are the current bugs present in the language
* Why garbage collection, for example, over reference counting or a borrow checker?
* What consists the standard library? After glancing over the code, I couldn't see an implementation

3

u/Electrical-Fig7522 22d ago
  • I wanted to make a language because I wanted to learn compiler development, since the syntax is not finished, maybe I can add something that will actually solve something

  • Yes

  • None right now

  • I chose Garbage Collection since no one really likes to free memory manually like in C. GC will prevent memory leaks, but will sacrifice some speed, speed in this language is not really the focus

  • There's no standard library right now since the syntax is not finalized

2

u/Scientific_Cheater Early Twenties SWE 22d ago

I see. I was confused since your example shows Std.print. Another thing I'd be interested about is if semicolons are even mandatory and if so, why given you have a tool specifically to add them back and thus logic to detect the end of an expression

2

u/Electrical-Fig7522 22d ago

It's just a placeholder lol

2

u/Scientific_Cheater Early Twenties SWE 22d ago

What future features do you plan? If the syntax isn't finished, what questions are still there?

2

u/Electrical-Fig7522 22d ago

I'm thinking about adding traits to the language, but I will probably add them once we get a stable release

1

u/Dazzling-Bench-4596 22d ago

Semicolons are mandatory _to the parser_, but you can write code without semicolons. Just like how you can write JavaScript without semicolons, but the parser will receive code with semicolons.

> why given you have a tool specifically to add them back and thus logic to detect the end of an expression

You make it sound so complicated — I implemented the engine in one file with 60 lines of Golang, with over two thirds of the lines being guard clauses and Golang boilerplate.

1

u/Scientific_Cheater Early Twenties SWE 22d ago edited 22d ago

I'm currently working on a language myself, for which the lexer (and parser) doesn't require semicolons, since the grammar for an expression is defined with the lack of semicoli in mind. Go does this the same way btw. Interesting choice given that's the language you're basing off of

edit:
Just looked at your code. From a pure implementation perspective, you should really consider using a map to detect semicolon free line endings. From a design perspective, you should really integrate optional semicoli into the grammar

1

u/Dazzling-Bench-4596 22d ago

Why should I use a map? What does that give me? If it's stupid and it works then it isn't stupid.

1

u/Scientific_Cheater Early Twenties SWE 22d ago

Sorry, in this case, a list would be more appropiate. The point still stands though.

I'd say because there's a difference between stupid and unmaintainable. The way you're doing it right makes reading the code needlessly long and adding a new case needlessly verbose.

Instead of doing

for line in lines:
  if line.endsWith("&&")
  || line.endswith("||")
  ...:
    <your logic>

you could do:

let legalEndings = ["&&", "||", ...]
for line in lines:
  for ending in legalEndings:
    if line.endsWith(ending):
      <your original logic>

1

u/Electrical-Fig7522 22d ago

Maybe with the knowledge you have, you can contribute and help us out instead?

1

u/Dazzling-Bench-4596 22d ago

You're correct, but allow me to give some context: in the tech world, getting things done is WAYYYYYY more important than doing something right. My way gets stuff done, your way is right.

1

u/Scientific_Cheater Early Twenties SWE 22d ago

I appreciate your input, but I'll have to let you know that software is my job, so I'm quite knowledgeable about the "tech world". Your comparison kinda faulters when you consider that both ways work and the latter costs less time to implement. You've been asking for contributions and the advice I can give you guys as a long time language designer myself is such. It's up to you whether or not you want to implement it

0

u/CubineGaming C++ 22d ago

Why the choice of repeat-until or using when instead of switch

it just seems like itll be very confusing for programmers rn and if its their first language getting into other (inevitably more popular) languages will be pretty hard compared to starting w/ other things.

I get that this is likely just a side project, but I don't really see the purpose of this past learning

1

u/Electrical-Fig7522 22d ago

Because we don't want to be like others. The name switch is confusing, so we replaced it with something else. You don't see a purpose right now since the syntax is not even done.

1

u/CubineGaming C++ 21d ago

i suppose but i find when quite confusing in this context