• Advertisement
Sign in to follow this  

java or javascript?

This topic is 1320 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone,

I want to make a game quite a time.

Eventually i want to make a FPS.

I know i have to start small and that's what i'm gonna do, but i do have a question.

I can start learning java, then i'm gonna start really small and become bit by bit better and use eventually an

engine like unreal or cry. But i read on the internet that unity is a more easy than those other engine, but it uses javascript. (probably more easy to learn to. Personally i think you can do more if you can program in Java, but it is the hard way and i tried it a few years ago and it was really hard for me. My question is: which one should i learn: java, or javascript? And if you have some other usefull information or tips, i would be glad to hear it.

Thanks 

Share this post


Link to post
Share on other sites
Advertisement

Contrary to what slicer4life just said, Java and Javascript do actually share a lot of similarities when it comes to their syntax. They both derive heavily from the C language and a lot of what you'll learn in Javascript and/or Java can easily transfer over to the whole C family of languages (for when/if you need to go more low level)

 

@Truerror, Really? Just the brackets? I'm pretty sure they share MUCH more than just that. Statements and flow control is basically the same, you've got 'if' and 'else' statements. While, do, and for loops, along with break and continue statements. Switch statements, which include 'case' and 'default' JUST like in C++. As for functions. Sure, its not statically typed like C++, and theirs more than one way to declare a function, but the flow of the code is very similar. Variable assignment and comparison is very similar to C++, you've got '=' to assign values and '==' to compare two (minus the ability to use pointers directly like in C++). These are just some examples of the similarities between the two languages SYNTAX (not how you declare functions or handle classes, or the fact that one is strongly typed while the other isn't).

Edited by xDarkShadowKnightx

Share this post


Link to post
Share on other sites

i would advise javascript over the java, but it is hard to argue comparsion of such complex things as im a nevbie in both, perspnaly prefer javascript

 

bTw can someone advise some short but good tutorials for javascript but focuses for canvas games writing ?

Share this post


Link to post
Share on other sites

The truth is both languages can be easy or hard, depending on what you wish to do. For scripting purposes, once you learn the syntax of the language (a one or two hour endeavor, tops) there would be little differences between them. You should concentrate on learning how to translate your ideas into instructions for the computer. You can do that in any language you want.

 

If you can use C# in Unity, go with that. It's strong-typed, which I think is important when starting out. It uses a syntax similar to Java, if I'm not mistaken, and the programming concepts you learn with it can be used in javascript, or in any other language.

Share this post


Link to post
Share on other sites

 once you learn the syntax of the language (a one or two hour endeavor, tops)

 

Its your imagination ;/ probably based on the fact that you already know this syntax, I am learning javascript basics after some 5 years of experience in c/winapi and for sure learning it is far not 2 hours (it is anyway interesting feeling learning the basic of the second language where basics of the forst i was learning and know for 10 years)

Share this post


Link to post
Share on other sites

Well, I meant to say things like:

 

- How do statements end (semicolon or no semicolon)

- How to write if's, for's and while's

- Operators

- Class and function definition

 

These are some differences between Python and C++

 

Python:

#Statements need no semicolon

print("Hello world!") #Function call. Arguments go inside parentheses. Strings go between quotes.

x = 0 # Assignment operator

#Structure of an IF

if x == 0:              # Comparison operators
    print("True")    # Forced indentation for scope, no brackets.
else:                    # Colon after if, elif, else
    print("False")

list = [1,2,3,4]

# Structure of a for loop

for item in list:
    print(item)

# Structure of a while loop

while list[0] != 1:
    print("Looping...")

# Function definition

def foo(arg1, arg2):                  #keyword def, arguments between parentheses, colon
     -- code to run --                   # Forced indentation

# Class definition

class Foo:
      def __init__(self):
            -- contructor code --
      -- define more attributes methods --

C++

// Needs main function
#include <iostream>

using namespace std; // Statements need semicolons

int main()
{
cout << "Hello World!" << endl;     // Bitwise shift operator
return 0;                           // Indentation is optional, brackets are necessary to indicate scope
}

int x = 0; // Assignment operator (strong-typed language, not syntax related, though)

// Structure of an IF

if (x == 0)
{
   cout << "True" << endl;
}
else
{
    cout << "False" << endl;
}

// For loop

for (int i = 0; i < 10; i++)
{
    // some code
}

// While loop

while (variable == value)
{
     // some code
}

// Function definition

void Foo(int arg1, bool arg2)     // starts with type, arguments between parentheses, also with type
{
    // some code
}

// Class definition

class Foo
{
      int privateAttribute;                               // Attribute

     public:

           Foo()                                                 // Constructor
           {
                  privateAttribute = 0;
           }
}

The examples might not be 100% accurate, but my point is that if you know what you're doing, syntax shouldn't be too much of a problem. How long did it take you to see the differences between the two blocks of code? And notice how syntax is consistent across the language, so the differences between a language and another tend to be consistent also.

 

A different thing is the actual use and logic of each language which can be extremely different, and it can take weeks or months to make the switch from one language to another.

Edited by DavitosanX

Share this post


Link to post
Share on other sites

you're doing, syntax shouldn't be too much of a problem. How long did it take you to see the differences between the two blocks of code? And notice how syntax is 

 

okay not important, i just wanted to say its not strictly two hours as

it may seem for some over optymistic person (if not the case you realy seen it many times and now by learning you mean finishing the gaps or relearning them, not realy learning first time)

 

even this short snippet  of python you can scan with eyes quick but you will not memorize it at first time you must make some habits/get accustomed and some other stuff (for example need to find and filter  materials to learn it also takes time,...

 

I know becouse Im learning javascript surface right now, I must find miterilals, i must rest i must repeat i must motivate myself, i must understand things are not clear,

 

 moves slow as a snail in my case - and when i asked syntax question to speed up things they didnt wanted here to answer me

Edited by fir

Share this post


Link to post
Share on other sites

The examples might not be 100% accurate, but my point is that if you know what you're doing, syntax shouldn't be too much of a problem. How long did it take you to see the differences between the two blocks of code? And notice how syntax is consistent across the language, so the differences between a language and another tend to be consistent also.

Not sure why you're even pointing any of this out because the things you pointed out are pretty much generic to all popular languages. A lot of them are concepts that came about from having to work with assembly and don't really say anything about the logic of a language.

Python and C++ might superficially seem similar, but they share as many similarities as cars and cows.

Share this post


Link to post
Share on other sites


the things you pointed out are pretty much generic to all popular languages.

 

The point I'm trying to make is that these basic concepts are what a new programmer should be learning, and just like you said, they are very much alike between languages. It doesn't really matter is the OP starts out with Java or Javascript, learning these building blocks, and most importantly the reasoning behind them, will make the transition from one to the other painless.

Share this post


Link to post
Share on other sites


The examples might not be 100% accurate, but my point is that if you know what you're doing, syntax shouldn't be too much of a problem. How long did it take you to see the differences between the two blocks of code? And notice how syntax is consistent across the language, so the differences between a language and another tend to be consistent also.

 

 

Now do the same with Scheme, R, Erlang or even Mips Asm and then tell me they look similar.  I get the point you are trying to make but you are over simplifying the issue.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement