r/Python • • Nov 07 '19

Python passed Java as the second-most popular language on GitHub by repository contributors

https://github.blog/2019-11-06-the-state-of-the-octoverse-2019/
1.4k Upvotes

158 comments sorted by

View all comments

Show parent comments

43

u/FishBoyBagel Nov 07 '19

Just curious, why would you never want to learn Java? I’m a freshman in college studying Python this semester and Java next semester.

69

u/[deleted] Nov 07 '19

Java is absurdly verbose compared to python. Granted, it’s faster, but its much slower to write.

28

u/QualitySoftwareGuy Nov 08 '19

Java is absurdly verbose compared to python. Granted, it’s faster, but its much slower to write.

It is, but some might also say it's easier to maintain medium-large sized applications in Java. I love Python, but best tool for the job is my motto.

0

u/[deleted] Nov 08 '19

[deleted]

4

u/Vaphell Nov 08 '19

let's not get ahead of ourselves with "strong types". Strong-ish, maybe. I certainly love losing type information while using generics, courtesy of type erasure ;-)

Checked exceptions? Lol.

→ More replies (1)

8

u/[deleted] Nov 08 '19

Depends on how the project was structured imo, but yes compiled languages are more strict so there are less “what the fuck was the author thinking” moments in maintenance

17

u/[deleted] Nov 08 '19

The problem with java isn't that it is statically typed, it's that it requires absurd amount of boilerplate to do literally anything. And it's OOP model is not good.

3

u/[deleted] Nov 08 '19

Java is pretty fast to write honestly. Long variables names are almost all auto completed. And compared to python I think java is faster to write in some instances, because it requires less testing and checks due to the compiler. Typed python helps a lot there though.

8

u/BigASchw Nov 07 '19

Exactly this, just printing hello world in each language is the perfect example as to why python is so much easier and more enjoyable to write in

44

u/AcousticDan Nov 07 '19 edited Nov 07 '19

I wouldn't judge a language on how printing "hello world" works.

→ More replies (10)

69

u/[deleted] Nov 07 '19

...python is so much easier and more enjoyable to write in

Most languages have strengths and weaknesses. Doing a task in a language it's ill suited for, just because that language is familiar and easy, will certainly be problematic down the road.

Learning Java at least lets one determine if it was the best tool for the task at hand.

1

u/alcalde Nov 07 '19

Doing a task in a language it's ill suited for, just because that language is familiar and easy, will certainly be problematic down the road.

If it's easy to do something in a language, then that language is well-suited for the task by definition.

24

u/Zalack Nov 07 '19

Not if performance is an issue or you don't have control over the target machine's python environment (there are ways around this last one but it generally comes with other tradeoffs).

I love python, I spend most of my job writing it -- but there are projects where the performance hit of using an interpreted language like python just isn't tenable.

3

u/Brandhout Nov 07 '19

I always thought C would be the way to go if you are looking for high performance. Mostly because I have come across a few high performance systems built in C.

What is your take on that?

8

u/redwall_hp Nov 08 '19

C is a loaded shotgun pointed at your foot, and dealing with strings makes you want to point it at your head instead. Yes, it's fast and excellent for low-level bit blasting, but it's not really a good option for "this relatively high level use case runs slowly."

Java is a perfect medium between Python and C.

5

u/[deleted] Nov 08 '19

I'd say C# fills that niche better than Java. It performs better and it's less verbose. The only real reason to pick Java over C# anymore is the lack of cross-platform support (and even that shouldn't be an issue anymore with .NET 5).

→ More replies (1)

3

u/Flynamic Nov 07 '19

I'd also recommend Go for that, the language gives you good tools to work with and it's compiled.

2

u/Laogeodritt Nov 08 '19

Anything that compiles to machine code will generally be usable for high performance applications. C is one of them; it's great for low-level performance optimisations. However, most performance problems aren't solved by low level optimisation, as a sibling comment to mine implies. That is to say, performance impact is most significant when it comes to how you, the engineer(s), chose how to organise various responsibilities/functionality at the highest abstraction level (architecture), how you designed all the components that make that up (code/class/function organisation, how data is stored and passed around), implementation choices (which algorithm you chose to sort your giant list, exact data structures and organisation of data, where you're having to translate date between different formats or data structures, communication protocols, etc.), and low level issues (how memory is used, overhead from function calls or data type checking, efficiency losses due to pointer dereferencing or register/cache misses in the processor during the inner loop of an algorithm, pretty much all performance critical computationally heavy algorithms, etc.).

You'll notice that last level is close to the hardware, incredibly specific, and performance gains are minimal compared to fixing a poor design - it's really only applicable to eking out the last little bit of performance, or performance in really computationally heavy parts of the program, where you might be calling the same routine or looping thousands of times per second or similar - small inefficiencies there add up a lot.

I would generally advocate for mixed technology systems when high performance is required, in most computing scenarios (embedded scenarios being a major exception). For example, python for most of the application (way cheaper due to ease of use), with C for the inner loop or computation heavy routines - spend the timr/developer salary writing low level code where it really matters. You can write Python bindings to call C from python easily.

→ More replies (1)
→ More replies (1)

10

u/[deleted] Nov 07 '19

With all due respect, no.

I understand your point, but I didn't say the task was easy to do in the language, I said the language was easy and familiar.

Is it possibly and easy to write a message queue in Python? Sure. Is it the best choice? Not by a long shot. Erlang is far better suited for that task, especially if you intend to scale. or Go, C++ and Java. That's not an exhaustive list; the intent is to show there are better tools, not which is best. All of the alternatives are arguably less easy, yet better options.

→ More replies (4)

5

u/1chriis1 Nov 08 '19

Unless, you encounter the stupidest hickups for a small indent. Love it though!

4

u/nemec Nov 08 '19

When your application is 300,000 lines of code it doesn't tend to matter much how long a "hello world" program is in comparison.

Sure, it sucks for a beginner, but presumably you won't be a beginner forever...

Java sucks though for other reasons

2

u/pwang99 Nov 07 '19

It’s not faster for a huge part of what people use software for, namely, large data processing (data science and machine learning)

→ More replies (4)

12

u/[deleted] Nov 07 '19 edited Nov 08 '19

Java isn’t bad. It’s verbose but extremely performant. It doesn’t cross over into “awful” territory until you start applying 20+ years of enterprise “patterns” to everything you do and you start contemplating stepping in front of oncoming traffic on a regular basis.

4

u/niceoutfive Nov 08 '19

In my experience, Java is more pedantic. You have to do it their way or the highway. Python is more easy going. You can do basically all the same stuff, but with fewer rules. In Java you have to write getters and setters (like user.getName()). But in Python you just say user.name.

Python gets it done with little hassle, Java gets it done but only if you recite the proper incantation during the right moon cycle while you write it. But it is pretty solid once you learn the arcane arts!

(Caveat: I know Java only in an educational environment, so we were being taught the "proper way." I'm sure that that is way more pedantic than when it is used for real development. Buuut, seeing some actual production Java code at my company, that appears to be the norm. You can get just as structural with Python too!)

You should very much learn Java though. If you know Java, you can figure out the other bad boys like C and C++ a lot easier. If you already know Java, congrats you now know probably 90% of C#. If you want to ever do Android development, you'll need Java (although Kotlin is also getting very big in that field)

→ More replies (7)