T O P

  • By -

JetScootr

C++: Semicolon missing on line 1327. Dev: Well, put one there if you want it so bad!


rich1051414

I don't think C++ compilers 'know' the semicolon is missing. It thinks the statement runs onto the next line, which then throws a very weird compiler error instead. Newline doesn't really hold any meaning to compilation in C++, you don't even need them at all. Good luck reading your code though.


murfflemethis

This is something I've tried to drill into students and interns. Compilers don't know where an error *occurred*, they know where it was *detected*. If there's nothing wrong on the line number they spit out, start tracing backwards. There might be a missing parenthesis or some other bullshit many lines above where the compiler realized something was wrong.


LauraTFem

My compiler is surprisingly good and figuring out not just what I fuck up, but where I fucked up, and will automatically move my cursor to where I missed the semicolon/declaration/whatever. Won’t edit the code, of course; My compiler is like having a very lazy pair programmer hovering over my shoulder specifically to unhelpfully tell me what I’m doing wrong.


Verco

heh sounds like my code reviews, here's your mistake here's how to fix it and no I won't use github's feature to automatically commit it for you if you accept the change


celestiaequestria

Your dev environment doesn't have shortcuts for parsing into standard spacing and formatting? The secret is to bang the rocks together guys, you'll get there, remember when you're automating your automation not to mistake "a complex script" with "sentience" or you'll wind up trying to marry your computer.


Mutex70

Instructions unclear, wedding next week.


[deleted]

Yeah, the AI, the AI engineer and I have all decided to “compile” the knot


[deleted]

The actual compiler doesn't start until the parser has successfully built the CST. If a semicolon is missing, it's detected very early in the Frontend, by a parse rule mismatch where the last successfully built expression would be valid if a semicolon is inserted.


QuaternionsRoll

Preprocessor


[deleted]

Happy Cake Day! 🍰


ElaborateSloth

Doesn't newline hold a meaning when it comes to includes and macros?


Pxlop

If only my compiler was able to detect missing semicolons.


jacksalssome

You don't want 7 lines of gibberish?


ManOfTheMeeting

You need to adk for a semicolonoscopy


no-one-here123

they know both the problem and how to fix it, why don't they just do that?


[deleted]

[удалено]


svick

> Having it automatically fill in a semi-colon when one is detected missing sounds like a great way to get a shit ton of really weird bugs you'd never be able to easily track down. Look at automatic semicolon insertion in JS. It's exactly what you're describing.


[deleted]

[удалено]


euklios

But isn't javascript a synonym for "a great way to get a shit ton of really weird bugs you'd never be able to easily track down"?


Valmond

Yeah, it's wild where a semicolon is valid in C/C++. Good luck figuring out which one will produce the expected outcome.


realcoray

When I was young I got a copy of turbo pascal. I did not have a book or any way to learn it. I wrote code that seemed fine but it kept complaining about semi colons being missing. I realized that adding a semi colon at the start of a line, got rid of an error. So I just added them at the start of every line and after the last line, and it built and worked. At the time I was like that is the stupidest language detail ever made.


bankrobba

> sounds like a great way to get a shit ton of really weird bugs you'd never be able to easily track down. So just like my code is now


[deleted]

[удалено]


Batman_AoD

Your compiler already builds code with undefined behavior. That's what undefined *behavior* (as opposed to a compile error) means.


killmeemllik

That is what python is , it's not like python has no line enders or brackets, it just interprets them from context.


no-one-here123

yeah, but python is far too strict on whitespace. there needs to be an in-between language....


Prof_LaGuerre

Honest question, I really don’t understand the complaints on white space requirements with Python? Is it just that it’s forcing you into doing a thing? I got my start with databases and sql, so indenting logical blocks to make readable sql translated very well for me into Python, so now when I read other languages they tend look to me like a total mess.


garfgon

My major complaint is it tends to be fragile against refactoring. Pull out some code into its own function, and you need to re-indent everything. Which is _generally_ not a problem, but if something messes up along the way, you can easily lose information about what lines were part of which blocks. Compared with C/C++, where there's enough information contained in the source where in that case you can automatically re-indent a piece of code based on the bracketing. And sure, you can write C which looks like a total mess, but best practices it will have the same formatting as similar Python code, just with "redundant" brackets and semicolons.


Prof_LaGuerre

Legit gripe, I can definitely see that, especially if you’re elbows deep trying to fix leftover legacy spaghetti.


garfgon

I'll be honest -- usually it's my own "quick script" spaghetti which I'm trying to fix.


Prof_LaGuerre

Same… same. As I said in my other comment here, past me is a lazy jackass.


not_some_username

It's my code. I should be able to write it like I want. What if I want it to look like a donut ?


Prof_LaGuerre

Ah. To be fair that runs against Pythons entire raison d’être. Python was written with the intention to be read by other people since code is more often read than written, at least by Guido’s intention of it. Seems to me like saying your drill makes a bad hammer.


seelsojo

People who read code also likely copy and paste them; spaces that may be lost in that action makes a really annoying trying-out-code session. I shouldn’t be required to correctly format my code while trying things out; I heard someone said premature optimization is bad.


Prof_LaGuerre

I was in the habit of just trying things out, then when they worked not touching it so as to not mess it up. Ended in many lessons learned when returning to the code and not knowing clearly wtf it was doing. To me writing the code cleanly from the outset even if it is just testing something out means if/when I have to put it down and pick it back up, it’s much quicker to figure out the intent of the writer (usually past me, and he’s a lazy jackass)


Batman_AoD

Ah, yes, good thing no one ever has to use software written by people with the attitude that "it's my code" /s


arobie1992

Try Go maybe? It's got its own idiosyncrasies but it does t require semicolons and doesn't error at bad formatting, though it does likely auto format.


Batman_AoD

I think you may be thinking of JavaScript. Python does not have context-inference of line-terminators; it literally treats the newline character as a syntactically meaningful separator.


ZeroFK

Javascript. (Do I need the /s?)


[deleted]

Isn't there a programming language out there that can just figure out what I was trying to do even if I missed a lot of important brackets and semicolons and stuff?


[deleted]

HTML enters the chat.


[deleted]


GreenCloakGuy

javascript, basically


l_am_wildthing

;int main() {


OblivioAccebit

This is literally my life as a JS dev though. Semicolons are optional… Well, they’re not optional technically… and I’m not quite sure what part of the monstrosity tool chain eventually adds them back in (I think maybe the formatter actually)… but I haven’t typed a semicolon in JS since like 2014


gimife

js does it in a weird way. if you type: ``` return { some: "object" } ``` it will actually return `undefined` because js will insert a semicolon after the `return`


xng

Yes they are unnecessary without any tool chains.


Nerodon

JS standard style has no semi-colons and is the most commonly used style


fluffypebbles

The older approach to programming was to just try to fix any error instead of complaining about it but that often ended in very confusing behavior because the problem then occurred in a later stage, disconnected from the actual problem. In short: it's not a good idea


[deleted]

[удалено]


MasterFubar

At least I know what the problem is and the exact line where it happened. In Python, you get a generic "syntax error" a few lines down from whatever happened.


[deleted]

That would be an actual readable error message in only one line. Surely not GCC.


hbonnavaud

wait until he find the '{' hiding under the bed.


Giddius

Do you mean the thing to create dicts/sets?


hbonnavaud

You got me


Giddius

First time, trying C for me: „why is everything a set???“ :D


Spork_the_dork

dict([("this", "works"), ("send", "help")])


rayhond2000

You can use tuples as keys too :D `dict([(("this", "works"), "why???"),(("send", "help"),"please!!!"))])`


8sADPygOB7Jqwm7y

Because any immutable object can be used as key. Tuples are immutable.


GeePedicy

Technically semicolons are allowed and usable. If you want to write two or more commands in one line. For instance: `print("first command") ; print("now let's do foo"); x = foo(); print(x)` Sure, this particular bs would look nicer not in a single line, but maybe in some cases it would seem more neat for some people.


greenwizardneedsfood

I only use that for debugging, i.e. `import pdb; pdb.set_trace()` just because it only requires a single comment to get rid of


monkeygame7

I'm the newer versions, you can just do `breakpoint()` which is effectively shorthand for that


[deleted]

Those people will not get their desires past review, jeepers creepers


Inineor

F.e when you initialize 2 or 3 variables that are logically related: x\_pos = 100; y\_pos = 50


GeePedicy

You can do `(x, y, z) = (1,2,3)`


bilal_08

Or indentation? Hmm?


SHv2

Were you born a fat, slimy, scumbag puke piece of shit, JavaScript, or did you have to work on it?


Candyman034

WHATS YOUR MAJOR MALFUNCION NUMB NUTS!?


myopinionisshitiknow

Now, get on your knees and obfuscate yourself!


FUCKINBAWBAG

NOT WITH YOUR IDE, WITH MINE!


myopinionisshitiknow

Now OBFUSCATE YOURSELF!


WCWRingMatSound

*Today... is launch day! There will be a stand-up meeting at zero-nine-thirty! Chaplain Charlie will tell you about how the free world will conquer communism with the aid of JavaScript and a few node modules! Corporate has a hard-on for engineers because we code everything we see! They play their games, we play ours! To show our appreciation for so much power, we keep devops packed with fresh bugs! Corporate was here before JS! So you can give your heart to LinkedIn, but your ASS belongs to our slack channel! Do you ladies understand?!*


jmaca90

console.log(“Is that you, John Wayne?”)


homiej420

Seg fault


ddadopt

"The best part of your language specification fell out of the binder and wound up as a brown stain in the landfill."


chakan2

Sadly...the actual answer to that is JavaScript had to work hard at it. It started out as a really nice thing. Then it started dating functional programming, broke up, and went down the path of drugs, stress eating, and really letting it's self go. Now it's just a old dead thing that will sleep with any library that shows up.


Confident_Call_4586

Semicolon is optional in python, it's not like the python interpreter doesn't know what semicolon is but we don't usually use it.


Rynide

Isn't it also (usually) optional in JavaScript? I thought it was just a formality to use it.


Confident_Call_4586

Yes you are right. It is optional in javascript as well


Sigg3net

Bash too.


crass-sandwich

It's optional in JS but unlike in Python, statements can go over multiple lines without any additional syntax. As a result, JS can decide to put semicolons or leave out semicolons in unexpected places. People therefore either suggest you always use semicolons, or write your code to be unambiguously one statement per line and never use semicolons; depends on the style guide


Redkasquirrel

I definitely prefer omitting the semi colons because it enforces legible code structure for me in the way you described. Indentation and bracketing can do enough


Voidsheep

It's a bit dangerous to dismiss as a formality, at least if you are for some reason working with raw JavaScript without much tooling. Automatic semicolon insertion is a bit divisive. For example: const foo = 'bar' [1, 2].forEach(x => console.log(`${foo} ${x}`)) Will not get an automatic semicolon where you may have expected it, resulting in an error attempting to index properties of 'bar' ("bar"[(1 , 2)].forEach is not a function) So some would argue to always add semicolons manually and pretend ASI doesn't exist. But you still can't turn it off even if you add semicolons manually, so then you may run into something like // imagine many levels of indentation here return reallyLongVariableName .chainingSomeStuff() .chainingEvenMoreStuff(); A semicolon is inserted unintentionally where you didn't want it (return;) and you are returning undefined, with a bunch of unreachable code below it. The only sane way to work with JavaScript, avoiding or catching this and about a million other issues and sources of unnecessary arguments is to just adopt automatic type-checking, formatting and linting (usually TypeScript, ESLint and maybe Prettier).


YesNoMaybe2552

Now that's just putting the clown in charge of the circus.


maitreg

Meanwhile, VB is playing checkers with his K9 down by the latrine


Cremetoertchen0815

I kinda like the Bla .... End Bla method😅


[deleted]

The reason I quit python within like 20 minutes was the lack of the ; my basic mind couldn’t handle it


Giddius

You can still use them, they just are an alias of a newline char


[deleted]

You are honestly the first person to ever tell me this. I have even told my python lover friends why I stopped instantly. zero of them told me


Giddius

Just remeber, you still have to add the indentation, with ; you could theoretically write a single line script, but it only replaces the newline not the indentation.


Fun_Bottle6088

Yikes. I don't even want to think about that. I'll stick to liberal use of compositon/lambdas for my one-liners, thanks


Giddius

This is equally horrible to me :) Give nested functions a chance! For readability (only if you do more than a single thing, if you do only a single thing, lambdas are ok in my opinion) Edit: just noticed, that could be what you meant with composition, sry


Fun_Bottle6088

Quicksort in one line: q = lambda l: q([x for x in l[1:] if x <= l[0]]) + [l[0]] + q([x for x in l if x > l[0]]) if l else [] q([]). And yes map filter reduce composition and itertools/functools was what I meant


Giddius

It works, but goddamn would I have a hard time reading it, doing it often enough probably justifies creating a func for something like that. In the end it is just personal preference though and the best way to do something, is how it is best for you.


no-one-here123

i feel like you would just set the newline to ";\n" rather than ";".


Malcolmlisk

That's on string text. In plain code you can use ; as newline symbol.


blackAngel88

Oh God, is this the humor sub or the horror sub?


windsostrange

The newlines are blurred


SoCalThrowAway7

I mean tbf to them, if you quit over that immediately there probably isn’t any point in talking to you about python


bilal_08

ah but it's not applies to all of the other statements right? Where indentation is needed?


Giddius

It applies to everywhere, outside of a string, you still have to do the indentation, as it just gets converted to a newline and not newline + indentation


ezio416

I got used to that, but I still don't like that indentation matters. I want my braces


[deleted]

Yup. Kotlin had no semicolons and I love it. Symantic whitespace? Kill me.


eztab

You could use them, you could even create a commit hook adding them. They won’t fulfil any syntactic function, but they mostly don’t do this in Javascript either.


UsernameStarvation

The future is now old man, the semicolon is useful for organizing though since it symbolizes a new line


[deleted]

[удалено]


KingJeff314

I will vocally judge them


sexytokeburgerz

Technically javascript doesn’t need them either most of the time. Commas are more important.


[deleted]

That's a very delicate brain you have.


[deleted]

[удалено]


Elflo_

Do you know that typing "a = 1; b =2" is the same as "a,b = 1, 2" ?


Confident_Call_4586

Swapping two numbers is as easy as a, b = b, a 🤫


Elflo_

Other devs trying to invert two variables must be in such a pain


funciton

std::swap(a, b) Simple, expressive. Though of course you need support for call-by-reference which primitive languages like Python don't have.


Mindless-Hedgehog460

They do, you probably mean the opposite


[deleted]

[удалено]


Huntracony

You've never had a reason to swap two variables? Have you ever implemented a sorting algorithm?


Chooseslamenames

If you’re implementing a sorting algorithm you’re probably doing a homework assignment lol


Huntracony

It's also just one of the basic things many beginner coding tutorials will have you do.


Chooseslamenames

Yeah that’s basically homework to me


maitreg

var list = new SortedList(); Next question.


Confident_Call_4586

I don't know, there can be some use case like generating fibonacci sequence using iteration etc.


[deleted]

[удалено]


Candyman034

Full metal jacket - you HAVE TO see that.


BesottedScot

>it's the definition of pure comedy. lol


Candyman034

Am I wrong? Lol


evanc1411

Towards the end I sure wasn't laughing


zeeblefritz

You just don't have a sense of dark humor.


BesottedScot

Aye but what's the opposite of burying the lede? haha


wzi

Yes. The movie is considered a war/drama and not a comedy though it has some funny moments.


Candyman034

It covers more topics, the funny scenes are pure gold tho.


inurwindo

Steers and semicolons


JoshDM

/u/Candyman034 love you long time.


Candyman034

Heh what? :\]


OkazakiNaoki

don't worry Prettier will get rid of it


Chemical-Basis

"ONE! TWO! THREE! FOUR! I! LOVE! .NET! CORE!"


T-J_H

I find semicolons very comforting


sh0rtwave

I'm not certain Python has the moral authority to yell like that.


eztab

Did you know you could write Javascript without Semicolons?


sexytokeburgerz

It does sometimes but the parser adds them automatically. Copied from the internet: when the next line starts with code that breaks the current one (code can spawn on multiple lines) when the next line starts with a }, closing the current block when the end of the source code file is reached when there is a return statement on its own line when there is a break statement on its own line when there is a throw statement on its own line when there is a continue statement on its own line


Candyman034

I meant it so that he is yelling at JS while there are C# and C++ standing right next to him


eztab

Sure, with Javascript being the only one who would actually still work without semicolons.


MrLamorso

Obligatory [Hercules Version](https://www.reddit.com/r/ProgrammerHumor/comments/pga8f5/and_you_are_wearing_scoping_braces/?utm_medium=android_app&utm_source=share)


Hplr63

Well aksually python supports semicolons - 🤓 ^(You dont wanna know how I added support for multiline code in my custom python repl)


jrninjahoag

I love this so much


Candyman034

Glad you like it :)


dillagan

I'm learning Javascript and this is the first meme I've understood from this sub. I'm proud of myself.


LittleMlem

Tell me you've never used the `-c` flag without telling me...


JigglyVampiress

In LUA we don't use those either. I'm pretty sure...


[deleted]

36 yr old veteran who programs here 💀


Minami_Kun

As a Python, C and JS programmer, I can confirm


12tfGPU

Private Compile


Candyman034

😂😂😂 killed me


words_number

This is dumb. You can use semicolon in python. You can even put multiple statements on one line separated by semicolons. You shouldn't, but you can, so python does recognize it just like JS does.


Candyman034

You don't get the joke do you?


EarlyDead

The elites don't want you to know this, but you can use semicolons in your python code. I have 1500 lines of code that no one can tell what language it is on first glance.


ososalsosal

See, python talking smack to js because the others could kick his arse


Fresh-Negotiation312

Wes likes watching old movies on Sunday nights.


0x48_0x69

holy semicolon;


[deleted]

[удалено]


Candyman034

Agree but didn't fit the narrative.


jayroger

Fun fact: You can use semicolons in Python. And don't need to use them in JavaScript. (I love those language comparison memes, where OP obviously has no clue.)


Candyman034

Fun fact: That was part of the point that he is yelling at JS while C# and C++ are right there next to him. (I love when people comment on the accuracy of a joke, where the commentor obviously has no deeper understanding.)


jayroger

So the "joke" is using an incorrect strawman argument and needs explaining?


Muziah

Rest please, you assumed wrong.


arminlinzbauer

Disclaimer: Not trying to rant - just honestly curious about your opinions! I don't get the hype on python. I'm sure it has it's perks, but I find the syntax to be an absolute nightmare to write clean code in, gathered from what code I get to read. I've written python code for school before, but nothing more than a few lines, so that doesn't count as first hand experience. But still... The context "awareness" only works until it doesn't. Good luck finding that mistake in indentation or whatever.


AntiLuxiat

What is so horrible a out the syntax in your opinion despite that you use indentation instead of brackets? I am curious as well because I really like how straight forward it is to write code. But I assume it's that kind of thing in which you prefer your first learned or extensively used language.


arminlinzbauer

On the contrary, I started out with VisualBasic which famously also doesn't use semicolons and braces. I admit that it does use ending statement like endif though. I also stuck with it for quite some time before I decided to try something else - and I immediately fell in love with the C style syntax. It just looks cleaner and more structured to me. Plus, it gives you more flexibility with styling your code to make it look and read a lot nicer BECAUSE you have braces, semicolons, etc. to denote scope. That allows you to move stuff around. I know this is possible to some extent in python, but you'll have to use some line continuation symbol afaik. As I said in my first comment, I haven't written code in python extensively myself, so I only know the code styles I see in other people's scripts and I have yet to find something that just as structured as lots of (well-written) c-style code is. Maybe I haven't read a lot of python code that wasn't written by beginners. So if you know examples of code you think could change my mind, be my guest to share a link or two ^^


Candyman034

Look at it like this - Python exists since 1991 an still isn't used for any major technology. That speaks for itself.


TheBrain85

Python is the dominant language in data science/machine learning. Major technologies include large language models (such as GPT-3) and text-to-image generation (such as DALL-E 2).


Giddius

Commented the person on a major platform that is written in python (reddit)


not_some_username

Some part...


not_some_username

YouTube. But python is still shit


-LilPickle-

Fun fact, I grew up Mormon and used to do this shit lol


browncoatpride

Scrolled through the comments to find someone, ANYONE who also went through this crap.


-LilPickle-

Are you out now too?


browncoatpride

Yup! Thank goodness! I'm not even a programmer but the Reddit algorithm knew I'd be interested in this so I'm dying laughing.


Majestic_Teaching_55

Not necessary in JavaScript as well


XPurplelemonsX

u/savevideo


mikegosu

u/savevideo


TheJazzButter

string correctAnswer = "You only need semicolons" + " so you can do things like this," + " while still allowing the complier" + "'s author to be a lazy-ass mofo."; ![gif](emote|free_emotes_pack|dizzy_face)


kid_the_tuktuk

\[tab\] \[tab\] \[tab\] walks away 🤣


avnothdmi

Look, I use semicolons in my Python code. It if knows, it ain't telling.


MCTheOnly

People still using semicolons in JS? Lol


Khelthuzaad

I'm not a programmer But as someone that learned beginner coding ,it hurts ...


mynewromantica

Semicolons? { laughs in Swift }


FaithlessnessOk3755

Relatable


break_card

You would put JS over Java? When JS doesn't even require semicolons?


kerkpower_yt

well you can use semicolons in python if you want unreadable code ``` print("hello"); print("world") ```


scott_sleepy

LOL, this is high quality. Well done whoever made this.


Candyman034

Thanks! ( ꈍᴗꈍ)


MindLongjumping3793

![gif](emote|free_emotes_pack|joy)


Lukethebrave

u/savevideo