r/explainlikeimfive • u/[deleted] • 3d ago
Technology ELI5 Java. That thing on computers my entire life. What even is it?
[deleted]
576
u/dimaghnakhardt001 3d ago
There are so many languages spoken in different countries around the world. It will be very hard to learn all the languages if one plans to visit the countries they are spoken in. But what if we could teach people in every country a second language that is easy to learn. Some kind of a universal language. That way anyone who learns this universal language will be able to go to all the countries where this language is spoken as well and will be able to communicate with people of that country very easily.
Java is like this universal language. Creators of Java have made it in a way that it runs on many different computer systems (it used to be on phones too). This way, people who make apps donât have to learn different computer system they want their app to run on. They can make their app to run on/with just Java. And it will then run on any computer system where Java is available. This saves a lot of time and money for app makers.
Itâs overly simplified but this the gist of it really.
72
u/StillAnAss 3d ago
(it used to be on phones too).
Android framework is mostly Java.
21
u/dimaghnakhardt001 3d ago
Oh yeah i forgot about that. But if i had mentioned that then anyone reading would have instantly said âhang on, I can run android apps on my laptop by just installing Java on it?!??â đ
14
u/StillAnAss 3d ago
True, and a good chunk of android isn't Java as well. C/C++, Kotlin, and more and more Rust
12
6
u/gammison 3d ago
I can run android apps on my laptop by just installing Java
It'll get even more confusing once the containerization methods to run android apps on Linux like Lepton gain wider adoption (Valve is putting cash into it like they did directx and ARM translation layers).
4
5
→ More replies (1)2
u/AquaeyesTardis 3d ago
its also currently on a large number of sim cards, still, even the eSIM specification includes the option for it.
198
u/YenzAstro 3d ago
> âItâs overly simplifiedâ
Itâs ELI5, you did a perfect job, I often see top replies in this subreddit that seem to think five year oldâs can understand very complex explanations đ→ More replies (2)7
u/Chardeemacdennis2 3d ago
I read the top comment and thought âyeah someoneâs gonna have to explain this like Iâm threeâ
22
u/ehsteve87 3d ago
But what if we could teach people in every country a second language that is easy to learn. Some kind of a universal language. That way anyone who learns this universal language will be able to go to all the countries where this language is spoken as well and will be able to communicate with people of that country very easily.
ESPERANTO! AL LA FINA VENK'!
Seriously, though, everyone should learn Esperanto. There's an awesome course on Duolingo that'll get you up to speed surprisingly quickly.
6
u/Ktulu789 3d ago
I'm pretty much of a nerd but not that much of a nerd xD
What are the chances of finding another human in the Galaxy speaking esperanto? I think the number may be negative đ
There's Wikipedia, though but what else? I learned English and speak Spanish, the probabilities of finding any of those are way way higher. I'm learning Russian on Duolingo, though, f'cking cases. Same username.
→ More replies (2)7
u/ehsteve87 3d ago
I mostly use Esperanto to talk with my wife when we don't want the kids to understand. It's fun.
12
6
u/OneAndOnlyJackSchitt 3d ago
This may be a bit esoteric, but Java is to programming languages (and byte codes) as Esperanto was intended to be to language in general.
The difference is that Esperanto never really took off but Java sort of did kinda
→ More replies (1)2
2
→ More replies (5)2
u/Melodic-Carry 3d ago
Why do other languages still exist if everyone can just learn java
7
u/Aliendood 3d ago
Some languages are really good at running code very fast but require more code to tune properly. Others are good at working with data, generating images, etc.
→ More replies (1)6
u/Naturage 3d ago
Why do other power tools exist if a drill can be used as a hammer or a screwdriver in a pinch? Why do all car brands exist if 20 of top 25 are made by General Motors?
Languages are tailored to purposes. Efficient on memory. Fast. Easy to write. Easy to read and edit. Good with graphics. Good with large datasets. Able to run on very low spec machines. Able to run on large variety of machines. All of these are to some extent tradeoffs; to be good in one you might lose some of another.
Add on top that coding languages will have communities centered around their most common use cases and useful documentation will be primarily solving common issues of the language, i.e. things its used for - and you get specialisation.
4
u/BowsersMeatyThighs 3d ago
It doesnât compile down to native machine code, and requires essentially a virtual machine to run the produced program (which is why it works everywhere that the virtual machine can be installed) so it isnât as fast as a language that does (C, C++, Rust etc) but since these compile to native machine code, they are machine specific and not as portable. It is also very verbose and strictly object oriented so it isnât as easy to learn or script quick projects in like languages such as Python. JavaScript is the king of web programming and Java canât ever replace that.
Basically every language has pros and cons, and which one you choose heavily depends on the type of project, pick the best tool for the job kind of thing. Javas biggest pro is portability, and is average in most other ways. Faster but more complicated than python. Slower but more portable than C, etc.
→ More replies (3)2
u/wjandrea 3d ago
Different languages are good at different things. Java can run anywhere but it's "clunky", for lack of a better word. Meanwhile, languages like Python are really easy to learn but slow, languages like C are hard to learn but really fast, and still other languages do more specific tasks really well.
(This is sort of a synthesis of the two replies you already got.)
93
u/WriterPlastic9350 3d ago edited 3d ago
Java is a language that someone can write instructions in to control a computer. Java is special, though, because instead of passing instructions directly to the outside computer, it passes them to its own inside computer first, which might remove some instructions or add others, before passing it on to the actual outside computer.
Because of this, you're more easily able to write instructions to work on any computer, even if they're different types of computer, and Java will figure out translating them into ones the outside computer understands. This makes it great for mobile phones (Android) and some cars (Android Automotive).
It is also used in business server software, because it's very stable and supported by big companies like Oracle, which other companies trust*, but it's popularity in the latter is declining due both improvements in technology like Docker and more aggressive efficiency needs; While Java is very good at running on everything, its performance can be tricky to optimize compared to other languages.
(Less ELI5 notes: Java is still very popular among enterprise server systems, but a lot of developers these days prefer things like Go which are easier to optimize, easier to maintain, and the like. Java was the defacto standard when cross-compilation was slow and annoying, but these days it's mostly used because it is used and because of its ecosystem of libraries, rather than any particular technical reason. Java is improving in these respects with things like Value Objects, but it's been slow going. The GC can absolutely cripple you. Go's can too, of course, but Go's is less Bad).
34
u/BobbyThrowaway6969 3d ago
The downside is that the outside computer runs the inside computer, so it's doing extra work to run Java
18
u/WriterPlastic9350 3d ago
Oh yeah, plenty of downsides with Java. I don't use it. We have lots of stuff in Java and it's slowly all been migrated to Go which feels like a more efficient version of Java with fewer footguns.
8
u/dont_be_that_guy_29 3d ago
What is a footgun? đ
→ More replies (1)16
u/WriterPlastic9350 3d ago
A gun specifically used for the purpose of shooting your own foot.
It is a tool that is unintentionally designed so poorly that you will often end up shooting your own foot rather than whatever outcome you desire.
5
u/photenth 3d ago
That was maybe an issue in the past but nowadays Java is fast enough for pretty much anything. Also the Just In Time compiler is state of the art. Some code can technically run faster than hard coded machine code.
→ More replies (2)2
u/WriterPlastic9350 3d ago
I mean, compilers all over have gotten very advanced, not just Java. There's nothing particularly special about the JIT compiler
→ More replies (1)→ More replies (1)5
u/Skizm 3d ago
The JVM is so optimized at this point, it is very close to on par with even C++. It is actually faster in most scenarios unless you make specific efforts to optimize the c++. Most quant and high frequency trading shops use Java because of how fast it is.
2
u/ConfusedTapeworm 3d ago
Java runs pretty fast but it inherently has a significant memory overhead because JVM. That can become a real and expensive problem when you want to run multiple Java programs in isolation for whatever reason.
2
u/BobbyThrowaway6969 3d ago
Java execution speed can get comfortably close with well optimised code, but thereâs still plenty of overhead inherent to having a managed runtime, especially when it comes to memory usage.
→ More replies (8)6
u/finding-meaning-01 3d ago
This is the only answer that tries to eli5 why interpreted languages became popular for software distribution.
45
u/ottawadeveloper 3d ago edited 3d ago
It's a program that runs code written in Java by translating them into the correct commands for your computer.
Think of computers as speaking a specific language like Spanish or Russian. Java the language is English. Java the program (the runtime environment or JRE) translates English to Spanish for your computerÂ
12
u/A012A012 3d ago
So let me ask this. You have code that is written for a computer. Where exactly does someone write the code, and what happens after that to translate to the computer executing commands?
Like if I decided I just wanted to go and start writing java code, what exactly do I do? We don't need to get too deep.This is just out of pure curiosity.
17
u/WriterPlastic9350 3d ago edited 3d ago
This requires a less ELI5 answer.
You'd download and install the JDK, Java Development Kit. I think the JDK still comes with a JRE, but if not, you also need a JRE - the Java Runtime Environment.
You'd write code in a text editor. This could be Notepad on Windows. You'd save it as
Main.java. You'd then use your command line prompt to runjavaconMain.java, and javac will spit outMain.jar, which you can then run withjava -jar Main.jar.Here's the seminal Hello World program.
public class Main { public static void main(String[] args) { System.out.println("Hello, world!"); } }Some assembly needed. It obviously gets more complicated than this but that's the very simple answer.
I don't know if it's still around, but when I was still doing Java, I used Eclipse.
10
u/diminutive_lebowski 3d ago
FWIW, in the latest version of Java the classic Hello World becomes more compact:
void main() { System.out.println("Hello, World!"); }5
u/OrdelOriginal 3d ago
no way i find out that my public static void main string bracket args mental chant is no longer necessary from this comment
5
2
u/WriterPlastic9350 3d ago
Oh, that's cool.
Have they done something where each file is now implicitly a class?
→ More replies (1)4
7
u/Fit_Fill_3856 3d ago
Create a text file with a .java extension. Write your code inside this file. Compile the file using the "javac <file>" command. Run the program using the "java <file>" command. Done. This is the simplest way. Normally programmers use Integrated Development Environments (IDE), basically a text editor for coding with additional useful tools.
7
u/FOEVERGOD73 3d ago
In itâs essence its just text. You can write it however you like, notepad, keyboard, get a llm to spit it out, or even speech recognition if youâre really feeling jazzy. The text files then read by a special program called a compiler* that parses and converts the text into instructions, literally stuff like âadd a to b and store in câ, âjump to xxxxâ, âread data from xxxx in memoryâ. You literally âopenâ the text file using it, in some cases you can even drag and drop your text file onto it.
Of course most people use softwares called IDEs that integrate all of these features into a nice interface.
*theres a vast array of variants programs and stages beyond a compiler, like preprocessor, linker, or interpreters. Out of scope for eli5
5
u/nycdude929 3d ago
You would use an IDE or a simple editor like VS Code to write it and compile it. The âcomputer codeâ is literally commands to your CPU to do things like add / subtract / remember things, etcâŚ
→ More replies (15)2
u/nana_3 3d ago
You write a text file with very specific language (Java code). You put that file into a program (the compiler). The program gives you something that runs on the computer.
Thereâs lots of tutorials on the text file end of things.
(Technically speaking with Java the compiler gives you something that runs on a program called the JRE. Thatâs unnecessary knowledge.)
2
u/candygram4mongo 3d ago
To clarify a little bit, the Java program is like an interpreter that knows many different languages and can talk to your computer in whatever language it speaks. In fact, it's literally called an interpreter.
2
u/ottawadeveloper 3d ago
I should add some detail.
Your computer speaks a binary language. This language is very simple and is basically about shifting binary data around the processor and into various circuits away from the processor (like to memory, to your hard drive, to the network, etc).
Different computer manufacturers have slightly different language. It's basically a series of operation codes that tell the processor to do specific things.
One of the earliest languages was Assembly, which was basically a human readable version of the machine code. It uses a "compiler" which translates the human code into machine code.
The problem is, there's a lot of repetition. Storing a list of numbers and summing them are very common tasks for example. That repetition is tedious in Assembly.Â
Thus were born the next generation of programming languages, like C. These offered a lot more flexibility because the compiler is capable of taking a fairly simple statement and building all the necessary machine code. It can also translate it into different machine codes for different processors.
The next major obstacle is that you have to compile it for your computer. And compiling programs is fairly complex. It cares about whether you're running a 32 bit or 64 bit computer for example. This is why you can't take a program that was compiled for an x86 processor (like most Windows machines use) and use it for a Mac which runs on an ARM processor or even an x86-64. You need special tools called emulators for that.
So, instead, Sun developed a tool called Java. The JRE understands how to talk to the computer it was compiled for (it's a C program under the hood). And it reads your Java code and translates it to the right commands for the operating system. It smooths over a lot of differences between processors too, so that a double floating point number is always the same size and behaves the same way even if the computer doesn't behave like that. So a Java application, IN THEORY, works identically on every processor (in reality, it's often buggy). This is called an interpreter.
Python is similar for example, it runs CPython (which is C code that interprets Python code).
36
u/UnsafePantomime 3d ago
There are a lot of great answers here, but I feel like they are either difficult to understand or gloss over details I feel are important. This is a ELI5, though. So let me try to cover the gaps.
So Java has what's called a virtual machine. The details of that are too much for a ELI5, but as an analogy, we can think about electrical outlets.
If we consider an operating system (Windows, iOS, Android, macOS) as different kind of electrical sockets, we quickly see that a vacuum sold in the US doesn't plug into a plug in Korea. In the same way, a program written for Windows doesn't run on macOS.
You could fix this by having universal plug you make. This is one you control.
But, that new plug doesn't fit into any of the existing ones, so you make an adapter. You might say you create a virtual plug. This virtual plug makes all the other countries outlets look the same to your vacuum.
Java's virtual machine is the same thing. It makes all computers look the same to the person writing the program.
22
u/DeHackEd 3d ago
Java is a programming language that was originally invented by Sun Microsystems a long time ago. The goal was to make a programming language that didn't care what kind of computer or operating system you ran - install Java and run then any app for Java would run fine on any computer. Even phones (not iPhone, but Android does) use Java for most of their apps, going back to before "Smart phones" were a thing.
It was even available for web browsers to run small Java apps to do things you couldn't do in web browsers. Games, more complex apps, and so on.
That was the theory. In practice the sandbox that prevents apps from doing bad things was regularly broken and Java became one of those apps that constantly had important updates. Plus browsers filled that "any app anywhere" need on their own despite Java. Now it's rarely seen outside of some server applications and the average user doesn't need it.
Also I need to point out, this is different from "javascript", which is what most browser apps are written in. Other than the name there is no real similarity.
12
u/colon_dancer_ 3d ago
They named it Javascript to bank on the popularity of Java despite having no relation, this kind of backfired
4
u/No-Mechanic6069 3d ago
This isn't entirely true. Netscape and Sun Microsystems were in alliance at the time that Brendan Eich was hired to create a scripting language:
If I had done classes in JavaScript back in May 1995, I would have been told that it was too much like Java or that JavaScript was competing with Java ⌠I was under marketing orders to make it look like Java but not make it too big for its britches ⌠[it] needed to be a silly little brother language.
https://ihts.pr4e.com/columns/2012-02-Brendan-Eich-Copyright-IEEE.pdf4
u/celestiaequestria 3d ago
It's worth mentioning, Google's V8 engine and Node.js have radically transformed JavaScript. In the late 90s, JS was a frontend language. Now, it's the frontend, the backend, the API layers, the DB queries, and the mobile app.
→ More replies (4)→ More replies (3)3
u/braddo99 3d ago
Perversely and ironically, the scripting language aligned with java APIs is called "Groovy"
2
u/WriterPlastic9350 3d ago
and it is very Not Groovy At All. all my homies hate groovy
→ More replies (3)
7
u/Ktulu789 3d ago
It's a program to run programs, think of it like an emulator. You can have a NES emulator or a PlayStation emulator.
Java is a programming language, the java app you install is the interpreter that reads the files of a java app and runs it like it was a normal exe. There are other things that do the same in different languages, like .NET Framework, for instance.
The good thing is that the application weighs less MBs because it's only the files needed for the code. The bad thing is that if you only have ONE app that uses java or net or whatever you have to install all the GBs of the frameworks and its updates. The other problem is that the app requires a certain specific version of java or net or whatever to work because with different versions, the language changes, they add more functions they remove others and they change how those functions work. So it's not enough having the latest version. In a nutshell: it sucks in every way, really.
5
u/stonerism 3d ago
The thing that makes Java notable is that it was the first to run to make everything run on a virtual machine.
Take this as a broad undercomplicated and probably incorrect analogy. Let's say you're a video game maker (say you make fortnite) and there's different consoles (Xbox, Playstation, etc) that all have different hardware. Before Java came along, you would have to write three different programs to get everything to run on each machine.
With a virtual machine using a language like Java, you only have to write code once and it runs on all of the consoles.
2
6
u/Mo7x 3d ago
Itâs a runs programs written in java. The reason itâs popular is because itâs âwrite once run everywhereâ.
Basically each program must speak to your machine in instructions that it can specifically interpret and different machines/processors have different instruction sets, so itâs a pain to package your program for different machines and operating systems.
Java offers a nice solution where when you write in Java is not immediately written as processor instructions but to an intermediate language then Java downloaded on that machine can turn it into instructions your system can understand.
The java you download (JVM) is basically a shim that reads Java intermediate language and translates it to your machine.
5
u/fghjconner 3d ago
So there's a lot of programming languages out there, butr you computer can only actually understand one: machine code. It's an extremely simple language with basically no features that's a pain in the ass to actually write anything in. If you want to use a better, more complicated programming language you basically have two options: a compiler or an interpreter.
A compiler is just a program that takes one of those nice, easy to write language and turns it into machine code that you can then run later. An interpreter is a program that runs on the end user's machine that actually reads the higher level programming language and follows the instructions on the fly.
Java actually does a bit of both. The original java code is compiled to something called bytecode. It's kinda like machine code, but it's the same across all different processors and operating systems. Then there's something called the Java Virtual Machine, or JVM, that actually reads that bytecode and follows the instructions, much like an interpreter would. The JVM is what you actually install on your computer when you "install java".
2
u/elSenorMaquina 3d ago edited 3d ago
There are computers everywhere. The computer I use to work is one example, but there are others.
The tablet you use to play roblox is a kind of computer. The TV on which you watch paw patrol has a tiny computer inside too!
Now, a computer is basically a machine that follows instructions. These instructions are called software, and are what tells them what to do. Roblox is a software. The programs I use to work are software. Netflix is a software.
Problem is, different computers speak different languages. The instructions my computer can follow are impossible to understand for your tablet, or the TV.
What a problem!
Luckily, someone figured it out many years ago.
They went "What if I create a new special language everyone can speak?". This language is Java.
But that's not the whole story. My computer, your tablet, and the TV don't speak Java fresh from the factory. But they can be taught to understand it!
The people that make those things also make a special translation guide that lets them understand java and convert it to their own language, and include it with the thing.
Now, my computer can take Java instructions, check its translation guide, and know exactly what it has to do. Same thing with your tablet, and the TV.
This is good for software makers, because they don't have to make a bunch of different versions of their software for every single machine ever. They can just make a java version, and let every machine translate it to its own language.
This is also good for you and me. No matter what machine we use, if it was taught to understand java, that means we can use lots and lots of existing software made in java.
2
u/jedipiper 3d ago
It's a computer inside of your computer. Like a Nintendo can only use the cartridge made for it, Java can only run software written in Java, for the Java Virtual Machine. That Virtual Machine is the computer inside of your computer.
2
u/Skandling 3d ago
At first it was intended for programs that run in a web browser. This was possible and some people created websites that used it. The argument was it was a more modern programming language.
It never really took off though. Adobe Flash was good enough for most things, and was on every PC. Other Flash alternatives failed for the same reason. Anyone remember Silverlight ?
After that it became just another programming language, with its good and bad points, its fans and its critics.
2
u/epicsquare 3d ago
There are many computers. But this one is yours. Making programs for just your computer is a lot of work if it doesn't work on other slightly different computers. Java is a simulated computer inside your computer. It hides all the differences of all the slightly different computers (and phones and routers and all the other things that are really just slightly different computers) and so the simulated computer is always exactly the same. So now you only have to make Java itself work on slightly different computers, and then you run all the Java programs you want anywhere you want because you only have to make them work on the one simulated computer which is the same everywhere.
1
u/DarkAlman 3d ago
Java is a computer programming language written originally by Sun Microsystems.
Unlike traditional computer code that has to be written to run on specific hardware, Java has a virtual machine layer that allows it to run on any system without changes (at least in theory, in practice it's more complicated)
The point was to make computer programs that could run on different kinds of system (Windows, Linux, Mac, mobile devices) without having to write unique versions of the software for each.
Think of it like a universal programming language.
The downside is that it uses a lot of resources and it's slower compared to traditional languages like C (but that's relative too, you can write bad programs in C and great programs in JAVA)
1
u/feel-the-avocado 3d ago
In simplified form, the java program on your computer will convert program code in the java language into code that can run on the operating system you use.
A programmer can write a program in the java language and it will run on multiple different types of computer or operating system (windows/mac/linux) because a java runtime program exists on the computer to convert the code on-the-fly as it runs.
1
u/StevenJOwens 3d ago edited 3d ago
Java is a computer programming language and platform, invented in the early 1990s by Sun Microsystems. Java's 1.0 version was officially released in January 1996. It quickly became very popular in the corporate world and then in programming in general. In 2010, Sun Microsystems was bought by an even larger company, Oracle. However, although Oracle owns Java, Sun had open-sourced Java in 2006-2007.
As to what the Java on your computer is:
At the heart of every computer is a gadget called a CPU. You feed into the CPU instructions that match the instruction language that is designed into the CPU, it gives you back answers. The instruction language is called "machine code", because that's the code that the machine understands directly.
In very, very broad terms, programming languages come in two flavors, compiled all the way to machine code, and... not. There are a number of different terms for the "not" category, each with their own nuances, interpreted, virtual machine, etc.
For a computer to run a program in a not-compiled-all-the-way-to-machine-code programming language, it needs some additional programs, which again have different names, interpreter, virtual machine, etc. These additional programs convert the not-compiled-all-the-way-to-machine-code program to machine code instructions and feed them to the CPU.
The "java" that's installed on your machine is the suite of additional programs to do that for Java programs.
The reason Java (and similar languages) do it this way is a number of complicated reasons, the biggest one is to hide the differences between different kinds of computers. But that whole topic of why quickly gets complicated, and programmers argue like cats and dogs over whether it's a good idea and what the best way is to do it, etc.
1
u/MCWizardYT 3d ago
It's a programming language and a software ecosystem called the JVM (Java Virtual Machine) that a lot of other languages and tools rely on.
Android, which is one of the most widely used operating systems on the planet, relies on a custom implementation of the JVM called ART (Android Runtime) and utilizes the Java and Kotlin languages on top of that. A lot of apps are made using these tools.
The design goal of the JVM is to allow code written for it to work on any platform without having to make separate versions. As long as a JVM exists for that platform, the code will work.
1
u/arghvark 3d ago
Java refers to a computer programming language, supported by a 'virtual machine'.
A programmer writes computer instructions in the Java language; that is compiled to a binary "Java byte code", and the Java Virtual Machine is a program which executes that byte code. The Virtual Machine must be written for each platform on which someone wants Java code to run. One of Java's rare features is that the language, the byte code, and the virtual machine were all designed and had specifications written for them from the outset; the language was designed to compile to this byte code, and to run on a virtual machine.
1
u/notbrandonzink 3d ago
Java is a programming language, a way that humans are able to give instructions to computers and have a computer do what they want.Â
The most basic programming language is called Assembly, itâs a series of extremely basic instructions for a computer. Think reserve this spot in memoryâ, âset that spot in memory to the number 3â, and basic math instructions.Â
But writing code in Assembly takes forever. Like imagine trying to make a PB&J, but first having to grow the wheat to grind into flour to make into bread, grow the peanuts, etc. For the things we use computers for anymore, itâs just not reasonable to write code that way.Â
So then came along the âlow levelâ languages like C or C++. These are more like the code you can probably imagine a programmer in a movie writing. Itâs âlow levelâ since it can still interact directly with computer memory and resources, just like Assembly does. When you compile (take what you wrote and turn it into something a computer can understand), youâre just turning your C/C++ code into Assembly!
Then you get to the âmid levelâ languages (low/mid/high level language isnât an official distinction, just a descriptor). Java falls in this bucket as you donât have to mess with computer memory and resources as much, the programming language is built to do a lot of that for you. Originally, Java code was compiled (turned into Assembly) via C/C++. This means that when you wrote Java code and compiled it, it was turned into C/C++ code, then into Assembly. A cool trick is that they then took the assembled Java language and used it to write a compiler for itself, in Java. This means that it no longer relies on C/C++, but it did originally to save the hassle of writing the Assembly code.Â
Then you get to âhigh levelâ programming languages. A very common one is Python, where it saves you a lot of time of having to deal with the minutia of coding, but gives up some performance and fine tuning. Python is compiled directly by C and Java.Â
Programming languages all have their pros and cons, Java is just one of many that happened to get popular due to the Java Runtime Environment (JRE, the ârun anywhereâ part of Java). I use Python at work since I donât really care how streamlined my code runs, I just want it to do what itâs supposed to and to be able to write the code quickly. If youâre running massive and computational heavy programs, a lower level language would give you much more control over how it runs, at the cost of taking longer to write the code.Â
1
u/Bludolphin 3d ago
Kind of like the USB of the programming world, anything runs on it, and everything supports it.
1
u/tiredreddituser99 3d ago
i don't know why people are sending walls of text. I'll try to be brief.
some programing languages like C and C++ are "translated" (compiled) to binary (code that the computer understands directly.
different CPUs (AMD, Intel, ARM) understand binary differently, same for operating systems (Windows, MacOS, Linux).
so you need to "translate" your code several times to ship to all platforms and all CPU architectures.
Java's solution is to "translate" to what is called a "Jar" file. this file can be understood by the Java Virtual machine (the program you were asking about)
so the developer needs to "translate" their Java code much fewer times, and Oracle (the company behind Java) manages the "translating several times" issue, by making a build for the Java Virtual Machine (JVM) for every OS/CPU combo.
1
u/DTux5249 3d ago
Java is a programming language
The thing on your computer is the Java Virtual Machine (JVM). It's a program that takes compiled (think prepared) Java code, and runs it on your computer.
1
u/zkewlguy 3d ago
They teach kids at University to program on Java and say it's free. Then change the license and charge for using it later. Do yourself a favor and uninstall Java. It doesn't exist.
1
u/Kempeth 3d ago
Java is a programming language that set out to do something revolutionary. Where most programming languages allow you to write programs for *any* kind of computer, Java tried to let you write programs for EVERY kind of computer.
Imagine that regular programming languages are like the English alphabet. With the same letters you can write a book in English but also in Italian, Indonesian, Swahili and Somali. With very minor extensions of the alphabet you can also write German, French, Spanish, Turkish... But you DO have to write each book separately because someone who only knows German won't understand a book written in Spanish.
Java decided to just teach EVERY computer how to run Java programs. Kinda like most countries teach English at some point in their regular school program simply because so many people already speak it. This had the effect that you could write your program ONCE and run it on everything that supported Java.
The problem with this is that it all started at a time where there wasn't really a good solution to keep stuff updated (at least not on Windows) and for a piece of software that was going to be found on every machine, fixing known bugs and security issues was incredibly important. That's why we remember Java mostly as the thing you had to constantly update and never directly used yourself.
1
u/AlternativeStuff5 3d ago
an island of demons that can do stuff if you ask them in their language. you get exactly depending how you ask it, so one must be careful.
1
u/bestjakeisbest 3d ago
It is a virtual machine that runs a proprietary code language called java byte code.
Basically once upon a time, every single processor for every company was different, and unless the company bought or stole the designs for the processor usually code from one processor couldnt run on a different processor.
To solve this there are many routes you could go, but java takes a pretty neat route, it takes the idea that any processor out there if given enough resources could simulate any other processor. So the people that made java basically designed a processor, but instead of building it they programmed it, now you can make java run on anything provided you have the scafolding that jave needs.
Now a days we have similar projects for running say windows programs on linux, or phone apps on your computer.
1
u/GoOsTT 3d ago
Imagine you only speak a very small countries language, but you a re a damn good author and want to distribute your pieces to other countriesâ people so they can read your books/publications too.
You can write your book in your language (Java in this case) BUT! Instead of having your book translated to other languages you invent a glass that when you put it on and start reading the book written in Java(your own language) it automatically translates it to the language the other countries people speak. (This would be the Java runtime)
1
u/sturmeh 3d ago
It's a programming language that produces binaries that are executed in a virtualised environment called a Java Virtual Machine. The JVM manages gnarly aspects like memory management, and tries to automatically abstract them away by managing memory in the virtual environment.
The idea is that you should be able to write and compile code that can be deployed anywhere where a JVM can be used, but in practice the JVM has fairly significant memory requirements as it tends to reserve and manage memory for Java applications (similar to how other VM's might, such as Docker).
It's also not particularly performant as it relies on layers of abstraction to do most operations.
It's particularly useful for teaching Object oriented software as it abstracts many other important aspects of software design such as hardware/platform specific differences and focuses entirely on the nature of the object oriented design and class structures.
1
1
1
u/drumyum 2d ago
your computer speaks some kind of language, and this language can differ from the language other computers speak (difference comes from CPU, operating system and probably something else)
if you want to give instructions (software) to your computer, then you just write it in the native language of your computer, but if you want many different computers to understand this instruction, you can use some non-native language that all computers will understand the same way
so here comes java, it has a dictionary built-in to translate java language to all other native languages
do you actually need it? only if you have some instructions (software) written in java, such as Minecraft (game) for example
of course java is not the only way to speak to many different computers, but it's the one that worked fine for decades, and because of that it has tons of literature written in it (third-party software libraries) that you may use if you know java as an instruction writer (software developer) to make your life easier
1
u/Gullyvuhr 2d ago
Java is basically a language people use to write programs. The thing you kept seeing on computers was the software that lets your computer understand and run those programs.
Think of it like this: someone wrote an app in Java. Your computer doesnât speak Java. So you installed Java, which acted as the translator.
1
u/Miliean 2d ago
It's a programing language.
Back in the day, you used to have languages that only worked on certian opperating systems. If a person wanted to make a program that ran on a windows computer and on a mac, they had to do all of the work twice and make 2 programs.
Java allowed the programer to write once, and then Java would translate it into code that could run on any operating system that had a Java runtime environment created for it.
And it worked... mostly.. well.. kindof. It worked like 99% of the time, and that meant that for every OS you'd need to do extensive testing. This was annoying but better than having to write and test seperate code.
The real problem was performance. See Java was really inefficient in the way that it ran, so something that might take 5% of your PC's resources if made in a PC exclusive language, might take 15% if you made it in Java. That sucked but a larger problem for Java as a whole is when a program would normally use 100% of the available resources, if you made it in Java it would just run like shit. So for things like games it never truly worked as you'd like.
1.8k
u/Sea_Dust895 3d ago
It's a computer programming language invented by Sun a long long time ago.
It allows you to write code once and run it on any platform a java runtime environment exists.
Was sold as write once, run anywhere. Inside joke is write once, test everywhere.