1 hour in Java

And a second in julia
It’s about writing the code, not execution time. Otherwise Assembly wouldn’t take 7 years…
I can see it going both ways. Talking about execution times, this would be an exaggeration, but then, these memes always are.
Some languages are just worse to work with. like JavaScript. Console.log is like sure I’ll log your object but I’ll tell you what it is now, not what it was when you logged it.
Python, JavaScript, C#, Swift, Go…

Java/TypeScript

😒

Lol, at poo pooing typescript in a thread praising python of all languages

TypeScript might be fine, if it didn’t typically rely on a JavaScript stack that can and will ignore the nominal types.

TBF you probably don’t have to use any native JS libraries, so it’s kind of user error.

Dude… Java is not JavaScript
Ah, the list of required skills on the last job posting I looked at…

And

++++++++ [>++++++++++++>+++++++++++++<<-] >++++. -. >+++++++. <+. +.

in brainfuck

Check out my whitespace:
Whitespace (programming language) - Wikipedia

Good old brainfuck 👌
Yeah but due to the extra indentation in the second image, the python party doesn’t work.
Sorry, are we talking about spaces or tabs? I want to comment on same indentation to not break the thread
I don’t understand why people complain about their Python code breaking because it relies on indentation instead of explicit {} syntax. I’ve never had an issue with it and it’s not just because I’m used to it because Python is the only language I use that relies on whitespace like that. I think the complainers just don’t know how to indent properly, which makes me really glad they’re writing in a language that forces them to instead of pushing unreadable garbage in other languages.
I once wrote a bot in python tdownloaded a ical file, looked for chances and informed me if found. The space indentation made it hell to follow the code in my opinion.

What about spaces made it hard? What language would have been easier? In curly brace languages, 99% of the time, a curly brace is followed by a line break and an indent. Python is similar except it’s typically a colon, line break, then indent.

What I have learned is: If the code is indented too deeply, it’s a code problem, not the language.

Torvalds infamously wrote:

“… if you need more than 3 levels of indentation, you’re screwed anyway, and should fix your program.”

linux/Documentation/process/coding-style.rst at master · torvalds/linux

Linux kernel source tree. Contribute to torvalds/linux development by creating an account on GitHub.

GitHub
Torvalds wrote this about C. There’s plenty languages where it’s much more common and less of a complexity indicator to open up scopes.

Correct, I linked the source of the quote. My implication is the general idea is applicable here. Is python one of these languages where it is idiomatic to nest code deeply?

The Zen of Python:

Flat is better than nested.

From the python I have seen and written, deep nesting is avoided.

PEP 20 – The Zen of Python | peps.python.org

Long time Pythoneer Tim Peters succinctly channels the BDFL’s guiding principles for Python’s design into 20 aphorisms, only 19 of which have been written down.

Python Enhancement Proposals (PEPs)
Too much nested code was likely part of the problem, but not being able to easily tell where a block of coded ended without seeing the top of the block made it difficult to work with.
That’s fair! Takes time to get used to. Modern editors make this easier by highlighting the current indent level, or can even make the top X lines of the current closure “stick” to the top of the editor for those really long blocks.
Having those features would really have made it easier. I have only ever written my python code in Sublime Text. While it is a sublime text editor, at is not ideal (compared to how it is to write Java in IntelliJ) for Python. (Maybe with addons but I never delved into that more than a few.)
I don't get it because my phyton code is indented exactly the same as all my other code. Each block of code one tab in/out, how else would you do it?

It’s because there is no clear indication of where a block ends.

Here is some sample code. I find it difficult to tell how many indentations I have or where I need to write if I want to continue at a certain level.

import time import aiohttp """ Retreives the data from RSS URL and return the status codes as well as the data. Return -1 if something went wrong. """ async def get_rss_feed(rss_url): async with aiohttp.ClientSession() as session: try: retry_count = 0 while retry_count < 5: async with session.get(rss_url) as resp: if resp.status == 200: return {'status': resp.status, 'data': await resp.text()} else: retry_count += 1 time.sleep(60) if retry_count == 5: raise ValueError('To many failed connection attempts', retry_count) except aiohttp.InvalidURL as error: return {'status': -1, 'data': f"Error: {rss_url} is not a valid URL.", 'error': error} except aiohttp.ClientConnectorError as error: return {'status': -1, 'data': f"Error: Could not connect to {rss_url}.", 'error': error} except ValueError as error: return {'status': -1, 'data': f"Error: Could not connect to {rss_url} after {retry_count} attempts.", 'error': error}
its just not as clear especially when u are indenting stuff inside stuff with a bunch of conditions everywhere its hard to read just from indentation, and with the () or {} u can just click on it and most text editors will show u from where to where its going.

especially when u are indenting stuff inside stuff with a bunch of conditions everywhere

That’s an anti pattern in basically every language though. The fix is to simplify those conditionals, not use a curly-bracketed language.

I mainly found it annoying while writing code, because the lack of braces makes it difficult to tell when a scope ends. Plenty times, I’ve wanted to add something to the end of a for-loop, but had too little indentation.
Usually this means I get a runtime error, because it can’t access some variable from the loop-scope. But worst case, it only executes once after the loop and I don’t notice the problem.

Another big thing I miss when not having explicit braces, is opening up new/anonymous scopes to isolate variables, which helps prevent mistakes down the line + reduces code complexity.

For example, this is a thing I do quite regularly:

let client = { let client = new Client() let timeout = config.load("client.timeout") client.set_timeout(timeout) client //implicit return value of this scope when evaluated as an expression } client.request_something()

It allows me to visually group the initialization code for the client and I don’t need to have the timeout variable in scope afterwards. Depending on the language, you can also have the client variable mutable inside the scope and then immutable outside.

Yes, this could be pulled out as a function to achieve something similar, but in my experience people (including me) will often just not do that, because it’s only the timeout variable or whatever.

wanted to add something to the end of a for-loop, but had too little indentation

To address this, I prefer reducing length & depth of nested code, so the for/while is rarely ever not visible along with everything inside it. Others have success with editors that draw indentation lines.

opening up new/anonymous scopes

I occasionally use Python nested functions for this purpose

I can see why you’d prefer braces in that case. I actually personally prefer {} over indentation as a matter of opinion, I just see them both as working fine 99% of the time. I’d also definitely take whitespace over some shenanigans like start/end to define scopes.
I have never had any problems with it either but don’t get me started on YAML.
Try finding a bug related to indentation in a 15 year old python codebase by the worst programmers on the planet. You won’t think that there’s no issues with it after that point. In any other language you literally just reformat and you’ll see the bug. That’s not the case in Python.

I’ve been coding around 25 years and got my start in perl. I absolutely hated python when I first used it. I use it all the time now. I still prefer my curly braces but I don’t have any trouble with python or mind the whitespace anymore. I just run it through ruff every save. I do the same with go everything goes through gofumpt. I really think a lot of it is a generational thing. Older people are just used to curly brackets.

I do get peoples complaints about the packaging. Unless you’re a dev already it’s a bit extra to deal with shuffling virtual environments because the system python environments almost never work out of the box, at least in the last few distros I’ve used. Once I adjusted though it’s no problem. I run half my dev stuff in toolboxes with their own environment anyway.

Java feels like McDonald’s and python feels like a grocery store.

Rust feels like a femboi hooters where they offer IVs you don’t think they’re qualified to administer.

I don’t understand any of these analogies at all
Me neither but now I’m interested in Femboi-Hooters 👀
C is a makeshift kitchen deep in the Lacandon Jungle. If you burn your food, you start a forest fire and die.

My indirect experience with python is that it is slow as hell. Anytime I install an app that includes python it lags 15-30 minutes on that step. Anytime I’m asked to install something with conda it takes 30 minutes to an hour.

I’m sure that is just due to environmental and implementation issues, but the Java fans say the same thing…

Yeah conda is slow af, but you can change the env solver which makes things much faster and there’s also mamba/miniconda which I haven’t tried but is supposedly much faster

Conda actually now uses the Mamba solver under the hood, as of the 23.10.0 release: docs.conda.io/projects/…/release-notes.html#id43

Unfortunately, their release notes page is buggy, so this link will stop pointing to the correct release when they publish their next release…

Release notes — conda 24.7.2.dev42 documentation

With things like wsl, conda has also become less useful. Anaconda is terrible software and the need for conda managed packages is mostly lost outside of the windows OS in my opinion.
It’s near-universally regarded as a great prototyping language. For prod you should use something big-boy, like Java, or if you want to get fancy, Rust.
The “Big Boys” use tests to gauge when code is production ready, they don’t rely on a typing system and call it a day. I’ve seen monoliths made out of bash serve their purpose for years without a glitch, thanks to tests.
Tests are good too, although you can go overboard. You can write tests in Java or Rust or similar.
That feels like a packaging issue, which would be a problem specific to the developer of that app, not Python. For the most part, pip packages install basically instantaneously.

But one compiling error is Java is 7 run time errors in python.

There is a type error and you couldn’t have known it beforehand? Thanks for nothing

With type annotations, this problem is mostly alleviated in practice, while still keeping the productivity gains of duck typing.
In my experience, Python’s type annotations are annoying as hell, because there’s no inference.
You can use mypy and/or Pydantic.

Neither of those provide type inference? Type inference is when you give the compiler only occasional type hints and it can still figure out what the types are behind the scenes.

For example:

name = "World" greeting = "Hello " + name compile_error = greeting / 42

In a type-inferred language, the compiler would automatically know that:

  • the first line is of type String, because it’s trivially initiated as one.
  • the second line is of type String, because String + String results in a String.
  • the third line is non-sense, because greeting is a String and cannot be divided by a number. It could tell this before you run the program.
  • Mypy on the other hand can only tell these things, if you give the first two lines an explicit type hint:

    name: String = "World" greeting: String = "Hello " + name

    Having to do this on every line of code is extremely noisy and makes refactoring annoying. I can absolutely understand that Python folks think you get productivity gains from duck typing, if this is the version of static typing they’re presented.

    And we did excessively use mypy + type hints + pydantic on my most recent Python project. These are not the silver bullet you think they are…

    If you’re going to post a code example, at least check that it works. Here’s your example, with no type hints, giving me errors both from the LSP, and when trying to run via mypy: imgur.com/a/Hq5Y5Gt.
    imgur.com

    Discover the magic of the internet at Imgur, a community powered entertainment destination. Lift your spirits with funny jokes, trending memes, entertaining gifs, inspiring stories, viral videos, and so much more from users.

    Imgur
    I will confess that I get a sense of psychological comfort from strict typing, even though everyone agrees Python is faster for a quick hack. I usually go with Haskell for quick stuff.
    I wrote my bachelor’s thesis in Haskell and have never touched it again.
    A lot of people feel that way. If I need to generate a set of numbers or a certain string, though, it’s pretty easy to punch out a one-liner in GHCi, and that’s usually my use case.
    When did baccalaureate theses become a thing?
    I don’t know if you’re trying to be funny or your autocorrect is, but in Germany, when they switched from diploma to the bachelor/master system, both bachelor and master come with a theses. Many people leave with a bachelor, especially in computer science, so that might be why. Don’t know about other countries