Image Image Image




Post new topic Reply to topic  [ 86 posts ]  Go to page 1, 2, 3, 4, 5  Next
Author Message
 Post subject: Yet Another Language War
PostPosted: Mon Sep 21, 2009 7:20 pm 
Offline
Senior member
User avatar

Posts: 120
Favourite Bot: mine, in writing
indiana wrote:
Java is much better than C for botting.


I won't start a language war.
I won't start a language war.
I won't start a language war.

:xx16


Top
 Profile E-mail  
 
 Post subject: Re: Write his own bot in java: Existing framework ?
PostPosted: Mon Sep 21, 2009 7:25 pm 
Offline
PokerAI fellow
User avatar

Posts: 7731
Favourite Bot: V12
Well this wasn't a general language statement. There are still applications for which C++ if better over Java and C#, but it's definetly not better for developing bots.

_________________
indiana


Top
 Profile E-mail  
 
 Post subject: Re: Write his own bot in java: Existing framework ?
PostPosted: Mon Sep 21, 2009 7:27 pm 
Offline
Senior member
User avatar

Posts: 120
Favourite Bot: mine, in writing
Well I'm not going to tell you that this or this language is better, because to be honest I don't know.

But that seems like a very strong statement. If you're referring to ease of development I'd say that it depends... and it is certainly not true if your experience is C++ and not Java. If you're referring to speed, I'd have a hard time agreeing with you (although to be perfectly fair we'd need to compare 2 identical implementations in the same language).


Top
 Profile E-mail  
 
 Post subject: Re: Write his own bot in java: Existing framework ?
PostPosted: Mon Sep 21, 2009 7:36 pm 
Offline
PokerAI fellow
User avatar

Posts: 7731
Favourite Bot: V12
sob wrote:
Well I'm not going to tell you that this or this language is better, because to be honest I don't know.

But that seems like a very strong statement. If you're referring to ease of development I'd say that it depends... and it is certainly not true if your experience is C++ and not Java. If you're referring to speed, I'd have a hard time agreeing with you (although to be perfectly fair we'd need to compare 2 identical implementations in the same language).


Well, if someone is used to a particular language then switching to another is always hard. If you are profficient in Pacscal, switching to C and C++ is painfull (but worth it). So for some people it might be the same with C++ and Java.

It's a strong statement, but also based on the adoption of the languages nowadays. Java is the most used language - people wouldn' do that for now reason. Java is superior over C++ for algorithmic applications, client/server or apps that involve threading, etc. Microsoft wouldn't build C# to copy best of Java if this wasn't the case :)

I have also personally developed in both so this also pretty much reflect my personal experience.

_________________
indiana


Top
 Profile E-mail  
 
 Post subject: Re: Write his own bot in java: Existing framework ?
PostPosted: Mon Sep 21, 2009 7:51 pm 
Offline
Senior member
User avatar

Posts: 120
Favourite Bot: mine, in writing
C# and Java have clear advantages over C++.
And they're both of the same kind.

Now I would have to agree that Java is better than C/C++ for ease of development.

Regarding speed/algorithmics... I would have to strongly disagree (being myself an experienced programmer in both).

Let's leave it at that :)



(btw for the 7 card Hand Eval contest, is the C implementation of the #1 not faster than its Java counterpart?)


Top
 Profile E-mail  
 
 Post subject: Re: Write his own bot in java: Existing framework ?
PostPosted: Mon Sep 21, 2009 8:01 pm 
Offline
PokerAI fellow
User avatar

Posts: 7731
Favourite Bot: V12
sob wrote:
Regarding speed/algorithmics... I would have to strongly disagree (being myself an experienced programmer in both).

I don't think C++ is faster over Java if you code the same thing (some simple algorithm, e.g.) in both languages. Java is basically compiled to native code, so no really difference to a C++ compiled code.

P.S. wrt the 7card evaluator thread, I did this comparison with one of the slower ;) evaluators (mine), so I coded it in C and java, and performance was the same.

_________________
indiana


Top
 Profile E-mail  
 
 Post subject: Re: Write his own bot in java: Existing framework ?
PostPosted: Mon Sep 21, 2009 8:59 pm 
Offline
Regular member
User avatar

Posts: 59
Location: Belgium
Favourite Bot: Estéban
indiana wrote:
I don't think C++ is faster over Java if you code the same thing (some simple algorithm, e.g.) in both languages.


The algorithm itself might be almost the same speed, but, if you write decent c(++), memory management is much faster (lot less overhead) than in Java to name one of the C(++) advantages.
Don't understand me wrong, I have been working as a java consultant for quite some time, and I'm just in love with the language... but for programming tasks where you have to get the absolute maximum out of your performance, I still use c++.
However, if you're experienced with Java you probably write Java code which runs much faster than the C(++) code written by an average programmer. On the other hand will code written by an experienced C++ programmer always run faster than equivalent Java code (on the long term if lots of iterations are used) because the footprint is a lot smaller.

A huge advantage of Java is off course that you can write the same application in only half the amount of time, with half the amount of bugs :)

Anyway, I also have no intend to start a language discussion, as I love both C++ and Java (while I dislike C# for that matter, but that's probably because I never really used it for a real project).

_________________
The most prolific period of pessimism comes at twenty-one or thereabouts, when the first attempt is made to translate dreams into reality. -- Broun, Heywood


Top
 Profile E-mail  
 
 Post subject: Re: Write his own bot in java: Existing framework ?
PostPosted: Mon Sep 21, 2009 9:07 pm 
Offline
PokerAI fellow
User avatar

Posts: 7731
Favourite Bot: V12
I agree that memory management might be better, if you manage it yourself, rather then relying on a garbage collection. However doing that over big codebase is almost impossible. And there are also techniques in Java (like pooling objects) that can eliminate the negatives from Garbage collection. Of course, if you have so critical pieces of code that has to be of extreme performance, you wouldn't use objects in these in the first place, but rather byte[], and then we are back to the same performance.

Instead of arguing, I should rather [re]post this comment from a subforum few days ago :)

Quote:
To be quite honest, I am pretty amazed at the tricks I had to pull out of my hat to get my c++ library to compete with the java code speed-wise. I've always been a bit prejudiced about java's speed, but apparently modern java can be really fast. Good to know


But OK, now we are turning this to a language discussion :)

I only argued that Java/C# is better for bot development.

_________________
indiana


Top
 Profile E-mail  
 
 Post subject: Re: Write his own bot in java: Existing framework ?
PostPosted: Tue Sep 22, 2009 2:35 pm 
Offline
New member
User avatar

Posts: 4
Favourite Bot: proprietary
Hello, first post ;) I want to share my opinion on the language question.

As java is compiled to the java byte code (and C# to CIL) which is at execution time interpreted by the JVM and "live-translated" into native processor commands, it is certainly true that java has disadvantages in speed. But java development is (imo) more efficient not only due to memory management and garbage collection but due to the fact that it is a strong typed language. Most IDEs will discover type errors at programming time whereas in c/++ such problems will lead to runtime exceptions.

However, most problems with "speed" are results of bad implementations. Famous example: the sum of 1 to N can be calculated like
for (i=1..N) { sum += i }
or better
sum = N*(N+1)/2
I know, everybody knows that example ;) Still it holds that the (slight) performance advantage of one or the other language is neglectible if you can optimize an algorithm from complexity O(n^2) to, lets say, O(n log n).

And if there is a large iteration that cannot be avoided/optimized, there always the possibility of integrating native libraries into (more comfortable) languages. Why don't code a library of rules and representation of hands and tables in one language while using highly optimized native libs (e.g. Pokersource poker-eval) for hand evaluation and other computationally complex issus?

In the end it is allways a matter of personal preference and of what other (open source) solutions/parts should be used.

Cheers


Top
 Profile E-mail  
 
 Post subject: Re: Yet Another Language War
PostPosted: Tue Sep 22, 2009 3:14 pm 
Offline
PokerAI fellow
User avatar

Posts: 1239
Favourite Bot: my bot
AFAIK C and C++ don't do array bounds checking, but Java does. C# lets you choose. I'd guess that makes some difference to speed if you are doing lots of work with arrays.


Top
 Profile E-mail  
 
 Post subject: Re: Write his own bot in java: Existing framework ?
PostPosted: Tue Sep 22, 2009 5:34 pm 
Offline
Regular member
User avatar

Posts: 59
Location: Belgium
Favourite Bot: Estéban
fish wrote:
Hello, first post ;) I want to share my opinion on the language question.
As java is compiled to the java byte code (and C# to CIL) which is at execution time interpreted by the JVM and "live-translated" into native processor commands, it is certainly true that java has disadvantages in speed.


Java has been using JIT compiling for quite a while now... so no more bytecode interpreting. Bytecode is translated to native code once before the very first execution of the instruction.

fish wrote:
But java development is (imo) more efficient not only due to memory management and garbage collection but due to the fact that it is a strong typed language. Most IDEs will discover type errors at programming time whereas in c/++ such problems will lead to runtime exceptions.


I personally don't find that a very convincing argument. However, I agree that development in Java is easier/faster and in my opinion that's just because Java is an object oriented language while C++ is not (no it is not! :))

fish wrote:
However, most problems with "speed" are results of bad implementations. Famous example: the sum of 1 to N can be calculated like
for (i=1..N) { sum += i }
or better
sum = N*(N+1)/2


Absolutely agree. A lot of people are profiling their application and even rewriting it in a 'faster language' while their logic itself could just be implemented more efficiently.

But in the end, I still believe that C++ is faster if you know how to use it. The disadvantages of C can usually overcome by decent design (smart pointers, exception handling, ...)
However, it's wrong offcourse to compare the performance of your algorithm using an ArrayList in Java with the performance of the same algorithm using a native array in C... The only reason why C might be faster than Java, is that you have the power to control low level shizzle, while you simply don't have that amount of power in Java (which is a good thing in most situations). If you know what you're doing, you can write extremely efficient algorithms in C, easily incorporating assembly lines, accessing hardware resources without the need for an intermediate layer, etc.

That said, for most applications I would prefer Java, but for botting (and image processing/computer vision), I'm a passionated C++ fan :)

_________________
The most prolific period of pessimism comes at twenty-one or thereabouts, when the first attempt is made to translate dreams into reality. -- Broun, Heywood


Top
 Profile E-mail  
 
 Post subject: Re: Yet Another Language War
PostPosted: Tue Sep 22, 2009 6:26 pm 
Offline
PokerAI fellow
User avatar

Posts: 7731
Favourite Bot: V12
For me C++ is almost at the level of assembler already - I will use it - if I must to, otherwise I wouldn't bother with it.

The speed argument is all myth. Java is as fast as C++. If someone doesn't believe it, he should simply try it out :)

For botting Java is much better, mainly you have straightforward java.awt.Robot class that gives all you need w.r.t. input/output (and does NOT give you a lot of things that you should realy not use), plus it's just more productive language, easier to debug, etc. Dealing with low level process crashes is so much 199x :)

_________________
indiana


Top
 Profile E-mail  
 
 Post subject: Re: Yet Another Language War
PostPosted: Tue Sep 22, 2009 6:40 pm 
Offline
Senior member
User avatar

Posts: 120
Favourite Bot: mine, in writing
So it looks like I *did* start a language war after all.

I'd be curious though to see the execution time of the following algorithm.


- create a 1024x65536 matrix of double (32bit precision) // time series with 65536 observation points over 1024 components
- fill it with random numbers ~N(0,1)
- calculate its correlation matrix


There's not a thousand ways to do it.

But I'd _really_ be curious to see who's faster.


Top
 Profile E-mail  
 
 Post subject: Re: Yet Another Language War
PostPosted: Tue Sep 22, 2009 6:51 pm 
Offline
PokerAI fellow
User avatar

Posts: 7731
Favourite Bot: V12
Well, then do it - I think the code will be almost 100% portable (the same) between C & Java if you want to do this rigth away. If you start to optimize like play around with data representations and so on it will differ.

For me the hand evaluator example was always representative for poker, and out of the box measurements produced same performance for C++ and Java.

_________________
indiana


Top
 Profile E-mail  
 
 Post subject: Re: Yet Another Language War
PostPosted: Tue Sep 22, 2009 6:54 pm 
Offline
Senior member
User avatar

Posts: 120
Favourite Bot: mine, in writing
I'm doing it right now actually in C first.

You're right, it would make much more sense to try it out on a Hand Eval though... but longer and more prone to dependence on implementation.


Top
 Profile E-mail  
 
 Post subject: Re: Yet Another Language War
PostPosted: Tue Sep 22, 2009 7:07 pm 
Offline
Regular member
User avatar

Posts: 59
Location: Belgium
Favourite Bot: Estéban
execution time will be similar (in a loop at least) but that's not the way to test performance difference :)
The perceived performance difference between C++ and Java is just because in Java a programmer will work more object oriented, scalable, and will automatically adopt best practice design patterns.
In C(++) your code will almost always be less object oriented and a lot tighter (you will automatically think twice before creating a new object, because you also have to destroy it afterwards).

This causes most C++ applications to be faster than Java applications. Not because C++ is faster, but just because the programmer adopts a different coding style.

Edit: And the funny thing is that this performance difference becomes most noticable when implementing high level business logic, and not when implementing low level algorithms like sorting for instance.

_________________
The most prolific period of pessimism comes at twenty-one or thereabouts, when the first attempt is made to translate dreams into reality. -- Broun, Heywood


Top
 Profile E-mail  
 
 Post subject: Re: Yet Another Language War
PostPosted: Tue Sep 22, 2009 7:19 pm 
Offline
Senior member
User avatar

Posts: 120
Favourite Bot: mine, in writing
Actually I agree with all you said.

The proper way to test speed would be to have 2 implementations for something high level. Not low level.


Top
 Profile E-mail  
 
 Post subject: Re: Yet Another Language War
PostPosted: Tue Sep 22, 2009 8:51 pm 
Offline
PokerAI fellow
User avatar

Posts: 7731
Favourite Bot: V12
Well, I still disagree. If you code more object oriented high level business logic, then pure bytes-and-bits performance is even more ignorable, as you would anyway wait e.g. for 1 second on the DB or call a web services, and then the (potentially claimed) 0.0123 nanoseconds that you would save by coding it in C++ would be ignorable anyway.

Anyway, I can only say that if I had to decide the language I would develop my bot routines once again I would once again decide 100% for Java. Obviously people [try to] develop bots in much more crappy languages than C++, and there might be some of them that even succeeds, so the language is largely not the decisive factor of how successfull you would be.

_________________
indiana


Top
 Profile E-mail  
 
 Post subject: Re: Yet Another Language War
PostPosted: Tue Sep 22, 2009 11:07 pm 
Offline
Regular member
User avatar

Posts: 59
Location: Belgium
Favourite Bot: Estéban
indiana wrote:
Well, I still disagree. If you code more object oriented high level business logic, then pure bytes-and-bits performance is even more ignorable, as you would anyway wait e.g. for 1 second on the DB or call a web services, and then the (potentially claimed) 0.0123 nanoseconds that you would save by coding it in C++ would be ignorable anyway.


That's not what it is about... High level actually means higher form of abstraction, and in essence you loose information when you abstract. This means that going from an abstraction to the actual implementation (business model -> machine code) is basically reverse engineering, just like a compiler 'reverse engineers' your programming code into a suitable set of instructions.
The higher your abstraction, the less likely it is that the reverse engineered result reflects the optimal solution, and that is where performance is lost.

Edit: an analogy: a denormalized datamodel is usually a lot more performant than a nice normalized datamodel. A text file (compare it with c code) is much faster than a normalised model (compare it with java)

_________________
The most prolific period of pessimism comes at twenty-one or thereabouts, when the first attempt is made to translate dreams into reality. -- Broun, Heywood


Top
 Profile E-mail  
 
 Post subject: Re: Yet Another Language War
PostPosted: Tue Sep 22, 2009 11:26 pm 
Offline
PokerAI fellow
User avatar

Posts: 7731
Favourite Bot: V12
I didn't picked up on the higher level term, I picked up on the business logic one.

Well, let's leave this thread to rest. Java vs C++ is kind of question that can't be resolved. Such questions are solved only by time :), C++ getting less and less used over time, and Java (and the laguages after it) getting more and more used, for good reasons.

You can't make me not recommend Java/C# as a better language for botting, and I can't make you drop C++ (If I look back 15y ago, it was a pain in the ass for me to drop Pascal in favor of C, so I can imagine the feelings).

Image

_________________
indiana


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 86 posts ]  Go to page 1, 2, 3, 4, 5  Next


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: