GLB vs C

Previous topic - Next topic

Robert

For what Im programming GLB is perfect but I wonder if I could get better performence if I did my programs directly in C whit SDL or something or if I could gain much by do more in inline. How much is it between GLB and the C code it produce? I do some AI stuff and it is really importent that it is not a factor 10 or more slover than it need to be.

bigsofty

The C transcoding in GLBasic is actually pretty efficient.

A quick tip to examine the C code.

Type this in your function...

Code (glbasic) Select
INLINE
BLAH
ENDINLINE


This will cause an error in the compilation of the transcoded C code. Double click on the error line number in the console pane. This will take you to the C code and the function that you were in when you typed the BLAH error. You can now examine the C code and make your own mind up whether it needs inlining. Remember to close the C code though before the next compile as the IDE won't update it again.

Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Robert

It looks rather direct but I im not so skilled in C that I can get in to to much detail.

I am one of the basic mutilated persons that you refer to in your signature so I rather want to stick to GLB but with C you at least dont have to deal with oop. 

bigsofty

#3
GLB actually produces C++ but rest assured that 99% of the time, GLB creates C++ code that's as efficient as coding in C++ from the start. It produces very fast code in my experience!  ;)
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Robert

I think so to partly because it doesn't seems to do så much error checking. If you get to many element in to an array for example the programs just terminates. I like that crude simplicity and I hope and belive it also means its fast.

UBERmonkeybot

Have you turned debug on?

Robert

No but I really don't need it. It only terminates when a array go out of scope and other errors I have my own methods to find. But to be fair I guess it doesn't have to be that way if you use debug.

r0ber7

Quote from: Robert on 2016-Apr-03
I do some AI stuff and it is really importent that it is not a factor 10 or more slover than it need to be.
:offtopic:
Neural networks? If you're considering switching to a different language for AI, Python is the best language. A lot of academics work with it, which are basically the same people that do a lot of AI. There are tons of modules.

https://wiki.python.org/moin/PythonForArtificialIntelligence

You could run a python API, and have a GLBasic client.

Robert

Quote from: r0ber7 on 2016-Apr-04

Neural networks? If you're considering switching to a different language for AI, Python is the best language. A lot of academics work with it, which are basically the same people that do a lot of AI. There are tons of modules.

https://wiki.python.org/moin/PythonForArtificialIntelligence

You could run a python API, and have a GLBasic client.


Im playing with a boardgame - five in a row for testing but I plan to use the principles for other games to - and when I made it playing with it self for learnig I just use the term AI for it.

I will sure check out Python for it. How do you use GLB as a client btw?

kanonet

I cant imagine a scripting language like python to be faster than natively compiled languages like C/C++. I think they just use it, because its easier for them and still fast enough. Generally I would advice you to simply write your code and benchmark it, thats the best way, if you want to know the performance.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Robert

Quote from: kanonet on 2016-Apr-05
I cant imagine a scripting language like python to be faster than natively compiled languages like C/C++. I think they just use it, because its easier for them and still fast enough. Generally I would advice you to simply write your code and benchmark it, thats the best way, if you want to know the performance.

No I don't think it is fast enough for what I'm doing but it was the part with using another language -like GLB - as a client that made me interested. But I don't really know what that means.

kanonet

Generally GLBasic allowes the usage of net sockets, so you can use this to allow commuication with other apps, no matter how they were written (as long as they use web sockets too).
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Robert

Ok you mean client in that way. That could be useful.

spacefractal

GlBasic compiles to c++ internally. Glbasic its self was wrote in c++.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

r0ber7

Quote from: Robert on 2016-Apr-05
Ok you mean client in that way. That could be useful.

Yeah, like, the AI part of Siri doesn't run on your phone either.  :)