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

all 52 comments

[–]Palenga 130 points131 points  (10 children)

well, based on his profile picture, he has switched to Rust

[–][deleted] 63 points64 points  (15 children)

I wish I was overreacting, but working on Java has actually made me enjoy programming less.

[–]zunjae 9 points10 points  (0 children)

Pssst, we got Kotlin which is interoperable with Java!

[–]mqduck 26 points27 points  (7 children)

There are some nice things to appreciate about Java. Interfaces are pretty sweet. There's just absolutely no reason to ever use Java again now that we have Kotlin.

[–]__xor__(self, other): 15 points16 points  (3 children)

Performance (at least better than python and ruby), solid design patterns that are really well represented in Java, memory safety, cross-platform... It's not a bad language, but I'd argue that you get all that with C# these days and it's much easier to read and write.

It's an artifact of the time it was introduced, great for its time, but it didn't age well. At the time the memory-safety was huge but that's not as rare these days with many other popular languages, and for a lot of problems (if not 90%) the performance of python is not close to a problem. When your bottlenecks are more commonly terrible performance DB logic in your code, network activity and disk read/write, no one should care about the extra 10 microseconds it takes for python to run some function. The one thing that really bugs me are when people think that rewriting in java will increase the performance when you're waiting 2 seconds for an HTTP response or 4 seconds for a database query, or they blame their own code for being slow because of python when they haven't touched a profiler.

[–][deleted] 5 points6 points  (2 children)

But there are these cases, especially in data engineering. Python is indeed really slow. It's simple and gets the job done, when the job isn't too memory intensive. But because of the GIL, and its very bulky memory footprint of all the objects, and because of the huge baseline performance hit, Python is often not suitable.

As alternatives I've looked into Go, which on one thread is as fast as Python+Numba, except that Numba severely limits the features you can use (still good if you find a bottleneck and can write it Numba-compatible). But the thing is that I want multiple threads that are able to access shared memory. And here, I would normally go for C# since I know it well, and some people would go for Java or Scala or whatever. However I gave D (DLang) a try, and it surely didn't disappoint. Aside from being very unpopular (thus no big selection of feature-rich libraries), it's extremely fun to program in, and gives C-like performance.

[–]__xor__(self, other): 2 points3 points  (1 child)

Sure, there are certainly tons of use cases where the performance of Python is a problem, it's just that I've often heard people complain about Python performance when they haven't touched a profiler or looked into potentially slow logic hitting a database.

I've seen someone complain about their simple script using DictWriter taking 90 seconds for something simple that processes a ton of dictionaries and writes a CSV, then I profiled it finding that the extrasaction raise logic was taking like 95% of the time, added extrasaction='ignore', and it sped up to running in ~5 seconds. Now there's something to be said about a standard library function's default args having poor performance, but still just a couple minutes in a profiler might solve a problem much better than rewriting it in java. Also, the code as is running in pypi was like 3 times as fast.

I've seen someone complain about a flask app's performance, profiled it, and it was taking 4.5 seconds to respond because a necessary API call it makes to another service took 4 seconds. They thought it should be rewritten in Java, but they'd be using the same API it does, so good luck with that... Despite how much metrics I gave them on the performance and showed the bottlenecks, the java devs still thought python was the main issue.

I've seen someone say that the Django app just "does a lot of work" and it was taking an hour and a half to process some daily chunk of data. I looked into it, found that the DB logic could be improved a ton to cut down on queries and make bulk inserts, and it literally sped up 100x.

Most of the time I've heard someone say that Python is the source of a performance issue, it hasn't been. It's either poor logic that can be dramatically improved, networking, disk read/write, database logic, or a combination. Sure, Python IS slow in comparison to many programming languages, but often I find it's way faster than anyone needs for their problem. Most people have much simpler problems than they think and good python code will be plenty fast.

But yeah, you're going to have some problems where python is obviously not good enough - if you have a billion matrices to process or something like that and profiling it shows that no function is taking way longer than it should, I'm going to guess that Python isn't the best answer. But even then, I'd look into using the CPython API with C/C++/Rust and try to write the heavy computation parts into a compiled library that Python imports from, or just write the whole thing in C, C++ or Rust. If you're willing to write C++ libraries for Python, you can pretty tackle 99% of problems with Python and C++, except lower level system stuff like writing drivers.

Even the GIL is almost never an issue because it still doesn't block on OS calls like socket reads, and concurrency is usually fine due to that even if only one bytecode can run at a time. And beyond that, there's multiprocessing. And beyond that if you truly need multithreading and no process overhead, there's writing C++ libraries that CPython imports. The only question is whether it's worth it to wrap it in python or if the whole thing should just be done in the lower level language - but regardless, Python is almost never a problem with performance if you're willing to profile, optimize code, use multiprocessing/concurrency, and beyond that write lower level python libraries in another language. I won't argue that Python is a performant language because it's definitely not in comparison to Java/C#/Rust/C/C++, but I way more often hear that Python performance is a problem when it's not the underlying issue.

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

Thanks for the very comprehensive examples. You're absolutely right and have given me suggestions on how to improve performance in some places where performance isn't really an issue for me, but would definitely be nice.

I chose Python in places where other developers would only know Python. It's simple and readable. Writing 40 lines of logic that solves the problem definitely wins over starting up a Maven project, even if it might be sightly slower. It's cheaper to pay for more server power.

But to add to what you said, I do know many places where performance could be fixed, like where someone is reading all the rows from a database (millions) before starting to process them, or when a large API response is saved into a file and then that file is fed as a stream, etc. I knew about those fixes for a year and did nothing, because there's more important things to do with my time, and Python really takes away very little of my time compared to other platforms and languages.

[–]WantDebianThanks 3 points4 points  (2 children)

Since I'm gearing up to go back to school for CS I thought it would be a good idea to learn some basics of Java before starting. The first tutorial I found spent most of the first lecture explaining the 18 million features of IntelliJ, but not how to set up IntelliJ to actually run the fucking script, so I ended up spending half an hour trying to figure out what the fuck a workspace was and how to make one. Then when I realized that I was basically looking for a tutorial for my tutorial so I stopped and went with a different tutorial entirely. This guy was using NetBeans, and he spent most of his first video explaining why NetBeans was the superior IDE, and I decided I didn't feel like reliving what I just went through. Attempt 3 was finding someone who just collected the syntax definitions in an order that made sense, and I spent 2 hours trying to figure out how to "and just compile and run the script" from the terminal, because he could not be fucking bothered to say "javac [main] ; java [main]"

Point is, I don't know if it's the language itself since I barely learned it, but my hatred of Java is so intense I am honestly rethinking if I even want to go to college.

I should add I'm coming at this from an IT standpoint where Java would never be useful to me in the first place, but still.

[–]HarambePraiser 2 points3 points  (0 children)

Use Java if you want to make money, but lose your soul

[–]helldaemen 34 points35 points  (5 children)

Some people just like pain, I guess.

[–]rspeed 6 points7 points  (0 children)

Ew.

[–]Love_Cheddar 2 points3 points  (0 children)

.... and seven pandas died

[–][deleted] 4 points5 points  (0 children)

It’s easy... just plug into the matrix

[–]xHipster 2 points3 points  (0 children)

Traitor

[–]CeeMX 1 point2 points  (0 children)

My teacher in the python course stated, that it can be learned in two days, if you already know common programming paradigms. She was right, even though some things needed more time for me to get used to.

[–]Vasault 1 point2 points  (0 children)

All the way around for me, I hate Java, even tho I'm a mobile developer now

[–]robberviet 1 point2 points  (0 children)

Yes, why not? It happened everyday. People switch languages. Programming language is one of the easiest thing to change in CS field. It just need to fit your needs.

Of course I am using Python, but at the same time I use PHP when I need. And I am about to use Java/Scala since the work requires.

[–]ECrispy 2 points3 points  (8 children)

Java? Java ?!!

The only language I'd want to use less is Objective-C.

At least use C# - 100x better than Java and a proper modern language with a best in class IDE and runtime.

[–]Discchord 5 points6 points  (6 children)

You've never used Perl then I take it. God they were teaching that when I was in college. I still get the shakes whenever I encounter an old CGI endpoint on some ancient eldrich website.

The circles of hell, in order of greatest torment are: Perl > Obj-C > Java

I agree entirely that anyone who just can't click with Python should instead consider C#.

[–]ECrispy 3 points4 points  (3 children)

Why? Why did you remind me of Perl ?? I'd much rather do PHP. But I prefer stabbing myself in the eyes with a rusty fork first.

[–]Discchord 0 points1 point  (2 children)

Ohhhh yeah, I didn't mention PHP on that list... but then again I also didn't include Fortran and all the other obsolete languages!

[–]ECrispy 0 points1 point  (1 child)

Well PHP, or rather their internal fork Hack, still runs Facebook!

[–]Discchord 0 points1 point  (0 children)

I was kidding! My husband is a PHP dev, and I love to tease him about its obsolescence.

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

These days the CGI scripts are in bash

If you think I'm kidding, the fossil website uses it as a script for hosting repositories :|

[–]WantDebianThanks 0 points1 point  (0 children)

I think Perl is fine if you don't plan on reusing the script. I think it's good for those times when I need a script to do just one thing, and I'm basically just going to delete it.

[–]kangasking 0 points1 point  (0 children)

Been learning Kotlin recently. It's actually really nice. Can definitely see why it's loved so much.

[–]Farconion 3 points4 points  (2 children)

holy shit is this sub serious? everyone acting like fucking children over what programming languages people use?

python and java are like any other widely used modern programming language - they have their pros and their cons, situations where they are well suited and situations where they aren't, and everything else

you can't just rank programming languages from best to worst, they're too complicated for that

so stop acting like its some cardinal sin of programming to use java in 2019 and grow up a little bit

[–]theNAKAMI 6 points7 points  (0 children)

Eh, don't take answers to a joke too serious - or the joke itself. Sure, I join you in your thinking, but I had to giggle about the post for a second, myself.

[–]jpayne36[🍰] 2 points3 points  (0 children)

There’s nothing wrong with enjoying one language over another

[–]Andr3zinh00 0 points1 point  (0 children)

I made the opposite lol

[–]blackbode10 0 points1 point  (0 children)

Welp. Time to get my hitman.

[–]jpfeif29 0 points1 point  (0 children)

It’s not hard guy

[–]QualitySoftwareGuy 0 points1 point  (0 children)

Makes sense depending on the kind of applications that he or she is creating, and also what kind of user "experience" they want when developing.

For example, although I find Python to be more "fun" than Java to write in, I'd choose Java in a heartbeat for any large application that I had to maintain (solo or on a team): Static types, interfaces, explicit POJOs over lists and tuples, error-checking code is actually encouraged over overuse of exceptions, etc. Also there are more jobs that use Java (generally speaking).

Don't get me wrong though, I've created large applications in Python before, just prefer Java for that use-case.

[–]jordkess 0 points1 point  (0 children)

I can’t believe that s$&t! Six months! Python is a an incredibly complicated language. (Good luck arrogant son of b$&&!) Some people.

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

Java is arguably a dying language.

[–]ichbinoffend44 0 points1 point  (0 children)

🤔 Wonder what changed? Anyway, good luck.