Jump to content

Recommended Posts

It's been a while since I did any proper Java (as apposed to javascript), but I used to use Eclipse. Unfortuantely I have grown to hate Eclipse with a passion (I have used it for the last two years for Flex and Coldfusion development). I find it slow and buggy in the main - this could very well be down to the Flex plugins, but I seem to remember that it was always a bit temporamental - everything seemed to be a little 'tacked on' rather than integrated.

Anyway, I thought I might try an blow some cobwebs off my Java knowledge over the festive period in preparation for ToH and ultimately Arma 3 integration.

Any suggestions on a decent IDE for Java? I have heard good things about Intellij IDEA, but I haven't tried it.

IntelliJ is my favorite. You have a free version with all basics included available:

http://www.jetbrains.com/idea/

Share this post


Link to post
Share on other sites

I really have no idea what switching to Java means, so I'm hoping BIS, or our community guru's can answer these questions.

I've seen a lot of excitement, but no concise explanation as to what this will add to our game (I'm mainly thinking ArmA3) and what it means for the modding community.

Java is cross-platform right? Does this add any exciting possibilities for integration with web servers, 3rd party apps, mobile devices, Linux/OSX, etc?

Will changing the scripting engine add more features and possibilities? Please give examples even if it's educated speculation.

Is someone able to compare two basic script examples to demonstrate how the code would differ?

Will it make mission making easier? Will mission makers be able to copy each other's 'objects' or modules/functions whatever, more easily than copy and modifying sqf files to get basic building blocks of advanced missions started?

Share this post


Link to post
Share on other sites

Oh my. I'd never expected that my kowledge of Java could be used to script in RV. :cool:

True OO scripting sounds really exciting.

Share this post


Link to post
Share on other sites
Excellent! Thank you so much BIS!

I wish we can get a full Java API to access to ArmA 3 game engine so that we can develop plugin for the game. Modding for the game would just be OUTSTANDING

I second that, and would be nice to have it sandboxed to protect the boxes from any code that can be sent from client if the current "addons/mods" setup is going to to remain.

Share this post


Link to post
Share on other sites
I've seen a lot of excitement, but no concise explanation as to what this will add to our game (I'm mainly thinking ArmA3) and what it means for the modding community.

http://forums.bistudio.com/showpost.php?p=2074445&postcount=49

Java is cross-platform right? Does this add any exciting possibilities for integration with web servers, 3rd party apps, mobile devices, Linux/OSX, etc?

Using ArmA on those systems... No. Accessing scripting/servers/missions from this devices... maybe, depends on the kind of JVM integration in ToH ArmA.

Will changing the scripting engine add more features and possibilities? Please give examples even if it's educated speculation.

Is someone able to compare two basic script examples to demonstrate how the code would differ?

The main difference is, that you wrap SQF like code into classes, methods and functions. Its more a difference in syntax than in commands (probably all known sqf commands will have a similar command in java).

Maybe:

//In SQF
player setdammage 1; 

//In Java (method of a player/unit-class)
player.setdammage(1);

//OR (a value owned by a class/object)
player.dammage = 1;

[s]//Or (function with 2 arguments: the object and the damage value)
setdammage(player, 1);[/s]

Will mission makers be able to copy each other's 'objects' or modules/functions whatever, more easily than copy and modifying sqf files to get basic building blocks of advanced missions started?

Yes, thats one of the ideas behind OOP.

Edited by NeoArmageddon

Share this post


Link to post
Share on other sites

Hey NeoArmaggedon... One question:

//Or (function with 2 arguments: the object and the damage value)
setdammage(player, 1);

With the example above can i use it instead of forEach in sqf?

Example:

SQF:

{_x setdammage 1} forEach [king, noble ,peasant];

Java:

setdammage([king, noble, peasant], 1);

Took me a while to understand sqf, so i might as well start learning Java basics :)

---------- Post added at 10:50 ---------- Previous post was at 10:34 ----------

seems that an "if" statement does not need "then after the condition...

if (condition) {...} else {...};

Share this post


Link to post
Share on other sites

when i look at java code i want to do this:smash:

its a language i really dislike. i would rather have python in the game than java. even tho java is a bit faster. but it takes 5 time+ as much code to do the same job compared to python.. the code you would write in 2-3 months in python. would take 1 year for java. i just hope i'll be able to use jython.

me want some big snakes in the game instead :p

but overall im exsited about what will be possible to do with the new embeded language.

Share this post


Link to post
Share on other sites
when i look at java code i want to do this:smash:

its a language i really dislike. i would rather have python in the game than java. even tho java is a bit faster. but it takes 5 time+ as much code to do the same job compared to python.. the code you would write in 2-3 months in python. would take 1 year for java. i just hope i'll be able to use jython.

me want some big snakes in the game instead :p

but overall im exsited about what will be possible to do with the new embeded language.

Java > SQF, most definitely. Performance, OO, UI (Swing), etc.

Implementing the Java VM was a great idea, the only other real option IMO is implementing Mono with .NET VM, as it also supports different languages.

According to the info released, it should be fine to run Jython: http://www.jython.org/ or jRuby: http://jruby.org/.

But for really time/performance critical functions / projects, it's probably best to use Java.

Edited by Sickboy

Share this post


Link to post
Share on other sites
i would rather have python in the game than java.

Jython. :)

Might work - unsure yet because it is said to require "a set of support libraries which are used by the compiled Java bytecodes". Since we don't yet have any proper info on the JVM used by the RV engine, it is unclear whether these libraries can be referenced/imported.

EDIT: wtfNinja'd by teh master ninja. :D

Share this post


Link to post
Share on other sites
Hey NeoArmaggedon... One question:

With the example above can i use it instead of forEach in sqf?

Example:

SQF:

{_x setdammage 1} forEach [king, noble ,peasant];

Java:

setdammage([king, noble, peasant], 1);

Yes and No. Its possible because in the last example, setdammage is a real function instead of a method owned by a class. That means, it could be overloaded with a parameterlist like

setdammage(array of objects, value);

This would be a completely new function, with own code and parameterlist but with the same name as setdammage(single object, value).

Then in setdammage(array of objects, value)'s code will be some kind of forEach loop. The advantage is, that you have to write it just one time (in the function overloading).

[EDIT]See rommels post on next page for correction. I thought more in C++ syntax, because thats the language I am working with most of the time.[/EDIT]

But as already said: This hardly depends on BIS implementation of java and wrapping of existing commands. BUT if we dont get such commands we (the programmers/community) are able to write our own libaries, that server us with such commands.

If there is no build in setdammage(array of objects, value), I will write you one :D

Edited by NeoArmageddon

Share this post


Link to post
Share on other sites

Good explanation NeoArmageddon. I just hope there won't be those bridges but a lot more object orientation. :P

Concerning the IDE: I started off with Netbeans. It did the trick back then. UI for basic stuff like coding and debugging is very comfortable, imo better than with Eclipse.

I had to switch to eclipse for work. I soon got used to it and found that it works better for integrated processes. From subversion to running apache servers for tests.

I have been using Visual Studio 2010 for multiple months too and i gotta say it's a pain in the ass. Maybe it's just C# with VS 2010 though :D

On another note: I've been looking into python recently and it makes a lot of stuff much easier, because it's much less rigid and redundant than java. I just miss type safety. That prevents me from using it in a bigger project.

Btw: One of my favorite quotes: http://bash.org/?946461

My first thought after reading it was: "He forgot the .build() before getting the value". :crazy_o:

Share this post


Link to post
Share on other sites
I really have no idea what switching to Java means, so I'm hoping BIS, or our community guru's can answer these questions.

I've seen a lot of excitement, but no concise explanation as to what this will add to our game (I'm mainly thinking ArmA3) and what it means for the modding community.

See this post for an example of what I have in mind.

I think Java brings alot more to the table than people realize. Some of the big benefits include:

  • People can use whatever language they want, Java, Jython, Groovy, etc. and their programs will (should) be completely compatible and interoperable with each other.
  • The vast amount of Java libraries available for things like creating/saving/loading XML files. If you need to do something, someone has likely published a library that does it.
  • Easier debugging and testing.
  • Easier code sharing (see below).
  • Easily generate complete documentation for your project from comments in the code. Generating HTML documentation and deploying it to a web server is a one click procedure once you have your build set up.
  • While Java can be quite verbose, I think it will be easier for new programmers to learn. There are also scads of Java tutorials for people to learn from.
  • Static type checking. There is no "type system" in sqf, there are just "objects" and "arrays" of things. If you get something wrong you don't know about it until your script fails in-game. In Java you can say things like "this function takes a list of integers", "this function takes an array of strings", etc. If you get it wrong you get a little red squiggly line under the offending code in the editor and the project won't compile. Having the editor tell you about a coding error instead of the game is a huge time saver.
Java is cross-platform right? Does this add any exciting possibilities for integration with web servers, 3rd party apps, mobile devices, Linux/OSX, etc?

Quite possibly, but it will depend on what BIS lets us do in the JVM and if the JVM is just available in the client code or if it can be used for server code as well. You can definitely develop Java code on almost any OS.

Will changing the scripting engine add more features and possibilities? Please give examples even if it's educated speculation.

Not likely, at least not at first. Java will just give us another way to do what is already available in sqf, it will just make doing it tons easier.

Will it make mission making easier? Will mission makers be able to copy each other's 'objects' or modules/functions whatever, more easily than copy and modifying sqf files to get basic building blocks of advanced missions started?

Absolutely. This is the #1 benefit of the switch to Java. Writing one module (package in Java lingo) that does one thing and does it well, and then sharing/reusing that module to create others is what Java is all about.

Another of the big benefits will be the ability use a proper dependency management system. For example, if I want to create a mission that uses Package-A published by person X, and Package-A uses Package-B published by person Y I have to hunt down the latest versions of Package-A and Package-B from the net, copy them somewhere to my local hard drive, and then import them into my project. If/when person X and/or person Y updates their packages I have to scour the net again for the latest versions and re-install. If Package-B in turn uses other packages or other libraries I have to hunt them down as well. In any real programming project the dependency management can become a nightmare. Windows programmers refer to the problem as "DLL Hell".

With a dependency management system (we use Maven at work) you simply add a few lines to your build configuration saying what external packages you want to use and their version numbers and Maven finds and downloads everything you need. When you want to use a different version of a package you simply update the build configuration and Maven does the rest.

I am pretty sure non-Java programmers are not excited about this... but I pee a little bit every time I think about it...

Share this post


Link to post
Share on other sites
In my opinion the main difference between Java and SQF is, that java is object-oriented. That means you dont write procedural codes like in sqf, with linear commands and new script calls (exec).

Do you know how to write OO-style in C? Long story short, you can do the same in SQF. It's a lot of boilerplate, heavy verbose syntax, and generally not very readable, but it's doable.

For example: Maybe we are able to use a SQL-lib with Java, so we can get functionalities like JayLib-dll, but there is a waste amount of other possibilities.

For now we'll have to wait and see what they're doing in TOJ - until then we're only guessing. After all, they're doing something to block addon and mission makers from hacking your computer.

Another difference: Java is precompiled into bytecode, the JVM (the interpreter) is able to read this bytecode and it translates it for the Arma engine),

Most likely there will be some JIT involved, which I think it what you were trying to say. This means we'll get close to native performance except where synchronization/locking is involved. And I suspect such locking may happen for most of the API for now.

as far as i know, sqf is not precompiled (if you dont use preprocessFile). So ArmA is processing sqf scripts while you call a specific script. This will probably make the optimized JVM faster (but this also depend on BIS implementation).

Preprocessfile only deals with preprocessing - #define macros, (non-nested) conditional compilation (#ifdef #else #endif). The real key is the "compile" command, which takes a string and produce a "code" type variable which can be called. (execvm is basically an alias for "call compile preprocessfile", exec is the sqs interpreter which was deprecated in arma1 or so.) The compile command has the opportunity to produce bytecode for interpretation; nearly all "interpreted" languages do that nowadays, and it's excellent for performance. Not nearly as good as JIT though.

The key difference in that aspect is that JVMs have since long ago done JIT compilation to native code. This means that java code that does not touch any APIs (where we may hit synchronization overhead) will be as fast as the computer is able to do that operation (with the safety guarantees java gives). For example, given an array of 1000 positions on the map, the job of computing all the distances between each point will still be 499500 distances to calculate, but each such operation can be done a whole lot faster because the sqf interpreter has a whole lot of work to do for each value. We may be speaking of an order of magnitude, or two, even before skipping the sqrt call if we only need to compare them.

One of the traps of language comparisons is to use a sub-optimal solution in either language. In my statement above I assumed the sqf would be doing number crunching; there is a way to do it in sqf which may well do the above task faster. If you use objects, setposasl and distance commands. "Contorting the game engine to do it for you", producing hard-to-read code. I haven't benchmarked it, so I can't say for sure. I doubt it'll come close to jvm jit number crunching in any case.

----

One thing worrying me is that people might withhold the source code for their works and only publish the compiled classes. That SQF was enforced readable (else arma wouldn't run it; compile tostring only a partial exception) was a considerable boon for the development of the scripting community.

It'll also be a good idea for keeping mission file sizes down, too, so this will probably happen by default for missions.

----

For some reason I tend to get rather verbose in programming topics.

---------- Post added at 06:13 PM ---------- Previous post was at 06:07 PM ----------

I am pretty sure non-Java programmers are not excited about this... but I pee a little bit every time I think about it...

Much as I generally dislike java... I'm happy with the change. There's simply too much wrong with sqf.

Share this post


Link to post
Share on other sites
Do you know how to write OO-style in C? Long story short, you can do the same in SQF. It's a lot of boilerplate, heavy verbose syntax, and generally not very readable, but it's doable.

Its doable, but not very efficient and advisable (you already mentioned all disadvantages). I have never heard of somebody building OOP-constructions (classes, methods, polymorphism) just in SQF.

(Using ingame objects (logics, heliH, etc) with SQF-code is clearly some kind of OOP.)

For now we'll have to wait and see what they're doing in TOJ - until then we're only guessing.

That the reason why I said, that all my assumptions are just guessed.

Preprocessfile only deals with preprocessing - #define macros,

I mixed something up with call compile which I often used back in A1. But as far as I know, this command also compiles functions like compile was invoke. But this seems to be Off-Topic.

Edited by NeoArmageddon

Share this post


Link to post
Share on other sites
... setdammage(object, value)[/i]

Java doesn't allow functions like that. At all. It is purely objects. (although not strictly pure OOP)

No static functions, only static methods.

So maybe, as it were, it could be:

sqf.setdamage(object, value);

Maybe allowing easier porting of code.

Share this post


Link to post
Share on other sites
Java doesn't allow functions like that.

Thanks, I often mix up C++ and Java syntax (I am writing most of the time C/C++).

SQF-class for backward compatiblity sounds very interesting!

I can't wait for the patch!!!

Share this post


Link to post
Share on other sites

Is it possible to confirm if code execution profiling will be available for performance tuning (rogue CPU/RAM hogs)?

Will code scheduling will be more efficient (when compared to the whole SQS/SQF/FSM/etc scheduling)?

EDIT: Oh, and does this have any effect on the whole code locality concept?

Share this post


Link to post
Share on other sites

I would just love to see some example Java code, i.e. some small snippet that is doing something with the game world. Just to see what it looks like. :D

Share this post


Link to post
Share on other sites

Basic Java package that can be used from the engine looks like something like this:

package mypackage;

import com.bistudio.JNIScripting.RVEngine;

public class MyClass { public static Object outputHelloWorld(Object[] args) { RVEngine.hint("Hello world"); return null; } }

Share this post


Link to post
Share on other sites

Thanks. Very interesting. :)

I really, really want to start speculating and asking more questions, but I think I'd better just wait until more info is released. This is at least a nice little insight into the "bridge". ;)

Edited by MadDogX

Share this post


Link to post
Share on other sites
Basic Java package that can be used from the engine looks like something like this:

Thanks Maruk!!:D

Share this post


Link to post
Share on other sites
Basic Java package that can be used from the engine looks like something like this:

Is there a reason that you didn't write it with void instead?

package mypackage;
import com.bistudio.JNIScripting.RVEngine;
public class MyClass 
{ 
   public static void outputHelloWorld(Object[] args) 
   { 
       RVEngine.hint("Hello world"); 
   }
} 

Share this post


Link to post
Share on other sites
Basic Java package that can be used from the engine looks like something like this:

Hello Maruk,

Could you please give a response to these questions.

1. Does the JVM use by ArmA 3 will be a copy embedded into the game or would it be possible to use one's system JVM ?

2. Do you intend to deliver the Java API as libraries? If so would it be possible to develop programs that use these libraries without running the game?

3. Does the Java process/threads in ArmA 3 will have restrictions like system files or Socket access limitations? What about remote control possibilities of the JVM?

Thanks again for supporting Java into ArmA 3.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×