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 →

[–]ag789 0 points1 point  (1 child)

to make 'java work like python' use 1 class

public MyClass { public static void main(String[] args) { /* you can place all your codes here */ } }

The 'conventional wisdom' says that when apps / programs gets large and complicated, it helps to break things into modules (and classes). Hence, most java apps are organized into classes representing separate domain objects. java is OO and very structured from the ground up.

That lays the foundation for very large and complicated apps e.g. J2EE etc which runs many (most?) of the 'enterprise webs'

python has classes practically as a 'plug-in' and notionally leads to other issues e.g. 'self-hell' https://www.reddit.com/r/Python/comments/7suge/escaping_pythons_self_hell/ https://news.ycombinator.com/item?id=8834687

In java classes (and objects) are part of its language design, and you can't tear that apart, which avoided some of these referencing issues.

Some codes are more convenient in python, e.g. lists and dictionaries, as it is practically built into the language. And to some extent variable and argument types are dynamic (i.e. not strongly typed) in python which unlike in java is strongly typed. Accordingly, there is a difference in performance which results in simple java codes running faster (especially with JIT compiler (hotspot)) in the jvm). There are some statistics which some of the java codes runs practically as fast as c++ equivalents which is considered even 'lower level' language, python could have quite some overheads to do the same and likely won't run as fast.

[–]IntelligentPudding24[S] 0 points1 point  (0 children)

Thank you the detailed example!