Why not Java?

@Jmv38, @bee - Keep in mind that he is a single developer and is devoting most of his time right now into finishing up his iOS 7 design for Editorial (which is also simply amazing).

After using all of them (Lua, Java, Python, C#) - I agree with all the pro-Lua advocates on here. From a developers perspective, It’s just far easier to ‘knock something up’ to try out ideas without being bogged down with the pedantic syntax and semantics of certain languages - which also leads it to be accesible for newbies and beginners.

It’s also interesting that the developers of Unity went for Java rather than Lua as one of its scripting languages. Similarly, I’ve been doing a lot with Unity and C# lately - it’s quite amazing how much more effort I need to do something similar in C# that I would quickly code in Lua. Although, admittedly C# is a far more flexible language, especially with the OOP stuff.

Python is fab, but really use it these days for writing tools and utilities which perhaps is its strength. It’s string handling is second to none. :smiley:

@andymac3d very interesting points. Could you descrbe 1 example of ‘flexible OOP feature’ that is easy with C# but cannot be easily implmented in lua by creating the required object (as was done for class() )? This is a naive question, i would really like to understand.

@Zoyt now i understand why the update didnt show up for me…

@andymac3d I believe Unity uses JavaScript not Java.

@Briarfox Apparently it actually uses Unityscript, from what I’ve heard.

From what I’ve hear/read/seen it uses a combination of scripts, you can code in javascript, lua and if I’m not mistaken also java and some others like C#

but I can be wrong :stuck_out_tongue:

@Briarfox - apologies, you’re correct (was just being a bit lazy and forgot the ‘script’ bit!).
As a matter of interest it’s more akin to Microsofts JScript but optimised for speed (probably some sort of JIT compiled code, rather than interpreted as I understand it).

@Prynok - to add to the confusion UnityScript = JavaScript :wink:

@stevon8ter - you’re wrong :wink: JavaScript/UnityScript, C# and Boo (sort of a bit like Python) are the only ones supported. No Lua, but I think you can get a 3rd party Lua plugin from the Unity asset store - but it’s probably not very well supported/integrated. To be honest, most Game Devs tend to use C# for doing hardcore stuff in Unity, Boo is pretty much ignored these days.

@Jmv38 - the OOP stuff is pretty powerful in C# - As an example, I quite like the fact you can implement event handlers within classes. Classes and objects can then subscribe and listen to events from other classes and then act on them automatically when they occur. This in itself is really useful when developing games or UI driven stuff which tend to be heavily event-centric. Obviously a lot of these sort of features could be implemented in Lua (maybe with co-routines?) - but it’s nice to have them out-of-the-box so to speak - hope this helps. :smiley:

Thanks for the example. I see what you mean in this one: i have myself implemented touch and drawing management this way in XFC: objects have to register if they want to be touchable or drawn, it makes the management of these functions much simpler (and i just used tables, not coroutines).

To specify, in Unity, JavaScript is sometimes called UnityScript because a few things are changed. First of all (unless my data is old), they haven’t supported some parts of JavaScript like switch statements. The big difference is that you can strictly type variables, kind of like what JavaScript 2 was planned to be (I’m very sad they shut down that amazing project).
Also, people commonly mistake that JavaScript is slower than C#. UnityScript/JavaScript is actually written by Unity, so it was made specifically for Unity. So it it just about the same speed as C#.

@Simeon Ahh sorry I thought I saw you say something along the lines of you played with java at the start but too many limitations at the time, dont quote me on it though! But yeah just playing with Java the past few days it is structutally very different to Lua. Don’t get me wrong Lua was my favourite language before codea and has been since, I don’t see Java changing that due to Lua’s amazing ability to write less and achieve more. Codea itself reinforced my favourtism of Lua but I would like to possibly join a company to do with programming and everyone needs a java programmer these days! Plus I’d like to start using unity. Lua is definitely a great option for speed to weight. @Bee it sucks and it doesn’t is what im seeing, I quite like it now I can half understand what Im writing but eclipse helps a lot with auto correct which personally I think is quite efficient for seeing mistakes in the beginning and easily debugs simple scripts, otherwise I wouldn’t have a clue!

@Bee @Luatee Java doesn’t suck, you just haven’t learned enough… A lot of developers like/use Java because it works on almost every OS, excluding maybe iOS. Yeah, it takes a lot of effort to make a window, but once you’ve memorized how to do it, everything else is easy. All you have to do is code it once, export it a few ways, and suddenly you’ve got downloads for almost every OS.

@SkyTheCoder - I see where your coming from. You can do everything in Java, like a normal app (almost), without any trouble. Why it sucks is really the speed and security of it. I’m all for the idea, not the way it’s executed.

@SkyTheCoder For me, I understand the language itself, by like @Zoyt I don’t like the way its executed. There are to many things to remember (How to make a window, sprites, etc.) which would be better of if you do something like Codea, where you just use a built in function to do all the graphics. Of course, that’s just my opinion.

There are many ups and downs if each method… The worsted part is it’s tuning a whole VM.

@Luatee - There’s always this if you want the console: https://itunes.apple.com/us/app/java-programming-language/id486207896?mt=8
Edit: Just ran across this when searching for Processing (which runs in Java): https://itunes.apple.com/us/app/processing-for-dummies/id505852347?mt=8 IDK how good it is, but from the screenshots, it looks pretty good.
Edit: I also forgot to mention you might be confused because it does have processing.js, not Processing. So the following code (from an example) works:

// Farbkreis
// by Michael Markert
// 
// Version History
// 0.1  2009-12-28  first version
// 0.2  2010-01-07  added rotation
//
// RGB Farbkreis
//
//
// ***** How to use *****
// 
// + see FileExporter
// 'c'  show color wheel
// 'd'  show degrees


// settings
boolean draw_wheel = true;
boolean draw_degrees = true;

// sketch properties
int s = width;    // size
int w = s;      // width
int h = s;      // height

// color wheel properties
int cx = w / 2;
int cy = h / 2;
int radius = s - (s>>1) - (s>>3); // wheel size
int segments = 6;                 // number of segments
float segmentAngle;               // angle of each segment


// Text Properties
PFont font;

void setupFont() {  
   font = createFont("Arial", 10);
   textFont(font);
   textAlign(CENTER, CENTER);
}

void setup() {
   // canvas
   //size(w,h);
   mouseX = width;
   mouseY = height;
   setupFont();
}

void draw() {
   background(0);
   noStroke();  
   colorMode(HSB, 360, w, h);
   
   translate(0,100);
   //translate(wheelOffsetTranslateX,height);
   //rotate(radians(wheelOffset));
   
   segmentAngle = 360 / segments;
   float angle, i;
   float vx, tx;
   float vy, ty;
   
   // draw color wheel
   if(draw_wheel) {
      pushMatrix();
      beginShape(TRIANGLE_FAN);
      vertex(cx, cy);
      for(angle=0; angle<=360; angle+=segmentAngle) {
         vx = cx + cos(radians(angle)) * radius;
         vy = cy + sin(radians(angle)) * radius;
         vertex(vx, vy);
         fill(angle, mouseX, mouseY);//(mouseY*(-1))+50);
      }
      // close
      if(angle>360) {
         angle=360;
         vx = cx + cos(radians(angle)) * radius;
         vy = cy + sin(radians(angle)) * radius;
         vertex(vx, vy);
      }
      endShape();
      popMatrix();
   }
   
   // draw degree numbers
   for(angle=0; angle<=360; angle+=segmentAngle) {
      if(draw_degrees) {
         tx = cx + cos(radians(angle)) * (radius + 25);
         ty = cy + sin(radians(angle)) * (radius + 25);
         if(draw_degrees && (angle < 360)) {
            pushMatrix();
            //        rotate(90);
            //        fill(#666666);
            //        text(""+angle+"°", tx+1, ty+1);
            fill(angle, mouseX, mouseY);//(mouseY*(-1))+50);
            text(""+(int)angle+"°", tx, ty);
            popMatrix();
         }
      }
   }
   
}

void mousePressed() {
   if(mouseY>s){
      if(mouseX>=(width/2)){
         if(segments<360){ segments++; }
      } else {
         if(segments>1) { segments--; }
      }
   }
}

void keyPressed() {
   //println("KeyPressed: "+key);
   //println(keyCode);
   
   // set new number of segments
   if(keyCode==UP) { if(segments<360){ segments++; } }
   if(key==',') { if(segments<360){ segments++; } }
   if(keyCode==DOWN) { if(segments>1) { segments--; } }
   if(key=='.') { if(segments>1) { segments--; } }
   if(key=='0') { segments = 3; }
   if(key=='1') { segments = 4; }
   if(key=='2') { segments = 5; }
   if(key=='3') { segments = 6; }
   if(key=='4') { segments = 12; }
   if(key=='5') { segments = 24; }
   if(key=='6') { segments = 45; }
   if(key=='7') { segments = 90; }
   if(key=='8') { segments = 180; }
   if(key=='9') { segments = 360; }
   if(key=='c') { draw_wheel = !draw_wheel; }
   if(key=='d') { draw_degrees = !draw_degrees; }
}

@Prynok. JavaScript is easiest to put some text on the screen. It runs in a browser window and directly manipulates the DOM.

To open a real (non-console) window in Java takes several lines of code before you can display text.

JavaScript and Java are utterly different programming languages. Google it.

@skythecoder: I might not learn enough on Java. But I’ve worked using Java for about 3 years as a professional programmer. And learn Java long enough before that. I’m not using it anymore on the last 8 years though. Yet I still stand on my opinion: Java sucks. :slight_smile:

Being used widely, both in term of developers and architectures, doesn’t mean Java is a good language. There are many factors that made a programming language becomes popular, despite the flaws. PHP is another bad language that (luckily) got very popular. It’s even worst than Java.

@Luatee - Yup, Procoding is JavaScript.