Open eix128 opened 3 years ago
Well at least , this can be used on constexpr expression functions
The main problem is that this stuff is experimental, and there are already other sort of working C/C++ -> Java translators too. You should probably check those out as well.
Which translator ? I dont know any good commercial tool or opensource.
The latest most advanced attempt in that direction is probably Sulong: https://github.com/oracle/graal/tree/master/sulong
I read its documentation , as far as I know , what it does is translate some function calls in one language to another language , instead of translating a *.cpp file to a human readable *.java file
, Is my understanding correct?
for example on C++ to make socket connection , we should call
socket("...
function call.
On java you use new Socket(....
what it does is , it also translate system calls. Not just grammer.Its so powerful
My question is ,whether it can be used as code generation
?
for example, for the following code:
class UF {
public:
UF(int n) {
parents_ = vector<int>(n + 1, 0);
ranks_ = vector<int>(n + 1, 0);
for (int i = 0; i < parents_.size(); ++i)
parents_[i] = i;
}
bool Union(int u, int v) {
int pu = Find(u);
int pv = Find(v);
if (pu == pv) return false;
if (ranks_[pu] > ranks_[pv]) {
parents_[pv] = pu;
}
else if (ranks_[pv] > ranks_[pu]) {
parents_[pu] = pv;
}
else {
parents_[pu] = pv;
++ranks_[pv];
}
return true;
}
int Find(int id) {
if (id != parents_[id])
parents_[id] = Find(parents_[id]);
return parents_[id];
}
bool connected(int x, int y) {
return Find(x) == Find(y);
}
private:
vector<int> parents_;
vector<int> ranks_;
};
What I want is to output java source code of the form
class{
public func1(){...}
public func2(){...}
public func2(){...}
}
, can it do this? if so,How can I configure and use it?
Hi , facebook released TransCoder library. https://github.com/facebookresearch/TransCoder
You can listen details https://www.youtube.com/watch?v=xTzFJIknh7E Also documents: https://ai.facebook.com/blog/deep-learning-to-translate-between-programming-languages/
Also you can check this video https://www.youtube.com/watch?v=1VHtP5FV0kM&feature=youtu.be
For optimization between Java , C++ , this library can be used. That we can convert C++ to Java directly if possible.
Maybe JavaCPP can enable this feature that translates C++ code to Java on some functions or code blocks. So we can run method without jni.
Also python is rising. Maybe you can extend this for python