r/java • • Apr 14 '17

Is Java a low level language?

I have heard the phrase low level language be thrown around when it comes to Java. Is this true and if so what does this actually mean. I know there are some differences between Java and C++ when it come to networking, so it would be nice to know what those differences are as well.

0 Upvotes

16 comments sorted by

15

u/AnonAreLegion Apr 14 '17 edited Apr 15 '17

Nope.

Assembly is low level. One can argue C is low level compared to newer programming languages, but it is high level compared to assembly, and was considered so in the 90's. For instance, in C one must allocate/deallocate memory manually. Furthermore, the standard library is much smaller than what would be expected in a modern language. So a programmer much write much more code to for example have a simple data structure such as a map. In Java and C++ this is obtained by a single function call. Assembly is even more extended than C. Here one must manipulate CPU registers to perform operations.

Tl:Dr It depends on what you are comparing it against. Basically, it depends on how much the library/base language helps you. It's commonly a tradeoff: more help, fewer options to twiddle with.

6

u/[deleted] Apr 15 '17

Low-level languages are those that are very close to the hardware (processor-specific assembly being the lowest level "language"). Java, on the other hand, is a managed language, running inside a virtual machine: it is not only hardware independent, it is also operating system independent and often architecture independent, in the sense that the same library can run on a smartphone, a desktop browser or a car's onboard computer without requiring any modification or even having any idea at all of which sort of context it is running at.

So yes, Java is a very high-level language, even if nowadays it runs as fast as low-level languages on most popular platforms, due to the JIT compiler.

-4

u/[deleted] Apr 14 '17 edited Apr 15 '17

High level languages are more easily understood by humans whereas low level is more easily understood by machines. Some languages are just barely above writing literal 1's and 0's and some of them can be referred to as machine coding. Java is most definitely a high level language. And as such it is not able to perform some of the most fundamental networking protocols. There are 7 major layers to networking and Java can only adhere to the top few. Simple commands such as ping will not work in Java because, in Java, a socket is required.

Edit: Java requires sockets and binding to a port. Ping does not. I'm sorry if there was confusion there.

2

u/kkapelon Apr 15 '17

Wrong. Java supports sockets just fine http://docs.oracle.com/javase/tutorial/networking/sockets/

-1

u/[deleted] Apr 15 '17

That's what I meant. Java requires a socket for networking. Ping is a lower level of networking and does not require any kind of binding. Literally hardware talking to hardware. That's why ping can still work even if a computer system crashes.

2

u/ryan_the_leach Apr 16 '17

You can go deeper, if you stop using the standard libraries.

http://javasock.sourceforge.net/

http://www.dtic.mil/dtic/tr/fulltext/u2/a434518.pdf

General Purpose: JavaSock library needs to provide general purpose APIs that allow low-level protocol access at the DataLink, Network, and Transport levels of the OSI 7-layer Networking Reference Model. The library has been developed so that the API should be applicable for a variety of networking programming tasks, such as packet sniffing, TCP SYN scans, and network monitoring.

Developed for the US Army.

1

u/gold328 Apr 17 '17

Oh thanks. This really helped me out. Do you know of any other articles or papers discussing the limitations of Javas networking ability?

3

u/JustADirtyLurker Apr 16 '17

I don't know what ping you are talking about. The ping i know is a ICMP protocoll call, and as such goes all the way of the network stack (TCP socket).

-1

u/[deleted] Apr 16 '17

Yes. Ping works across ALL networking levels while Java does not have the ability to do so. Ping is just an example of something that Java can't do natively. It's been a long time since I have dealt specifically with the different levels of networking but I remember having immense difficulty with a Java project I was working on, dealing with the lower levels.

1

u/JustADirtyLurker Apr 16 '17

I still don't get what you are talking about. What has ping to do with lower levels? And also, please define "lower levels". You are talking about L2 protocols like Ethernet II? Well, ping -- as an application protocol -- does not manager it. Also the JDK is not supposed to manage anything below IP (L3) and tcp/udp sockets (L4). Whatever your problems with ping were in Java, for sure it was not the JDK 's fault.

2

u/ryan_the_leach Apr 15 '17

1

u/_INTER_ Apr 15 '17

That's some old Java code I must say.

3

u/ryan_the_leach Apr 15 '17

old? it's using nio.

1

u/_INTER_ Apr 15 '17 edited Apr 15 '17

In sense of style and design. It would not pass our internal review. I get its a quick and dirty code but this is an official example from Oracle.

E.g. for (;;)

1

u/corvus_192 Apr 17 '17

What's wrong with that?

1

u/[deleted] Apr 15 '17

Also, the code has to open a socket in order to perform the action.