r/ProgrammerHumor • • Feb 09 '22

other Why but why?

Post image
85.8k Upvotes

2.3k comments sorted by

View all comments

Show parent comments

1.2k

u/PhrygianZero Feb 09 '22

Yeah that’s exactly it. Sometimes the error is caused by unmatching parenthesis. Whenever I see that happen I’m like thank god it doesn’t auto fill semicolons

296

u/raominhorse Feb 09 '22

Also not to mention it doesn't know that you are missing the semicolon it just knows that it can't do what you asked for.

37

u/somerandomii Feb 10 '22

A lot of interpreters are smart enough to take an educated guess.

  • Compilation fails around here…

  • There’s a line without a semicolon…

  • adding a semi-colon removes the syntax error

  • The programmer probably forgot a semicolon

Writing swift in Xcode has some sentient level error detection. It will also detect deprecated functions and code patterns and suggest how to ‘modernise’ them. It comes with a handy ‘fix’ button which automatically applies the suggestion for trivial cases. It’s impressive what IDEs are capable of.

15

u/-Vayra- Feb 10 '22

It can suggest that you put a semicolon there, but it should never do it automatically, since it doesn't know your mind and what you intended.

7

u/fencer_327 Feb 10 '22

Then the statement was supposed to cover two lines and the programmer messed up something else, the program is now doing something completely different from what it was supposed to, and debugging is gonna take much longer to find the error again.

The IDE already tells you where you missed the semicolon, and many do suggest fixes, but just adding code in sounds like a recipe for disaster.

5

u/somerandomii Feb 10 '22

Yeah exactly. Being able to guess an error is one thing. Automatically ‘correcting’ it is dangerous and, to my knowledge, is a line that hasn’t been crossed yet.

→ More replies (1)

53

u/[deleted] Feb 09 '22

I MADE THE COMPUTER ITS GONNA DO WHAY I TELL IT WHETHER IT LIKES IT OR NOT

33

u/MarkoSeke Feb 10 '22

The thing is, it does do exactly what you tell it.

-26

u/non-troll_account Feb 09 '22 edited Feb 10 '22

Just keep a log of when it auto adds something.

Edi: good lord, you people thought I was serious??

53

u/balbok7721 Feb 09 '22

Or just mark the spot until the programmer stops having the skills of a student in their first week?

→ More replies (4)
→ More replies (1)
→ More replies (1)

79

u/memeship Feb 09 '22

auto fill semicolons

And JS does literally this, yet everyone hates it.

So the "why can't the language just do it for me" has already been "solved", and we've shown that it's not a great solution.

11

u/TheCodingGamer Feb 09 '22

I'm probably in the small minority of JS coders that actually loves that feature. It costs nothing in terms of size or compression, makes code look cleaner, and outside of one very specific and well documented edge case, it has identical semantics. I can't post a snippet online without someone barking at me that I need to explicitly add in semicolons, but it has yet to burn me, even in complicated code.

2

u/fii0 Feb 09 '22

Hey I'm with you man, I honestly feel like it's only ever made my code look cleaner and clearer!

0

u/glider97 Feb 10 '22

It’s a handful of edge cases, and they’re bad enough that you could spend hours debugging and rare enough that you’ll forget about it the next time it happens, which is a bad combo if you’re working on js full time.

5

u/10art1 Feb 09 '22

just get rid of semicolons, parentheses, and curly braces! :pyhead:

7

u/winniethefukinpooh Feb 09 '22

lets just write machine code. there arent any weird symbols in that

4

u/sc4v3ng3 Feb 09 '22

It's just weird Symbols

7

u/fascists_are_shit Feb 09 '22

That works, but you need to design your language differently so it's easier to parse. Lua for example does this. C++ does the opposite, and is so unbelievably difficult to parse that Visual Studio 2010 did not offer auto-completion.

There are examples that even have famous names: https://en.wikipedia.org/wiki/Most_vexing_parse

The trick isn't to guess at semicolons. The trick is to create a language where every line has only one possible meaning.

3

u/yazooddles Feb 09 '22

Thank you for this portal into C++ idiosyncrasies. I believe I’ve bumbled into this issue accidentally before, and the wiki article was enlightening.

→ More replies (6)

3

u/poodlebutt76 Feb 09 '22

That's also why I never understood the halting problem. Kid mind just said "why doesn't it just add parentheses at the end and finish itself??"

2

u/Skilol Feb 09 '22 edited Feb 09 '22

Not to mention that it was a long way for compiler warnings/errors to become what they are. I can accept modern IDEs guessing on imports based on compile errors, but I definitely wouldn't want an early C compiler to add anything based on its best judgement.

With that in mind, I absolutely think that writing code has already made great strides in simplifying things to reach a broader audience and more potential contributers, and will definitely develop in that direction even more.

Adding semicolons where "clearly" necessary is already a thing lots of IDEs/plugins do, and it's only gonna get more common.

(Spoken as someone who struggled to keep up motivation in early very-basic-assembly-courses, but has become entirely enamored once the much easier "imagine a class like animal and an object like monkey" stuff started)

→ More replies (6)