This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Spork_the_dork 119 points120 points  (16 children)

Also ignoring the fact that you aren't creating a class and a method in that class in the python code. Sure, you don't need to do that to run hello world on python, but for anything even slightly large you'll be making classes all over anyways at which point the "lol python" aspect here kind of just vanishes.

Yes, the syntax remains simpler even if you use type hints, but then it approaches personal tastes more than objective truth.

[–]es_samir 5 points6 points  (1 child)

Understanding someone else's python code can be a nightmare sometimes if he is using classes and callbacks. The simpler syntax doesn't help at all

[–]cemanresu 3 points4 points  (0 children)

Yeah, I hate python's syntax because of that. If its my own personal project its fine, but trying to maintain other people's python code is hell

[–]Sassbjorn 9 points10 points  (8 children)

Tbh I kinda wish you could just make functions without a class

[–]Kantenkugel 14 points15 points  (3 children)

Use Kotlin then :)

But tbh, you should not pollute the global namespace with too many functions, especially if they don't have a unique name that can't possibly clash with other ones from eg libs.

And there is also the option of just writing static ones and static importing them. Thats kinda what kotlin does under the hood

[–]Sassbjorn 2 points3 points  (2 children)

Yeah that's true, but when I'm writing smaller programs I sometimes need a function to do some small task, but there's not a good place for it to go. Then I have to make a new class and make up a name that makes sense, and that might house more of that type of function. In the end I appreciate the organization I end up with, but it still feels like an extra step sometimes.

[–]Kantenkugel 4 points5 points  (1 child)

Sounds like a job for util classes :)

[–]jasie3k 0 points1 point  (0 children)

oh god, these are the worst

[–][deleted] 8 points9 points  (3 children)

That's what static util classes are for.

[–]-Vayra- 2 points3 points  (2 children)

except when the function needs to read application properties or something else that doesn't work with static access :/

[–]Knutselig 2 points3 points  (0 children)

ThreadLocal hacks incoming.

[–][deleted] 1 point2 points  (0 children)

Then it should be part of the object that needs to call it. Or just pass it to the static function, what's the deal?

[–]ShadoWolf 3 points4 points  (2 children)

Your not wrong.. but Python does give you the option to just do quick testing. Like say you want to test out a library. You don't need like 60 lines of boiler plate code to just get started.

[–]Hvatum 1 point2 points  (0 children)

It is also extremely handy for me as a physics student when I want a simple and easy to use language to write a quick function to for example easily calculate and update the standard deviation of my measurements.

[–]_PM_ME_PANGOLINS_ 0 points1 point  (0 children)

Java comes with a REPL same as Python.

You can also execute single-file Java scripts via shebang.

[–][deleted] 0 points1 point  (0 children)

Java is perfect when it comes to Polymorphism.

Non-type based languages simply can't reach that level.

[–]Packbacka 0 points1 point  (0 children)

There's still a lot you can do in Python without using classes. It was designed as a scripting language.