PDA

View Full Version : ThinBasic... an alternative?



Polarwolf
13-08-2008, 17:57
Hello everyone! :)
I'm a User of PureBasic which I realy love for its speed, libs, small exe's and alot other stuff.

Yesterday I was chilling at the Forums when I read something about THINBasic. I though "What the...?" And sofortly started searching about ThinBasic and PowerBasic. PowerBasic seems to be nice but I dislike to spend a few houndred dollar if I already got a good language (PureBasic). But then I started to take a clooser look at ThinBasic. From what I heared its fast and supports 2D / 3D very well. (TBGL...?) Anyway I got some questions now:

What makes ThinBasic special?
Should I switch from PB to TB?
WHY should I switch?
Is TB realy that much fast then PB?
How big are the EXE's from TB and do I have to give any additional file?
What exactly is TBGL and who develops it?

I know I might be able to answer that questions myself with some more searching... but I hope you might help me with that.

ErosOlmi
13-08-2008, 18:21
Hi Polarwolf and welcome here.

I will try to give you some fast info that maybe some other thinBasic user will be able to integrate.

First and most important
thinBasic is an interpreted language not a compiler. PowerBasic and PureBasic are compilers. It means they produce real 32bit code.
thinBasic does not produce any 32bit executable code but read a text file (your source code), parse it and interpret it on the fly.

What makes ThinBasic special?
Well, this is very personal question. thinBasic can be special in different ways for different users. I think everyone of us should reply to this question. And if nothing special, maybe thinBasic is not the right tool. But I'm sure if one programmer or just someone loving programming spend enough time with thinBasic and thinBasic community, everyone will be able to find something special.

Should I switch from PB to TB?
I think NO. PB (here stand for PowerBasic / PureBasic) is very special and good product.
thinBasic is something else maybe used in conjunction with PB or for some special projects.

WHY should I switch?
You do not have to switch but use the best tool for every specific project.
There can be projects where you absolutely need a compiler. Other where an interpreted language like thinBasic can be used.

Is TB realy that much fast then PB?
An interpreted language cannot be fast as a an executable application generated by a true compiler.
That said, thinBasic is very fast compared with other interpreted languages. You can have a look inside "\thinBasic\SampleScripts\general\Speed\" directory. There are some benchmark scripts that can give you an idea about how fast is thinBasic. Also you will find some posts here in community forum talking about thinBasic execution speed. We worked on execution speed a lot.

How big are the EXE's from TB and do I have to give any additional file?
Even if thinBasic is an interpreted language, Roberto has created what we call Bundled Exe.
Bundled Exe are executable produced by thinAir IDE that are very similar to ZIP compressed files. They contains the main thinBasic engine plus the original script (usually obfuscated) plus additional files the programmer decide to add in there. When Bundled Exe are executed, all files included in there are exploded on disk and a special process is in change to start the main script. At the end, Bundled Exe behave is similar a standard exe.
Usually executable created by thinAir are not bigger that 300/400 Kb but if you have used many modules or you decide to put images, sounds, or other files or even directories inside them, size will increase proportionally.

What exactly is TBGL and who develops it?
thinBasic has a modular structure.
It means it has a Core engine in charge of the main parsing process plus all memory handling, variables, program flow, ... Around the main Core engine there are many additional modules (special DLLs) that implements the main thinBasic language adding many new keywords. There are modules for: file handling, user interface, console, math, ... and OpenGl. TBGL is one of the many modules specifically designed to implement OpenGL and a lot of additional stuffs like bone system, entity system. TBGL is developed by Petr Schreiber.
Modules can be developed using different languages and compilers: PowerBasic, C, C++, ASM, FreeBasic.

_________________________________________________
Well, for the moment I think this can be enough. Hope other will add more.

Ciao
Eros

Petr Schreiber
13-08-2008, 18:51
Hi Polarwolf,

welcome to the world of ThinBasic :)

I agree with Eros in all points, just have some additional comments:

Speed
ThinBasic is interpreter, but quite fast one, in my experience faster than default Windows Visual Basic Script for example, even for loops. On other side TB cannot compete with loop performance of compilers.

But it has few nice speed tweakers:

Lot of commands which "do a lot" internally so they run at native speed ( array scanning, model rendering )
Dynamic string concatentation using "+" is faster than C# one ( without string builder )
ThinBasic has module for assembler, so you can code functions or smaller proggies which can match compiled speed, as long as you are friend with ASM
Memory overlays can save time spent with data conversion


TBGL
Author of this module is just writing this post :) TBGL is developed thanks to supporting ThinBasic community for almost 3 years now. Language used to produce DLL is PowerBASIC for Windows, 8.04.

TBGL is module based on OpenGL library, so it provides access to hardware accelerated graphics. It is not basic 1:1 wrapper for OpenGL. Here are some features:

Initialization of OpenGL, including creating and destroying window
Basic keyboard and mouse input
Model loading and animation
Entity based system to for easier work with basic objects like cameras, lights, 3D primitives, models and more
Plotting text on screen or in 3D space
Automatic display list and texture garbage collection


... and much more, while maintaining compatibility with most cards on the market. Unlike GLUT for example, it is not callback based and it can be used to go more highlevel.
At the same time it can be freely combined with native low level OpenGL up to v2.1, which is provided to ThinBasic via header file.

You can learn more about TBGL from following resources:
TBGL website (http://psch.thinbasic.com/) - some tutorials and articles, plus download of auxiliary tools ( format converters, exporters, ... )
TBGL Bonus Pack 1.6.0.10 (http://www.thinbasic.com/index.php?option=com_docman&task=cat_view&gid=23&Itemid=66) - big package of 2D/3D graphics scripts contributed by forum members.


Petr

Polarwolf
13-08-2008, 21:35
WoW. Thank you people! You know what I love about "small" Languages? Exactly. The Codingteam is as close to the people who use their language as possible. (Sorry for my english... Im german) From what I hear now I'm kinda excited and will play around with Thin once I get some free days. Thank you very much! :)

Michael Hartlef
14-08-2008, 07:09
Hi fellow and welcome here,

yes you have mentioned a great or lets call it special feature that you don't find in PureBasic or any other basic out there. The developers of thinBasic and the 3rd party modules are all active thinBasic users and listen to your request to an extend that I have never seen elsewhere. We are like a family here, treat everyone with respect and help each other. THAT makes thinBasic stand out from all the other languages. Plus the fact that it is easily expandable with its SDK's.

Cheers
Michael

Pipes
14-08-2008, 15:35
Yo! (Texan for Hello in plain english)

More questions to add to this post.
Why did you choose to make thinBasic an interpreted language instead of compiled?
Why a scripting language?
What exactly do scripting languages provide? (advantages/disadvantages)

The Codingteam is as close to the people who use their language as possible.

I agree with the above. I'm a noob but I am definitely impressed with the quick responses and enthusiasm from the code team.

Pipes

ErosOlmi
14-08-2008, 16:13
Why did you choose to make thinBasic an interpreted language instead of compiled?
I started to develop thinBasic from a simple math parser I developed.
I do not have any experience in developing compilers so for me it was natural to go with an interpreter. I like parsers, tokenizer, and in general handling with complex data structures but zero knowledge on the EXE generation.
Roberto joined the project after some years I already developed thinBasic. He has a strong knowledge in ASM and EXE formats but not so strong in compilers too. He sometimes push me in the direction of creating a compiler. Maybe, in future, maybe.

Why a scripting language?
Well, I do not know how to reply to this question. Scripting is in general an application reading a text file (a script) and interpret it. So to me scripting language and interpreter are the same thing.

What exactly do scripting languages provide? (advantages/disadvantages)
I cannot reply with an exact answer to this question. There are many interpreter out there and everyone has its pro/cons, everyone has its own specific characteristics and peculiarities. We think to have some big advantages in the way we developed our module SDK. Everyone can contribute to thinBasic project developing modules that are compiled with real compiler. You can use PowerBasic, FreeBasic, C, ASM and few other compilers to develop thinBasic modules. Modules are special DLLs that implement new keywords in the language. Programmer developing modules has extreme freedom on how to design the syntax. thinBasic give you the parsing functionalities to interface with the main core. The rest is 100% your choice.
In general the biggest pro and also cons in scripting languages is the execution speed. It will not be even close to the speed you can get from a compiled application. But also on this area thinBasic can be a nice surprise. Everyone can try and test. For many many kind of applications thinBasic can be an alternative to compiled applications.

Hope to have replied to your questions.
Ciao
Eros

ErosOlmi
14-08-2008, 16:56
I agree with the above. I'm a noob but I am definitely impressed with the quick responses and enthusiasm from the code team.


Everyone can be code team in thinBasic.
Just develop a module and you will be in the crew ;)
And if you like, we will open a dedicated forum where you can support your module.

Polarwolf
14-08-2008, 17:24
Dudes I love you more'n more. Can ThinBasic already use Peek&Poke for Memoryaltering?

Petr Schreiber
14-08-2008, 17:36
Hi Polarvolf,

here is very basic example, as a bonus with memory variables overlays as well:


uses "console"

' -- Variable initalized to 3
dim LuckyNumber as long = 3

Printl "Lucky number : ", LuckyNumber

' -- Getting number using PEEK and pointer
Printl "Lucky number from pointer : ", peek( long, varptr(LuckyNumber) )

' -- Setting number using POKE
poke( long, varptr(LuckyNumber), 7 )
Printl "Lucky number after pointer assignment : ", LuckyNumber

' -- Create variable over already existing one
Dim HijackNumber as long at varptr(LuckyNumber)

HijackNumber = 9
Printl "Lucky number changed using overlay var: ", LuckyNumber

waitkey


VARPTR returns variable pointer to any thinBasic variable.
For dynamic strings you can use STRPTR.

Here is another trick - overlaying different data types:


uses "console"

' -- String variable
dim MyText as string = "ABC"

' -- BYTE array overlayed over string
dim MyASCII(3) AS BYTE at strptr(MyText)

PRINTL "MyText variable :", MyText

' -- As MyASCII overlays MyText, it contains its ASCII values anytime
' -- To print MyASCII array values you can write all elements of array
' -- with any delimiter using JOIN$
PRINTL "MyText variable ASCII values:", join$(MyASCII, ",")

' -- By assigning BYTE values we overwrite the string with D, E and F
ARRAY ASSIGN MyASCII() = 68, 69, 70

PRINTL "MyText modified from array :", MyText

waitkey



Bye,
Petr

ErosOlmi
14-08-2008, 17:41
Yes, thinBasic as a lot of way to handle memory directly.

Pointers (http://www.thinbasic.com/public/products/thinBasic/help/html/pointers.htm)

POKE (http://www.thinbasic.com/public/products/thinBasic/help/html/poke.htm)
POKE$ (http://www.thinbasic.com/public/products/thinBasic/help/html/poke$.htm)
PEEK (http://www.thinbasic.com/public/products/thinBasic/help/html/peek.htm)
PEEK$ (http://www.thinbasic.com/public/products/thinBasic/help/html/peek$.htm)
VARPTR (http://www.thinbasic.com/public/products/thinBasic/help/html/varptr.htm)
STRPTR (http://www.thinbasic.com/public/products/thinBasic/help/html/strptr.htm)
GETAT (http://www.thinbasic.com/public/products/thinBasic/help/html/getat.htm)
SETAT (http://www.thinbasic.com/public/products/thinBasic/help/html/setat.htm)

But there is more. DIM ... AT has a lot of power
DIM AnyVariable AT MemAddress
DIM ... AT ... let you declare any thinBasic supported variable telling thinBasic where to manage it memory allocation. In this way thinBasic will not allocate any memory but will use memory allocated by something else. Mainly it is like superimposing a logical structure (your variable) to a memory area and use that memory area in different ways.

For example imagine you want to use a string but at the same time use every char as BYTEs.
You can go using PEEK/PEEK$ but you can also do something like:

USES "Console"

DIM MyString AS STRING
MyString = "ABCDEFGH1234_WhatEver"

DIM MyArrayOfBytes(LEN(MyString)) AS BYTE AT STRPTR(MyString)

for counter as long = 1 to ubound(MyArrayOfBytes)
printl MyArrayOfBytes(Counter), " ", chr$(MyArrayOfBytes(Counter))
next

waitkey

So, in few words, you treat the same memory area in different ways using DIM ... AT ...
Important, you can use DIM ... AT ... with all thinBasic supported data types from single bytes to extended to arrays of UDT ... and so on.

Ciao
Eros

Polarwolf
14-08-2008, 17:58
Bäm. And you told me not to think about leaving PB behind (pure this time). This might be THE language for my friend and me. Since he wont buy PB and this seems to be a very great product. Impressive.

Pipes
14-08-2008, 20:03
Yo Eros!

Hope to have replied to your questions.

I like parsers, tokenizer, and in general handling with complex data strutures but zero knowledge on the EXE generation.

Yes you answered my curious questions about thinBasic. Since I don't know much about either parsers, tokenizers or exe generation. It seems interesting though.
About all I understand is BASIC. I've been messing around with various forms of it since the 1980's when I had my first timex sinclair computer with an awesome 2K of ram.
(We've come along way since then... ;D)

Hey, Keep up the good work. You convinced me... Me like thinBasic ;D