r/java • • Dec 19 '22

Java streams are black magic !

damn, they are really changed my life.

i was trying to run some custom logic on every line on some big CSV files. tried python dataframes, multiprocessing in python, pyspark. none of them did it in an acceptable time.

then i discovered java streams. i have a workflow that takes 70 minutes with pyspark. it takes 3.5 minutes with java streams.

more people should know about streams.

stream operations are more intuitive than anything i tried. i can make a lot of analysis on our data in record times thanks to streams.

i dont know how java does this.

226 Upvotes

150 comments sorted by

View all comments

Show parent comments

1

u/Worth_Trust_3825 Dec 19 '22

Before people get fed up, and rewrite the entire thing in either C# or java.

4

u/BlobbyMcBlobber Dec 19 '22

If this happens, then the wrong tool was chosen for the job. Python has its advantages and java has its own. They complement each other. The trick is using them for the right thing and not imagine they are some sports teams with a rivalry.

2

u/Worth_Trust_3825 Dec 19 '22

Yes. Python's advantage is prototyping. Or when you have some maths phd statistician that does not want to learn anything.

1

u/[deleted] Dec 19 '22

The selling point of Python is it's readability, the maths/science community can focus more on the stuff that matters to them, the language gets out of the way; besides, nowadays the maths PhD statistician most likely learned Python from highschool onwards and the C++ backed analysis packages are taught in most maths colleges alongside R and MatLab, at least here in Serbia.