Friday, February 15, 2013

Group tutorial: Coding with Javascript

Here's the site for reference to what I'm talking about.  link

I'm familiar with coding in Java, importing classes and checking syntax, but Javascript appears to be riddled with more advanced knowledge and methods that would appear to be illegal.  For example, in Java, this is an average section of code:

public class Banana()  //Must declare the class first.  Also, the filename and class name must match.
{
     String ohai="ohai";
//Syntax is key; remember the semicolon at the end.
     System.out.println(ohai);
//Here it outputs a String, named ohai, and set to "ohai".  (I would follow grammar rules on that period, but that would mean something entirely different in programming terms.)
}  //Remember these things.  They must go outside a method.  By the way, the double slash marks mean that the text following them is not active code, unless it is a method calling a file location.

In Javascript, we get this lovely mayhem:

function Update()
{
     transform.Translate(0,0,Time.deltaTime);
     transform.Translate(0,Time.deltaTime,0,Space.world);
// Having the two methods as shown is legal in Java; I just didn't show that in the first example.   However, methods like "Time.deltaTime" would be illegal, as they lack parentheses at the end.  Also, there is no simple (commonly denoted by all lowercase) class in Java named "function."  While one can create a more complex class with all lowercase letters, but this is not recommended to avoid confusion.
}

Also, sometimes you get code that reads "something :: random."  This is not taught in high school programming courses (I am not declaring a class), and thus my personal experience is minimal.

So if I'm helping with programming our game, I'll need to acclimate myself to the insanity of simplicity, and lack of easy modification options.  Joyous. :(

No comments:

Post a Comment