Author Topic: GLB vs C  (Read 4104 times)

Offline Robert

  • Mc. Print
  • *
  • Posts: 34
    • View Profile
GLB vs C
« on: 2016-Apr-03 »
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.

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2696
    • View Profile
Re: GLB vs C
« Reply #1 on: 2016-Apr-03 »
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)

Offline Robert

  • Mc. Print
  • *
  • Posts: 34
    • View Profile
Re: GLB vs C
« Reply #2 on: 2016-Apr-03 »
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. 

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2696
    • View Profile
Re: GLB vs C
« Reply #3 on: 2016-Apr-04 »
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!  ;)
« Last Edit: 2016-Apr-04 by bigsofty »
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)

Offline Robert

  • Mc. Print
  • *
  • Posts: 34
    • View Profile
Re: GLB vs C
« Reply #4 on: 2016-Apr-04 »
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.

Offline UBERmonkeybot

  • Mr. Polyvector
  • ***
  • Posts: 243
    • View Profile
Re: GLB vs C
« Reply #5 on: 2016-Apr-04 »
Have you turned debug on?

Offline Robert

  • Mc. Print
  • *
  • Posts: 34
    • View Profile
Re: GLB vs C
« Reply #6 on: 2016-Apr-04 »
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.

Offline r0ber7

  • Prof. Inline
  • *****
  • Posts: 550
    • View Profile
Re: GLB vs C
« Reply #7 on: 2016-Apr-04 »
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.

Offline Robert

  • Mc. Print
  • *
  • Posts: 34
    • View Profile
Re: GLB vs C
« Reply #8 on: 2016-Apr-05 »

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?

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: GLB vs C
« Reply #9 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.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Offline Robert

  • Mc. Print
  • *
  • Posts: 34
    • View Profile
Re: GLB vs C
« Reply #10 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.

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: GLB vs C
« Reply #11 on: 2016-Apr-05 »
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

Offline Robert

  • Mc. Print
  • *
  • Posts: 34
    • View Profile
Re: GLB vs C
« Reply #12 on: 2016-Apr-05 »
Ok you mean client in that way. That could be useful.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3929
    • View Profile
    • Space Fractal
Re: GLB vs C
« Reply #13 on: 2016-Apr-06 »
GlBasic compiles to c++ internally. Glbasic its self was wrote in c++.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation and The beagle Jam.

Offline r0ber7

  • Prof. Inline
  • *****
  • Posts: 550
    • View Profile
Re: GLB vs C
« Reply #14 on: 2016-Apr-07 »
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.  :)