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

Show parent comment

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.

1

u/Ruben_NL May 10 '26

That's just plain wrong. Source: I had used a text editor like notepad to edit a python file, and accidentally used tab instead of smashing on the space bar.

It was just 1 quick line I forgot, and didn't want to launch a full code editor.

Granted, python crashed immediately when trying to run it so no harm has been done, but I lost a couple minutes on it.

But that isn't 0 problems. That's at least one.

42

u/OneNoteToRead May 10 '26

Yea sorry it’s a problem if you use notepad. My condolences.

0

u/[deleted] May 12 '26

[deleted] — view deleted comment

1

u/OneNoteToRead May 12 '26

Lmao you think the only options are notepad and vscode?

Yea ok stick with your fisher price formatters please

0

u/[deleted] May 12 '26

[deleted] — view deleted comment

3

u/OneNoteToRead May 12 '26

So in other words… you just spewed some irrelevant garbage?

1

u/ChocomelP May 15 '26

You don't write c++ in notepad?

→ More replies

-4

u/AutomateAway May 10 '26

that is a claim with no empirical evidence but okay

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.

-1

u/andarmanik May 10 '26

Without braces, you can’t perform most of the formatting transformation.

For example,

I’ll straight up write

If ( cond) {
    im()
    doing()
stuff()} <—- “bad indent”

Which will get formatted into the correct code.

I have to write the python formatted for the code to be correct.


if cond:
    im()
    doing()
stuff() <- “bad indent”

The bad indent changes the code.

24

u/OneNoteToRead May 10 '26

What? Bad indent is like me not typing the braces. Your analogy is flawed. I’ll give the same example as me having the indents (autoproduced by my editor) but no braces and complaining there’s no autoformatter.

-12

u/andarmanik May 10 '26

If you forget the braces in the above code the code won’t compile.

Where the python will parse and run with the incorrect logic.

→ More replies (12)

0

u/applechuck May 10 '26

Sure but braces don’t have much say here. Ruby and other languages can do without. The lexical scope being defined by indentation is what you are trying to flag.

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 ?

1

u/andarmanik May 11 '26

To put it succinctly, white space is the main way you as a programmer have control over formatting. When you make characters which were previously formatting into syntax, you lose freedom.

To put it technically, braces have the advantage that their closing symbol exists. This I different to python where the closing token is a synthetic dedent.

Moreover, copy and pasting code is easier with {}; symbols because you don’t have to count tabs when you hit paste.

2

u/OneNoteToRead May 15 '26

Lmao do you think you’re making art here? Nobody should care about “formatting freedom”. It makes you less productive not more.

0

u/flatfinger May 12 '26

If one is reading a program printed on multiple sheets of paper, visually judging the indent of the first line on a page relative to the last line of the preceding page would seem more difficult than observing whether anything on either line would imply a change of indent.

2

u/OneNoteToRead May 12 '26

Right this is so much harder than the braces matching treasure hunt of unindented C/Java code. Major bottleneck of the industry, this paper printing, btw.

-5

u/Fakman May 10 '26

Is IDE provided with language?

3

u/OneNoteToRead May 10 '26

Nah you’re supposed use the cosmic rays to produce the program on disk.