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 need to implement a library which will be called from multiple languages - Java, Python, Perl and possibly more in the future. I'd hate to implement (and maintain) the same thing again and again in multiple languages.
One option I can think of is to write the core functionality in C/C++ and use SWIG to generate bindings for target languages; or maybe write the bindings myself.
Thre are some reasons why it can't be an independent service.
Are there any other mature alternatives? I am looking for options to compare before I settle for one.
Ideally, I'd like to do it using a source to source compiler or a source code generator. But I can't find one that supports all of the above languages - with potential for future additions.
I may consider any alternative binding generators if they provide any advantages over SWIG.
Thanks in advance for any pointers!
The simplest way is to write the library in C with a simple API. Every non-obscure language has some way to interface with C code.
Depending on the style of the API, SWIG can save some time in generating the bindings; but unless it's very big and regular, you might find it easier to write the bindings by hand.
Some Languages (at least Python in your question) have an FFI mechanism, that lets you write the whole binding in the target language, making it much easier to deploy and maintain. Note that most of those are focused on C APIs, not C++.
Depends on how you plan on access the library, is it possible to expose the public API via Web Services?
This way you can write the shared module in any language and access it via a common protocol such as a RESTfull web service.
Look at Microservices architecture.
Related
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 6 years ago.
Improve this question
I am working on a small project on metadata extraction from documents and have run into, eh a dilemma. I have some libraries in Java which work well with document-handling for information retrieval, like Apache Tika, POI etc and some more tools in other languages like Ruby(pdf-extract) and a script in bash to fetch data from a RESTful API using wget.
AFAIK, Code reuse is a good thing, right? But then, if its not possible (natively, I mean) to reuse all this code, What approach has to be taken?
Using Java to run terminal-commands is a solution but I don't think it is good programming practice.
Integrating multiple technologies is something that is very common in real world applications. In order for it to scale properly, you probably want to use some methodology to keep things consistent. To me, the weakest part is probably fetching using wget, but that's my opinion.
In order to integrate and for everything to scale nicely you may want to look at some message passing protocols and have some sort of handling of queues where individual workers run in different programming languages and environments. Look at:
https://www.amqp.org/ (message passing standard)
https://www.rabbitmq.com/ (Java, .NET, Ruby, Python, PHP, JavaScript...
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 have a legacy ISO prolog application of medium size that I would like to move to a JVM based language. The application is a command line tool that parses text files, does some evaluation/transformations and then export a text based file.
My team develops mainly in Java so we have a lot of existing java competence and reusable components. Prolog competence is however very low.
I don't expect there to be a tool that takes prolog source code and transform it to some other language. But I'm trying to understand what would be the easiest solution. Starting from scratch in Java or using a more functional language like Clojure?
But I'm trying to understand what would be the easiest solution.
Some implementations of Prolog run on the JVM platform. Wikipedia lists 5 of them here: http://en.wikipedia.org/wiki/Comparison_of_Prolog_implementations. So maybe the easiest solution is train someone in your team in Prolog, and just port the application to a JVM Prolog implementation. (Which might be a simple thing ...)
Someone on your team is likely to need Prolog skills anyway to successfully translate Prolog to some other language.
However, I recognize that there could be other reasons to translate; e.g. if the existing Prolog code needs a major overhaul anyway.
That is mainly depending on your team's skill. You mentioned that your team has a pretty good Java skills; why not starting with that?
If they don't know LISP, they will spent a lot of time learning it from the scratch. Learning LISP is quite an investment but it is definitely pays in the end.
Although Clojure is going to help you a lot in your case (because of data flow and data transformation), I would say that Java is a better bet since your team is competent with it.
You could consider using Clojure together with core.logic (tutorial) which is a miniKanren implementation. You would need some logic/functional programming skills but you could stay on the JVM.
Prolog is so different from java and other Object Oriented Language. I studied this language to see an other way of programming.
But I dont think there is a magic solution to convert prolog app to a java app. The logic is not the same and no other language is like Prolog. I think you will have to analyse what your prolog app does exactly and go from scractch with a new java app.
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 6 years ago.
Improve this question
I am interested in using OCaml or Haskell to develop an engine for statistical computing. This functionality is supposed to work on data that is going to be provided by a model driven, Object Oriented information system. The whole thing needs to scale up and out.
I can see a lot of benefits in using Haskell for example, but getting the data in an out of the Haskell code is tricky. There are always out of the box options like C/C++ interfaces or JNI, but in an architecture which is supposed to scale, I find these approaches problematic and error prone.
Considering FP is on the rise, how do people integrate these languages into widely used languages, hence technologies such as Java? I have been using ZeroMQ and Protocol Buffers for Eiffel to Java integration for example, but are there any options which has proven to be stable and high performance?
Ps: Stackoverflow warns me that this question appears subjective, but I am asking about actual technical solutions to connect different runtimes. I have no intention of discussing pros/cons of any language or paradigm.
Have you considered using Scala? It supports functional programming on a JVM platform. You could integrate it with Java, but you might find that is not needed.
You may also find it is faster than Haskell, esp. with tighter integration with Java.
http://benchmarksgame.alioth.debian.org/u64q/which-programs-are-fastest.html
F# will give you functional programming with the .Net platform for "free".
OcamlJava can interface Java with Ocaml:
OCaml-Java is an effort to make Objective Caml available on the Java platform, currently supporting 3.11.2. The project has two concrete objectives: first, the ability to run Objective Caml sources that have been compiled using ocamlc; second, the ability to compile Objective Caml sources into executable jar files.
You use languages such as Scala, i.e. languages that already run on the JVM.
There are plenty functional languages that run on the JVM and thus integrate quite nicely with the rest of the java code.
My favorite is Scala, but there is also Clojure and Groovy, just to mention a few.
Using Scala or F# would be the real solutions as others say, but just in case if you like something easier to start with, you can also do some functional programming in Java (or C#) like these people https://www.google.com/search?q=functional+programming+java as FP is a programming style that favors immutability.
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 8 years ago.
Improve this question
Could you please help me understanding under what scenario JNI (or Java Native Interface) could be useful from web application development perspective?
I did read some articles that promises that JNI can give you access to native application like menu bar/scroll bar etc, so the user interface can be more catchy... however these things can be done in other technologies rather than Java.
I'm still not able to find practical uses of JNI. Have you used the JNI in your projects/apps ever? and for what?
JNI is useful if you need to call some lower level language (C, C++, assembler) function from within Java. Many projects use JNI, for example:
JOGL (Java library for making calls to OpenGL, a C library)
SWT (Java UI library that uses JNI to call a native windowing library, for example GTK on Linux)
There are utilities to automatically generate JNI code, like SWIG, which can dramatically ease the pain of generating JNI wrapper code (which involves writing a bit of Java and some of the underlying language).
It shouldn't be necessary for web development since just about anything you need is already written in Java--and it would also be a terrible idea because it will make your app platform dependent.
It is sometimes used to access a system API an old DLL that you must use without rewriting for some awful management-related reason.
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.