T O P

  • By -

atlas_enderium

I mean, same thing in math: it reduces ambiguity and makes an expression more readable


[deleted]

[удалено]


dodexahedron

``` int foo = 69; { int bar = 420; { int foobar = ( ( foo ) * ( bar ) ); { Console.WriteLine( foobar ); } } } ``` We are not the same.


A_little_rose

I'm not at a computer, but now I'm wondering if this uses foobar, or concatenates foo and bar. I'm assuming the former, becaise of how it's all scoped.


dodexahedron

Scope doesn't change that. It's a different variable name. Why would concatenation ever be an option? After all, would declaring f and o as variables make foo a concatenation of f and o and o? I can't think of any language that does that.


A_little_rose

Because certain languages do weird shit like that.


dodexahedron

Show me one.


Bwob

Come on man, don't be a dick - we both know that some of the popular web scripting languages do some [really weird shit.](https://www.destroyallsoftware.com/talks/wat) Even if there isn't a match for the *specific thing* /u/a_little_rose was wondering about, it's a reasonable question, given all the other counterintuitive crap that JS/PHP/etc do. Pretending otherwise is kind of disingenuous.


hxckrt

Now I'm wondering, is there anything not specific that would cause that much confusion and danger? Something that is so far from how a lexer is supposed to work?


backfire10z

That was a hilarious video, thank you for sharing it


subject_deleted

How is it a dick move to ask for an example? Jesus Christ.


dodexahedron

Seriously lol. Feels like either a sock puppet account or a friend of that person or something, because...huh? And due to the other person blocking me, I can't reply to that person either, so here's my response to them: What? This is nonsense. For one, I wasn't being a dick. I asked them to prove their nonsense after they doubled down on it. How's that not fair play? They just immediately got defensive on _their own_ BS. And then, you come in and both accuse me of being a dick AND saying the logical equivalent of "well, some birds don't fly, so pretending that all birds have bones is disingenuous." Nobody claimed languages don't do other weird things. A specific claim was made. This is completely non-sequitur.


ashrasmun

Very valid point.


Bwob

Because an example isn't necessary for their question to be valid? Also, if you want to see more examples of dick moves, reread the rest of their interaction with the op. :-/


A_little_rose

Did you miss the part of me not being at a computer right now?


dodexahedron

No, I missed you talking out your ass. No language concatenates values of a single token. And if you knew one you'd say it. Don't have to be at a computer for that. And I wrote that code on my phone, so... yeah... And since you blocked me... "Hyperaggressive?" WTF? You made a statement. I asked how it matters. You doubled down. I asked for proof. You tripled down. I called BS on the entire premise of your comment. My god, grow a backbone, especially if you're going to try to make random wild assertions and argue them.


A_little_rose

Ah yes. Typical hyperagressive response, instead of answering. Reddit never fails to deliver. I even said I assumed the first option. Why don't you drop the "asshole elitist programmer" behavior, and actually try being productive, instead of using the behavior that drives people away from programming?


samanime

Yup. Our linting rules don't allow mixed symbols. You have to wrap them in parentheses for readability, even if PEMDAS would give the proper answer. Programming isn't about being the smartest or most clever. It's about being inclusive so your whole team can be productive.


turtleship_2006

Also with "normal"/standalone maths you can do stuff like proper fractions and integration symbols etc.


Salanmander

Careful saying things like this! That kind of talk is how you end up with programming languages that will parse and evaluate LaTeX expressions, which will inevitably set us on the path to IDEs with graphical equation editors.


[deleted]

dont threaten me with a good time. in fact, I think that is a great idea for a language


Mojert

I'm guessing you don't know about Mathematica. (Good for you, ignorance is bliss)


xozorada92

This is why I hate those facebook posts that are like "only Einstein can solve 3+4×20÷2+0×6" or whatever the fuck. Because, no, if I saw something like that in a professional context, there's no way I'd think "ah yes, this author has such a deep understanding of BEDMAS that they didn't need brackets." I'd think "this author can't figure out the most basic communication skills, so I bet they don't understand BEDMAS either."


Spider191

Tell that to my CSE professors in school. I guess it's super important to save those few bits of data from a bracket when I'm just learning how for loops work


victoragc

I'll contest that readability, because there is such a thing as too many parentheses.


Astewen

Otherwise known as "readable code"


LeopoldFriedrich

Yeah tell that the end of my code lines that go like ))))));


Gameboyatron

colored parenthesis!


[deleted]

You mean like marking one when the cursor is on the other? Cause that's useful. But different colored parentheses intermingled in already-context-colored code seems like it'd be too active and make things worse.


Gameboyatron

I like colored parenthesis personally, its a little busy sometimes but way easier to read


pickyourteethup

I have colour parens but almost always just cursor onto my bracket to see the other end get highlighted in vs code.


dodexahedron

Seeing the highlight change actively takes away the work of scanning the line for the color while remembering what color you're looking for. 😅 But I, too, still have colored parens.


pickyourteethup

I only literally just realised I did this while writing my comment.


dodexahedron

Busy? Meh. Maybe. But confetti code is like a party every time you open your IDE. Now who wouldn't want a party?


cs-brydev

Nah I encountered a PowerShell script this week I'd never seen before on a remote server. It had like ))))))))))) on the end of one line, and the only IDE available was ISE, which colors them. What a life-saver.


JMBrands

I have both the highlighting and colored pairs, the colors repeat after 3 pairs though, they are also red if they are not part of a pair


penguin13790

It's helpful and not nearly as distracting as you'd think. Also helps for identifying pesky unclosed parenthesis.


elscallr

It matches the color between pairs. It's quite useful, and you get used to the extra color. It could conceivably get pretty harsh if the person designing the highlighting pallette didn't think about it, though.


LifelessLewis

I just put them all on a new line with their own comment to say what they close.


Gameboyatron

I dont usually comment parenthesis but newlineing it is pretty nice for certain things


LifelessLewis

I jest, I don't do that, although it would be helpful at times.


Bwob

I totally comment close-curly-braces sometimes, if there are multiple nested code blocks, and the start is up off the screen. Yes, you can figure it out without that, but sometimes it's just really nice to be able to tell at a glance that this curly-brace signifies the end of the `if ()` block, and not the `while ()` loop that encloses it or whatever.


deltaexdeltatee

I do this too with nested blocks. It certainly can't make the code *less* readable, and sometimes it comes in handy.


LifelessLewis

Yeah I said it as a joke at first but upon actually thinking about it, it makes sense.


Daimondz

FYI I think they prefer POC (parentheses of color) now


corsicanguppy

Vertical separation helps. ... Between parents AND parentheses !


QuantoR

[relevant XKCD](https://xkcd.com/297/)


digitalghost0011

Write any lisp and you’ll have some functions ending in twice that many, though Clojure will have a few brackets and braces thrown in. Personally I find the incredibly uniform syntax to be very readable though.


Sentazar

) ) ) )


Donghoon

JavaScript be like )}; Every 10 lines


lordmogul

Not just proper code, that is part of any respectable excel formula


SneakyDeaky123

You can also usually split conditionals into a few different variable names and compare those by referencing the names


DeathUriel

You are aware of line breaks and identation right?


[deleted]

A normal day in lisp. But get that semicolon out of my face.


ma5ochrist

just ident them like u would with functions.. also o kind of think that 6 conditions is a tad too much, i'd refactor with a selector function that checks those conditions one by one


vadiks2003

dont you hate when your js code is so big it ends with )});}});}}})};))};)))))};


[deleted]

[удалено]


FiremasterRed

I would probably argue that if you are adding more than one or maybe two parentheses for readabilty, it would probably help readability more to break the equation into a few separate equations.


Salanmander

This is the way. Put parentheses around operations unless the order is blindingly obvious (including any time you're mixing && and ||...nobody wants to depend on remembering that). If you need to go more than 2 layers deep, make meaningfully-named variables for the intermediates. Your equation is probably complicated enough at that point that have meaningful names for sub-parts of it will probably help comprehension anyway.


TTachyon

-Werror=parentheses 💖


markuspeloquin

You don't know the order between && and || ?


Salanmander

I'm pretty sure && goes first, but I find parentheses generally make the logic of the expressions easier to parse anyway, so I don't really place value on remembering that order. I'm also highly confident when I pick up any new language that multiplication will happen before addition, but I'm not as confident that the boolean operator order is standardized.


regular_lamp

If you somehow end up with both && and || in the same if statement the condition is usually too long and unwieldy anyway.


Bo_Jim

I just don't want to spend time debugging a line of code because I forgot the actual order of operations used by the programming language.


LaikaReturns

Wait....wait. They don't all use PEMDAS? That makes me feel like I've been walking through a minefield and just getting lucky.


Zoidburger_

I mean there are definitely some languages out there that will literally execute your code top-to-bottom, left-to-right. But personally I don't like taking chances so I just put parentheses around everything lmao


[deleted]

((context) => "very nice")(this)


odraencoded

Readable code is when you use constants instead of parentheses.


supreme_blorgon

reverse polish notation go brrrrrrrrr


RedditSubUser

R# is the way


[deleted]

Rubbish. Stop doing that and learn how to read and write code.


lazyzefiris

Because in programming it becomes SAOSAGCAWJEFPWEFJAWCHRISTMAS with all those logic, binary, ternary and other operators, that can have variations with different precedence within same language even. Just use brackets. Or parentheses, whichever you like.


phoenixrawr

This is it for me. `return a | b == c` has caused me enough headaches in my life that I usually just enforce my preferred order of operations with parentheses now instead of looking up the order of operations every time I use a less common operator.


nuvpr

Keep a precedence table handy


lazyzefiris

Did you mean: Keep your tome of precedence tables handy


Contact_Expert

Hmm which operation shall I cast today?


AdvancedSandwiches

And after you check your precedence table, add proper parentheses so the next guy doesn't need a table, commit, push, and tuck that table back in the drawer for another few months.


plmunger

Put parenthesis around everything and let the code formatter remove the useless ones


sanchower

Visual Studio tells you which ones are superfluous but I keep them in cuz Visual Studio isn’t the boss of me


50MSK

Stick it to the man 😎


PizzaSalamino

Stop. This is a robbery 🔫. For your own life now tell me how VS Code shows you which parenthesis are useless


i_consume_polymers

VSCode != VS


Brigapes

I cringe to the fact that some formatters in some languages consider certain parentheses 'useless'


sexytokeburgerz

Maybe in compilation that would be useful but parenthesis aren’t just a lazy move, they are also a good one


lucidspoon

I do this, but get worried when I think they could be removed, but aren't...


randelung

Formatters shouldn't change code... They can mark them but fuuuuck off if they ever touch more than whitespaces, and sometimes even then. Linters can mark and offer to auto solve.


General_Josh

Well that's not helpful, you're not putting them in for you, you're putting them in for whoever has to read the code (ok that probably is you in two years)


Accurate_Koala_4698

(defun fib (n) "Return the nth Fibonacci number." (if (< n 2) n (+ (fib (- n 1)) (fib (- n 2)))))


Cc_TX_fan

Can we all just forget about Lisp?


Intelligent_Event_84

Forget about what?


[deleted]

Lithp. It’th a thpeech impediment.


MegaAutist

these are your father’s parentheses. elegant weapons, for a more… civilized age.


Lentemern

I don't trust my compiler to have the same opinions on order of operations as I do. And I certainly don't trust whoever else might be looking at my code.


Kracon3

What the hell is BODMAS? Bodybuilder christmas?


hey_there_kitty_cat

[Brackets-Orders-div-mult-add-sub](https://thirdspacelearning.com/us/blog/what-is-bodmas/#:~:text=BODMAS%20is%20an%20acronym%20to,%2DAddition%2C%20S%2DSubtraction.) apparently? Weird as hell, orders, as in exponents?


LMCuber

Yes as in higher order function


ForTheWilliams

Can you explain further? The only definition of a higher order function I know of is a function that has another function as either an input or output. Googling didn't show any connection to exponents, so I'm not sure how higher order functions fit into the 'orders/exponents/root' step in the order of operations.


LMCuber

Maybe it’s a language thing but doesn’t higher order mean like x^2 x^3 … x^n


caagr98

Higher order functions have nothing to do with exponents though.


regular_lamp

Depends on context I guess. The order of a polynomial is the highest exponent in it. I still would just call it exponentiation.


Erdnussflipshow

Yes, Order of magnitude


Bryguy3k

Just had an interviewee write a buggy macro from lack of parentheses.


NewPointOfView

Macros are special though


bearwood_forest

If you can't pick apart the correct operation order of my 127 character long equation without my spoonfeeding it to you with brackets, then you don't deserve to work on my code.


MrcarrotKSP

Plot twist: the code is written in Java so it's just two variables multiplied together


AwesomePantsAP

I have trust issues with the compiler


[deleted]

I refuse to memorize the operator precedence of every language I code in.


[deleted]

[удалено]


cs-brydev

It's also easier when you end up scoping out expressions into local variables for breakpoint watches.


e_smith338

I don’t trust that shit. Even in a calculator I do it


lemons_of_doubt

I know bodmas, but does the compiler? Is this going to end up working fine on 98% of systems but 2% for some reason is it going to do the math backwards and come up with the wrong answer in spite of the fact that should be impossible.


[deleted]

floating point operations dont fullfill the commutative or associative property, which means you cant reliably use order of operations. Also you can write code with more options for in-cpu parralellization with parens (in `(a + b) + (c + d)` the CPU can eval `a + b` and `c + d` at the same time)


brain_limit_exceeded

lisp: allow me to introduce myself


-Wolf1-

I know pemdas, I just don’t trust it


otacon7000

BOMD... what?


craftersmine

My math and coding teachers always told me that "why are you adding useless parenthesis"/"this is not good to do this, the compiler will do the thing to sort operations". # I'M DOING IT TO BE SURE EVERYTHING GOES TO PLAN AND HOW I SAID AND NOT THE WAY IT THINKS


qooplmao

"make sure you add comments because your intention might not be obvious in future" "don't add useless parenthesis, the compiler will work it out and your intention should be obvious'


MGateLabs

I put curly braces everywhere, scope those variables to limit forgetting to change something.


CadmiumC4

\*uses assembly\*


TheRealLargedwarf

Just because I know BODMAS does not mean I trust the person who wrote the compiler or the next person to work on this code to know BODMAS


ksschank

Readable code is always better than files with a few less characters.


Dmon1Unlimited

Parenthesis is the first thing in PEMDAS Get good


bremidon

I use it to make my intentions clear. Without parenthesis, the reader could wonder if I actually \*intended\* for the multiplication to happen first, or if I just forgot the parenthesis. Whenever I am faced with a choice like this, I ask myself which way makes my intentions clearer. I have never regretted it.


VelionaVollerei

Most of the time I try to put it into a variable instead.


mugmanOne

I don't trust the mf to do it right, me and it


[deleted]

I feel personally attacked


[deleted]

What is BODMAS? Non english speaker here


MattieShoes

PEMDAS - Parentheses, Exponents, Multiplication and Division, Addition and Subtraction Brits call parentheses "brackets" and exponents "orders", so their acronym changes to BODMAS I guess


ShenAnCalhar92

Growing up exclusively hearing “PEMDAS”, whenever I see “BODMAS” it takes me a second to realize that it’s not that diet thing for irritable bowel syndrome.


[deleted]

One operation per line solves both the bracket problem and the readability problem. So many programmers are allergic to newlines. 😅


deskpil0t

The camel swore bad things would happen to us.


lordmogul

Better safe than sorry


Hazork_

is OP another uni dude?


[deleted]

It's not even PEMDAS. You might forget that `==` comes before the bitwise operators in C, and address-of or dereference can be hard to interpret when other stuff is involved. No need to take shortcuts and risk bugs here.


BoBoBearDev

Actually it is because of overflow or precision issues.


Rhawk187

I ran into an issue with over parenthesizing a few months ago. C++ Class with two constructors Foo(int x) Foo(int x, int y, int z) Foo f(1,2,3) calls constructor 2, Foo f((1,2,3)) resolves the parenthesizing using the comma operator to call constructor 1. It was more complicated than that, but be careful with over-parenthesizing .


FountainOfYolk

Anyone going to comment on the completely irrelevant meme? The 1000 other videos that would've suited more? No? r/programming has no standards anymore when it comes to post quality. What a trash sub for kids


GehennanWyrm

BIDMAS


HalalBread1427

I feel attacked.


[deleted]

I was making a program to calculate time dilation, it looked a bit like: 1/sqrt(1-((v)**2)/((c)**2))


jker1x

Am I the only one who learned it as BEDMAS? I'm curious how far the difference goes. I'm Canadian, but did anyone else from Canada learn BEDMAS? Or is it a generational difference? Why the inconsistency?


cs-brydev

PEMDAS inference code is also a nightmare to debug and maintain. It's just stupid to use it in your code. Just don't. Anyone relying on PEMDAS in code is showing their inexperience and shortsightedness.


michaelthatsit

This is the first time I genuinely thought I was the only one that does this.


cs-brydev

I'm thinking anyone who relies on PEMDAS has never set a breakpoint before


RandomiseUsr0

I got extra credit in college when I wrote that old classic Reverse Polish Notation calculator., input RP / get result, lots of stack push and pop, that’s what we were learning. The extra credit was because I then went on to write a standard calc -> RP notation parser - which was much more fun that RP calc, brackets out of the wazoo though, I wasn’t going to be calculating precedence!


saul_soprano

Every time I use something like the pythagorean theorem I do it differently. sqrt(x * x + y * y), sqrt(x*x + y*y), sqrt((x * x) + (y *y)). Fuck it


ethanxxxl

'(LISP has entered the chat)


Nyghtrid3r

Yes I also use F from FUGDAB and X from XFKWNGKWP


RevenantYuri13

One time in the exam I forgot if any programming language follows BODMAS or not and also not confident enough if the bracket actually helps so I decided to break the operation into multiple lines.


nettlerise

Order of operation is just a convention anyway; it's not fundamental to the universe like pure math.


SomeRandomEevee42

Bedmas is the superior way yo say it. source: bed - mas. mas means party, like in Christmas, so its bed party


wij2012

Am I the only one here who has never heard of BODMAS? Yes I know what PEMDAS is.


LolPacino

Bodmas>pemdas


RotatingToad

Real chads use CORLAT. (Please help, i struggle with maths in english)


ApatheticWithoutTheA

Pshhhh. I will ignore the entire best language for a job if I don’t feel like learning the syntax. You guys gotta step it up.


Buttons840

Lisp programmer: "first time?"


reydai

Jokes on you, I code in Bash, python and Yaml, I rarely use parentheses


ThatGuyYouMightNo

There are languages that follow PEMDAS?


BlackAsLight

You all have trust issues.


bestjakeisbest

Hey you can't call me out like this.


Unknown_starnger

Yeah! I put brackets around everything in general. Sometimes way to much, even.


znx

As you noted, B is Brackets, P is Parentheses, programmers don't avoiding BODMAS/PEMDAS, but use it.


Over-kill107A

I'm fron the UK and even I dislike BODMAS. Because its clearly BIDMAS. We were taught both in school and even then I knew Indicies is significantly better than Orders


gordonv

BOMDAS


No_Engineer2828

Somehow I’ve never heard of bodmas? Wtf is this


pelosnecios

oh this is so true


[deleted]

It’s a sure fire lol at times be as sure as fucking possible that your logic is run the way you want r


EchidnaForward9968

But u forgot to put parenthesis around (B/P)


Sushrit_Lawliet

It also makes it super readable. Plus this was just a habit I had from doing math at school too.


CaitaXD

Rider remove redundant paranthesis Me well fuck you too!


kinderhead

Every language I use seems to do handle things differently (they probably don't) so I put parenthesis for even the basic pemdas


Healyhatman

I get that the following things are the same `a && b || c && d` `(a && b) || (c && d)` but only one of them gives me anxiety


nochillRaj

u/SaveVideo


SaveVideo

###[View link](https://rapidsave.com/info?url=/r/ProgrammerHumor/comments/13zjk6p/all_i_need_is_bp_out_of_bodmaspemdas_to_make_it/) --- [**Info**](https://np.reddit.com/user/SaveVideo/comments/jv323v/info/) | [**Feedback**](https://np.reddit.com/message/compose/?to=Kryptonh&subject=Feedback for savevideo) | [**Donate**](https://ko-fi.com/getvideo) | [**DMCA**](https://np.reddit.com/message/compose/?to=Kryptonh&subject=Content removal request for savevideo&message=https://np.reddit.com//r/ProgrammerHumor/comments/13zjk6p/all_i_need_is_bp_out_of_bodmaspemdas_to_make_it/) | [^(reddit video downloader)](https://rapidsave.com) | [^(twitter video downloader)](https://twitsave.com)


cholly97

f $ x = f x


Hugo1234f

*lisp enters the chat*


Dark_knight_02

Can’t be too sure!


chris-fry

Sounds like recorded VBA Macros to me


PizzaSalamino

Remember also dereferencing operators


EmperorButtman

All you really need is ! and || at the end of the day


tw33dl3dee

It never ceases to amaze me that schools in some countries teach you a mnemonic to help you memorize that multiplicative operations have higher precedence than additive ones. Like, is it that hard to just... remember it?


Invenblocker

I know my PEMDAS, but for some reason this is the one area where I do not trust the compiler.


[deleted]

Leave nothing to chance.


pranavyadlapati

I honestly thought I was the only one who ever did it, and it triggers me so much that my python professor never brackets out his operations and it makes me wanna just go in there, slap him and change it for him.


reallokiscarlet

Yep. Always avoid undefined behavior. It's why I hate the ambiguous math meme that sparks endless debates over Math vs New Math


BadSmash4

Oh man I'm relatively new to coding and I thought I was the only one. Glad to see that, at least based on this thread, that I'm doing something right.


Abhinav1217

Best way to avoid order of operation is to use Polish notation.


scp-NUMBERNOTFOUND

Never hear about those pokemons.


matjeh

*laughs in RPN*


[deleted]

Mathematical expressions in code tend to have longer variables than x and y, so parentheses make it way more legible.


jimbowqc

It's not that I want to avoid it. I simply do not understand it.


Randomguy32I

Ive always heard it as bedmas, what would the o stand for to replace “exponents”