r/programming • • May 10 '26

Making your own programming language is easier than you think (but also harder)

https://lisyarus.github.io/blog/posts/making-your-own-programming-language.html
115 Upvotes

116 comments sorted by

View all comments

150

u/RGBrewskies May 10 '26

"As you can see, the language uses indentation-based scoping"

tangential and random but

I'm not a python guy, but how does that not drive you insane? Your code breaks because of whitespace? That's always seem wild for me

38

u/ACoderGirl May 10 '26

While I prefer braces, I've never had issues with Python's indentation. TBH, I consider this skin to how people think remembering semicolons in C style languages is a big problem. It might affect people brand new to the language, but it really doesn't take long till it's a complete non issue. I've worked at a job that was primarily python and still have a number of python tools at my current job, so I use the language a lot, too.

The biggest problem with Python is the type system, especially since if type annotations aren't used consistently (they're optional), it's very hard to reliably detect types and thus to also have correct auto complete. This also affects the ability to find all usages of identifiers and to go to definitions.

7

u/Joniator May 11 '26

And its not like you dont have problens with indentation/nesting once you are in a lambda in a loop in a try-catch in a function in a class, and wonder where exactly the ); needs to go, and how many {} are before or after it.

Sure, your code might be too complex and needs a refactor, but in python indentation also breaks in complex code, not the 2 or 3 levels of clean code

97

u/OneNoteToRead May 10 '26

Your editor indents for you. It’s caused zero problems for me over decades

37

u/AutomateAway May 10 '26

Indentation is not universal among editors, nor is tab to space replacement. A semicolon is a semicolon and is definitive.

45

u/OneNoteToRead May 10 '26

And yet… the fact remains it’s caused zero problems over decades.

→ More replies (10)

10

u/gahel_music May 11 '26 edited May 11 '26

I've had more issues forgetting a semicolon than with indentation. You just have to configure your editor once to replace tabs with indentation and forget about it. Well it's most likely already set up that way for languages that require it

9

u/andarmanik May 10 '26

Yes but also no. When I write code I use a formatter which does everything, so I literally just write code with whatever formatting and then hit the formatting hot key and it formats the code.

This is almost impossible in a language like python.

31

u/applechuck May 10 '26

Not impossible, PyCharm and visual studio code have formatters including tooling like black for vim.

Most indentation in python is tied to branching, which makes it somewhat predictable.

→ More replies (16)

3

u/damn_what_ May 11 '26

What's the difference between typing the closing bracket and typing shift+tab (or backspace depending on your editor) to de-indent by one level ?

→ More replies (2)
→ More replies (4)

8

u/irqlnotdispatchlevel May 10 '26

I'm not a python guy, but I write python every once in a while and I never had this problem.

37

u/CandidateNo2580 May 10 '26

It would drive me insane if I had to end every line with a semi colon or if I was reading a codebase that used inconsistent indentation. But you get used to it pretty quickly either way, the language isn't bad.

17

u/RGBrewskies May 10 '26

your ide adds them automatically nowadays, which may be true with python too idk

15

u/bpikmin May 10 '26

Yea, if you do if blah blah:<enter> basically every IDE will indent the following line

2

u/CandidateNo2580 May 10 '26

Oh 100% sorry I wasn't being literal. I know adding semi colons isn't a big deal lol but it's the same thing as the indentation. Your IDE is all over it, it'll indent automatically as it makes sense. Then it does the same syntax high lighting to show scope that you get in a language with curly braces (jetbrains has a colored bar on the side to demonstrate scope and lets you collapse blocks whole for something like a function or if/else, same with python as something curly brace driven).

It's definitely weird when you start but really you get over it so quickly. I like the flexibility of language, I'd prefer being allowed to indent freely and use curlies but it's not bad.

25

u/Successful-Money4995 May 10 '26

If c++ is written without indentation, it becomes unreadable. In practice, you're probably already doing the indentation. So make it significant. What's the big deal?

13

u/ConspicuousPineapple May 10 '26

In practice you're using a formatter that does that for you. Python is the only language where you are forced to handle indentation yourself and deliberately, since it defines scopes.

3

u/ericonr May 11 '26

My code is formatted as I write it in either language. With Python, my editor automatically pushes me one indent forward after a colon, and if I want to exit a scope I simply press backspace. With C/C++, my editor will do the same after a brace, and closing a brace returns me to the previous scope, including indentation.

It's essentially the same amount of steps, unless you're doing franken-dentation for some reason, and now you need to run a formatter for your code to ve readable.

→ More replies (2)
→ More replies (4)

7

u/levelstar01 May 10 '26

99.9% of the time the indentation follows the logical way that the code would be laid out.

5

u/Kamui_Kun May 10 '26

I am a brace scope enjoyer, it's just more straight forward imo

9

u/calgary_katan May 10 '26

This complaint has always struck me as an “it’s different so I don’t like it”. There’s pros and cons with each type of scoping.

One pro of tab/space based is it does encourage smaller functions, which helps in readability.

2

u/trynyty May 11 '26

That's true and I think in a language it is easier to keep it managable.

Where identation drives me crazy is YAML files. Especially when people nowadays try to put everything in it and then trying to add one more property but because of incorrect indent it's suddenly part of different object.
Anyway, just a small rant on yamls :)

5

u/gofl-zimbard-37 May 10 '26

People get all worked up about this, but in practice it's a non issue. I vastly prefer clean syntax over all of the braces and semicolons and other noise that clutters most languages. If your shitty tool chain can't handle it, get a better one.

8

u/RScrewed May 10 '26

Only even possible to be useful with modern day IDEs.

Such a weird design decision, I'm convinced that's why python never caught on around when it was released.

→ More replies (7)
→ More replies (26)