Top Mud Sites Forum

Top Mud Sites Forum (http://www.topmudsites.com/forums/index.php)
-   MUD Coding (http://www.topmudsites.com/forums/forumdisplay.php?f=9)
-   -   Combining of Languanges (http://www.topmudsites.com/forums/showthread.php?t=410)

NealSilfer 01-03-2006 08:01 PM

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

KaVir 01-04-2006 08:07 AM

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.

Kastagaar 01-13-2006 04:09 AM

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.


All times are GMT -4. The time now is 12:39 AM.

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright Top Mud Sites.com 2022