是否存在Java到C ++转换器/工具? [英] Does a Java to C++ converter/tool exist?
问题描述
我总是问自己是否可以制作Java到C ++转换器。
I always asked myself if it would be possible to make a Java to C++ converter.
也许是一种将Java语法转换为C ++语法的工具?
Maybe a tool that converts the Java syntax to the C++ syntax?
我知道这些语言有所不同,但很简单,比如语义匹配1到1的循环。
I am aware that the languages differ, but simple things like loops where the semantics match 1 to 1.
是有这样的工具吗?或者是否可以制作一个?
Is there such a tool? Or is it possible to make one?
推荐答案
只要有足够的时间,金钱和资源,就可以做任何事情。这是实用的吗?除了琐碎的例子之外并不是真的。或者更确切地说,它取决于什么构成了可接受的错误率。
It's possible to do anything given enough time, money and resources. Is it practical? Beyond trivial examples not really. Or rather it depends on what constitutes an acceptable error rate.
真正的问题是Java中的习语与C ++不同。例如,Java到C#实际上要容易得多(因为习语更相似)。当然最大的是C ++具有析构函数和手动管理的内存。 Java使用finally块来处理这种行为并且具有垃圾收集。
The real problem is that the idioms are different in Java to C++. Java to C# for example would actually be far easier (because the idioms are much more similar). The biggest of course is that C++ has destructors and manually managed memory. Java uses finally blocks for this kind of behaviour and has garbage collection.
Java也有一个共同的Object超类型。 C ++没有。
Also Java has a common Object supertype. C++ doesn't.
模板的泛型几乎是不可能的,我想象不到。
The generics to templates would be nigh on impossible I would imagine.
这篇关于是否存在Java到C ++转换器/工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!