What is Pure Java [closed] - java

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 months ago.
Improve this question
I was invited to interview for Pure Java Developer
Please help me to understand what is Pure Java.
Can't find any information about it.

Pure Java code is code that "conforms to Java's ideal of universal portability"
It means code that does not rely on native features.
An aspect of Java is to be portable across different operating systems (write once, run anywhere). Writing code that can only be used on specific operating systems contradicts this.
Simply by googling "Pure Java", you can find resources on it, such as PDFs and other articles.

What does "pure Java" mean?
Well, you would need to ask the person who used the phrase1 to know what they meant. But when a seasoned Java professional hears the phrase, they are likely to think it refers to "100% Pure Java".
"100% Pure Java" was a pre-2000 Sun Microsystems initiative to promote the writing of portable Java code. There is even a "100% Pure Java Cookbook" that says how to do it.
What does the "100% pure" mean?
The Cookbook says it like this:
The 100% Pure Java™ Standard
The "100% Pure Java™ Standard" is part of Sun Microsystems initiative
to promote the development of portable applications, applets2, beans,
class libraries, and servlets written using the Java™ Programming
language. Compliance to the standard consists of code analysis and
testing the program on multiple Java Application Environments.
Basically, 100% pure Java is about portability. It means avoiding things like:
using native code libraries,
using external applications,
making platform and operating system specific assumptions; e.g. that "\n" is the line separator or "/" is the pathname separator,
and so on.
This does NOT mean "uses only Java SE or Java EE APIs", although:
using Java platform vendor's extensions to the standard APIs, or
using new platform features such as Java 8 streams, etc
both arguably work against Java platform independence. And Java has dropped certain features in more recent releases, which also affects portability and platform independence. (Try running an applet on a modern JVM ...)
1 - Lots of people are happy to borrow someone else's terminology and give a new meaning to it, then state their new meaning as the real meaning. In this case, my guess is that the person who invited you to the interview is a recruiter or manager who has minimal technical understanding. They may be saying "pure Java" because they think it will make the job more attractive to the right kind of prospects. Or maybe they are confusing "pure Java" with "core Java". Who knows ...
2- Ahem ... dead technology.

I would consider 'Pure Java' to be Core Java. The Classes, Interfaces and APIs that are referenced as part of the Javadoc for that particular JDK.
E.g. Oracle JDK 8 - https://docs.oracle.com/javase/8/docs/api/

Related

Why is an interpreted language considered more portable? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 months ago.
Improve this question
Java is often cited as being more portable than other, say compiled, languages as the executable can be run on any platform with a JVM. But code written in C can be run on any platform with a C compiler.
So, naively, there are two alternatives: make lots of different compilers for lots of different platforms and transfer source code over a network for say an applet, which is compiled client-side; or make lots of different virtual machines to run on lots of different platforms and transfer the same, executable program or applets over networks.
Why is the latter better? I can see how server-side compilation is desirable, but I feel there is more to it than this. I can appreciate that it was less work for Sun Microsystems to create JVMs for many platforms than compilers for many platforms, but this surely wasn't the major motivation.
But code written in C can be run on any platform with a C compiler.
Not in the same way. You either need to compile it on that machine with that specific compiler, or need a compiler that is capable of cross-compiling. Either way, you have a bigger workload.
Still, there is some C Code that is quite portable. A simple program that just calculates basic arithmetic is quite portable, even in C, if you are willing to compile it to different platforms.
The second big important difference is the platform. As soon as you do I/O or use syscalls, your code becomes platform-specific, just because you need to directly interface with the host system. An interpreted language offers a unified platform. If my programs runs on the JVM, it just runs on it, no matter which system is host to the JVM. If I use "native" calls to the host OS, I have to use the proper ones for each OS - but with Java, my "OS" is the JVM.
Btw, there is so called "portable" C/C++ code, but it also hinges on similar concepts as the JVM. If you use Qt and similar libraries that offer uniform APIs on multiple platforms, then you can create quite portable C/C++ programs.
The perhaps most authoritative answer to why Java was designed to be interpreted may be found in the whitepaper that announced the Java language back in 1995:
1.2.3 Architecture Neutral and Portable
Java technology is designed to support applications that will be deployed into heterogeneous network environments. In such environments, applications must be capable of executing on a variety of hardware architectures. Within this variety of hardware platforms, applications must execute atop a variety of operating systems and interoperate with multiple programming language interfaces. To accommodate the diversity of operating environments, the Java Compiler TM product generates bytecodes--an architecture neutral intermediate format designed to transport code efficiently to multiple hardware and software platforms. The interpreted nature of Java technology solves both the binary distribution problem and the version problem; the same Java programming language byte codes will run on any platform.
Architecture neutrality is just one part of a truly portable system. Java technology takes portability a stage further by being strict in its definition of the basic language. Java technology puts a stake in the ground and specifies the sizes of its basic data types and the behavior of its arithmetic operators. Your programs are the same on every platform--there are no data type incompatibilities across hardware and software architectures.
and
1.2.5 Interpreted, Threaded, and Dynamic
The Java interpreter can execute Java bytecodes directly on any machine to which the interpreter and run-time system have been ported. In an interpreted platform such as Java technology-based system, the link phase of a program is simple, incremental, and lightweight. You benefit from much faster development cycles--prototyping, experimentation, and rapid development are the normal case, versus the traditional heavyweight compile, link, and test cycles.
It is also worth mentioning that the Java API goes far beyond standard libraries for C or C++.
Note that this perspective is somewhat dated. While largely still accurate, a modern take on the trade-off between a priori and runtime compilation whould include the additional optimization oppurtunities afforded by execution time statistics, and probably avoid the use of the word "interpreted" altogether - at least if we are somewhat serious about performance.

JVM versus C++ compiler [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a query in which I cannot give a satisfactory answer. Java is notorious for its independence over machine architectures grace to JVM. I 've understood the following:
Different JVM implementations are sitting on different machines as to produce the appropriate output (different for any different architecture) from the same input(.class files).
Let's now consider C++. Why not to do the same with Java? Namely, implement different C++ compiler versions for different architectures, feed them with the same source and make every compiler produce the appropriate output; just make C++ compiler to mimic JVM!
This is my query since I cannot understand why Java is unique in that...
The C++ compiler already does that. The difference is that whereas class files are interpreted by the JVM, C++ applications aren't (usually) distributed as source files.
This of course also requires that you use standard libraries which are available for all the platforms. There's nothing very magical here. You have compiled languages such as C++, partially compiled like Java and interpreted such as Ruby.
As far as I know this is exactly what happens (as Kayaman said). You write one source, and compile it for different platforms, for example gcc/mingw or visual for Windows, gcc for Linux etc.
The difference between C/C++ and Java is that from C and C++ it is much easier to do direct system calls, to directly work with the filesystem, with sound devices etc. These system calls will differ for each system, which is what makes the code not portable. This means that portability for C++ code is the choice of the programmer.
Because if you do that you have Java. If C++ doesn't have a direct connection with the low level resources than lots of advantages of this language disappear. It's kind of the same thing with C++ and assembling language. Creating a more high-level language will have a negative effect on the control of the machine's resources.
Read this about Java: Java Architecture

Which are the advantages of developing in Java a server-side application compared to other languages? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
Our company is starting the development of a client-server application and a discussion is going on about which technologies should be used.
For the client (GUI) side we tend to QT and C++. For the server side, we have been advised to use Java and indeed it looks like it is one of the languages being used most for server development.
Can anyone elaborate on the advantages offered by Java for server side development and why adopting it should make our life as developers easier and/or allow us to reach better results than if we used, let´s say, .NET or even C++?
Thanks in advance.
Some advantages:
Run compiled code across platforms.
Managed memory (garbage collection).
Hude wealth of excellent open-source libaries.
Large developer market.
Easy migration for C++ developers.
Some disadvantages:
Aging language — has not kept up with language advances IMO (e.g. adding functional facilities).
Future uncertain after Oracle aquistion (will become clearer with time).
Low level programming difficult.
You may want to look also at other languages which run on the JVM, such as Scala and Groovy, at .NET (it can run on Linux et al using Mono) and even the D language, which provides a C++ like, compiled to native, language with modern features such as garbage collection (optional), code contracts, lambdas etc. These languages provide many of the benefits of Java over C/C++ but have also taken the progression a bit further or in different directions.
Apart from platform independence, the main advantage of server-side Java development is the wide selection of mature libraries and standardized frameworks. However, the main focus here is on web development.
For a C++ client, Java could still be beneficial if you use REST as protocol between client and server (JAX-RS is pretty nice). Otherwise, it depends very much on your application domain and whether there are Java libraries that could help you in that regard.
Let's put it this way... it's not which server-side language is better and what not, it is what's available in your company that you can leverage of and make good use of it. When you work in a big corporation, sometimes you cannot just introduce "yet another language"... it doesn't work that way. :)
Further, every language has its pros and cons. You can almost argue the pros/cons in both way depending on how biased or open-minded you are. You can choose RoR and all that bleeding age technologies, but if your team members are not comfortable in dealing a brand new language, how exactly are you going to maintain the project in long run? I mean, if your team is familiar with PHP, I don't see anything wrong using that compared to Java, .NET, etc.
Your customers don't care the underlying implementation as long as it works.
Java advantages:
- mature
- good to excellent backward compatibility
- wide range of available frameworks for almost any problem
- robust - garbage collection, APIs as java.util.concurrent
- great tools to manage code quality, good IDEs etc.
- very good performance
- support for scripting
disadvantages:
- sometimes too many frameworks for the same thing
- not all the frameworks have as good quality of code as you need
- looks easier than really it is
You have many options in server side. Since you have the control over server side you can basically use anything. Using .NET forces you to use Windows Server so i will prefer a framework that can run on any operating system and is portable.
Java was the right answer 5-10 years ago. Because it had portability, and can work on any system. But these days developers look for languages/frameworks that are easier to use, maintain and code. I will vote on Python these days for server side development because of this, its fast it easier to read and maintain code wise, and it has many open source projects/libraries that you can use, even Google is favoring python over Java(GAE had python support first, then support for Java came). You can use django on python for web development and twisted for writing a server that uses TCP to communicate.
There are several issues you need taken in accout to select the language:
which are the languages which know your team best / good enougth
which are the languages which know the team thet must maintain the server
are there the right frameworks with an quality that makes you want to use them
will the code be maintainable as long as the server is in production
how fast will be the development -- the importent thing here is not the time you spend to type the code - more important is the time that you need until the product works stable enougth to use it for production without reasonable bugs
communication with other systems - if every system you need to communicate with is an .net - that it would be wise to build the new system in .net too
are there any constraints (must use this server, open source policy of your company, ...)
cost of licences, ...
...
At least the descicion to use a specific language for an project with a reasonable size, is always the question of cost. But not only the cost to build the system, also the cost to maintain it. - The points mentioned above are all cost related: for example: if you do not knwo the language you are slower (-> $), if the system can not be maintained, it must be rebuiled (-> $), if there are not the right libs, you need to implemnt it by your own (-> $), if the language you picked make it easy for bugs to hide, you need a long time until the system can go in production (-> $)
In MHO, the advantages of Java are: the wide spread knowlege (this is for .net too), a huge amount of realy mature open source framworks (this is the point for Java against .net), and the usage of a strong typed system and a compiler wich result in less bugs is a long term advantage of Java and .net over every not strong typed scripting language)
One must have for all languages you use on a Server is an Garbage collection!

Java is open-source, so what? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I always hear that Java being open-source is a big benefit, but I fail to see how Java being open-source should draw me to use it as opposed to .NET which is closed-source. This website has some Q&A sections (What is the significance of these developments to the industry? in particular) that give a little info, but is being free the only (or the biggest) advantage to Java being open-source?
Since I am a beginner, have any of you pros noticed any major difference since the change was made?
EDIT:
Please disregard the .NET part of this question, I was simply using it as a comparison. What I really care about is knowing what benefit becoming open-source has been to Java.
If you are a mainstream user, there is probably no immediate benefit for you.
However, the open-source base of Java makes it easier for people to adapt it to more niche requirements that the closed-source vendor sees no need to support. Smaller vendors (or open source projects) can come up with solutions to these special needs.
For example, Java runs on a great variety of platforms and operating systems, most of them supported by companies other than Sun (granted, that was the case even before it was open source).
have any of you pros noticed any major difference since the change was made
I like the fact that Linux distributions now include the "official" Sun JVM and JDK, rather than making you install it separately or use the "mostly-compatible" alternative implementation that was provided.
Not entirely fair to say .NET is closed source - Microsoft's .NET runtime and development tools are closed-source.
Mono is an open-source implementation of many things in the .NET world - the CLR and C# being the biggest.
The primary implementation of .NET is closed source, though there are competing open-source implementations.
The primary implementation of JVM is open source, though there are competing closed-source implementations.
The standard for Java remains entirely under control of Sun (Oracle). Others are allowed to provide input, but final decisions are up to Sun.
The standard for CLR is entirely under control of the ECMA and ISO. Microsoft is allowed to provide input, but the final decision is up to the standards bodies. If Microsoft did ignore their decision, it's open to question whether the standard would remain relevant.
The improvements to OpenJDK since it was open-sourced have been immeasurable, here is just a few:
The Zero project, contributed by Redhat, has ported Hotspot to many new platforms like PowerPC (32 and 64 bit), IA-64, ARM and zSeries, and made future ports to other platforms much easier. The Shark subproject has also given it better performance on some of those platforms
The OpenJDK has been ported to new operating systems, such as Haiku and BSD
Many bugs have been reported and fixed by individuals and companies
Apple has joined the OpenJDK project and a MacOS port is in the pipeline
So has IBM
Various innovative projects, such as IcedRobot have become possible
OpenJDK jtreg tests are now available to other Java implementations
Some of the direct benefits to the average Java programmer are:
You can investigate and fix bugs in the JDK source code
You can build custom versions of the OpenJDK (eg. strip it down to make it smaller)
You don't need to pay license fees to ship OpenJDK on embedded devices
Java and .Net are both standards for which anyone can write an open-source implementation. .Net 3.0 just happens to have no complete open-source implementations.
Regardless of openness, the difference for you (and the reason many people choose Java at all) is portability. There are far more implementations of Java, and most are closed.
Java can create apps for cell phones. Java can create web apps. Java runs on Mac. Not .Net.
Sun is just advertising the simplification and standardization which a common open-source core may provide. But if you look closely at the page you linked, you'll see that it's using the future tense.
Opening up the JVM source helps in porting it to other architectures such as ARM for embedded use.
More choices. Flexibility. Java Community Process. I think mainly lower cost of ownership - Eclipse+ApacheServer+Linux - are all free.

What is the difference between Java and C++? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
What is the difference between Java and C++? Are both object-oriented?
This is far too general a question to be answered here.
Java is an explicitly object-oriented language, with the harder-to-use bits snipped off.
C++ is a multi-paradigm language with the safety off. You can do object-oriented programming in it, as well as procedural and generic.
If you had a more specific question, we could be of more help. Why did you ask? If you want recommendations for a particular platform, or project, or whatever, we could be more responsive.
A C++ programmer will tell you that Java is rubbish. A Java programmer will tell you that C++ is rubbish. Therefore I conclude that they are indeed the same thing.
Each language designed with different purposes in mind, so IMO it's not fair to compare the two from one perspective, and ignore the other.
Generally speaking, C++ is an open standard, designed for implementing high performance systems where speed and performance and critical, there are lots of impressing projects designed using this language like Phoenix Lander, Adobe Acrobat Reader and others. C++ gives the developer the ability to program using a very high level abstraction -using generics for example, and, when needed, go down deep to the bare metal of the machine -to handle an interrupt for instance.
Java was designed with other purposes in mind, when Sun was planning Oak (later called Java), it focused on web applications so it supported the language with a bunch of heavy libraries of easy-to-use interfaces considering that. and portability (Compile once, run anywhere) using JVM, which prevents the programmer from coding to specific machine, but instead coding to a sandbox which in turn runs the code on the hosting machine, and this has obviously negative reflections on performance/speed.
Comparison of those two language is a popular cause of debate between programmers, and this is due to their different working demands and nature, IMO every language has made mistakes in order to mature, for example, C++'s exported templates, and Java's lack of procedural programming (Big Mistake). plus, each one has its pros and cons regarding different aspects, hence the one that balance productivity/performance issue IS the right language.
For more information Wikipedia's comprehensive article on Comparison of Java and C++
It might be interesting to take a look at what languages are used (and being used) to create major systems (like Google) from here.
One of the most important differences hasn't been mentioned yet - one is compiled to machine code, the other is compiled to bytecode which is interpreted by a virtual machine.
Everything is Object in Java as everything is derived from java.lang.Object But this is not the case in C++
No pointers in Java whereas C++ has provide support for pointers
No destructors in java (Java has automatic garbage collection) but C++ has destructors to do that
Thread support is built in Java but not in C++
No scope resolution operator in Java
No Goto statement in Java
No Multiple Inheritance allowed in Java but C++ allows that
No operator overloading is allowed in Java but C++ allows that
Java is interpreted for most part and hence Platform independent
Both are object oriented but they are very different languages. This probably isn't the best forum to ask for the differences... I would suggest you look both up on Wikipedia and review the descriptions there. You will be able to see the differences very quickly for yourself.
I love c++ but unless you absolutely need to use c++ then use something else. When you need to use c++ then you will know the difference, Grasshopper.
(hint do not write device drivers, video decoders, encryption libraries, 3-d graphics engines or language run-time engines in java).
Yes, both are object oriented programming languages.
C++ is an evolution to C. Which was a system programming language. C++ Added many features to the language to make it object oriented. It became the mainstream programming language for that reason.
Java is an evolution of C++, with different goals ( cross platform for instance ). It remove some of the features that make C++ so hard to learn. Simplify others and remove others.
The main difference is C++ programs are compiled directly to machine code ( understood by the CPU ) while Java programs are compiled to be run in a "Virtual Machine" the JVM most of the cases. For these reasons java programs were interpreted by another program and at the beginning were veeeery slow programs. Nowadays the VM may optimize this code and make it run very very fast.
See this link.http://www.javacoffeebreak.com/articles/thinkinginjava/comparingc++andjava.html
Gross but accurate oversimplification: Java is easier. C++ is faster.
Just a quick addition to what David Thornley posted. C++ is a procedural language that supports Objects and OO design. Java is pure OO. Java does less but on more.

Categories