DEV Community

Mario_V
Mario_V

Posted on

Phase 1 FlatIron

Hello to whoever is reading this so for the first phase at Flatiron I will talk about how different programming with JavaScript and HTML when compared to C# in Unity, at least to me. So to begin with creating a script in Unity regardless of whether it's in 2D or 3D has a default template while JavaScript does not and as far as I know doesn't need one since the script you're writing can vary depending on the project you are working on. HTML probably has the same case although I believe there are plugins to have the very basics like <!DOCTYPE HTML> and the

and elements in the script by default but just like JavaScript the rest of the script will most likely look very different when compared to another HTML script from a different project. Another comparison I would like to make is between Unity methods and JavaScript functions they're both used only when called by another part of the script, and they're both used to hold code that will more than likely get repeated and can both take in different parameters that they will need to use to return the right outcome. The biggest difference between the two of them is the fact that in Javascript functions need to be declared with the word function followed by their name paratheses parameters if you need them and brackets while in Unity methods are declared with either void if they return nothing or the datatype they need to return followed by it's name with parentheses, parameters and brackets. Then there were how different and similar variables were, of course, there were still integers, floats, booleans, and strings but not in the same way in Unity you declare a variable with its assigned datatype meaning it can only ever be an integer or one of the others and to be fair you can change it by using a method similar to parse float or int but you would then need to store that value in a new variable to use it. And in Javascript that isn't the case so far we have only been using const or let which can be any datatype and change between them which made writing in Javascript a little difficult since I wasn't used to writing code that way. The last comparison and the most interesting one to me is how the scripts themselves run, Unity code can only run if it is called or written between one of the main methods that run code, like void start or void update, this also makes it easier to structure code and read since if you know what you're trying to find know where to look. On the other hand, JavaScript can be written, at least to my current knowledge, anywhere of course there are ways to structure it on your own like making sure variables are made before they are called or else you won't be able to use them. Because of this during the first week writing in JavaScript was pretty difficult because I wasn't sure where some lines, functions, and variables should go.

Top comments (0)