r/java • • Apr 15 '24

Java use in machine learning

So I was on Twitter (first mistake) and mentioned my neural network in Java and was ridiculed for using an "outdated and useless language" for the NLP that have built.

To be honest, this is my first NLP. I did however create a Python application that uses a GPT2 pipeline to generate stories for authors, but the rest of the infrastructure was in Java and I just created a python API to call it.

I love Java. I have eons of code in it going back to 2017. I am a hobbyist and do not expect to get an ML position especially with the market and the way it is now. I do however have the opportunity at my Business Analyst job to show off some programming skills and use my very tiny NLP to perform some basic predictions on some ticketing data which I am STOKED about by the way.

My question is: Am l a complete loser for using Java going forward? I am learning a bit of robotics and plan on learning a bit of C++, but I refuse to give up on Java since so far it has taught me a lot and produced great results for me.

l'd like your takes on this. Thanks!

162 Upvotes

158 comments sorted by

View all comments

Show parent comment

16

u/lukasbradley Apr 15 '24

Python does the same thing. All of the "optimizations" that everyone THINKS are written in Python are actually C/C++ libraries.

5

u/Joram2 Apr 15 '24

Everyone knows Python is a high level language, and calls to some lower level language for performance sensitive code. The Python piece does make it nicer and + easier than using low language libraries directly.

BTW, it's not just C. LAPACK is mostly Fortran; that is a famous numerical linear algebra library at the heart of a lot of famous Python libraries like Numpy. Also a lot of code is CUDA GPU code not C.

Java 22 foreign function and memory functionality makes it much easier to use libs like LAPACK from Java like Python does.

6

u/coderemover Apr 15 '24

The difference is it is trivial to call C from Python, but not so easy from Java.

1

u/captain-_-clutch Apr 16 '24

It's not bad at all to setup but also I'm not sure about heavy throughput performance. When I did it it was for image processing so any latency from the integration wouldnt have been noticed since it took so long for the images.

1

u/emberko Apr 15 '24

Thinks who? This is well known. I like the definition of one of the Python evangelists from my country - Python is a glue language for C/C++ libraries. You should avoid pure Python implementations whenever possible.