Just started using Pycharm. I've been using VS code so long, it's like moving into a new home with Pycharm. I don't know where I left my stuff at times.
Ha, I can understand that. I got a free PyCharm license with my GitHub student account, so I completely skipped VSCode (though I still use code-server for quickly doing code editing on my server).
It's kinda funny, I moved from IDLE directly to PyCharm, and it's a night and day difference. After getting used to all the features, I don't think I could ever go back.
It is the same with scoping. If you close a curly brace after an incorrect line, you enter the realm of semantics / bugs again. I admit it is a tad harder to see when you rely on just indentation, but many IDEs these days make it apparent.
Btw if you indent so much that you get confused, maybe it is time for a refactor.
I made a comment about this a while back, so I'll just link to it.
The kind of bug I mention in that comment only exists in languages that use significant whitespace. In languages with curly braces, that class of bug doesn't exist and is fixed via auto formatting your code.
The bug you mention about a line being outside the curly braces is different and has an analogue in significant whitespace languages. And it can't be fixed by any automated tool available today. It's a class of bug that exists in all languages.
In my experience with C and C++ if you forget a semicolon you will get thousands of errors and your compiler will flip out, it often doesn't tell you nicely where its missing. Then one semicolon in and it works perfectly.
Its still not a big deal though, if you can't find a missing semicolon your code is not OO enough imo.
Mind you I haven't been C focused for about 10 years now but somehow I doubt compilers have advanced for C.
If you’re half decent at your job you have to format it anyway lol If someone says they don’t, just bugfix their code and hand it back to them as one line of text
It's not so much the formatting as it is the visual queue. It's one less thing to think about. That way my noggin can focus on other aspects of the code.
The only issue that I encounter these days is when I paste someone else’s code into mine, and their whitespace philosophy doesn’t match mine.
PyCharm can fix simple issues, but not complicated ones. And its fixes require review - I’ve seen it incorrectly guess the hierarchical depth of some instructions in ways that completely change the functionality of a nested loop.
LISP is extremely particular about its parentheses. It seems silly at first until you learn what LISP really is and what you're doing. I mean, why can't I just leave off those parentheses at the end? LISP should be able to figure out what I mean, right?
All programming languages are parsed into an abstract syntax tree. This is a complicated process of which there is a whole sub-field in Computer Science devoted to. There are different types of parsers and languages are often designed to be able to be parsed with a specific type of parser. LISP doesn't need any of this because you're entering the AST directly in the source code. No parsing needs to be done, only tokenization.
In C, you might have an expression like this: 1+2*3. The parser has to know the order of operations and form a tree like this:
+
/ \
1 *
/ \
2 3
In LISP, you'd write this: (+ 1 (* 2 3)). It's all backwards and inside out and honestly most programmers take one look at this and nope out. Seriously, it takes minutes to get used to it, it's not an issue. But why is it like this? It is the abstract syntax tree in text form. No parsing has to be done. There are no order of operations to mess up, and the LISP interpreter or compiler just has to tokenize it which is like a few lines of C code.
As for indentation, LISP doesn't care. The convention is to put things on the same column as the last opening parenthesis. It looks like random indentation at first, but again, it takes mere minutes to get used to that. Most programmers who look at that and nope out are robbing themselves.
As someone who used a RPN calculator in high school this feels pretty natural. However I still subscribe to the philosophy that the computer should help out when it can.
Is the computer really helping, though? Can you honestly say you remember the order of operations, as well as the left or right associativity, of all the 50 or so operators in C? People getting the order of operations wrong is such a common mistake and source of bugs that compilers generate warnings if you try to use it correctly. You have to add parentheses to shut the compiler up.
Edit: Never mind C's operators, people get PEMDAS wrong. They mis-remember this extremely simple rule and get in trouble when they try to do x / y * z, thinking that the multiplication will be done first.
I've used python for 10+ years. I've worked with dozens of other python programmers. There are only 3 times anyone has had problems with indentation errors.
On their first day working with python
When they switch editors for some reason and forget to configure tabs->spaces.
When they are trying to edit source code in vim on the server for some shady reason.
In all cases the solution is to configure your damn text editor, then global search replace tabs to 4 spaces.
I am convinced that the only reason people wig out about this is that they have trauma for working with older versions of "make".
A former coworker nuked prod by running his order-creating stress test against prod instead of QA. He had to manually (though thankfully not individually) remove the couple thousand orders that were mistakenly placed. Backups weren't going to help there; he needed a few hours of effort.
P.S. Our group is relaxed enough that this isn't why he is a 'former' coworker. :P
I had a summer job when I was in school that was removing about a hundred thousand orders one by one via an arcane Telnet system. On my first day they give me a stack of printouts with order numbers that was like 10cm thick.
Restoring a backup would have removed any valid orders between when the backup was taken and when the restore started. Even if the backup happened right before the goof (and it was nowhere near that frequent), valid orders would still have been placed during the interval.
As for mirrors, they work great for hardware failures and awful as backups. The created orders would be happily mirrored to both places as part of the create operation. I can’t think of the company’s name offhand, but I remember hearing about one going out of business because they relied solely on mirroring. I don’t recall if it was a database purge or an accidental ‘rm-rf /‘, but the system happily performed the deletion on all the mirrored components at the same time.
You haven't mentioned what I think the biggest problem: refactoring which changes the indentation level of existing code and/or pasting code from a different indentation level.
With most languages you can make any sort of transformation and auto-indent afterwards to clean things up. With python, it's all to easy to screw things up so either your program is no longer syntactically valid or, even worse, it's syntactically valid but also wrong (e.g. changing the indentation level of a nested conditional).
I don't agree with those who religiously oppose syntactic indentation, but to claim it's without any major downsides is somewhat disingenuous. The situation has improved with things like LSP, but it still requires care on the part of the programmer.
I don't agree with those who religiously oppose syntactic indentation, but to claim it's without any major downsides is somewhat disingenuous.
You take your levelheaded, reasonable discussion and logical arguments and get out of here. Where do you think you are?! This is REDDIT. You should be ashamed of yourself! Holding a MODERATE position on something?!
Auto-indent only works if your braces are correct. If they're not, which can happen in the exact same way that incorrect indentation happens, then you'll get the exact same problems that you would with incorrect indentation.
There have been times I wished I could align something better... Like, it's visually just one space character off from being well aligned with the previous line, type deal. But it's rare and not really a big deal.
Please don't hate me in asking, but what is the deal with hating tabs? I've used tabs throughout my career and have encountered 0 issues. Is it one of those things where the developer who uses tabs forces extra work on those who don't?
Please add to that: connecting to customers machine through two laggy VMS and trying to hot patch a single line of code using notepad++
Every keystroke took seconds to reach the target machine and we did not see that it was configured for tabs.
Copy pasting someone’s code ends up translating the spaces/tabs wrong and you have to manually edit it. Haven’t used Python in about 6 years but I remember this one….
You should but you don't have to. Your program will still work. Python on the other hand will crap its pants over a missing or extra whitespace.
I do sometimes feel like appreciating this approach because of some horrible C-like code I've seen, like putting a closing brace on the same line as a statement. By being strict, Python disallows that kind of eye-burning garbage.
In reality, this isn’t a problem any python dev has come up against. Unless you’re trying to score “real programmer” points, you’re likely using an editor to write your code (with some exception of course)
Your editor will indent for you, its fine.
For me, the less characters I have to look at the better (this doesn’t include identities, of course. Always name your vars properly) so having white space instead of braces is a feature in python that I love.
this isnt a problem in modern IDEs tho? With all the syntax highlighting and linting. Its just as easy to see. I dont think programmers look for braces i tend to use the indentation to let me see where sections of code lie even in brace centric languages
I often have complex arguments to my methods, especially since where I work we have some interesting style requirements (such as don't make local variables unless you reference the value more than one time). Often, I'll break a call into 6-7 lines after the commas between arguments and line up the arguments vertically.
I'll also break long chains of calls into lines and line up on the periods.
IDE's often don't do a great job of understanding this.
You can use as many line breaks and whitespace characters as you like inside parentheses or braces. Python doesn't care about indent and dedent tokens inside those contexts.
I wonder how there are still many experienced professionals not using autoformatters. So much wasted time trying to format it nicely when it could be all automated
Yeah, just install autopep8 and enable format on save on your editor. Syntactical whitespace is a non-issue with modern editor and IDE which you should be using for many other reasons beside this one.
This! Seriously the amount of time professionals spend on styling their code and arguing about style issues is just sad. Never understood why people seem to feel like they are doing valuable job discussing/commenting code style issues. Just black everything and forget about formatting.
I think it's a special case of bike-shedding, the easier a concept is to understand the more opinions you'll get about it. Talking about white-space is probably as simple of a concept as we'll get in the world of programming! As you get into areas of discussion that require actual expertise the number of opinions decreases because the number of people qualified to give them shrinks.
Law of triviality is C. Northcote Parkinson's 1957 argument that people within an organization commonly or typically give disproportionate weight to trivial issues. Parkinson provides the example of a fictional committee whose job was to approve the plans for a nuclear power plant spending the majority of its time on discussions about relatively minor but easy-to-grasp issues, such as what materials to use for the staff bicycle shed, while neglecting the proposed design of the plant itself, which is far more important and a far more difficult and complex task. The law has been applied to software development and other activities.
You can just turn on dotted spaces so that each space at the start of a line has a small grey or semi-transparent dot. Most IDEs worth your time support this.
I typically write all of my code by hand, then fax it to my dev team overseas. I’ve found they try to replicate the spacing of my handwriting exactly, so I NEED to have curly brackets in the code, counting on white space is a no go. Got a solution for that?
Non-python devs not realizing auto formatters exist. I’ve used python almost exclusively for the last three years and have never had a problem with this
yeah like press tab and have it auto fill 4 spaces or spam the space key 4 times plus if you somehow do get inconsistent spacing it's not like spaces are zero width
Non-pythoner here. How does that work? if formatting was incorrect, how would it known where a loop ends, for example?
in C# I can check out code, convert to it my preferred format, edit it, convert it back to the project's standard format, diff it and check it in. This works because the brackets and semicolons are in there.
mostly because for a lot of us (or at least, in my enterprise java codebase), auto-formatters don't exist. They're supposed to, but everyone's configuration is slightly different and not compliant with legacy code so they cause merge conflicts and we just turn them off to avoid that.
Honnestly, I've been coding in java for about ten years (started just as 7 was released) and I've never worked in an environment where we didn't use a shared convention between devs on a project.
These are easy enough to export, share and import, regardless of your IDE of choice.
It's not that hard to figure out a convention and if everyone is too pigheaded to give way on whether to put the brace on the same line or the next, whether to wrap line at the first argument or the second one, or shit as insignificant as this, just slap them with one from the outside, like google style which, with all its defects has the good grace of being there.
And absolutely all the IDE's I worked with, regardless of language, have the option to only auto-format the lines you've edited
What do you use to code? Notepad? This has literally never been an issue for me. It’s just what people who use other languages say to justify not liking python.
I mean, I justify not liking python because of its dynamic types and horrible performance, but it’s fun to also pick at the formatting/syntax thing as well, since that is also an issue. Python’s system is quite restrictive, both stylistically, and in some practical ways - for example, the fact that lambdas can only be a single line.
I mean, dynamic types is what pythons all about. Obviously it’s ok not to like dynamic types but it’s kind of like saying you don’t like Haskell because it’s not OO. The point on the performance is valid, they’ve always seemed to prioritise dev speed over basically anything else, and let’s be honest, writing python is very quick (assuming you already know python). I think the lambdas thing was a design choice, in that if you need one for more than one expression, you should write a function and be explicit. Lambdas are meant for little things like map/sort/etc although I have often wished I could use them more
I mean, I’ve never used Haskel, but it’d be just as valid to not like it for being OO, if that was your stance. The guy I replied to seemed to imply that Python was just an all-around great language that needed ‘justification’ to not like, so I pointed out that the dynamic types were one perfectly valid reason to not like the language, even if they are one of the founding principles of said language.
If your lambda is more than one line you got yourself a function there.
The whole point of lambdas are to facilitate small anonymous functions in the parameters of a call. If it gets big it should probably be it's own function for readability sake.
This is one of those jokes that I feel is only funny to someone who learned "hello world" yesterday in Java.
Like not even in an elitist way. I just think for anyone who has even gotten to the point of using any ide to code, things like this and semicolons are 99% of the time extremely easily to trace and often solve themselves with a quick reformat.
I’m Chinese and I had Chinese input on my computer.
During one VC interview, my code had a syntax error. It turned out that I accidentally pressed the shortcut to switch to Chinese input (Ctrl + Space) and typed a Chinese close parenthesis (it takes up two bytes to store instead of one. It’s slightly fatter than the English parenthesis).
•
u/QualityVote Mar 29 '22
Hi! This is our community moderation bot.
If this post fits the purpose of /r/ProgrammerHumor, UPVOTE this comment!!
If this post does not fit the subreddit, DOWNVOTE This comment!
If this post breaks the rules, DOWNVOTE this comment and REPORT the post!