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.
Related
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.
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
I am looking for either Opensource or Free Java API for Time Series Analysis using AR, ARIMA etc. I need this api for DDOS Attack analysis.
I googled around and found 2 solutions but both are not completely solving the problem:
1) This same question was asked earlier in stackoverflow and a solution was posted regarding SuanSu Api but this API is not free
2) Apache Math Library, but this API provides other forms of Regression like Simple, OLS, GLS etc but not Auto Regression.
I checked for Options in Machine Learning apis like Mahout but not luck yet. Please suggest an appropiate API
I spent my 4th year Computing project on implementing time series forecasting for Java heap usage prediction using ARIMA, Holt Winters etc, so I might be in a good position to advise you on this.
Your best option by far is using the R language, you can call on the forecasting libraries provided by R, through Java by using the JRI library found here. R is well documented, free and open source. You can even run R on a server and then make calls to it via command line using Rserve, which then returns forecasts over HTTP but JRI is the local equivalent if memory serves me correctly.
If you have any questions, let me know.
Have a look at spark-timeseries. The source code is mostly Scala, but it's relatively simple to use the library from within Java. If you're in a place where you are doing time series analysis on the JVM, then you should consider learning Spark/Scala anyways.
The library is young as of this writing and has room for improvement and growth, but as of version 0.3 it implements AR, ARIMA, simple exponential smoothing (EWMA), and Holt-Winters smoothing. It's areas for improvement are a better automatic ARIMA algorithm, support for seasonal ARIMA, and state space modeling, but it's already very useful.
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
I am looking for a library/API that has some out of the box data and control dependence analyses for Java programs. This would be a static analysis on the control flow graph (CFG) of the given program to compute data dependences and control dependences. I would like to avoid reimplementing these techniques/algorithms if they have already been done. An inter-procedural analysis would be great, but I could work with a library that does an intra-procedural one as well.
Any suggestions would be greatly appreciated.
Edit: One thing I have found is jChord, but I haven't been able to determine yet if it actually has any of the out of the box functionality that I am looking for or if I would have to implement it myself.
Another possibility is the joeq library which seems to at least have the infrastructure necessary for doing this, but the documentation (or lack thereof) is making it difficult for me to tell what it is actually capable of.
I am sure Eclipse does plenty of data flow analysis underneath the hood, but I haven't seen anything yet that is public facing. Anyone know of the Eclipse API having stuff like this?
Try http://www.sable.mcgill.ca/soot/
OP says he is interested in non-open source systems too.
Our DMS Software Reengineering Toolkit with its Java Front End can parse Java source code in all dialects 1.4-1.7, producing full ASTs, build symbol tables, compute types of expressions, and determine control and dataflows within methods, including explicity control dependence as requested by OP.
Usually folks that are interested in advanced analyses have something other than the raw analysis in mind. DMS is an ecosystem of program analysis and transformation tools, that can be used to leverage such analyses into diagnostics about the existing code in terms of source location (drawn directly from the ASTs) or source code (prettyprinted from a subtree of interest), or to generate new code fragments (by assembling ASTs and prettyprinting them) or finally by actually changing the original code (by modifying the ASTs using procedural modifications or better yet, source-to-source transformation, and prettyprinting the modified AST).
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.
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 7 years ago.
Improve this question
Please help me identify some small to medium sized open source projects that embody object oriented design (preferably in C++ or Java). I would like to use these projects to demonstrate how real world problems (as opposed to contrived text book examples) can be solved with an object oriented design. I want to be able to present a plausible explanation of why certain things were chosen to be objects and how they all work together to solve a problem.
Google Chromium (C++): windows, tabs, plugins etc. are all classes.
The Unreal Tournament Public Source Code (432 Headers) contains the declarations of the Unreal engine class library written in C++. I found it to be a rich example of a large object-oriented program. It taught me a lot about how to modularize and object-orient my code. It also demonstrates many tactics for getting a handle on a large code base.
Also, because all you can read are header files, you'll have a fun (and educational) time trying to figure out how the whole thing comes together. (I actually ended up writing my own x86 disassembler so I could cheat and read some of the definitions!)
On the same note, the Doom 3 SDK contains a large chunk of the Doom/Quake engine written in very readable C++.
Just about any large project designed in Java is object-oriented, almost by definition. You can take a look at Apache Hadoop as a large-scale, open-source, objected oriented project written in Java. Another is Apache Ant.
Eclipse would be a good example on the Java side: the plugin architecture is all object oriented.
I asked the same thing to my OO mentor. He pointed me to the JUnit sources, with the recommendation to see how it evolved version by version. This would show you how Kent Beck writes Java code.
Another example on this vein would be the sources of Fit by Ward Cunningham.