Multithreading implementation - pro and cons between java and C [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 8 years ago.
Improve this question
I have a task to extend an implementation of an ongoing project written in C that is already working well, so that it will be multi-threaded.
I have many years of experience with Java, but very limited for C. So basically I have some options like the following:
Rewrite all of the code to Java and later implement multi-threading in Java
Implement multi-threading in Java by calling some methods from C library through JNI
Learn C and continue the task in C.
By considering that the multi-threaded version does not have to get the latest update from the C library, and probably later I might need to put these code in some big data framework like Hadoop.
In order to find out which option could be better for me, I would need comments about the following questions based on what you have already experienced before.
How smooth it will be to call a C function from Java and if there is any significant limitation?
What are the pro and cons of implementing multi-threading in C?
And also which option that you think is better?

I would go on 3. Multithreading relies on few basic concepts of mutex and semaphores, both in the POSIX standard, and I would recommend you learning them. The C concepts are really basic, the most difficult thing you have to learn will probably be pointers so nothing hard. Having coded multithread projects both in Java and in C I would recommend C (having an hard Java background it's difficult to say for me! ) to learn an important part of POSIX standard (used in Unix too), not to depend on extern libraries and virtual machines. If you want to do it in Java, I would exclude solution 2 and make a standalone Java project, it has appropriate libraries to support multithreading.

Related

Good practices for Data Scientists that work in R and engineers who work in Java and C++ collaborating [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
My company has a production application being built in Java and C++. We have recently added Data Scientists who are skilled at and using R. I am wondering what best practices people have for making sure that work done in R is best leveraged. For instance is our best option to call R code from Java or C++? I have located http://www.renjin.org/about.html.
Or is there a good way to convert code from R to Java or C++?
I am not a big fan of Renjin as its Java-based interpreter will only cover a subset of CRAN, and at that the subset that does not involve calls to C++.
I am a bigger fan of either
separation of concern:
use something like Rserve for headless connection from anything (including Java), or
use something like OpenCPU to turn everything into web-based access
for heavier-duty work, interface C++ directly via Rcpp which well over 400 CRAN packages do.

Java: SQL and Statistics/Machine Learning [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 8 years ago.
Improve this question
I have a question for you concerning Java. I am basically a Java user and did most of my work with it. However, in the machine learning classes I took in college, we used mostly python with the scikit-learn and numpy packages.
Now I want to do a project where I crawl data from the web, store it in SQL databases, and then do machine learning on this data. Maybe some of you have experience with those things and share some of it? I mean, of course it is possible to do these things with java, but maybe you have had some particular experiences on why I should use something else or what to consider?
I am happy for all your thoughts :-)
Have a great weekend!
It turns out that programming language and database implementation are secondary problems. Think first about the machine learning you want to do. Review the existing packages (in any language) and pick one according to how well it fits the needs of the business problem you are trying to solve. Then work with whatever language is most convenient for that package. You will probably find that no single language is suitable for all parts of the problem; you will end up gluing together Java, Python, R, shell scripts, etc, to make a complete solution, and there's nothing wrong with that. Consider that your job is problem solving instead of programming in a specific language and go from there.

Limitations (drawbacks) of java programming language? [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 9 years ago.
Improve this question
I am a beginner in java programming language, I have recently studied basic concepts of java programming language. I just want to know, What are the limitations of Java programming language in terms of memory management and other run time related issues.
Thanks in advance.
Java is OO programming language. Within that realm, considering static typing, there aren't much limitations. Java works well. At present JVM does not do tail call optimization, which can be considered a limitation. But that is limitation of the JVM, not the language. With Java 8 there are closures, and anonymous functions. The syntax is a bit ugly, but it's kind of ok. So we can't complain there. However, when comparing to functional languages (thinking Haskell), I miss array comprehensions, lazy evaluation the most.
The way in which Java approaches concurrency is using threads with shared data. We know that shared data can make parallel programming difficult. If Java has build in mechanisms for message passing like ZMQ or green threads (like Kilim) with no shared data, it would be cooler. But earlier on during the design phase they choose green threads, but later on moved to native ones for performance gains. Concurrency using STM (Software Transactional Memory) would be make great addition to java.utils.concurrent library. These aren't limitations per se, they can be added at a later point in time, using JSRs. But at present we do not have such mechanism.

Why jvm is written in c++, any specific reason.? [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 9 years ago.
Improve this question
I know that JVM is written in c++ but my primary question is java being good language probably better than c and c++, what is the necessity of writing it in c++. Any specific reason? just to want to know it might help others while facing interview at least. please dont debate as this forum doesnt support. Please give me solid reasons. thank you.
Java code needs the JVM to execute. However C++ is compiled into machine code, so it is executed more or less by the hardware.
Thus you can see that to write the JVM using java, would mean that you need a JVM to run the JVM... hence not possible..
This is the same with most if not all interpreted languages. They are written in C / C++. Typically C since that was more stable when the language was taking shape (e.g perl), and also because it is seen as being more light weight and faster (?) than C++.
When going from the design of a language X to the implementation, one thing is sure : you don't have access to language X tools because they don't exists yet. You need to use language Y.Now once you have language X running you can say you completely switch implementation from Y to X. But there is a cost : You are written a new software which should behave exactly like an old one. If the benefits outweighs the costs, then it can be a viable option.

Programming language decision for C++ legacy project workflow [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 5 years ago.
Improve this question
I have quite a lot of C++ legacy code modules from my colleagues, unfortunately poorly written. Each is doing a different job, but they are all GNU C++ code running under Linux.
I want to write a controller program, to make a singular C++ module for a workflow, for a very urgent demo. Also I need to write a front-end web-app allowing clients submitting jobs to the controller.
My main criteria are:
development speed (very urgent demo)
good binding with C++ (I have legacy code I do not want to rewrite in another language)
smooth introduction of new programming language to team (has some python, java and perl knowledge)
What programming language fits my needs best, and why?
Details:
I lean towards python for its perfect binding with C++, as writing JNI is too much work, and kind of obsolete nowadays. However, no one in my team is Python programmer; I do know some Python (no experience in server side programming at all). I have been developing Java EE apps last year, but I do not think JNI is a good solution. Only one team member knows some Perl, others are pure C++ programmers.
Noting the "very urgent demo" part, assuming that that would take about a month, depending on the complexity, I'd stick to the familiar.
True, maintaining python would be easier in the end, and learning python should be a breeze, if you deem it viable.
I'd say, have the team learn python and do the basic stuff, as you learn the deeper parts, you could build classes for them to extend/implement. That way, you get things done as they learn.
Given the urgency, I'd have to stick with C++.
Without that, I'd say keep what you got, but feel free to switch to a preferred language when refactoring. That would be the time to do it.
What you should not do, ever, is "port" anything to another language without rewriting or changing functionality in any way. It is a total waste of time, when the "best" outcome you can hope for is that it has no new bugs when you are done.
I would use Python. You could write very basic wrappers using the Python C API and then call said functions from Python with relative ease.

Categories