how i got rid of semicolons in my scripting language

preview_player
Показать описание
i used go's technique :^)
Рекомендации по теме
Комментарии
Автор

This video was well-explained and informative. I've been following this project for a little while now, and it seems to be shaping up into something pretty awesome. Keep up the good work, champ.

numbertumbers
Автор

I've always felt like the semicolon was freeing more than limiting. I honestly don't know when the war on semicolons started but it doesn't make sense to me.
Even as a beginner, just adding a semicolon to the end of every statement isn't some big time sink. It becomes habit so quickly that it's not even a conscious process for most after just a bit of programming (and if you don't partake in a large enough bit of programming for it to become one, having to add a semicolon probably doesn't matter to you).
Imho it even makes it clearer to *humans* how to visually parse complex code expressions.

HoloTheDrunk
Автор

The only reason I like semicolons is because you can shove all your code into one line and the compiler will still accept it. I once saw a video where someone made flappy bird in Unity using only 1 line of code and it was hellish to read.

EarthItself
Автор

I like the way OCaml does it, they have no block delimiters (braces etc) or semicolons, while still not relying on white space. The code is just really pretty, really nice and really easy to write. (Also formatters are easy!)

awwastor
Автор

Great succinct video! I love how you used other languages for inspiration. I think your approach is a pretty good fit for your goals.

I'm working on my own programming language and these designs take forever to make sometimes.

NathanHedglin
Автор

And then there's JavaScript which again manages to have the worst possible solution: making semicolons optional *after* the language was released, which means you can write otherwise valid JS code which is misinterpreted if you remove the semicolons.

SaHaRaSquad
Автор

damn, i ususally don't follow language-creation. it seems to me like a solved science: so long as everybody is writing code and it all works, it doesnt super matter what you use. but you just went "yeah, GO tried to solve the problem and only got halfway, so i just kinda went all the way and made it 100% better."

PokeNebula
Автор

I appreciate what you’re trying to do, but I disagree and will keep my semi-colons. I tend to give my functions long descriptive names, for ease of understanding. Since I only have limited horizontal space on the editor, given I work with multiple side by side windows, I prefer being able to ignore and white-space in favor of using the indentation solely for aesthetics, and using the curly brackets and semicolons to clearly denote where scope and lines (respectively) end.

pirateskeleton
Автор

as a javascript coder, i can tell you semicolon insertion is NOT without its problems.
sometimes js can insert semicolons when you don't want it to, and it sometimes doesn't insert semicolons when you do want it to.
(i've only had this problem once, however)

notwithouttext
Автор

One of the rules I had implemented for a language I had made was no trailing expressions. It removes a lot of the ambiguity while parsing and also avoids leaving unnecessary values that clutter the code
You could also just use a different syntax for tuples as to de-ambiguate them from function calls: #[], #(), <> etc

imfastboi
Автор

You should check out Julia. In Julia a newline or semicolon can separate expressions but within an expression a newline doesn’t mean anything.

Edit: it looks like Julia is similar to Go in that if the expression is not finished newline is ignored.

miguelprovencio
Автор

i was just about to ask you to have a look at go right before you mentioned that you did lmao

raianmr
Автор

The indentation-based syntax is so hard to mess up
in an interpreted language
near a keyboard where you can accidentally change a line if you touch it

JorgetePanete
Автор

3:53
yea thats the reason i probably would still prefer having semicolons

theres also the fact that it makes code more readable

RenderingUser
Автор

I use Julia a lot, and Julia really only needs semicolons if you want to do multi-statement lines. But what's really cool is that you can have something like
x = zeros(Int, 12); for i in 1:6, j in 1:6 x[i + j] += 1 end
You could have also done for i in 1:6, j in 1:6; x[i+j]+=1; end, but those two semicolons in the for loop are automatically figured out. It also does the Go-style "if I can't end with this token, keep reading" thing.

spacelem
Автор

Nice short and succinct video. I would suggest you consider how Lisp manages this. It restricts the grammar like Lua, but does it in a really interesting way. Since every statement is a list, it's immediately clear where lists begin and end and thus where statements begin and end. It also isn't much of a problem because every function definition is one statement (containing statemennts (which contain statements), (and more statements)). Being a functional language allows it to get away with this.

nile
Автор

People talk about whether things are "beginner friendly" and rush off trying to solve things. I am a beginner. Semicolons presented zero barrier to entry. "Put a ; at the end" is something I learned day one and hasn't been an issue, even if I forget sometimes and have to go back to add it in. If we want to talk punctuation, parentheses, " vs ', and the \ in things like \n are far less beginner friendly.

If it's an aesthetic choice then fine. If you think it represents an efficiency gain to not have semicolons, also fine. But you, who probably knows like 5 programming languages, has been coding for years, and is writing your own scripting language, is pretty much entirely out of touch with what beginners struggle with when learning to program.

The reason "semicolon at the end" isn't a problem for beginners to learn, is because in basically every written language on earth, we put a bit of punctuation at the end of a sentence to denote that it has ended. Semicolons represent the same thing that a period does in English: this statement is over.

Just because a compiler or interpreter may not need that, the important point about code is that it is human readable. Which means that, as best it can, it probably ought not stray too far from some base principles such as "clarify for fellow dumb humans that a statement has ended with punctuation".

So it's cool, sure, what you've done. But I think the justification is flimsy.

charliecharliewhiskey
Автор

one of the most controversial topics in programming languages haha. nice video! I really like your devlogs, maybe you should make some about making your PL :)

aradarbel
Автор

I thought for all my life that compilers were magic assembly code written to break down the code we passed as text, but now I slowly realise that compilers are just code themselves, even sometimes in the same language they're compiling.

BirinderSingh
Автор

Semicolons also allows the parser and lexer to easily recover from a syntax error. Thus, unlike Python that can only output one syntax error at a time. Rust, C, C++ can all "jump" to the next semicolon or other major deliminator and keep parsing.

clehaxze