Java on the hardware level, the differences from C++?

Good day!

Recently started to learn Java with the book "Java 8. Guide for beginners | Shildt Herbert", it says, and I quote:

The Java language was conceived in 1991 by employees of Sun Microsystems by James Gosling, Patrick Naughton, Chris Worth, ed Frank and Mike Sheridan. It was originally called Oak, but in 1995, when his progress
market usages marketers, it was renamed Java. Surprisingly, on
first, the developers of the language did not set ourselves the task of developing Internet applications. Their goal of biiju create a platform-independent language,
which it would be possible to write embedded software for various
household equipment with microprocessor control, including toasters, microwave ovens and remote controls. As a rule, devices of this type are used controllers based on microprocessors with different architectures and executable code generated by the compilers of most of the existing
at that time, programming languages were focused on certain types of processors. A characteristic example can serve as the C++ language.


The creation of a C++ compiler that is executable code would generate byte-code, it is possible, but the C++ language has several properties,
preventing its use for development of Internet applications.
The most important of these is the support of pointers. A pointer contains
address of some object in memory. Using pointers
you can access resources outside the program that creates gaps in
security system. In Java pointers are not supported, and hence
there are no complications with safety.


Here I had the following questions:
1. If Java is simply not able addresses to addresses of memory, how it might be applied or used in "hardware"?
2. What niche is and where is it used Java for applications on the Internet, if in this niche, have well established PHP, Javascript, and third party programs(Redis, Node.js, Sphinx, etc.) written in C/C++ that is also used for the construction of HighLoad applications?
April 19th 20 at 12:13
2 answers
April 19th 20 at 12:15
Solution
The authors hoped that the hardware can be accessed using abstractions - the manufacturer of iron from itself implements the java machine, and on top of it you can run application code.

You forget about the big layer of the history of technology, which was much before that - the 8-bit home computers (dozens of them) and the programming language basic.

So, computers of that time were dramatically different - different media (tapes, diskettes, cartridges), different equipment (stick another CPU in the drive? Yes nivapros! different speed for PAL and NTSC versions - easy!). But basic was everywhere allowed, with some alterations, to carry programs from machine to machine.

Thus, the authors were in this historical context (they all grew up in the arms of some VIC-20). There is becoming a logical desire to do the same thing, only better - take a modern language, standartiniam syntax and do likewise - manufacturer of iron gives us the Java machine with the right level of abstraction - and all programs running from architecture to architecture without alterations.

Partly, it worked on older gamers, in the era of j2me is Java just stuck in phone - games, browsers, maps (there was even Indexcard), reading room, cutilce - a whole bunch.

Another stage of evolution that you probably didn't find - (the chord, I'm old, I'm very old) - attempts to create interactive web pages.
"We also have portable Java everywhere - let's vlupit her support in the browser in the form of applets - small applications." Then abruptly activated the virus writers and other riff-raff - thanks branchy and leaky architecture, applets can do every game.

Now the applet in java can be found in any old iron, on it there is a GUI for remote administration of servers, switches and storage. You browser visit a piece of metal, and then you throws out a heap of warnings that will now be running some terrible leaky ON, keep the pants, and then fly off. Sure? Sure? And I agree with this? And so?

And then began to actively use JavaScript, mainly by inventing Ajax - continuing fiercely to pull the owl (the system for creating digital libraries for scientists/HTML) to the globe (the task of creating a interactive GUI with a nice layout).

Are you still back at Perle did not refractorily
Then the following questions arise from your answers:

1. Is Java a full replacement for C/C++ in terms of productivity and flexibility, ie is it possible to use Java in "custom iron Assembly" and that it's not inferior to the performance?
1.1. For example you need to write a program for a device with its own unique processor architecture, it is necessary to write your own compiler in Assembly language? - alysa66 commented on April 19th 20 at 12:18
@alysa66, 1.1. so, only the JVM is not a compiler and interpreter! If you have a unique device, will you please provide the JVM for him. And will the JVM will given where to work. Naturally, the performance of the code written directly in assembler, will potentially be higher. But then sacrifice speed for portability of code. - Ida_Thomps commented on April 19th 20 at 12:21
April 19th 20 at 12:17
Solution
I'll try to answer:

1. The lack of pointers in java does not mean that it can't work with memory. This was done to increase security, and wrote about Child. That is, to you, for example, did not go beyond the array size in the process of the program. Child, by the way, writes about pointers about how potential security breach, and not as the inability to work with memory in General: "using pointers to access resources outside the programthat creates gaps in the security system."

2. Java is a niche for the development of enterprise solutions. In particular for the banking sector. If you have, for example, simply an Internet store, it is best to use php, js, to make it faster and easier.
Then the following questions arise from your answers:

1. Is Java a full replacement for C/C++ in terms of productivity and flexibility, ie is it possible to use Java in "custom iron Assembly" and that it's not inferior to the performance?
1.1. For example you need to write a program for a device with its own unique processor architecture, it is necessary to write your own compiler in Assembly language? - alysa66 commented on April 19th 20 at 12:20
@alysa66, if you want to write a program for a device with its own unique CPU architecture, the required performance, then you more suitable C/C++. - Cole.Sta commented on April 19th 20 at 12:23
@Cole.StaCan be more about the distinction between C/C++ and Java? - alysa66 commented on April 19th 20 at 12:26
@alysa66, language C provides more opportunities to work with memory than java. Language more efficient than java. Programming for different architectures is usually done in C. the jvm Itself is written in C. simply put, going back to your original question, for pieces of iron choice C is virtually uncontested and rarely where you will meet other reviews. If you want more detail about the differences, you can start with these sources:
  1. Times
  2. Two
  3. Three
- Cole.Sta commented on April 19th 20 at 12:29

Find more questions by tags C++Java