Page 1 of 2

Why java?

Posted: Wed Apr 07, 2010 3:43 am
by Crom
Hi, i'm prepearing some servers of others games and these emulators all are made in C++, why you prefer java?

As i know C++ is more stable, "powerfull" and "easy" to work, i said easy becausein C++ or work or not.
An emulator on C++ or C# aren't be "better"?

Re: Why java?

Posted: Wed Apr 07, 2010 5:21 am
by ThePhoenixBird
This has to do with some L2j history:
  • Project L2j was started by l2chef as a way to "learn" java stuff... nowdays... you see what it has become...
  • C++ or C# is not better than Java, either Java is not better than C++ or C#, you only need to know how to program efficiently to get an efficient application it doesnt matter the language you use, that is why we are so strict with contributions.
  • C++(80's) is older than Java (90's) so OldSchool programmers learned it on the college as the mighty stuff, nowdays you can still see people that says that C++ is the best... but did they really have seen on other languages? did they really have learned about Java or they just dont care to learn another programming language (programmer hell's nightmare) since they have been using the same old one for more than 30 years because is the one that they learned on the college and the one they know the best...

Re: Why java?

Posted: Wed Apr 07, 2010 8:25 am
by antons007
i am learning c# on college and here java :D

Re: Why java?

Posted: Wed Apr 07, 2010 8:56 am
by BiggBoss
platform-independient

Re: Why java?

Posted: Wed Apr 07, 2010 12:10 pm
by rocoder
BiggBoss wrote:platform-independient
+1 :mrgreen:

btw http://www.idiom.com/~zilla/Computer/ja ... hmark.html

Re: Why java?

Posted: Wed Apr 07, 2010 1:24 pm
by Vapulabe
Why use Java

1) Cross platform
Perl, PHP, Python, Java, Tk/TCL are all cross platform languages.
Despite Microsoft pretending the opposite, C# (and whole .NET/IL stack) is NOT cross platform dur to some core libraries which only exists on Microsoft windows

2) Helps keeping the program clean
No multiple inheritance, no pointers and some other java's features help you to NOT do spaghetti code.
Some say that python does the same because it forces you to properly indent code... which is plainly non-sense. A simple missing tab may be an algorithmic error without triggering a syntax error (unlike C/C++/Perl/Java/PHP/... with their { } pairs)
Using implementation instead of multiple inheritance give you ONE axis to follow to find inherited functions (and no problem of function defined in multiple parent classes)
No pointers means no tricky pointer arithmetic, the first cause of error in C/C++
Exception mechanism force you to explicitely manage all exception returned (either using try/catch or returning it to caller function)
Javadoc *should* help you create a proper class documentation (well, L2J don't have any javadoc) which is an important reference document when other people join the project (DOxygen allow the same under many other langages like C/C++/PHP/Perl/...)

3) Slow startup but runs quite fast.
The impression that Java is slow comes from the startup which takes some time. But a server should (nearly) never restart so that is a one time problem...
Once Java is running, it's quite fast. Some big profile web sites use JSP and Java servlets.

4) Safe language
Java runs in a virtual machine. You may create security profiles and such to further restrict what the program can do, the JAR file can be signed,...
I don't know how it'll be going, but during SUN time (before buyout by Oracle), security in JVM has always be the uppermost priority, before bells and whistles (unlike some other software companies)

5) freely available
Some langages require a rather expensive developping environment that most people don't have available (Windev anyone ?), Java developper kit is free.

Java vs other languages

C/C++ :
lots of portability problems for the network access... Many libraries may come to your help and offset that problem.
Pointers are a real nightmare... and lead to many errors (and remote exploits)

PERL :
PERL is great... but you'll have some trouble finding people who can do good programming in PERL... Also, it's a rather difficult to learn langage (with lots of implicit variable magic and such)

PHP :
while it's well used on the web, it's nearly never used for stand alone applications. It's quite simple to use but I doubt it'll behave well for a crowded server... although it should be possible to do it.

C# :
Basically, it's nothing other than a bastardized Java which lose it's cross-platform aspect.

Python :
Python is easy to program, and easy to make obscure errors that will take hours to find...

Code: Select all

 if (a==b) :  if (c==d) :    f1()    f2() if (a==b) :  if (c==d) :    f1()  f2() 
Both snippets are valid and won't trigger the syntax analyser... first call the 2 functions if a=B AND c=d. second call the first function if a=b and c=d then the second if a=b. Only difference is A WHITE SPACE !!!

there are other problems with python, but this one is the more serious for any project which will lead to big and complex code.

Re: Why java?

Posted: Thu Apr 08, 2010 10:25 pm
by poltomb
Vapulabe wrote:C# :
Basically, it's nothing other than a bastardized Java which lose it's cross-platform aspect.
Not anymore :)
http://mono-project.com/Compatibility
There are some things in C# that I like much better in java (like namespaces vs packages and partial classes)

And agree for the other languages. In addition, PHP and PERL are interpreted languages, making them a bit slower than intermediate language (bytecode/cil) and true machine code.

Re: Why java?

Posted: Fri Apr 09, 2010 1:42 am
by Crom
Ok, if i understand well the best code for a project like that is java because is a cross plataform languaje and it's free, yes?

DELPHI, Kobold, unix and these are not posible options?

Re: Why java?

Posted: Fri Apr 09, 2010 6:39 am
by rocoder
DELPHI cross platform?? :O
Kobold <---first time when I heard

Re: Why java?

Posted: Fri Apr 09, 2010 7:21 am
by Aikimaniac
Crom wrote:Ok, if i understand well the best code for a project like that is java because is a cross plataform languaje and it's free, yes?

DELPHI, Kobold, unix and these are not posible options?
unix :shock:

Re: Why java?

Posted: Fri Apr 09, 2010 8:54 am
by BiggBoss
Crom wrote:Ok, if i understand well the best code for a project like that is java because is a cross plataform languaje and it's free, yes?

DELPHI, Kobold, unix and these are not posible options?
unix is a kind of operative system, based in users privilegies

http://en.wikipedia.org/wiki/Unix

Re: Why java?

Posted: Fri Apr 09, 2010 1:54 pm
by poltomb
rocoder wrote:DELPHI cross platform?? :O
Kobold <---first time when I heard
I think he meant cobol: http://en.wikipedia.org/wiki/COBOL

Re: Why java?

Posted: Fri Apr 09, 2010 3:13 pm
by Crom
rocoder wrote:DELPHI cross platform?? :O
Kobold <---first time when I heard
I didn't say DELPHI wass a cross plataform...
BiggBoss wrote:unix is a kind of operative system, based in users privilegies

http://en.wikipedia.org/wiki/Unix
Thx for the info ^_^
poltomb wrote:I think he meant cobol: http://en.wikipedia.org/wiki/COBOL
Yeah, sorry i'm a D&D player xDDDD

Re: Why java?

Posted: Fri Apr 09, 2010 4:55 pm
by Vapulabe
poltomb wrote:
Vapulabe wrote:C# :
Basically, it's nothing other than a bastardized Java which lose it's cross-platform aspect.
Not anymore :)
http://mono-project.com/Compatibility
There are some things in C# that I like much better in java (like namespaces vs packages and partial classes)
Well, compatibility is still partial as C# also has a big part open for Native (windows) Code, Managed DirectX and other calls to windows API which have no sense under Linux.

It's true that core C# can be used under Linux... But not all the langage... That's why you find GTK and QT bindings to C# (to allow some cross platform).
poltomb wrote:And agree for the other languages. In addition, PHP and PERL are interpreted languages, making them a bit slower than intermediate language (bytecode/cil) and true machine code.
Well, not really true... When a PHP script is executed, it's first compiled to an intermediate langage (resulting code can be cached by PHP accelerators and I think that it may also be saved for futher faster execution) and as far as I know, PERL is also compiled JIT

Re: Why java?

Posted: Wed Jun 16, 2010 9:32 am
by Naminator_X_
The fact that Java runs in virtual environment makes it slow. That virtualization costs. Yet you need a lot more than 2-3k people to stress a quad core xeon in virtualization still in C/C++ you would've achieved greater performance IF you have proper garbage collector. Question - why are there no accurate hardware benchmarks written in Java ? :)

I admit it is REALLY powerful language but in performance doesn't stand a chance vs "old school". The PROs of java is that it is outstanding in rapid programming...i mean...something that takes you day or two in java takes like a week in C++ with all that testing and debugging...

P.S: L2 server could be done cross-platform in C/C++. After all it doesn't require much of OS assistance (i don't see where i will need Win32 API for example)...in my eyes servers should be running only on linux/unix boxes...windows is for playing the game "and doing spreadsheets" (:D like in Mac ads) thus this will decrease the number of noob servers which you have to agree with me...lower the judgement of lineage.

I had this situation once. I talked with a friend of mine and he told me that WoW (LoL) is better than Lineage ][ and i was like :shock: :shock: :shock: ....ok...as an old forum troll i asked him why...why that piece of sh.it is better than L2...his answer was that WoW servers are better and have most of the game working (btw WoW servers are done in C++ :) )...and i was like lol..."that's a reason" but in some weird way he is actually right. There are MANY crappy servers...actually most of the servers are crappy...there are few good ones with serious and dedicated admins. Though im going much offtopic i must agree that sometimes it is up to the developer :) If you know code optimizations i dont really think you'll notice any performance issues until you get like...10k players but that didn't happen even in retail (maybe in korean...damn koreans :D )