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
Post funny things about programming here! (Or just rant about your favourite programming language.)
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
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.
And then the quick hack gets a permanent solution and the next employee has to fight trough the spagetti.
This may be true, but it's equally true in any programming language, so not really relevant.
I find Python is quick for the first 30 minutes. If you need any kind of libraries, or assistance from an IDE, or a distribution build, or you're more familiar with another language, then it isn't quicker.
If you need any kind of libraries
PyPI has a huge selection of libraries
assistance from an IDE
PyCharm a super powerful IDE, VSCode has tons of Python extensions that L rival PyCharm's functionality, lots of other IDEs have decent python support
or a distribution build
Not sure exactly what you mean by this
or you're more familiar with another language
Yeah this can be said about any language. "You're quickest in the language you're most familiar with". That's basically a tautology.
Oh boy, you really wanna talk about it?
PyPI has a huge selection of libraries
It does, but the lack of static typing means it is more difficult to interact with foreign code (correctly).
When I pull in a library in a JVM language or Rust etc., I quickly glance at the documentation to get a rough idea of the entrypoint for the library.
Like, let's say I want to create a .tar file, then the short "Writing an archive" example tells me all I need to know to get started: https://crates.io/crates/tar
If I need to find out more, like how to add a directory, then having the tar Builder
initialized is enough for me to just ask my code completion. It will tell me the other available functions + their documentation + what parameters they accept.
If I make a mistake, the compiler will immediately tell me.
In Python, my experience was completely different. Pulling in a library often meant genuinely reading through its documentation to figure out how to call it, because the auto-completion was always unreliable at best.
Some libraries' functions wouldn't even tell you what types you're allowed to feed into them, nor what type they return, and not even even diving into their code would help, because they just never had to actually specify it.
PyCharm a super powerful IDE, VSCode has tons of Python extensions that L rival PyCharm's functionality, lots of other IDEs have decent python support
Yes, PyCharm is a super powerful IDE when compared to Nodepad++. But it's a trashcan fire compared to IntelliJ or even the much younger RustRover.
Half the time it can't assist you, because no one knows what types your code even has at that point.
The other half of the time, it can't assist you, because, for whatever reason, the Python interpreter configured in it can't resolve the imports.
And the third half of the time, it can't assist you, because of what I already mentioned above, that the libraries you use just don't specify types.
These are problems I've encountered when working on a larger project with multiple sub-components. It cost us so much time and eventually seemed to just be impossible to fix, so I ended up coding in a plain text editor, because at least that wouldn't constantly color everything red despite there being no errors.
These problems are lessened for smaller projects, but in that case, you also don't need assistance from an IDE.
or a distribution build
Not sure exactly what you mean by this
What I mean by that is that Python tooling is terrible. There's five different ways to do everything, which you have to decide between, and in the end, they all have weird limitations (which is probably why four others exist).
or you're more familiar with another language
Yeah this can be said about any language. "You're quickest in the language you're most familiar with". That's basically a tautology.
Yes. That is all I wanted to say by that. People just often claim that Python is a great prototyping language, to the point where the guy I was responding to, felt they're doing the wrong thing by using the familiar tool instead. I'm telling them, they're not.
What I mean by that is that Python tooling is terrible. There's five different ways to do everything, which you have to decide between, and in the end, they all have weird limitations (which is probably why four others exist).
There’s actually at least 15 different ways (the fifteenth one is called rye and it’s where I got that article from). And yes your entire post is super accurate. The pycharm thing is ridiculous too because RubyMine is excellent in comparison. You just pull in a library with Ruby’s excellent (singular) package manager, and then RubyMine is able to autocomplete it pretty much perfectly. PyCharm can’t even manage to figure out that you added a new dependency to whatever flavor of the week package manager you’re using this time.
Oh man, this isn't meant to shit talk Rye (from what I've heard of it, it actually is a decent effort), but it's literally this comic then:
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.
I find it's possible to operate Python as a statically typed language if you wanted, though it takes some setup with external tooling. It wasn't hard, but had to set up pyright, editor integration, configuration to type check strictly and along with tests, and CI.
I even find the type system to be far more powerful than how I remembered Java's to be (though I'm not familiar with the newest Java versions).
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:
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...
In Java you get a bunch of unexpected NullPointerExceptions instead...
The IDE can assist you before it even becomes a problem, so even more time saved.
This little hack is gonna cost us 51 CPU cycles.
And
++++++++ [>++++++++++++>+++++++++++++<<-] >++++. -. >+++++++. <+. +.
in brainfuck
Good old brainfuck 👌
Yeah but due to the extra indentation in the second image, the python part doesn't work.
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 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.
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.
Sorry, are we talking about spaces or tabs? I want to comment on same indentation to not break the thread
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 👀
Oddly specific
C is a makeshift kitchen deep in the Lacandon Jungle. If you burn your food, you start a forest fire and die.
Python, Java/TypeScript, C#, Swift, Go...
Ah, the list of required skills on the last job posting I looked at…
And 42 seconds in jython.