1,874 reputation
11924
bio website
location
age
visits member for 4 years, 3 months
seen Aug 11 at 22:29

Jun
12
comment Should I use parentheses in logical statements even where not necessary?
In all the languages I work with regularly it's .member before unary operators, unary before binary operators, * and / before + and - before < and > and == before && before || before assignment. Those rules are easy to remember because they match my "common sense" about how the operators are normally used (e.g., you wouldn't give == greater precedence than + or 1 + 1 == 2 stops working), and they cover 95% of the precedence questions I'd have.
Jun
12
comment Should I use parentheses in logical statements even where not necessary?
+1, parentheses for clarity are fine, but AND vs OR is a fairly basic case which I would want the other devs on my team to know. I worry that sometimes "using parentheses for clarity" is really "using parentheses so I never have to bother to learn the precedence".
Jun
12
comment Should I use parentheses in logical statements even where not necessary?
That said, the same precedence of AND/OR holds in Basic, Python, SQL... my impression is that this is the rule in the vast majority of modern languages (albeit not all).
Jun
12
comment Should I use parentheses in logical statements even where not necessary?
@GradyPlayer, Yeah, I said && and || instead of and and or to try to cover myself here. I think all the C-style languages are consistent about this (C, C++, Java, C#, JavaScript, ...).
Jun
12
comment Should I use parentheses in logical statements even where not necessary?
Just remember && is times and || is plus, and you'll never forget which comes first.
Jun
5
comment Career Day: how do I make “computer programmer” sound cool to 8 years old?
I don't know about 8 year olds, but my 4 year old recently discovered that my job has something to do with the Internet. She rushed to her Mom, shouting "Mommy, did you know Daddy works for the INTERNET?!? You buy things from there!"
Feb
26
awarded  Caucus
Dec
1
awarded  Notable Question
Sep
9
awarded  Notable Question
Sep
2
awarded  Yearling
Jul
13
awarded  Notable Question
May
3
awarded  Good Question
Nov
24
awarded  Popular Question
Nov
14
awarded  Popular Question
Oct
1
awarded  Nice Question
Sep
3
awarded  Yearling
Aug
23
awarded  Good Question
May
26
awarded  Good Answer
May
13
awarded  Popular Question
May
9
awarded  Favorite Question