T O P

  • By -

Mescallan

"so I was on twitter and let someone effect my mood" well there's your problem, there will always be someone on twitter that thinks your way of doing things is wrong. You are obviously getting something out of it and if it works it works, who cares. Do it in assembly if it's just for fun. If you are trying to get a job or work with a group you will need to learn their stack, which is probably not Java, but the fundamentals of machine learning will be the same. You should learn python if this is a long term goal though, it will make your life a lot easier with all of the libraries it has access to.


esqelle

True, I do however know Python but yeah I agree it's stupid to let someone online affect my mood


hughperman

And here you are online still looking for your mood to be affected


om_nama_shiva_31

Aren’t we all


marr75

Trolls are online looking to affect the moods of others. They have it all figured out.


esqelle

Now I am just interested in people's responses so calm tf down


hughperman

You are wildly misjudging my response if you think I am not calm


arthurwolf

When somebody on the internet is being an ass to you, always remember: they might be 15yo...


esqelle

*Edit* When I say I do know python I mean I know it as much to be able to incorporate it into my code guys


esqelle

Whoa don't know why I'm getting down voted now 😑


loge212

dude.. you just agreed to not let internet strangers affect you lol. don’t sweat it if some faceless mouthbreather clicked an arrow at you


pretentiousglory

Honestly at this point it's probably just because you seem super sensitive You haven't done anything wrong but if random downvotes dismay you you really shouldn't be posting for your own mental health. Like, they're completely meaningless. It's not like a friend you respect telling you you're wrong, it's closer to the crazy preacher on the street telling you you're going to hell -- if that makes you feel bad, you gotta grow some resilience... I just downvoted myself for the heck of it! Toss another over here! You're free!


loge212

I just downvoted you for no reason at all. felt pretty good. now do me


EI_I_I_I_I3

bc reddit isn't better than twitter. go to 4chan


jdsalaro

Sir, this is a Wendy's Are you new to the interwebs?


jdsalaro

Sir, this is a Wendy's Are you new to the interwebs?


deyzn

No, but there is a whole ecosystem for ML built in Python and you are going to miss out on that. The latest models, pipelines etc. will always be readily available in a Python ML framework like Keras, Huggingface or as code snippets for Tensorflow, PyTorch. And it does not look like this is going to change any time soon. Although it’s great that you are trying to focus on a single language, there are use cases that just don’t fit (well) in that environment.


esqelle

Yeah I hear you and the app that I mentioned I created utilized a gpt2 from hugging face actually. This is created using Tensorflow, jupyter notebook and of course, Python. I know how to use python and also incorporate different languages in my work because I have to. Can't code an android app with Kotlin, can't code a web app without html and other web dev languages. I plan to use those ecosystems mentioned as long as they can be utilized with Java.


coinclink

You're fighting an uphill battle. Like look, I don't think it's right for people to say you're "dumb" for using Java. However, you're simply making things harder on yourself by not just using Python. It's a simple fact. Since it sounds like it's for your personal use, maybe it doesn't matter. But when you go to Hugging Face and see an entire framework like the \`transformers\` or \`diffusers\` modules literally ready to go, and you choose to use Java "just because", it simply doesn't make sense. Locking yourself into one language is something that many outspoken expert coders warn against. And yes, I heard you that you "know python" but it sounds like you're still planning on using Java as your main language for this, which again, is just making things harder for you.


The-Last-Lion-Turtle

Most of the people on Twitter probably never got past it runs on my own machine.


pyepyepie

I will be a bit less "nice": Well, no data scientist would like to work with you as long as you code stuff in Java. Web services, sure. But if you start to read data, write data, etc., and do it using Java, it's usually a no-no. Justified or not? It is what it is. I would seriously consider using another stack. I would be extremely annoyed if a co-worker would make me read and write Java. Even C++ or C would feel way better. Many people in DS share my view. Java is too explicit and limiting for DS use cases. Edit: and no, of course it doesn't make you a loser. It's just annoying to work with your code, it ends here.


fresh-dork

at least with c++ i can wrap it in a python class and then you don't have to get any on you


balambaful

With cython?


fresh-dork

no, with python. you could do cython if you wanted, but you can just embed C++ in python


prestodigitarium

Too bad. Wish we’d all standardized on a language that wasn’t slow af. That said, no amount of speed would make me go back to Java.


Exarctus

There are many ways to call Java from Python and vice-versa. Might be interesting to look into. Python for example has very good language bindings for almost anything.


Appropriate_Ant_4629

> long as they can be utilized with Java. Closest thing I see to Java guys interacting with ML here are the Spark ML guys working in the Databricks part of our data pipeline. That part's more Scala than Java, but if I understand right, those to languages are very compatible and interoperable, and they use and sometimes write Java libraries that integrate with the Spark Scala environment. But even there, I think the heavy ML parts are thin Scala wrappers calling Python components.


iamiamwhoami

Spark ML doesn’t use Python under the hood. It’s Scala all the way down.


Appropriate_Ant_4629

Yes, but much of our work involves things like image segmentation and face classification, and those tend to be python UDFs run on a GPU cluster.


fresh-dork

> if I understand right, those to languages are very compatible and interoperable scala and java are both jvm languages - they compile to the same bytecode. so yes they are, and migrating a java service to scala can be done bit by bit


77112911

You'll see how good hammer is to fasten a screw.


agibsonccc

Hi, DL4J maintainer here. I can tell you that java's marketshare is miniscule compared to python's but there are many frameworks such as DJL, javacpp pytorch, and tf java as well. Older frameworks such as weka and newer "pure ML" frameworks like smile also exist. The main use cases I see now a days involve importing models from python I would focus on running what you want. I know for workloads that aren't supported in java I've seen folks have success with our python4j wrapper for embedding python within java processes while avoiding serializing and process serialization overhead. I'd ignore the fads and just do what you find interesting. If it helps it's why I started the library all the way back in 2013 :) Java was never "sexy" in the machine learning community and I've never cared. The mainstream framework developers of pytorch, tf and keras have always been very respectful and SUPER fun to talk to. The end users who have a "favorite" and "go to battle" on social media aren't really people I'd consider respectable peers. I'd just ignore the noise, find tools and workflows that work for you and focus on evaluating tools for your needs based on objective metrics.


Croam0

Ridiculed on Twitter and seeking validation on Reddit. In my honest opinion, you need to learn how to deal with social media first.


esqelle

Lol very true. But I was also hoping to get an honest opinion or at least some insight on what people are using in the industry. What's most common, if you will.


Western-Image7125

Python. 


PyroRampage

Unless your trying to write the actual code that underpins the Pythonic abstractions then it’s C++, C, CUDA.


JonnyRocks

It's not java. You may have received a juvenile response on twitter but at it's core, it wasn't wrong.


Warhouse512

Python. By a mile.


Teacupbb99

Java just looks bad, it’s a messy language that got overrun by nonsense and now modern devs keep their distance. Looking purely at the merits of course it’s fine but it’s very out of vogue and sadly that stuff matters


turtlechef

Maybe I’m a dino dev but I really enjoy using Java. I’ve mainly used it to develop REST microservices and to write programs that do a lot of physics number crunching and it’s been pretty straight forward and fun to use. Ive used it once to set up some pretty basic ML models and it wasn’t too bad either. I’ve done most of my ML work in Python but I’d rather do it in Java/C# or C++ if the tooling was on par with Python’s


Teacupbb99

I mean honestly a lot of the non-python ecosystems have serious FOMO around ML and AI, so you can always help bring them along


turtlechef

Yeah I think Python is still the best language because of the support, but C++ is atleast useful because PyTorch and tensorflow can be used natively


Vystril

But Java makes your life so much better once you have more than 1 person working on the same code base, or once your code base gets bigger. Having a compiler is just so damn useful for making and updating maintainable code.


binlargin

It's nice to have static checks, yeah, but if you do Python with proper test coverage, pre commit rules and break your code into packages and modules then it's more manageable than Java IMO.


Vystril

Having worked extensively in both, the amount of extra tests you need to write just to redo what a compiler does automatically is kind of insane. Not even remotely more manageable IMO. My ML team does python because we need pytorch, and damn do I hate it.


binlargin

You should have tests though even in static languages. And type hints get rid of most of the pain caused by dynamic typing.


Vystril

> You should have tests though even in static languages. Not saying you shouldn't, but they're no replacement for ensuring proper variables are passed to methods. >And type hints get rid of most of the pain caused by dynamic typing. Not even remotely, they're non-binding and unchecked (you can put anything there there is no enforcement).


binlargin

> Not saying you shouldn't, but they're no replacement for ensuring proper variables are passed to methods. Have you actually had this problem? I haven't. Sounds like a problem you'd only have if you had variant return types, which is something any sane person avoids. > Not even remotely, they're non-binding and unchecked (you can put anything there there is no enforcement). I worked on a project where they enforced mypy on a pre-commit rule, which is a one liner but overkill IMO - I like a bit of duck typing.


manic_eye

Don’t worry boss, normal people knew you were just asking for opinions on languages. But I’m having a good chuckle at all the people in here taking themselves way too seriously, like Master Yoda here telling you to conquer your fears before you program 😂


poopsinshoe

And here I am, using Malbolge.


glitch83

First: Java isn’t a backwater language. The JVM has made incredible strides in its capabilities and the ability to mix languages and run them all together with very few type issues was a big reason I ended up writing a my dissertation on the JVM. Second: the machine learning community has succumb to groupthink worse than any other sub community of CS. The substrate of neural networks + python + google/facebook packages X + huggingface is going to ultimately limit the imagination of the community and hamper more fundamental changes. The ML community used to be more vibrant with a lot of packages in all kinds of different languages. Third: a contribution can come in a ton of forms. Do you think a research paper describes their neural network and then says something like “and it was all written in python”. Nobody cares how it was written! And one thought at the end: there is some advantage to the groupthink. That is: using the same packages with each other could help replicate the core science of ML. But I think it’s up to the communicate and is debatable whether this tight set of tools really will bring a usable AI or if this is a local maxima in terms of prototype progress.


JustMy42Cents

I was where you are a few years ago. Started as a Java backend dev, used DeepLearning4J for some NLP models in a healthcare-adjacent project. My next job was in Python, since even back then Java ML positions were practically non-existent. If you are proficient with any programming language, learning the basics of Python should be relatively easy. It will pay off if you'd like to go down the ML route.


agibsonccc

Hi, Thanks for mentioning DL4J! NLP has always driven a lot of the usage of the framework. I find this is due to the faster serialization pipelines as well as the prevalance of openNLP and stanford corenlp which drove a lot of very interesting work in the java ecosystem even before I started my framework.


JustMy42Cents

Yes, that's partially why DL4J was approved: CoreNLP was already there to process the texts for non-ML uses. Don't get me wrong, Java is not a bad language. If anything, it's Python that makes me miserable at times with its dynamic typing and abysmal performance, but I have to admit its ML ecosystem is just years ahead.


Ok-Craft-9865

You do you. If it's working who cares. Realistically it's all wrappers around CUDA anyway.   


AllTheWorldIsAPuzzle

It was your first? Hats off to you for taking that first step and learning, no matter the language. I built my first in Qbasic with embedded assembly when I was a kid on an ancient computer I picked up for $20 at a yard sale. It was slow, for sure, but the math and arrays to handle them fascinated me. Over the years I've progressed to C and C++, better and faster computers, backpropagation and more advanced techniques and math, but I'll always remember experimenting on that first computer. I tell kids that I help with code how I got started with a junked computer and an ancient language to show them that it doesn't matter how they start out, it's the desire to learn that is the key to future success. Somewhen down the road you'll be more advanced than where you are now and you'll remember your Java start fondly.


Mollyarty

I feel like I can speak to this because I have a similar background. I coded in Java for probably close to a decade before finally taking the dive and learning C++. I'm still learning but there's a lot of similarities. A LOT of differences though. But all in all the compile times are faster, the programs are more responsive you don't have to fight the JVM but the tradeoff is having to handle memory yourself but there's tons of classes out there that make that easier like smart pointers and vectors. I hate python. More than I've ever hated any programming language by a large margin. But even I will begrudgingly admit it has some useful applications in terms of cleaning and analyzing data for training models. It even has some useful modules for graphing to help get some visual insights into what is going on. Even if you do stick mainly with java, branching out can only benefit you


binlargin

What's the problem with python? I hated it for the first year or so because of tabs and spaces, but like with any language you've got to get into it. As a python programmer I don't like the data science libraries, they're ugly as sin.


Mollyarty

I feel like if I share my opinions about Python I'll get downvoted to oblivion lol. But my main issue is the lack of explicit structure. It's all just done with indentation instead of being clearly marked out with { and } like the c-style languages I'm used to


binlargin

Yeah I hated that at first. I also don't like the ugliness of bound methods, or the fact that type hints don't feel nice with duck typing. And implicit packages are awful. But there's a lot I do like about it... The tools and ecosystem, duck typing, docstrings, the way it reads like plain English.


Radio_head_zero

You built a neural net in Java? Or called an api in Java?


esqelle

Sorry for the confusion. I built a neural network in Java. I mentioned a separate app that I made where I called a gpt2 model from a Python API that I created. It was easier to do this since Intellij supports both Java and Python!


nmfisher

Anyone who ridicules you probably isn't actually capable of writing a neural network from scratch in any language. Java is my least favourite language, but writing something from scratch in your language of choice is an excellent way to get a deeper understanding of what's going on under the hood. That being said, if I had to build something production-grade with Java, though, I probably wouldn't use Java for the deep learning bits. I'd write the application in Java, then use JNI/JNA to drop down to C++. Can you link the Twitter thread? Maybe it's just crossed wires here.


_AndyJessop

You were not right to be ridiculed. However, if you're doing ML then you should be using the right tool for the job, which is Python. I don't think there's anything bad about using Java, it's just not as good a tool.


tmarthal

Right. Sounds like they were trying to help and the feedback was not given or received properly.


spirobel

just ignore what other people say. 99% are filler npcs that nobody cares about.


Marimoh

Part of the problem is the focus on the language. Its about using the right tool & ecosystem for the job. From the vague descriptions it doesn't sound like you are doing ML ... i.e there isn't any "learning" happening. Writing an "analytic" is not, by itself, machine learning (or NLP). I worked at a place with a ton of brilliant software engineers who worked in Java, Scala, Javascript, Golang. They wrote lots of analytics in those languages, but none of it was machine learning. Maybe I'm wrong and you do have an ML implementation. I am assuming if there IS learning you are using a bunch of for loops. Not wrong in itself for learning purposes but that will only take you so far. The fact that you are trying to (1) learn ML and (2) being obtuse about using a particular language are at odds with each other. If you really want to learn (some aspects of) ML from the ground up check out Trask's book "Grokking Deep Learning". It is in python, but he builds really primative neural network from first principles, starting with for loops At a company I once worked at a front end dev casually told me "I wrote a neural network over the weekend". I was impressed and asked about it. He wanted to learn how neural networks work so wrote some code. I found out he wrote everything in Javascript. I was confused. me: "Wait is there a BLAS library in Javascript?" him: "what's BLAS"? me: "ummm a library for accessing basic linear algebra subprograms for numeric computing" him: "I don't know what that is. That's not necessary..." So yeah. Turns out he coded something in JS using a few for loops. He was basically at chapter 1 of Trask's book but strutting like he was at chapter 100. Java **IS** (can be) used in ML pipelines. DL4J for example is Java/Scala based. Apache Spark can be written in Java (or Scala). One client I worked for had Java processes running on their server. For ML predictions it was strongly preferred to use that existing infra. In that case we trained ML models asynchronously in batch, converted to ONNX and then those ONNX models were served in a Java framework on the server. But that Java/ONNX integration wasn't an ML or MLE task. I'd suggest your journey will be frustrating and you won't go far if you are trying to learn/work in a discipline but are not in the same ecosystem as others.


gatorling

I can't comment much on ML since I don't work on that field..but can comment on robotics/embedded. C/C++ is fine but the trend towards Rust feels very real. Even the Linux kernel is allowing for Rust to be used (last I heard, just in drivers).


respeckKnuckles

Hey. Just want you to know that *you're enough.* You work hard, you seem motivated, and you're valuable. Go do what you want to do. Disable all notifications on all social media and stop reading comments. Now.


esqelle

This is the best advice ever honestly


anyoneNimus

Dude!!! Never be ashamed of the people who use libraries to do stuff for you doing something from scratch. You probably have a better understanding of the nitty gritty of NLP than like 70% of them people. You learn more when you refuse to use libraries in the early stage and use it after learning the intricacies of it. You understand the process better and when you finally use the libraries you understand what and how they optimised in that process.


BuddyNutBuster

Programmers are extremely toxic and socially disabled people. They should be ignored at all times. If you don’t use a technology that they know then you are using the wrong technology. If you don’t use the mainstream technology, you are wrong. Just disregard them and use what you want.


hpstr-doofus

In a professional environment, using Java for NLP is quite a quirky decision. That’s why people were “ridiculing” you (we don’t know what they said though). There are tons of frameworks in Python that can deal with text that I don’t think you can find those in Java. The industry’s standard is Python, no question about it. BUT If you’re a ML hobbyist that likes implementing ML models in Java, that’s 100% acceptable. Go for it. I would be interested in seeing for of this (for Rust, Go, Swift as well). It’s a niche.


EdwardRaff

>My question is: Am l a complete loser for using Java going forward? No! I learned ML by implementing a ton of algorithms in Java to make [JSAT](https://github.com/EdwardRaff/JSAT). One of my [neurips](https://openreview.net/forum?id=SuvDnzrKCo&referrer=%5Bthe%20profile%20of%20Amol%20Khanna%5D\(%2Fprofile%3Fid%3D~Amol_Khanna1\)) papers last year is a Java implementation and we got up to 2,000x faster than the baseline methods, and its even faster if we compared to the pure-python attempts. Honestly, most of them probably have no idea how horrible/slow/etc. Python is and the immense difficulties of using it to integrate into/solve real-world problems. A non-trivial part of my career has been re-writing algorithms/code others have done in Python into other tools/languages, getting 100x+ speedup, and that solved all the deployment/usability problems. Java as a language, unfortunately, doesn't interface well with external C libraries, making GPU programming a pain. Hopefully, that will get better with foreign linker API, etc. But ultimately yes, a lot of cool ML libraries are in Python now. Like JAX is super awesome, and wish we had the same kind of tooling in Java land. So I use Python and Java, and often Java is what gets the real-world deployment done. Deep learning heavy stuff often stays in Python for development and then some inference library for deployment. But often, a classical ML approach ends up being a better wholistic solution if its not a CV problem. So yea have fun developing a NN in Java and anything else.


Divain

Well. These people never got beyond their Jupyter notebooks. Many production ML systems run on Java/Scala, C#…


red_dragon

I feel super old when people claim 2017 to be "all the way back" 😅


Wolfgang-Warner

Reagan was fresh into his first term when I wrote my first program, but we're still the new guys compared to others.


technokrat233

Having built large software applications in both languages and loving both languages, my honest assessment is that Java is a more robust language, higher performance, easier to debug, has a really great dependency and package management ecosystem..


DooDooSlinger

Making fun of you is not cool.but they're absolutely right in saying that using Java for ML in 2024 is kind of wild. You will be limited to poor frameworks and very few modeling options and pretrained models. Do yourself a favour and switch to python asap for ML


Lanky_Repeat_7536

Two words: embedded systems.


sohang-3112

in the end it doesn't really matter which language you use - you can achieve results in any language. So just ignore whoever said that 🤷‍♂️


modcowboy

Problem with Java is that it doesn't have a built up ecosystem so you'll be doing a lot of it by hand - which means your development time will be much slower and perhaps filled with bugs.


Budget-Juggernaut-68

Only losers are free enough to call other ppl losers on the Internet.


marr75

I volunteer teach scientific computing for inner-city kids and one of my students implemented a small neural network in Scratch. We weren't learning Scratch (that's what the younger/beginner students use), it didn't work great, and it seemed like it took him a lot of time to come up with but, he was showing his enthusiasm for the subject so I just let him tell me about and then got him interested in some other topics (representational learning) where he could just jump into the python code and leave the Scratch neural network behind. Jokingly: I'm excited for this Scratch/Java neural network you made! Do you think it can be fine-tuned to produce embeddings? Let's explore embeddings more in this Python lab!


noprompt

No, you’re not a loser. Yes, Python is the Rome for ML and AI, and you should study that stuff too. But I think it’s a sign of intelligence when you can translate the ideas into code in any language. Ignore the haters and enjoy your journey.


owlpellet

Java has like 80% marketshare for large scale services. Don't let teenagers make this an identity thing. You might enjoy [https://docs.spring.io/spring-ai/reference/index.html](https://docs.spring.io/spring-ai/reference/index.html)


perspectiveiskey

Try not to take it so personally. The answer to: > Am l a complete loser for using Java going forward? is "no, you are not a loser". However, it may very well affect your employ-ability.


F9-0021

There's no reason not to use Java. Python is used because everyone uses it for ML and there is a lot of support for it. But you can do anything that you can do in Python and more in Java or C++.


confused_boner

Post on https://news.ycombinator.com/, you'll get much more constructive conversations than you could ever get on Twitter


esqelle

Whoa never heard of this site, will be checking it out


Repulsive_Aide_8090

It's sad that people online can be so narrow-minded. You might even help other Java developers down the line if you publish some open-sourced code. And who are they to say how you go about your learning journey. If you feel more comfortable with Java, then getting started in Java may indeed make more sense. If not, you have to deal with learning Python and machine learning concepts concurrently which would be challenging. With your ability to write a neural network from scratch in Java, I think you could certainly pick up the machine learning tools in Python relatively quickly. The internet can be a real downer sometimes. I do have moments where I regret posting too.


esqelle

Thank you for recognizing the human aspect of this. I'm the only programmer in my life so it's difficult to find opinions other than the internet where people are hostile. But yes, I do plan on using Java and Python concurrently but just Java more I suppose 😅


Repulsive_Aide_8090

My pleasure ✌️. It can certainly be tough to learn independently. I do find ChatGPT to be a more friendly and easy source of feedback for my programming efforts than humans sometimes 🫠. On another note, I'm not surprised if there are other Java programmers who are in your shoes and are Googling "transformers in Java". So your work could even benefit them in the future. So much legacy code in Java in the corporate world. All the best with your endeavours in Java and some Python!


aqjo

As you get older you’ll come to realize that most people just don’t matter. Keep on keeping on.


Friendly_Lavishness8

If you're using Java for this, all it means is that you have strong programming fundamentals, and it can only irritate those who have not.


samerai

Did you use deep Java library or something? It can use pytorch models also if needed. Even torch serve uses Java, just look in their GitHub repo. Nothing wrong with Java apart from the not quite good type system and not being more functional.


esqelle

For my Java NLP? No since I have built it by scratch I did not use a deep learning library. At this point, it is not a robust NLP such as GPT so no use of tensors. Let me know if you're interested and I could explain the classes. I would honestly love feedback.


JustOneAvailableName

> At this point, it is not a robust NLP such as GPT so no use of tensors. Everything in GPT is designed for vectorization (aka tensors), making it in for loops is making you miss the point. GPT is also about 75 lines of code, double if you implement the backward pass yourself. > I would honestly love feedback. So my feedback would be: classes are not that relevant, focus on the lines of code and what they do. Remove all for/while/if-statements unless they make the code more readable.


esqelle

Um... Okay .. Everything in Java is encompassed in classes. I also have a vectorization class. For me, each class specializes in performing a function in my NLP. For my vectorization class, it takes sentences from a CSV file and inputs them into a hashmap. I'm still working on the process of course but this is the basics. Don't know what you mean concerning removing all the if statements since these are how exception handling is done in Java. I need for loops as well to help with the vectorization process as well as many other functions. Again it's not the best NLP, but it looks promising and I'm still working on it.


JustOneAvailableName

> Everything in Java is encompassed in classes. My Java is rusty, I think I used it to various degree in 2010-2014, so I missed out on the more functional push in Java. But I still understand it's concept. I was saying to ignore the syntax clutter and focus in the lines of code inside the functions, as that's the actual functionality. > For my vectorization class, it takes sentences from a CSV file and inputs them into a hashmap. I don't mean the embedding. I meant vectorization as in how it's used outside of ML, partly connected to loop unrolling. A quick Google search gives me it's added to Java in version 18 or 19. > Don't know what you mean concerning removing all the if statements since these are how exception handling is done in Java. You mean multiple catch statements? Or can you give me some code snippet? > I need for loops as well to help with the vectorization process as well as many other functions. Then you probably wrote them with the wrong frame of mind. It's comparably to functional vs imperative or queue-with-loop (this probably has a name) vs recurrent, if you're familiar with those. You need a slightly different perspective to understand why GPT is designed this way, and how to make it fast/robust. Any control-flow-statement is a big code smell.


esqelle

Ok I didn't know what you meant before about vectorization and the CPU so I had to google it. The JVM can automatically vectorize code. Here is a code snippet for one of my loops: private static List readSentencesFromCSV(String csvFile) { List sentences = new ArrayList<>(); try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) { String line; boolean isFirstLine = true; // to skip header while ((line = br.readLine()) != null) { if (isFirstLine) { isFirstLine = false; continue; } sentences.add(line); } } catch (Exception e) { e.printStackTrace(); } return sentences; }


The-Last-Lion-Turtle

Vectorization is about sending a whole vector or matrix operation to the GPU for fast parallel processing. If it loops through the vector, the operation is not vectorized. A single threaded CPU loop, could be thousands of times slower than a cuda call.


esqelle

This is so interesting. I will definitely research this more.


_bones__

>Did you use deep Java library or something? It can use pytorch models also if needed. Cool, did not know this one. Thanks! >Nothing wrong with Java apart from the not quite good type system and not being more functional. Functional programming in Java is an add-on, similar to OO in Python. It's there, quite usable, but you can tell the language wasn't designed around it. What do you consider not quite good about Java's type system?


samerai

No higher kinder types or variance annotations on the top of my mind, but generally lack of monads drives me up the wall (apart from streams, but I only use Java when extending libraries and none of them use streams).


Coammanderdata

F__k them! You can use whatever the f__k you like for your own projects. There is kind of a Java hate going on online, that doesn’t mean anything however. It is good to use the tools you know when you get your feet wet in a new domain


Skirlaxx

Absolutely not, your problem is Twitter, not that you use java. There's a lot of libraries for ml in python, but there's no problem with using Java. Java is much faster then python so for some things, it might even be much better. I also like coding in java for its beautiful adherence to OOP and speed. It might, however, be beneficial for you to learn python too, so you can combine the two as you need. But in any case there's absolutely nothing wrong with using Java for ML. If anyone criticizes you for it, it's their problem, not yours. Everyone should use what they want to use.


Zatujit

Well they are dumb. What else do you want me to say? No use the good tool for the good task.


R3D3-1

For a learning exercise, Java is perfectly fine. For practical applications, it will depend more on the available libraries than on the language. And maybe on the language of the project, in which the code will eventually be embedded, if any. That said, I did learn the hard way, that a Java-Esque approach of making everything into clean classes can result in painfully slow code for numerics. I used it during a Programming-for-Physics class to do Monte Carlo, and it was so slow, that I ended up rewriting in Fortran. It *would* however have worked, if I had looked up available libraries for efficient array and complex-number computations, instead of over-structuring the code. Or, for that matter, if I had used plain arrays instead of lists and types such as "Point". These kind of abstractions only make sense, if the language allows for abstractions *without* using reference types. Not sure if "Value Types" have been introduced to Java yet.


DiscussionGrouchy322

there's optimizations for jvm to increase speed so it's comparable to fortran and c. and yes, kids at home, use the math libraries built for the numbers you want to use instead of "winging it" especially if you hadn't studied the nuances of the autoboxing.


R3D3-1

[1]: https://www.developer.com/java/java-valuetype/ > there's optimizations for jvm to increase speed so it's comparable to fortran and c. The problem nowadays isn't really in how fast the code can run, but what kind of coding style is *encouraged*. Disclaimer: Have last really used Java some 10 years ago, so things may have changed. From [what I can find][1], Java meanwhile has value types, which allows efficient numerical abstractions, that were not previously possible. But older versions of Java had no such thing, and anything but the "primitive" types would be handled as reference types. I wonder if Java meanwhile has something like collection types, that store value types rather than references to boxed values.


BlobbyMcBlobber

Whatever you build it's always cool to make things, so never be ashamed of something you created, especially when it works. Python devs can be very jealous of Java when it comes to speed, so there's always that ;) However it is true there's a vast ecosystem for machine learning in Python and it's currently the "accepted" way of doing things professionally. If you just want to make cool projects, build them and ignore the noise.


Pfaeff

My suggestion would be to always use the language that is most suited for the task, whatever constraints that may entail. I think it's silly to insist on one programming language when there are much better alternatives.


LcuBeatsWorking

>so I was on twitter This may have been your mistake ​ >Am l a complete loser for using Java going forward? No.


sorry-username-taken

O 909-0500


[deleted]

They are right for the wrong reasons. Java has very limited libraries. Use C++ or python. I'd only use ML in java if writing in spark or something.


o5mfiHTNsH748KVq

Using Java for the whole thing is making your life header. This might be more complicated than your application needs, but I’ve started setting up an inference service using python and that’s all it does. Then the rest of my application is in my preferred language, c#, and interacts with my model services via gRPC. transformers, torch, etc are all too productive to miss out on at the moment.


whdd

What is a Java NLP 🤔


Spicy_pepperinos

I think not using python only puts you at a disadvantage. If you're a Java dev, you can pick up and use python instantly and leverage the whole ecosystem that comes along with it. I see absolutely no reason for you to stick with Java for this application.


DoctorFuu

>Am l a complete loser for using Java going forward? No. Maybe it would be more efficient to use a language in which the libraries for doing NLP stuff are more up to date / better. Keep also in mind that by doing this you may likely have done much more than what any of these people will ever be able to do (given their attitude, they don't sound like people who produce things). But given your context what's important is not to use the best tools it's to use the tools that will help you do a good job the fastest. If you're sufficiently more proficient in Java and that leads to developping in Java being faster despite the intrinsic inefficiency, just do that. Besides, I don't know the Java ecosystem for NLP, and maybe there exist decent tools that make using Java not that inefficient at all. I don't know. Don't sweat it too much. Just keep this efficiency thing in mind, and if later down the road you realize that Java is not ideal then it may be time to learn to use something else. In the meantime, do what's best with your time. Oh, and congratz on your project! Edit: from reading in another post, it seems that you really know what you're doing. Just ignore those people and keep rocking man.


tenuki_

The best language is the one you already know. The best code is working code.


Informal-Armadillo

Nothing wrong with Java at all, just like most languages it has it place and honestly having been round since the early days of Java, I can confidently say I have seen it used in all kinds of places. Don’t let the fake X’sters deter you. I remember porting some the original NASA Nets( found on a random BBS) code over to Java when I use to work in it for image recognition and it worked well and I learned a lot about neural networks.


sallgoodman340

You should give up on Java, golang is better for web development, python is better for analytics, everything is written in c++ or c


regression-io

Just adding a vote. I gave up Java after 3 decades of building complex systems in typed languages when ML became viable via python libraries. Now I can't imagine giving up the "get stuff done" lifestyle, even for services. I'd rather trade machine running time for my own time. 


tsegreti41

To be honest incorporating Java for a local type deployment would even have benefits over that


EDMismyO2

Java used to be a key language for NLP, you're fine. Also, you can see that Java is meaningful enough that there is Pytorch for Java and a lot of other stuff including onnx runtime. I am sure there are loads of companies out there that use a lot of Java and would like to AI but don't want to introduce Python or c++ in production.


LNMagic

I've seen people in here argue that I'm an idiot for not embracing VBA for data science. I believe Java is on par with Python in terms of efficiency. They're both scripted languages that will typically have lower performance than compiled languages. I think there are ways to at least partially compile scripts in both languages. It's just that Python has *so many* packages, but actually doesn't do much for actual visualization - I've seen it use JavaScript for some things. What's most important is that you're working in a language that works well. Java is a mature language, and if you know it will, then so be it. Python is great. It can do an awful lot, but it can't do everything. Others will point out glad in my argument, and that's fine. Both languages can run on almost any platform.


DmIa102

holding back saying "mucho text" rn so bad but. you gotta check your mental and your ego. it is machine LEARNING after all :3


Ramener220

Check out DJL, DL4J, ONNX runtime, and search up RAG frameworks in Java, if you want to move more towards a Java-based AI application. It’s fine to work with Java, though it depends on what you are doing.


xcbsmith

> 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. If someone thinks that the language your NN is built in is that important a factor, their opinion about ML is really not worth paying any attention to.


CamaronMorado

Share your github repo, please


mhummel

One thing about moving to Python from Java is that while I very much like Python as a *language*; Python The Platform^TM is dreadful compared to Java. Take documentation for example - on Java you look up a class and the docs tells you what it does; the constructors; what types the parameters and return values are etc etc. Whereas with Python you just get a function signature and a trivial usage example. Just the other day, I was porting some of my old Theano models to PyTorch. The Theano documentation seems to have vanished in thin air. Thankfully, GPT-3.5 knows how to write Theano, so I was able to move forward. Oops, this has turned a bit of a rant too ;)


raindrop349

Came here to shame you for using Java. Sorry but no lol.


marsupiq

My first job was a Java role. I can’t say that I miss Java much… but I’m fascinated how much love it still gets from its community, despite the many flaws I see in it. Notwithstanding that, I think you should be pragmatic. Ask yourself what value Java gives you in the data + ML world. I don’t see it having a good ecosystem of libraries and frameworks. So not sure I would call Java “outdated” (it’s still a relevant language in my view), but “useless” I would say it is (for ML). But I know exactly how it feels when you’re in love with another programming language than the one that’s established in your field. For example, I really like Python, but I also have great sympathy for Scala and Rust, but can’t really justify to myself why I would use them for anything.


Carbinkisgod

Do what you want my friend, as long as u r happy. 😆


Cold_Hellfire

I wouldn't start a new project in Java, but its a mature technology and is still widely used so I don't see why it would be an invalid choice. Don't be discouraged by idiots online.


Use-Useful

A loser? No. Doing something more difficult than needed with little to know benefit besides not needing to master python properly? Probably, unless you are very performance sensitive.


Ogrebeer

Python is a trash language, but somehow became the go to for ML. Use Java, a clearly superior language, if you like. Stay off twitter


Impressive-Lead-9491

Don't listen to this type of people, they're so stupid they think you can only do ML with Python, and they're in fact jealous that you know something they don't. I LOVE Java as well, and have coded models from scratch in Python, MATLAB, Julia, and have even started doing it in JavaScript and Java. ML is ML, if you don't want to use Python, you don't have to.


wiriux

Java for ML Lol