Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Why we use Javascript for scripting instead of Java

Initiate Mage
Joined
Jul 26, 2014
Messages
29
Reaction score
0
I kinda curious since all the scripting like PQ and NPC are write in Javascript instead of Java is there any reason behind this ? Eg: A PQ need PQ script, NPC script, Portal script. Why can't we just write all in a single Java file ?

sorry im new to this kind of stuff, never touched in a single project
 
Initiate Mage
Joined
Jul 28, 2017
Messages
40
Reaction score
35
There are a fair few reasons to why to use script languages over compiled languages for some mechanics in the system. At first, one should think about: what is going to be implemented, is it "core mechanics" or "superficial mechanics"?

Core mechanics are considered the substantial code elements that should rarely make a change or update on the internal structure, so it should be assumed to be "final" when first implemented. Naturally, things may not go right at first, that code was planned to do something at first but something else popped up mid-development and changes are to take place, but this doesn't come in case here. E. g. are the individual concept elements in MapleStory: World, Channel, Character, etc.

And then, as you may have guessed, the "superficial mechanics", that should be some sporadic feature that may change anytime. Events are based on this concept. Also belonging here, codes that serve a very specific purpose, and make no sense to be in a "core level". Readily: NPCs, reactors and such.

Hope that answered your question. :):

EDIT:

I see I forgot to mention when to use script languages or compiled languages. Compiled languages, due to their proximity on machine language, are known to run much faster than interpreted/script language, thus suiting better core code.

Interpreted/script language, in counterpart, doesn't need to compile/can be compiled at runtime, suiting much better volatile code.
 
Last edited:
Upvote 0
Initiate Mage
Joined
Jul 26, 2014
Messages
29
Reaction score
0
okay thank for your post,i understand a quite of it.
So basicly, Compile language is faster than Script language but it's not always trigger so if we add it in java it will need to compiled (took longer time), so we use script language it will only trigger when we click on NPC.
We don't add both into a file because it will be a messy and we only need to create core for script to use base on it also prevent causing a lot more trouble in the future
 
Upvote 0
Initiate Mage
Joined
Jul 28, 2017
Messages
40
Reaction score
35
Essentially, one will not want to compile code that'll get to run just on a faraway map by a faraway NPC. It'd be too much resource consuming for a simple task, assuming the great amounts of those simple tasks scattered along the code. That's a task for a script, which will run one-time in a bunch of time.

For those things that should run frequently, compiled code suits better. Although it's not desired, say define some NPCs should use Java and some NPCs JS. Same objects should be handled the same way. So, in this case, say there's a specific task that should be performed by a bunch of NPCs, it's advised to make that specific task at compiled code rather than move some NPCs to run with compiled code.

Not that it must be done that way, don't get me wrong. It's just a matter of software architecture decision, that strikes to me to be cleaner to maintain.
 
Upvote 0
Back
Top