01-03-2006, 08:01 PM | #1 |
New Member
Join Date: Jan 2006
Posts: 1
|
Hello, I have little knowledge of the different programming languages out there. However I plan to change this by attending my local college. I was curious to know about combining different languages together to form a MUD. Are there certain rules or something that I should know about? I am more specifically interested in the combining of Java and C++ to form a MUD. Please no preaching of why I should use Java or C++ because that is not even a definite in the development of my MUD. I have done enough research to believe that for the type of MUD I would like to design learning Java and C++ is the way I need to go. Thank you for you consideration.
Neal |
01-04-2006, 08:07 AM | #2 |
Legend
Join Date: Apr 2002
Name: Richard
Home MUD: God Wars II
Posts: 2,052
|
What research, out of interest? I find it very difficult to see what advantage you might get from combining C++ and Java. I could understand it if you wanted a C++ server and a Java client, and I can see the advantages of embedding a language like Python or Perl into a hardcoded engine. But unless you've already got large amounts of both C++ and Java code that you want to avoid rewriting, or are creating the mud as a learning experience (eg to practice your COM skills) I can't see any reason why you'd want to build a codebase using both languages...
I'm not 'preaching', I'm just honestly curious. It seems like a thoroughly bizarre design decision, and I'd be really interested to see what sort of research inspired it. |
01-13-2006, 04:09 AM | #3 |
Member
|
I agree with KaVir: how bizarre, how bizarre.
The first thing that you should recognise is that Java and C++, despite their apparent syntactic similarities, are completely different languages in almost every respect. How you do things is just plain different. That said, Java does have an interface to external code via the JNI - Java Native Interface. Essentially, you can design a Java class, and mark methods as "native". [code] public class Foo { public native void stuff(); } [/quote] After compiling this class, you can extract a C++ header from it using the "javah" tool. Then, you can use that header as a basis to implement those methods marked native in C++. You then compile it into a DLL (presuming some compiler capable of this), and that code will run when that native method is called. |