PDA

View Full Version : Tbo2



John Spikowski
26-06-2018, 06:26
Hi Everyone!

It has been a while since I posted anything to the forum.

I was wondering how Eros and the thinBasic community feel about porting thinBasic to Oxygen Basic for a 32/64 bit interpreter with a JIT compiler option?

I think everyone has given Drake plenty of time to show they have an interest in carrying on with PowerBASIC as a commercial product. I'm not alone feeling there is no future investing in PB any longer.

I think an O2 boost would get thinBasic back in the spotlight and the community excited about a bright future.

John

FWIW:

I ran the thinBasic count to a million benchmark in in Script BASIC as a compare and here are my results.

thinBasic: 0.344 seconds

Script BASIC: (Windows 32 bit) 0.703 seconds.

This is only comparing the execution speed of the FOR/NEXT with a variable incremented.

primo
26-06-2018, 10:49
Hi John
yes every one feel sad that the PB development status in the freezer, and even the late BZ setting now in the paradise but he is allowed to work with computers 8 BIT only with 8088 cpu and DOS 2.0 this is because he can't predict while he was in the mundane world the quick advent of the 64BIT computing.
i don't think Eros is able to begin with a new compiler from scratch for too much reasons including he is busy in the work. and the age also play a role, this is my imagination.
there are many talks about Rust https://www.rust-lang.org/en-US/ and from the page it support Unicode as explained in the online code execution.
i have installed it and it produce small exe files. but i haven't gone more than "Hello World"

fn main() {
println!("Hello World");
}
the exe size is 150kb
also look Exploring Rust fat pointers https://iandouglasscott.com/
may be Eros , Petr look at it.

ErosOlmi
26-06-2018, 12:15
Petr is already testing RUST lang.

https://github.com/petrSchreiber/Rust-and-ThinBASIC-DLL-interop

ErosOlmi
26-06-2018, 14:37
Hi Everyone!

It has been a while since I posted anything to the forum.

I was wondering how Eros and the thinBasic community feel about porting thinBasic to Oxygen Basic for a 32/64 bit interpreter with a JIT compiler option?

I think everyone has given Drake plenty of time to show they have an interest in carrying on with PowerBASIC as a commercial product. I'm not alone feeling there is no future investing in PB any longer.

I think an O2 boost would get thinBasic back in the spotlight and the community excited about a bright future.

John

FWIW:

I ran the thinBasic count to a million benchmark in in Script BASIC as a compare and here are my results.

thinBasic: 0.344 seconds

Script BASIC: (Windows 32 bit) 0.703 seconds.

This is only comparing the execution speed of the FOR/NEXT with a variable incremented.

Ciao John,

So far I'm very happy with PB10.
It has all I need and much more.
Yes, having a 32 and 64 bit compiler would open thinBasic some new features but not much.
The most important would be to have more virtual memory available for each process but not much more features.
thinBasic is not a compiler but just a source code interpreter so I have no big advantages from 64bit.

Consider thinBasic project is now more than 150k lines of code. Moving from current compiler to another one would be a huge project.
But one of the positive fact of thinBasic structure is that it is modular so you can have Core engine written in PB10, another module written in FreeBasic (for example), another one in PB or C or RUST or FreePascal or whatever compiler able to generate 32bit DLLs. Why do I have to rewrite all when it is possible to cooperate with modules written with the language you prefer?

What I will for sure study will be to test if I'm able to develop a thinBasic module using Oxygen so developers interested to develop thinBasic modules will have another compiler available.
I do not see big troubles because Oxygen has almost the same variable data types that thinBasic has and the other way round.


And yes: thinBasic is quite fast considering it is a pure source code interpreter without any intermediate language generated.
If you will test more you will see that it has great speed in strings too.
Maybe not so fast in repetitive function calling passing parameters or defining local variables: most of the time is consumed in allocating / de-allocating memory in local stack (local variables and parameters).

Ciao
Eros

John Spikowski
26-06-2018, 17:07
Will thinBasic remain closed source for the foreseeable future?

ErosOlmi
26-06-2018, 22:13
thinBasic Core engine: yes.
Most of the modules I developed: yes.

Some module source code is available at GitHub: https://github.com/search?o=desc&q=thinbasic&s=updated&type=Repositories

And more will come.

John Spikowski
27-06-2018, 02:14
I'm happy to hear that O2 may become an alternative to PowerBASIC for expanding thinBasic.

Petr Schreiber
05-07-2018, 10:48
Hi John,

I do admire the work Charles did and does on OxygenBASIC. I watch the project with interest! I really do like it as JIT booster for thinBASIC scripts.

However, in my search for compiler tool for new module projects I landed in the land of Rust (https://www.rust-lang.org/en-US/). I use it for more than year now.

The main advantages for me are:

fabulous documentation (free book and reference guide)
well thought package system
long term vision, clear indication regarding which part of design is in progress, which is finished
performance of C without the extra layers of C++ (garbage collector and other unpredictable elements)
smart way to design object oriented design without repeating the class approach we have seen in ton of languages already


And of course, ready to use bindings for OpenGL, OpenCL, CUDA and Vulkan.

I agree with Eros that the diversity of languages used for thinBASIC development is very good - it is always tempting to stick with one language, but it is much better to simply use the right tool for given job.
ThinBASIC modularity allows this. Writing Rust bindings was piece of cake (with immense support from Eros :drink:).


Petr

primo
05-07-2018, 14:33
@Petr
i have installed your rust module with cargo build --release as you said, on my non configured rust installation using a big file (offline setup) but i got a x64 dll size 134kb. so i have uninstalled it and reinstalled it with online rustup‑init.exe and applying your instructions especially the For Default host triple? enter i686-pc-windows-msvc it is installed successfully, and then applying cargo build --release again inside your thinbasic rust package, and the produced DLL is 118kb in size. the test file "test_lib.tbasic" works okay with the rust_interop.dll
what do you advice for installing OpenGL with rust, as i have tried before with non configured Rust installation and i have failed. my system for running Rust is windows 7/ x64
Thanks for this project

John Spikowski
06-07-2018, 02:54
Hi Petr,

Glad to see you're still an active member of the thinBasic community.

I think Eros's thought's on using O2 as an alternative to PowerBASIC for custom modules is a great idea. Keeping it BASIC.

The extension modules for Script BASIC are written in C (C BASIC - gcc BASIC preprocessor) so they are cross platform.

Charles's DLLC is a gift for Script BASIC that keeps on giving. I could never thank Charles enough for all the effort he invested in unraveling SB and extending it with O2. (FFI, virtual DLLs, C variable / structures, low level COM, ...)

matthew
06-07-2018, 18:51
There is a very good guide here (http://nercury.github.io/rust/opengl/tutorial/2018/02/08/opengl-in-rust-from-scratch-00-setup.html) which shows you how to install OpenGL and SDL2 for Rust, primo. I used it today and have managed to get some OpenGL examples running on my computer.

John Spikowski
07-07-2018, 03:14
At 65, Rust doesn't sound like the right direction for me.

primo
07-07-2018, 09:17
Thank you matthew very much for the link and info, i will try it, just now i have tried a wrapper for OpenGL https://github.com/glium/glium
i have tried the first demo described in tuto-01-getting-started.md:
https://github.com/glium/glium/tree/master/book
don't know what to do but i have guessed to write cargo build and she have downloaded several things and after 20 seconds i have my-project.exe in a new target folder and when we run it it display a blue windows. so at least something. will try the other examples later.

@John, i thought i am 66 yo and said to myself "i'm older than him by a year" , i have consulted google and she direct me to this site http://birthdayscan.com they say i'm approx 63.5 y. so i am happy my age is smaller than 66. Eros should make a function for calculating the years from x1 to x2.
i am using Script Basic in testing the codes from old books available by hundreds from archive.org it is a nice language merging the old style with the new style, i use it with geany ide.

John Spikowski
07-07-2018, 12:19
i am using Script Basic in testing the codes from old books available by hundreds from archive.org it is a nice language merging the old style with the new style, i use it with geany ide.

One of the features I like about Script BASIC is I can use code gems from the past including MSQB and dress it up with modern UIs or add functionality with popular open source C libraries. (SQLite, cURL, ODBC, SDL, IUP, ...)

primo
07-07-2018, 16:38
John, just one question: i can't execute lines with multi statements such as
20 LET A=4:Let I=0:Let R=0 even it is a classic Basic habit, something i mess ?
i saw your version : 20 SPLIT "4,0,0" BY "," TO A,I,R
and it is good enough to replace the previous version.
i have installed IUP GUI iup_win32-b9.zip and the provided examples are enough for me to go on with.

John Spikowski
07-07-2018, 19:33
I don't think multiple statements per line came about until Quick BASIC.

The SPLIT also works as a one line replacement for DATA/READ.

Petr Schreiber
07-07-2018, 20:44
@John I get the point with the DLL sizes. The beauty of Rust is you can tweak it down as much as you like.
Rust even allows you to ommit the standard library altogether.

Earlies, I tried Rust, saw it does hello world at 134kB, laughed and left.

Then I came back and realised the bigger EXE size was just my misunderstanding. I can create 4kB "hello world" in Rust.
I did not do much promotion of Rust for module creation here yet. For a reason - I want to dig deeper in it and I think the great point for others to jump in would be once the "Rust 2018 (https://blog.rust-lang.org/2018/03/12/roadmap.html)" milestone is reached.

To not further hijack this thread - this is my last comment on Rust here for now. My apologies, dear Charles!

@Matthew Thanks for the examples!

I am mostly interested in Oxygen in form of module for thinBASIC, giving me a JIT hand for easy performance boost.
If there would be easy tutorial for newcomers, with case studies, it would add a lot of value for our community.

I did used Oxy for this in the past, when I return back, I usually find out my old code does not work and I scratch my head what changed.
Instead of diving to change logs, releasing "Boosting ThinBASIC with Oxygen in 20XX" yearly would be fantastic. What do you think John, Charles?


Petr

John Spikowski
07-07-2018, 23:19
O2 JIT is very cool for creating virtual DLLs. thinBasic should use Charles's DLLC dynamic FFI functionality to interface with APIs on the fly.

Charles Pegge
08-07-2018, 00:17
Hi Petr,

I'm intrigued by immutability. Do you find it useful in RUST?

Petr Schreiber
08-07-2018, 09:10
Hi Charles,

thanks for the question, I find the concept of mutability very useful. It gives the programmer more control over what happens with variables.
BASICally speaking, you can for example prevent passing the variable byRef, otherwise potentially causing it to be changed by other function.

By default, Rust variables are immutable. If you do this:


let answer = 42;
answer = 13;


...Rust will fire you an easy to understand error, because you are trying to modify immutable variable answer.

If you want total freedom (=default behaviour in most programming languages), you may opt for *mut* keyword, which enables the ability to change the value:


mut let answer = 42;
answer = 13;


The 3rd approach is to create immutable variable, and change it explicitly, with overshadowing using let statement:


let answer = 42;
let answer = 13; // Means, "I know it is immutable, but I really need to change the value and I know what am I doing"


It is well described here, along with differences between constants and immutable variables: https://doc.rust-lang.org/book/second-edition/ch03-01-variables-and-mutability.html

You may remember me being happy from OpenCL/CUDA, because it completely changed my way to design algorithms. With Rust, I am experiencing the same mind twist.
At first it seems like mountain of strange rules and obstacles, but in the end, you can see the ray of genius light and can only applaud the authors for challenging the obvious (like Rust did with allowing object oriented design - without classes, without garbage collector).


Petr

John Spikowski
08-07-2018, 16:50
I'm intrigued by immutability. Do you find it useful in RUST?

A language without variables and only constants would surely send me over the edge.

Charles Pegge
09-07-2018, 03:43
Thanks, Petr,

With regard to RUST's immutability rules, Would this construction be acceptable:



do {
let a=inkey()
if a<32 { exit do }
}

José Roca
09-07-2018, 05:33
Rust variables are immutable by default, but you can override it using mut. In other languages, they are mutable by default but you can use const to make it immutable. So, the same rules, but reversed.

John Spikowski
09-07-2018, 05:45
How are arguments passed to a function viewed in Rust? Is there any concept of LOCAL?

Charles Pegge
09-07-2018, 16:05
Constants can only be defined in terms of other constant expressions. They can be resolved at compile-time, whereas immutables may also be set by variable expressions in run-time (once only).

I'm interested in providing an immutability mode in o2, but I am puzzled as to how it could be used advantageously. :)


PS:
RUST has local variables, and parameter passing byval / byref, much the same as C / Basic.

primo
09-07-2018, 17:09
i believe the Rustologists only rename the jargon of C/Basic, beautifying it with Philosophy .
i have stopped to learn Rust after looking at this (simple program!!)
https://stackoverflow.com/questions/26321592/how-can-i-read-one-character-from-stdin-without-having-to-hit-enter

extern crate termios;
use std::io;
use std::io::Read;
use std::io::Write;
use termios::{Termios, TCSANOW, ECHO, ICANON, tcsetattr};

fn main() {
let stdin = 0; // couldn't get std::os::unix::io::FromRawFd to work
// on /dev/stdin or /dev/tty
let termios = Termios::from_fd(stdin).unwrap();
let mut new_termios = termios.clone(); // make a mutable copy of termios
// that we will modify
new_termios.c_lflag &= !(ICANON | ECHO); // no echo and canonical mode
tcsetattr(stdin, TCSANOW, &mut new_termios).unwrap();
let stdout = io::stdout();
let mut reader = io::stdin();
let mut buffer = [0;1]; // read exactly one byte
print!("Hit a key! ");
stdout.lock().flush().unwrap();
reader.read_exact(&mut buffer).unwrap();
println!("You have hit: {:?}", buffer);
tcsetattr(stdin, TCSANOW, & termios).unwrap(); // reset the stdin to
// original termios data
}

will focus on Basic Languages only
BUT i will stay watching the subject occasionally

ErosOlmi
09-07-2018, 18:32
:read::read::read:
:heat:
:shock16:

Too complex to me :)

John Spikowski
09-07-2018, 19:11
Here is the Script BASIC version of the GetKey Rust program.



IMPORT CIO.sbi
Start:
PRINT "Hit a key! "
buffer = CIO::getch()
IF buffer = 27 THEN GOTO Done
PRINT "\nYou have hit: ","[",FORMAT("%~000~",buffer),"] - ",CHR(buffer),"\n"
GOTO Start
Done:



C:\ScriptBASIC\examples\test>scriba getch.sb
Hit a key!
You have hit: [001] - ☺
Hit a key!
You have hit: [002] - ☻
Hit a key!
You have hit: [003] - ♥
Hit a key!
You have hit: [065] - A
Hit a key!
You have hit: [098] - b
Hit a key!
You have hit: [067] - C
Hit a key!
C:\ScriptBASIC\examples\test>

primo
10-07-2018, 09:07
Thanks John for the code. evidently we can know what it is doing since it is natural and readable, i have tested it after adding IMPORT "cio.bas" for the windows version.
this is one possibility for Thinbasic

Uses "Console"
String a
PrintL "Press ESC key to end program"
While a<>"[ESC]"
a = WaitKey
PrintL a
Wend
it will return the pressed character until we press ESC.
i just don't know why Eros have added "[]" to the captured character, but it is not a problem at all.
i think the programming language should not waste the Human Brain limited resources (100 billion neurons damaged by the Pollution, wars, Politics... ) especially in this noisy world with all the flood of information processed by the Mind so the designers of programming language should take care of this fact.

ErosOlmi
10-07-2018, 14:37
i just don't know why Eros have added "[]" to the captured character, but it is not a problem at all.


Reason is because WaitKey is able to get special multiple key press combination like in the following example:

Press ESC key to end program
[CTRL][PGUP]
[SHIFT][CTRL][PGDOWN]
[SHIFT][CTRL][END]
[SHIFT][CTRL][DOWN]
[SHIFT][CTRL][RIGHT]
[CTRL][UP]
[CTRL][DOWN]
[CTRL][LEFT]
[CTRL][RIGHT]
[ALT][LEFT]
[ALT][RIGHT]
[ALT][DOWN]
[ALT][UP]
[ALT][q]
[ALT][Q]
[ALT][e]
[ALT][c]
[ALT][d]

Using [] seemed to me a convenient way to get all possibilities.

primo
10-07-2018, 15:45
Thanks Eros,
That make sense, and in this case the [ ] is more suitable to use than as an example a pure Space or " " or ( ). and it is easy to remove with Remove$ function if we want.

John Spikowski
10-07-2018, 19:17
I will try to get a current Script BASIC Windows 32 bit Inno install posted on the scriptbasic.org forum for those interested in updating their toolbox.

John Spikowski
14-07-2018, 09:24
I have uploaded to the Script BASIC forum a current Windows 32 bit Inno install of Script BASIC. Let me know if you have any issues with it.

DOWNLOAD (http://www.scriptbasic.org/forum/index.php?action=dlattach;topic=356.0;attach=417)

primo
14-07-2018, 17:39
Thanks John, i have tested the setup with windows xp/32 and windows 7/x64.
my notes:
1- the setup add c:\scriptbasic\bin to the end of the path on the 2 systems. so i can run scriba from any console
2- using the provided IDE we can open any *.sb file and run it even if the file on the Desktop.
3- if we write some code in the IDE and then saving it with save. then run it, it will give error this:
error &H44: The file can not be read
when we check we don't find the file, ie the file does not saved
4-run the example cio_colors.sb from console and we will see the color show, but run it from the IDE and we will see the output on the bottom of the IDE as numbers without color like this 010203040506070809010011012013014015016... and not to a console.
5- the example com_99beers.sb since it is a SAPI voice, if we run it as it is it will stay too much time and we can't exit it, so if there is an interruption routine such as pressing ESC to exit will be fine.
i have changed it to FOR beers = 6 to 1 STEP -1

John Spikowski
14-07-2018, 18:25
Thanks for the feedback. The Windows path for SB should have been set by the install. The cio_colors.sb example is a console only example. If you run iup_web_dict.sb from the console, use sbwin.exe rather than scriba.exe as it has theming and isn't a console program. The SAVE issue is a new one for me. I'll see what's going on there. Good point about 99 beers. It needs a way to exit. This demo was added as a last minute inclusion and I didn't give it much thought.

@Eros - Can you split this thread where it became SB centric to the 'Other Scripting Languages' board?

Update:

SAVE seems to be working. Use New and create the file in the directory you want. Write your code and hit Save. The New function allows you to enter a filename in the OPEN (?) dialog if you don't select an existing script. This creates a blank file with the name you entered. default.sb will load into the IDE on startup if one exsits.

I think we can do a better job with this!

primo
15-07-2018, 04:54
Use New and create the file in the directory you want. Write your code and hit Save ..
Thanks John, yes this works. it is a handy IDE for the quick tests and for Debugging the code. we can use also Geany IDE for writing and testing the code.

John Spikowski
15-07-2018, 05:16
I use Ultra Edit. I only use the debugger if I want to single step through a script and look at variables

PRINT "Got Here!\n" is the debugger I use most offen.

If you mouse over a variable name in your code while in debug mode, it shows its current value.

There is a text file that defnes extension module function/sub calls and the required arguments that will pop up as an Intellisense helper. There is only a couple extension modules defined in this release. Feel free to expand on it and I will include it in the next release build.

John Spikowski
21-07-2018, 06:08
Hi Eros,

Any news on your work using O2 for thinBasic extension modules?

I would love to work with you on DLLC as it can benefit thinBasic as well as Script BASIC.

* Dynamic FFI
* Vitual DLL functions
* Low level COM
* Create / access C structures and variables
* more ...