Jump to content

  • Log In with Google      Sign In   
  • Create Account

java or javascript?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 Dalphin   Members   -  Reputation: 192

Like
0Likes
Like

Posted 09 June 2014 - 03:23 PM

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 



Sponsor:

#2 slicer4ever   Crossbones+   -  Reputation: 3883

Like
6Likes
Like

Posted 09 June 2014 - 04:19 PM

learn a language first, learn the fundamentals of programming first.  this knowledge will translate to nearly any other language.  languages have different programming paradigms, syntax, and usages. but if you understand the fundamentals of programming, picking up a new language will be far less daunting then when you learn your first language.

 

as to the two languages you are asking about, Javascript is manly used by browers, so it's likely you'll be learning html/css along with javascript to do things with it.  you'll be at the mercy of w/e browser you are using, but starting out this might be a good thing.  your not going to be making the next FPS anytime soon, so you shoudn't be worrying about performance, or the backend of rendering code atm, so javascript would get you an existing platform to branch out from.  that said, only modern browsers support things like canvas with HTML5 to make full games in, and they leave quite a bit to be desired.

 

Java on the other hand is ran by the JVM(Java Virtual Machine), that many computers have on them, so you'd likely be able to distribute your games without too much issue. Java and Javascript are nothing alike in terms of syntax/capability's though so don't let the name fool you(that's just a coincidence and doesn't actually mean their's any type of connection between the two.), Java is usually superior in performance to Javascript(but this is more to do with the enviroment javascript is usually found in).  Java also has a massive library with tons of documentation, so you'll be able to use many wrapper librarys to get games up and running pretty easily.

 

But my opinion is to pick one, and learn it, learn it well before moving on.


Edited by slicer4ever, 09 June 2014 - 04:25 PM.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#3 xDarkShadowKnightx   Members   -  Reputation: 398

Like
-2Likes
Like

Posted 09 June 2014 - 08:53 PM

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, 12 June 2014 - 09:00 PM.


#4 Truerror   Members   -  Reputation: 454

Like
6Likes
Like

Posted 09 June 2014 - 09:13 PM

First of all, there's a misunderstanding I'd like to clear up. Unity does not use JavaScript. It uses UnityScript. There are some fundamental differences between these two. JS is interpreted (most of the time), while UnityScript is JIT-compiled, as it runs on the .NET/Mono platform. As such it has access to .NET/Mono's standard library. It also support generics (though you can't make your own generics, AFAIK). Unity supports 3 languages: UnityScript, Boo (a Python-like language) and C#. All three runs on .NET/Mono, so speed is mostly not an issue in choosing your preferred language. However, if you think Java is hard, then C# would be as hard. On the other hand, if you do know Java, C# is your best choice. They are so similar to each other that an intermediate Java/C# programmer could learn the other in less than a week.

 

@xDarkShadowKnightx, IMHO the only similarity between their syntax is the brackets. How they declare functions are different. How they handle classes are different. JavaScript isn't even strongly-typed.

 

Oh, btw, I read somewhere that the naming wasn't a coincidence. The 'java' in JavaScript actually did come from Java the language. Supposedly, it was done to attract attention to the then-new language.



#5 Buster2000   Members   -  Reputation: 1662

Like
5Likes
Like

Posted 10 June 2014 - 01:48 AM


Contrary to what slicer4life just said, Java and Javascript do actually share a lot of similarities when it comes to their syntax.

 

This is only true when you read a few chapters from a beginners Javascript book.  Once you get into writing real Javascript apps you will soon find that apart from a few shared keywords there is very little similarity.  A lot of large javascript code bases that I have seen look a lot more like lisp than Java.  Also modern Javascript coders tend to use a lot of JQuery which makes it almost unrecognizable.

 

Javascript, UnityScript and ActionScript are all actually variations of ECMAScript.  Javascript used to be interpreted but nearly all modern browser Javascript engines use some form of JIT.  For all intents and perposes UnityScript is Javascript.

 

Truerror is correct Javascript has "java" in its name as a marketing ploy from Netscape.



#6 fir   Members   -  Reputation: -460

Like
-1Likes
Like

Posted 10 June 2014 - 12:32 PM

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 ?



#7 DavitosanX   Members   -  Reputation: 271

Like
1Likes
Like

Posted 10 June 2014 - 02:39 PM

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.


Starting out in game programming? Me too! Check out my blog, written by a newbie, for the newbies. http://myowngamejourney.blogspot.mx/


#8 fir   Members   -  Reputation: -460

Like
0Likes
Like

Posted 10 June 2014 - 02:48 PM

 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)



#9 DavitosanX   Members   -  Reputation: 271

Like
1Likes
Like

Posted 10 June 2014 - 04:24 PM

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, 10 June 2014 - 04:24 PM.

Starting out in game programming? Me too! Check out my blog, written by a newbie, for the newbies. http://myowngamejourney.blogspot.mx/


#10 fir   Members   -  Reputation: -460

Like
-2Likes
Like

Posted 10 June 2014 - 05:12 PM

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, 10 June 2014 - 05:17 PM.


#11 Satharis   Members   -  Reputation: 961

Like
0Likes
Like

Posted 11 June 2014 - 06:15 AM

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.

#12 DavitosanX   Members   -  Reputation: 271

Like
0Likes
Like

Posted 11 June 2014 - 06:40 AM


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.


Starting out in game programming? Me too! Check out my blog, written by a newbie, for the newbies. http://myowngamejourney.blogspot.mx/


#13 Buster2000   Members   -  Reputation: 1662

Like
0Likes
Like

Posted 11 June 2014 - 07:05 AM


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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS