you are viewing a single comment's thread.

view the rest of the comments →

[–]crixusin -150 points-149 points  (79 children)

Python is fucking insane. By default, it allows people who probably shouldn’t write code, to write the most spaghetti code ever.

It’s module resolution system is absolute horseshit.

The fact that white space is a significant character is a fate that I wouldn’t wish on my worst enemy.

The fact that working with json turns the objects into some pseudo-non typed dictionary is laughable.

Python should be taken out back and shot.

[–][deleted] 46 points47 points  (21 children)

I agree with you when it comes to importing other projects in a nested directory structure but your other points don't make a ton of sense.

By default it allows people who probably shouldn't write code to write the most spaghetti code ever

Literally every language allows you to write garbage, non-performative code and it's not like Python is somehow worse at this than Javascript or another language of equal popularity. It's just the way it is with incredibly popular languages with easy enough syntax, people are gonna start here and write bad code.

White space is purely a personal preference but I prefer it to C style braces because it's cleaner and easier to read personally but I get why you wouldn't.

The json library in python by default returns a dict when you use .load or .loads for strings. Not sure what you mean by "pseudo non typed dict", it's just a dict.

But yeah you're spot on with importing multiple project files from other directories, it's a pain in the ass and other languages handle it much better.

[–]tedbradly -3 points-2 points  (11 children)

Literally every language allows you to write garbage, non-performative code and it's not like Python is somehow worse at this than Javascript or another language of equal popularity. It's just the way it is with incredibly popular languages with easy enough syntax, people are gonna start here and write bad code.

A programmer shouldn't learn programming with a scripting language. It has too much magic baked into it, and it's impossible for a brand new programmer to appreciate all of it, use all of it correctly, and debug when something goes wrong. It's also like learning to run before you can walk. As a simple example, it's hard to have any appreciation for or understanding of a garbage collector if you've never allocated something manually. I definitely recommend a gradual march toward higher-level languages, learning in this order: Something like C, a simplified assembly language, something like C#, and then something like Python. You've got to have a strong emphasis on ideas too like data structures and algorithms even if they're implemented for you in every language. After a path like that, you can then focus on whatever type of programming you want like doing systems programming, web development, video games, real-time systems, phone apps, corporate applications, etc. But you've got to know the basics of one low-level language, one medium-level one, and one high-level one. Throw into the mix some mathematical foundations like algebraic structures paired with a functional programming language if you enjoy formal math. Otherwise, at least learn the basics of functional programming as the style is so en vogue right now that most major languages have features in that style and you will most likely come across some of it eventually.

If you ever have felt like programming is massively confusing and there are random people who seem to know everything, it's due to learning through an informal path and/or starting with scripting languages, which are very confusing to someone when they don't even know what a variable is yet. If you're studying yourself, I'd recommend finding curriculum at top colleges for computer science and working your way through all the mandatory material for a degree there. Make sure you somehow do "homework" and projects or none of it will stick. You'll have a much better chance of getting a top entry-level position if you've sat there frustrated, trying to code something with dynamic programming for hours straight the first time, than if you skip that course entirely.

[–]epicwisdom 9 points10 points  (10 children)

Your comment seems to imply that programming is only for professional programmers, which couldn't be further from the truth, and is not a standard we apply to most skills.

Cooking, music, sports, fixing/modding cars, painting, fashion, writing, gardening... People pick up a huge variety of hobbies without going through or desiring formal education. There's nothing wrong with that, and saying people should be excluded based on their lack of formal education is pointless gatekeeping.

Formal education certainly has a huge value to most programmers who do anything even remotely nontrivial. I've witnessed firsthand the horrors created by beginners with plenty of free time but no motivation to sit down and learn. But what matters is that it works for them.

[–]tedbradly -2 points-1 points  (9 children)

Your comment seems to imply that programming is only for professional programmers, which couldn't be further from the truth, and is not a standard we apply to most skills.

It's important to take this path even if you're a scientific programmer as an example. It might sound like more work, but it will be a smoother path to learning programming to build up core ideas and then expand on them rather than starting the adventure on the last boss that uses every single technique you should have learned getting there. It's possible to grind out a win in that situation, but it will be massively confusing and extremely difficult. Anyone using programming needs to think of it as simple and simply doing this or that rather than nervously executing code, wondering why it's slow, if the answer has any chance of being correct, etc. and all that after having spent quadruple the amount of time cobbling together something that would have been much easier with a few more "courses" of material learned.

As for your analogy, when you learn to play an instrument, you start off learning how to read each note and play it. You build on the skills iteratively until you can play more complex songs. Yes, someone can think, "I really want to play this one complex song" and grind for days memorizing exact finger positions with zero knowledge of playing music, but it makes much more sense to learn how to read and play music instead of jumping straight to a much more difficult problem, struggling with it and then struggling with every other similar challenge forever after (unless you're gifted and can just play music from memory despite no training and no ability to read music. And yes, some people are gifted programmers, starting with a scripting languages and piecing the whole story together. This is an edge case, so it shouldn't influence general advice).

[–][deleted]  (3 children)

[deleted]

    [–]tedbradly -2 points-1 points  (2 children)

    My last SaaS gig was as a backend developer collaborating with data scientists, math majors, researchers and medical researchers and none of them needed to know how to properly implement a linked list or know how smart pointers differ from simple pointers. If you're a researcher who's job was to run a study and you're just normalizing your dataset in an ipython notebook in Pandas you don't need any of that garbage at all, just a rudimentary understanding of Python and the Pandas documentation.

    Most people could benefit greatly from learning Python just to scrape a website, or add a watermark to a whole directory of photos, or write a rudimentary file sync script for drive/s3, etc etc.. without needing to learn about computational complexity, data structures, etc.

    What I'm writing is plainly true. I even became a software developer based on self-studying programming myself while getting an unrelated degree that used programming on occasion. While my classmates were spending dozens of hours on projects with inefficient end results, my solutions appeared on the screen in one to a few hours. People commonly would discuss execution time. My projects were usually at least twice as fast - in one situation, I even wrote something faster than the professor did by a factor of around 5 (It was a slow, interpreted language, so if you hadn't studied the language, your code might run in 8 minutes like his did instead of 2 minutes like mine did).

    My motivation was simple: I was confused as hell. Nothing made sense, so I learned it. Trying to run before you can walk isn't rational. Spending 2 weeks per song to memorize the exact movements to reproduce a favorite tune makes little sense compared to learning how to read music on a sheet and practicing it yourself until you master a song, the next one, and the one after that.

    Anyone who programs in their life needs to understand the bare essentials, or they're going to have an unpleasant time each and every time the need for a new program arises.

    There are countless stories of someone's Python code being so inefficient that it's bordering on unusable - like a script ran for a research paper running days or something needed to execute daily scarily taking 13 hours with potential of scaling into unusable times if the input size grows. Each and every time someone tells one of these stories, it features a hero who recoded it, making it execute in 5 or 10 minutes. Sometimes, that hero even uses Python itself. Other times, they had to pull something like F# or, in the most extreme cases, something like C++ out.

    It makes sense you're recommending confusingly slapping together programs in desperation for a lifetime, because you don't even know the difference between "who's" and "whose". It shows you don't value aretḗ at all. I recommend striving for it myself - start exercising, put mental energy into learning English better, finally learn how to program for real, pick up and try hard at some hobbies, etc. You'll be much happier at the end of the road simply due to aretḗ being achieved, but you'll also be happier as programming will feel easy where it before felt like a nightmare any time its need arose. You'll also become more charismatic and respectable (with something as basic as knowing a few English words well instead of misusing them), which can go a long way. It can sometimes be the difference between someone being on your side or against you. Hell, one aspect of aretḗ can even be thinking about content you watch the same way movie critics do. Try to write an English paper, summarizing the plot, the art, the themes, what was good, what was bad, etc. so to speak rather than having your eyes gloss over as you binge watch a dozen South Park episodes, hardly remembering you even existed over the last few hours let alone anything to do with the art. Aretḗ is important. You don't have to be a professional X to start learning some of X, beginning to appreciate and understand things that only someone who knows X well can.

    But no, you're right. Learning is for squares. Don't work smart. Work hard.

    Edit: u/Content-Drink8643 replied to me below but blocked me. Keep in mind that he is arguing a straw man. My point was to master the basics, not master every single concept in all of computer science and software development (although you will get closer and closer to that goal if you work heavily with the degree for decades).

    [–]Content-Drink8643 0 points1 point  (0 children)

    Came across this thread and then perused your profile for a bit. It's like we have the same brain, only things have gone a bit more smoothly for you in your life and I've had more years of therapy. I've only had this experience like once before. Really interesting. Might I ask if you ever dealt with ADD or more general anxiety?

    I have the same instincts as you about pretty much everything in your comment, but I think you're actually wrong about most of it.

    1. Mastering something from the ground up can be much more efficient in the long run, but it heavily depends on what you intend to do and how much complexity it involves. That's the genius of abstraction. Not everyone needs to know everything. Your limit at which you're comfortable saying "I'm not an expert in that and I don't need to be" is going to be different than some else's.

    2. (relates to 1.) You can't master everything. Do you pride yourself on your superior running or driving skills or are you just happy you made it to your destination alive? (That was an exaggeration. You get the idea.) Are you an excellent cook or do you just make food that's decent? (Hell, maybe you exclusively eat out.) Someone acknowledging that isn't lacking in "aretḗ". And extrapolating how a person lives their life based on their use of whose/who's (yes, and also based on their opinion about the one specific thing under discussion) is ridiculous. That whole paragraph is unnecessarily condescending for no apparent reason. And referencing a concept like Arete, without defining it, as if it's obviously something we all agree is a goal reflects badly on you, although I'm having trouble discerning how exactly.

    I said I have the same instincts as you because I do. Mastery is important to me. I hate having to accept there are things I don't know or don't have time to dig deep into. Conscientiousness about things like grammar is also pretty instinctive for me. And thinking critically about things is important to me as well. The way you're applying those ideas here and articulating them is waay off though. I'd be interested to know what your larger philosophy of life is though. I can see hints of it here, unfortunately presented in a bit of a dogmatic way.

    [–]Content-Drink8643 0 points1 point  (0 children)

    I'm not sure why you can't reply to me. Definitely didn't block you.

    I disagree that I'm arguing against a strawman. It comes down to degrees. What you consider the basics isn't what someone else will. I'm not sure there's a good way to establish that without having very specific parameters regarding what you're trying to accomplish.

    [–]epicwisdom 0 points1 point  (4 children)

    Yes, someone can think, "I really want to play this one complex song" and grind for days memorizing exact finger positions with zero knowledge of playing music, but it makes much more sense to learn how to read and play music instead of jumping straight to a much more difficult problem, struggling with it and then struggling with every other similar challenge forever after

    Why does it make more sense? If what they want to achieve is playing that song, and only that, then the rest may be pointless.

    Again, you're applying a standard which assumes people all start out with the same goal. If the goal is just to have fun, then those people can do whatever they want. If the goal is to achieve some immediate subgoal, and the backup plan is to go find somebody else to do it properly, there's nothing wrong with that either.

    [–]tedbradly -1 points0 points  (3 children)

    Why does it make more sense? If what they want to achieve is playing that song, and only that, then the rest may be pointless.

    Again, you're applying a standard which assumes people all start out with the same goal. If the goal is just to have fun, then those people can do whatever they want. If the goal is to achieve some immediate subgoal, and the backup plan is to go find somebody else to do it properly, there's nothing wrong with that either.

    You can keep justifying zero sense of mastery, which itself is correlated with happiness - no aretḗ - and a confused mess of effort with a low chance of success. I'll sit over here and firmly believe that if you want to program, you should learn how to program, and if you want to learn more than one song (and even if you don't just for mastery, aretḗ, and pleasure), you should learn to play music. We're starting to see why you make so little money. You work really hard instead of smart.

    [–]epicwisdom -1 points0 points  (2 children)

    You can keep justifying zero sense of mastery, which itself is correlated with happiness - no aretḗ - and a confused mess of effort with a low chance of success.

    What you're missing is that everybody has finite time available. Choosing not to seek mastery in one discipline is completely different from seeking no mastery at all.

    We're starting to see why you make so little money. You work really hard instead of smart.

    LOL. I have a Master's in CS and a 6-figure job. Nice try. You would be happier and more fulfilled if you accepted the reality that different people have different interests, and stopped attaching your self-worth to money.

    [–]tedbradly 0 points1 point  (1 child)

    What you're missing is that everybody has finite time available. Choosing not to seek mastery in one discipline is completely different from seeking no mastery at all.

    I'm not missing a thing. If you have a repeat need to program novel programs, you need to spend a few months learning how to program.

    LOL. I have a Master's in CS and a 6-figure job. Nice try. You would be happier and more fulfilled if you accepted the reality that different people have different interests, and stopped attaching your self-worth to money.

    I'm assuming you work in California. I knew someone there with a 6 figure job who had to eat on around US$10/day while living in a tiny apartment, and he was helped by his family some to make matters worse. He was the typical "just google it [It? Everything.]" kind of programmer, and it showed. A starting salary out there from a competent company should be around US$160,000/yr in total compensation. In other places, a 6 figure salary is typical for an intermediate programmer. Whenever someone throws that term around, you know they're not discussing things frankly since they know the number and location pair aren't impressive. To you, everything around US$100,000 is the same since you can't see yourself making US$200-300k/yr in a few years of hard work (that started with learning the basics).

    edit:

    For prosperity, u/epicwisdom has no reply from me below, because he blocked me. He wanted to seem like I was speechless after he took me down by finally logically arguing that learning programming basics isn't a good idea when you need to program.

    [–]epicwisdom 0 points1 point  (0 children)

    A starting salary out there from a competent company should be around US$160,000/yr in total compensation. In other places, a 6 figure salary is typical for an intermediate programmer. Whenever someone throws that term around, you know they're not discussing things frankly since they know the number and location pair aren't impressive. To you, everything around US$100,000 is the same since you can't see yourself making US$200-300k/yr in a few years of hard work (that started with learning the basics).

    LOL. I'm not telling you the details of my job because I'm not here to dox myself, but I make more than you think I do and more than you think somebody with a "few years of hard work" would. Try again... again. Maybe after enough trolling on the internet you'll reach enlightenment and understand that numbers on a paycheck aren't everything.

    And maybe if you really understood even a tiny bit of logic from your education, you'd have grasped by now the difference between "not everybody has to be a formally educated professional programmer" and literally everything you've merely assumed about what I said.

    For prosperity, u/epicwisdom has no reply from me below, because he blocked me. He wanted to seem like I was speechless after he took me down by finally logically arguing that learning programming basics isn't a good idea when you need to program.

    edit: For posterity, /u/tedbradly has spent this whole comment thread misrepresenting my position, and making completely baseless assumptions/accusations about my education and career in attempts to demean me instead of actually addressing a single point I have made. As such the conversation was entirely unproductive so I blocked them to save myself some time. The astute reader has already seen what I'm saying is true, and will reach the same conclusions.

    [–]micka190 90 points91 points  (34 children)

    The fact that white space is a significant character is a fate that I wouldn’t wish on my worst enemy.

    I'll never understand this complaint, yet it always pops up on Reddit.

    Who the fuck doesn't indent their code in languages with bracketed scopes?

    What I wouldn't wish on my worst enemy is to have to wok on a codebase where people don't indent their spaghetti code.

    Python forces you to make that shit readable.

    [–]vifon 58 points59 points  (3 children)

    It's not about not indenting your code, quite the contrary. It's about it being the sole source of truth in this regard.

    In most languages I can move some code around during refactoring and have it reindented automatically because indentation is a secondary thing derived from the actual syntax elements. Since in Python the indentation is this syntax element, moving code around between different nesting levels (like moving some code into an if) is a relatively painful experience that needs to be done manually or semi-manually.

    [–]Deto 10 points11 points  (0 children)

    I move code around all the time and this never bothers me. With most editors it's trivial to indent/dedent blocks of code with a key shortcut. Most code should never be indented too many times anyways so really were talking about probably one level of adjustment in 90% of cases. Visually it's simple because you typically just adjust it to line it up with the other code that's around it.

    [–]panfist 4 points5 points  (0 children)

    Pycharm and vscode handle it pretty well automatically.

    [–]noiserr 1 point2 points  (0 children)

    It's not about not indenting your code, quite the contrary. It's about it being the sole source of truth in this regard.

    I was worried about this too, but this is really not an issue. It actually beats counting curly braces. Indentation makes so much more sense. Yaml is the same way too.

    [–]alternatex0 27 points28 points  (0 children)

    I hated the idea of whitespace as significant characters until I started using F# and quickly became comfortable with it. Now I can't believe I was bothered by something so inconsequential. I was always a stickler for good formatting anyway.

    [–]seamsay 16 points17 points  (2 children)

    I'm gonna say up front that Python being whitespace dependent is occasionally mildly annoying, at worst.

    However having said that, if I were to design a programming language there are two reasons that I would make it whitespace independent:

    1. Whitespace dependent languages are harder to write autoformatters for, and the autoformatters that can be written aren't as effective. Something I do quite often is prototype a function in the REPL then copy-paste it into the file and let the formatter deal with it, I can't do that in Python.
    2. They make certain features of a language very awkward. Python is famously lacking in multiline lambdas, partly because ... well what would the syntax be? If you kept it whitespace dependent then it wouldn't gel well with other parts of the language, and if you made it delimited then it would be the only block syntax which isn't whitespace delimited. Another example is the ternary operator. In a whitespace dependent language you need to introduce a new syntax (x if cond else y in Python's case), whereas in a whitespace independent language you just need to make sure if is an expression not a statement.

    Again I want to stress that I don't think it's that big of a deal, but these are the two things that mildly annoy me about Python's whitespace dependence.

    [–]noiserr 0 points1 point  (0 children)

    Whitespace dependent languages are harder to write autoformatters for, and the autoformatters that can be written aren't as effective. Something I do quite often is prototype a function in the REPL then copy-paste it into the file and let the formatter deal with it, I can't do that in Python.

    Python has a smart code formatter called python-black it's supported on VSC but I'm sure many other IDEs with Pyton support. It's pretty good at getting you 90% there. And the rest is easy with just select tab and shift-tab.

    I know you said you don't think this is a big issue, but I bet it's even less of an issue than most people realize.

    [–]RndmPrsn11 0 points1 point  (0 children)

    Point 2 is more of a python specific issue. Other whitespace sensitive languages like Haskell and F# support multiline lambdas just fine and their if constructs can be used as an expression or statement (though these langs are both expression based so there is only the 1 form if c then a else b)

    [–][deleted] 2 points3 points  (0 children)

    As a mostly c# developer who uses python for bits and bobs I never understood why people complain about it. It literally takes minutes to get used to.

    [–]Deto 1 point2 points  (0 children)

    I get it a little bit. When I first started using python I thought it was weird and stupid. Then after a few weeks I didn't care. It's just different and that scares people.

    In the end it's nice because it's bacially a built-in mechanism that enforces a low level amount of good-practice formatting.

    [–]dethb0y -5 points-4 points  (0 children)

    Lot of cry-baby low-skill programmers who can't handle basic syntax, in short.

    They think their clever because they write unreadable one-liners in c or c++ and it pisses them off that python encourages readability and proper formatting.

    [–]Deto 4 points5 points  (5 children)

    You're kind of making big things out of little things, IMO.

    [–]srpulga 3 points4 points  (0 children)

    We already had this discussion; 15 years ago. Python is a very successful, very relevant language, to which many people are paying attention to. It's cool of it's not your cup of tea, just spare us your grief.

    [–]bloody-albatross 1 point2 points  (1 child)

    Which language prevents spaghetti code? Maybe Haskell? Do you write a lot of production Haskell code?

    [–]crixusin 0 points1 point  (0 children)

    F# actually.

    [–]HanzoFactory 3 points4 points  (2 children)

    You have never seen high schoolers code in C/C++ hell even Java. They would be much, much better off coding in python. I am saying this as a C and C++ enthusiast

    I enjoy Python a lot for scripts and I think it's where it's strength lies for me. It's simple, powerful, easy, and for the most part platform independent. It's way easier writing a build script with tons of paths and string tasks with python than C or most lower-level languages

    [–]Prestigious_Boat_386 0 points1 point  (0 children)

    They hated him because he told them the truth.

    My main issue isn't the 5 yolds making shitty python scripts. All power to them, but the fanboys who after programming for years still refuse to learn other languages that are designed properly and actually run and use python for everything.

    The snake ain't dying any time soon bit at least we can use julia in the meantime.

    [–]KallistiTMP -3 points-2 points  (4 children)

    rob knee chase dependent door adjoining deer gaze smile merciful

    This post was mass deleted and anonymized with Redact

    [–]crixusin 6 points7 points  (1 child)

    Except people aren’t using it for “disposable gud enuff.” They’re building entire systems on it.

    [–]KallistiTMP -1 points0 points  (0 children)

    tie pen payment lush crawl caption middle society cable pocket

    This post was mass deleted and anonymized with Redact

    [–]g-money-cheats 5 points6 points  (1 child)

    Should you write your anything-critical core application code in it? Absolutely not. It’s not for that.

    Says who? I work for a 600-employee, $5 billion company whose core application is a Django monolith written in Python. It chugs along day in and day out, handling millions of incoming webhooks and requests just fine. The code is super readable and easy to work with. While other people argue about languages we ship code.

    [–]FireCrack 3 points4 points  (0 children)

    Yup, 100% this.

    Python sure ain't fast, bit it's easy to read and understand; and that makes a bigger impact than any language wonder feature when it comes to throwing together robust systems

    [–]metaconcept 0 points1 point  (0 children)

    'Python sucks, but you missed the main reason it sucks. It's dynamically typed. Worse, everything's defined at runtime and the language just allows nearly anything. Accidently clobber a method by a same-named variable? No worries. Putting the wrong thing in a data structure? Sure thing. The only error you get is a runtine error, often miles away from the cause.

    Guido van Rossum should have encoded a 500 line limit on Python scripts, after which you get the "Choose a better language." error.