Canonical reference on JVM internals for programmer/developers [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
The title captures my question fairly well. I'm wondering if there is a good resource or leaping-off point for questions about how a JVM (not just HotSpot, but that's obviously the place to start) implements or handles a specific functionality? I'm not looking for the stuff that's in the JLS or JVM Spec -- I know to go there first.
For example: When trying to understand performance issues, we often get into conversations not about what the spec says, but what contemporary best-practices look like in practical implementations. For example, there is some urban mythology that says "final classes perform better in Java because the JVM can inline or otherwise optimize such things." Is there a general resource we can turn to in order to evaluate these claims that float around?
I offer an answer to my own question, with HotSpot-specific references. What about other vendors' offerings? Specifics to small JVMs? Multi-core specifics? Platforms specifics, if they make a difference? Specifics to other JVM languages?
Just to head off a couple of potential complaints: 1) This isn't about looking for premature optimizations (and in fact, better understanding of the platform should dissuade a better educated developer!); and 2) I know Java programmers are supposed to focus on nice, portable, run-anywhere code, but for many of us the platform specifics end up mattering!
This was inspired by some helpful comments on a specific question by Thorbjørn Ravn Andersen. I'm happy to collect some other more helpful examples beyond the one I cite above, to motivate why folks might want these kinds of resources.
Some interesting related questions on SO: Tail-call optimization in JVM, Killer JVM features, optimizations that are going to be useless tomorrow, Differences between JVM implementations.
Edited to Add: I'll award the answer either to the best individual reference mentioned, or to someone who provides a pointer to a website (perhaps built in response to this question) that best concentrates/catalogs JVM implementation wisdom and the practical consequences on client languages and developers.

The OpenJDK "JVM Internals" wiki is a place to start for HotSpot
Oracle's Java SE 6 Performance White Paper and its predecessors give a lot of insight, though isn't organized for my question per se
On synchronization for HotSpot, see my answer here.

Some time ago I put together a short summary about what advanced programmer should know about jvm internals and help him to understand concurrency, gc, jit etc. better. It is a concentrated summary based on specification and OpenJDK.

Related

What programming language (and IDE) is better suited for the refactoring Gilded Rose problem? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I would like to challenge myself with The Gilded Rose Problem. For the ones unfamiliar with this popular interview assignment, Brad Cypert gives some tips and a general introduction a in one of his blog posts. You can find it here.
In general, it is a problem about refactoring where you should meet some requirements by implementing additional functionalities by operating on a piece of (crappy) legacy code.
This challenge can be taken in most of the popular languages and I think that the combination between language and IDE (for refactoring purposes) is crucial to differentiate a great solution from an OK one. I was thinking about combining IntelliJ, since I have experience with it and I think it is great for refactoring and Java, since it is one of the language I am more comfortable with. However, any other recommendation is more than welcomed and I will be happy to try and experiment with new languages and tools.
Lastly, I was wondering whether someone could provide any guidelines or a more detailed tip based on past experiences about this problem.
You can choose any language and an IDE you are familiar with.
The Gilded Rose Problem is an example of bad code. You can train refactoring with this code. Refactoring is not only what can be supported directly by the IDE. Normally you should also think about the code if there is something that can be expressed in a simpler way.
It does not much depend on the language, according to Nikolaus Wirth (inventor of PASCAL): "A poor programmer can produce bad code in any language."

Ocaml learning resources [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
We are thinking of using functional languages in our projects. I'm trying to collect points on which functional language we can start with(we are mainly java developers). We are thinking of using Ocaml.
I tried learning from their website ocaml.org. I've following questions for those who use Ocaml at their workplace.
Does Ocaml reduce lines of code compared to say Java?
What editors do you use ?
I have see that there are many Ocaml library implementations-
Batteries,Core etc.In the beginning can only Batteries suffice?
Do you use Ocaml Core(by Jane Street)? How different is it compared
to standard one?
In the beginning, we are planing to use Ocaml in very small amount,possibly in house project.
At Vector Fabrics, we are using OCaml extensively.
Having recognised the advantages that functional programming could bring to our engineering activities (we are mainly constructing software tools for analysing C and C++ programs), we considered both Haskell and OCaml as languages to use. In the end, we decided to go for OCaml, mostly because its execution model is simpler (eager evaluation vs. Haskell's lazy evaluation) and therefore reasoning about the behaviour of programs is somewhat simpler for programmers who do not necessarily have a background in functional programming (we were especially concerned with reasoning about the space behaviour of programs, with is, sometimes even for experts, quite challenging in Haskell).
OCaml allowing you to selectively "escape" to imperative and even object-oriented programming is something that sometimes comes in handy but not something we recommend to our programmers as a good practice in everyday programming. Our rationale: once you adopt a functional programming language, you better use it to do functional programming in, otherwise you can easily end up writing imperative and object-oriented programs in (for that purposes) clumsy syntax. After all, if you're problem domain is better served with object-oriented programming, then you're better off selecting a language like Java that is far better suited for that.
Answering your questions:
Does Ocaml reduce lines of code compared to say Java? Yes, but only if indeed adopt a "functional style" of programming. Also, be careful: functional programs can be beautifully concise, but sometimes notation can obscure the inherent complexity of algorithms.
What editors do you use? We mainly use general-purpose editors like emacs and vim.
I have see that there are many Ocaml library implementations- Batteries,Core etc.In the beginning can only Batteries suffice? Batteries makes for a nice and arguably powerful-enough standard library (but so does Core). Depending on your problem domain, you may need to extend the standard libraries with your own utility libraries.
Do you use Ocaml Core(by Jane Street)? How different is it compared to standard one? We don't use it, but see, e.g., What are the pros and cons of Batteries and Core?.
Note that these questions have many possible answers and that I have answered them to a large extent exclusively from the Vector Fabrics perspective. In fact, your question may be a bit too broad for Stack Overflow.

Is "Java Concurrency In Practice" still valid? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Is Java Concurrency in Practice still valid? I am wondering whether the ideas, concepts and implementation described in the book are still compliant with the latest Java versions.
I ask because the latest edition was done in 2006.
While my perspective may be biased, my current intention for updating the book would be almost strictly additive, covering fork-join, parallel decomposition, and the new parallel bulk data operations coming in Java SE 8.
EDIT 2020: ... and Project Loom.
EDIT 2021: ... and Project Loom :)
EDIT 2022: ... and Project Loom !
Yes, it's still valid in my mind. There isn't big change in this area from 6 to 7. Fork-join is a new feature, which is very suitable for divide-and-conquer type of problems. But all the existing stuff inside the book, such as synchronization, volatile, servlet, are still very valid.
I bought this book in 2013. I had very serious doubts that it would be current and useful given that this edition was published so long ago. The technology world moves quickly, and software technology even faster. Even so, this book is foundational. The concepts and practices that are discussed are more underpinnings for good software design and engineering than updates on the latest and greatest API's. This book has been indispensable, and I am glad that I got it before I had decided to write even a single line of concurrent code. It's probably saved me countless hours.
Yes definitely it's still valid, but I will recommend in addition or as an introduction The Well-Grounded Java Developer a well written book with a chapter on modern Java concurrency techniques and nicely done examples.
I would say so. JDK7 adds the fork-join framework but that is an enhancement rather than a replacement for earlier concurrency tools.
Yes. Very much.
You can always keep track on new things being introduced in Java, however, the book does a fine job of explaining the fundamentals.
If it helps, this comes from a full time researcher in concurrency and parallelism using OOP.
Yes. Still it is valid and i have got good feedback from my friends. It is one of the best book for learning the concurrency in java. You can read the review for Java Concurrency In Practice
If you are going to start your project using Java 8 you might want to consider fresh books and tutorials as well because of new stuff appeared in Java 8 like streams,lambdas and new atomics - that changes development methods a little bit.
Well, the book looks promising when I read certain preview chapters online. It gives enough insight on Java and general concurrency aspects. One can keep this book as a handy outfit when designing and implementing both naive and sophisticated concurrency applications.

Any suggestions on learning Data structures and algorithms for java developers [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
What algorithms should a java developer(or maybe a better question would be a software developer in general) should know. I have Introduction to Algorithms by Cormen and Algorithms by Richard Johnsonbaugh at hand. Would going through their content be overkill?
from amazon data structures and algorithms in java
What algorithms should a java developer(or maybe a better question would be a software developer in general) should know.
There are no any specific Algorithms for C developers or for a Java developer. Algorithms is a "main" part of the Computer Science and here is the topic What algorithms should every developer know? and here Best source for Algorithms? and Good Data Structures text book
That's a very open-ended question, so a concise and useful answer is difficult. I would say that you need to know at least the data-structures and associated algorithms that Java provides in the standard libraries so that you know how and when to use each one. If you don't know the differences in structure and performance between an ArrayList and a LinkedList then you won't know when each one is appropriate. Similarly, if you don't know how a HashMap works then you can't know how to properly define classes that can be stored in one.
It's also instructive to learn a couple of different sorting and searching algorithms, for similar reasons.
This question here better answers what you ask.
It doesn't hurt to know stuff like that, but it will rarely come up*.
*Depends on what you're doing.
The CLRS is probably the most widely used one and reading it is definitely not overkill, just skip the proofs (I would read them just to enjoy, but not too much practical use). You may also want to check this one.

Java to C cross compilation [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Does anyone know of a good Java to C cross compiler?
Do they work well?
This is very similar to this question, and answers may be helpful to you: Compiler to translate Java to C.
Summary: There are tools for this (Toba, GCJ, etc), but you may run into problems with not all of the Java libraries being ported. In the end, tools will probably only do PART of the work, and you'll have to hand-code some of the rest.
A good first step is to convert your Java code to only use standard libraries available in Java 1.4. In fact, you'll probably want to wean as much as possible off of anything not in java.lang.* or java.util.* packages in order to simplify the porting procedure.
Depending on the size of your codebase, it may actually be easier to rewrite the bulk directly rather than relying on tools. Java and C have a lot of syntax similarity, but the mismatch between C's straight procedural code, and Java's object oriented features could cause problems. Automated tools may generate virtually unmaintainable C code when trying to work around this, and there's always the possibility for subtle bugs.
2016 update: Don't do this, not now, not ever. The options that used to provide this have not been maintained (GCJ, for example), and it's arguably easier to find a developer fluent in java than C. Also, Java performance has continued to improve, and baseline implementations tend to have similar performance. Optimized C is still faster, but the edge gets smaller and smaller with every JRE version.
Can you explain why you want to port your Java code to c?
If it's for performance you likely won't see much of an improvement. Java is a garbage collected language and currently there isn't an algorithm that can insert memory allocation and deallocation calls efficiently. There have been many researchers trying to solve this problem and they have some interesting solutions but I have not seen a good commercial product that can scale to large programs yet. You can look at the conference proceeding for previous ISMM conferences for more information.
If you want to speed your code up I suggest that you use a profiler and find the hot methods. Try and optimize the hot methods and if that is still not enough try and use JNI.

Categories