SyntaxBomb - Indie Coders

Languages & Coding => SmallBASIC => Topic started by: lettersquash on May 12, 2021, 21:28:19

Title: Standalone compiled code, e.g. exe?
Post by: lettersquash on May 12, 2021, 21:28:19
Hi Chris,

I saw this question come up quite a while back, and it got lost in amongst arguments about editors and other things. Is there any plan to allow SmallBASIC source to be compiled to a stand-alone program that can be distributed with obscured source (or even with open source)?

I'm wondering about using sB for something, but it needs to be easy for end users to install or unpack and run without loading a file into an editor first.
Title: Re: Standalone compiled code, e.g. exe?
Post by: bplus on May 13, 2021, 00:13:27
I might be able to convert something and compile for you in QB64. Is it very long?
Title: Re: Standalone compiled code, e.g. exe?
Post by: lettersquash on May 13, 2021, 00:33:37
I might be able to convert something and compile for you in QB64. Is it very long?
That sounds interesting. I gathered from earlier that it's possible to do that. It's a kind offer, or I might be able to do it myself if I learn the QB64. I may have looked at it, but I can't remember why I didn't use it.

It's nowhere near finished, I've got to learn a lot, and it could be pretty long and pretty complex by the time I'm done - it might not even come about. SB is just one of my options, but it's got potential. Ideally, I'd want to have an app that runs in Android too, and preferably Linux, but Windows would be a start.

Another option would be to use another language (AHK) for the Windows version and find something else (sB, or maybe RFO BASIC) for Android.

Anyway, thanks bplus. It's possible Chris is working on something to write an app straight from sB. I've no idea how easy or difficult it is.
Cheers mate,
¬~
Title: Re: Standalone compiled code, e.g. exe?
Post by: chrisws on May 13, 2021, 06:20:40
For windows and linux you could use the command line version and then just supply the .sbx byte-code file instead of the corresponding .bas file.

You could then provide a GUI using one of the modules.

For android, with some effort it would be possible to make some kind of development kit where you use the core of SmallBASIC but package it as your own app.
Title: Re: Standalone compiled code, e.g. exe?
Post by: round157 on May 17, 2021, 23:29:27
For windows and linux you could use the command line version and then just supply the .sbx byte-code file instead of the corresponding .bas file.



Hello, the description for making .sbx file is not clear. I can't make .sbx file successfully:


 new: ebm, optional SmallBASIC.ini settings control creation of .sbx files
    --- and enabling verbose compilation. settings are:
    --- genexe=0
    --- quiet=0

(https://smallbasic.github.io/pages/changelog.html)
Title: Re: Standalone compiled code, e.g. exe?
Post by: chrisws on May 19, 2021, 10:46:13
In the console version you can pass the -x option

$ sbasic -x foo.bas

This will run foo.bas and also produce foo.sbx

Now you can run:

$ sbasic foo.sbx

You can also kind-of de-compile the sbx with:

$ sbasic -s foo.sbx

This gives an idea of what's inside but the original source isn't recoverable.
Title: Re: Standalone compiled code, e.g. exe?
Post by: lettersquash on May 19, 2021, 20:55:09
Thanks Chris. With my level of knowledge, that all sounds a bit beyond me, unfortunately. I haven't really worked out how the modules work. If at some time there's a compiler that will do all that, it would be a great addition.
Title: Re: Standalone compiled code, e.g. exe?
Post by: bplus on May 20, 2021, 19:11:43
This reminds me you could compile or precompile Unit code if I remember correctly.

So what if you make an executable from that? Maybe still needs a really simple little sb line of code to activate, so still need sb to distribute, but we are getting closer aren't we?
Title: Re: Standalone compiled code, e.g. exe?
Post by: round157 on May 22, 2021, 11:06:38
Maybe many SmallBASIC users want a more convenient solution for making EXE files. I really hope that chrisws will create a new solution. Thanks first!  :)
Title: Re: Standalone compiled code, e.g. exe?
Post by: lettersquash on May 22, 2021, 16:33:08
Maybe many SmallBASIC users want a more convenient solution for making EXE files. I really hope that chrisws will create a new solution. Thanks first!  :)
Yes, or it might be someone else skilled enough who writes a utility for that. I wouldn't know where to start.
Title: Re: Standalone compiled code, e.g. exe?
Post by: bplus on May 22, 2021, 17:12:41
(Oh hey I got a message! Better yet it's in sb code, wouldn't have known had I not logged in to post this! LOL)

Quote
I wouldn't know where to start.

I am pretty sure you do know how to start but in case you don't, pick a language to write it in, say C++ then look it up on Internet:

Bam! someone is showing you how LOL
https://visualstudiomagazine.com/articles/2014/05/01/how-to-write-your-own-compiler-part-1.aspx

I am thinking it is a big project because I've built many an interpreter but I don't have the desire to overcome all the other things needed time, effort, skill... it would take more desire.

Plus QB64 doesn't have all the functions sb has but it's not hard to fill in missing subs and functions to get a compiled program. Just the other day, I was wondering how I would do Translate, oh that's easy but doing that Pairs thing, a little more tricky ;-))
Title: Re: Standalone compiled code, e.g. exe?
Post by: lettersquash on May 22, 2021, 20:37:03
(Oh hey I got a message! Better yet it's in sb code, wouldn't have known had I not logged in to post this! LOL)

Quote
I wouldn't know where to start.

I am pretty sure you do know how to start but in case you don't, pick a language to write it in, say C++ then look it up on Internet:

Bam! someone is showing you how LOL
https://visualstudiomagazine.com/articles/2014/05/01/how-to-write-your-own-compiler-part-1.aspx

I am thinking it is a big project because I've built many an interpreter but I don't have the desire to overcome all the other things needed time, effort, skill... it would take more desire.

Plus QB64 doesn't have all the functions sb has but it's not hard to fill in missing subs and functions to get a compiled program. Just the other day, I was wondering how I would do Translate, oh that's easy but doing that Pairs thing, a little more tricky ;-))
That's funny, when I said "someone", I was thinking of you! Oh well, never mind. Yes, I would - strictly speaking - know where to begin. Running away. :P
Title: Re: Standalone compiled code, e.g. exe?
Post by: round157 on May 25, 2021, 02:32:35

BUT if the runtime core is too multiplatform then is not easy to create binder...

So the above conclusion is almost the same as no solution.

Quote
well many users..yeah ..many ...
where are those many ?

Perhaps most of the SmallBASIC users only like to write programs sliently at home and don't use this SmallBASIC forum.
Title: Re: Standalone compiled code, e.g. exe?
Post by: round157 on May 25, 2021, 02:35:07
Maybe many SmallBASIC users want a more convenient solution for making EXE files. I really hope that chrisws will create a new solution. Thanks first!  :)
Yes, or it might be someone else skilled enough who writes a utility for that. I wouldn't know where to start.

Maybe "generate EXE file" should be the highest priority task on the roadmap, the to-do list or the wishlist of SmallBASIC.
Title: Re: Standalone compiled code, e.g. exe?
Post by: lettersquash on May 25, 2021, 17:09:11
Do i really need to repeat myself
No, but it never stopped you before. :P

Quote
well many users..yeah ..many ...
where are those many ?
They're all using your software. :))
Title: Re: Standalone compiled code, e.g. exe?
Post by: bplus on May 25, 2021, 17:59:43
Do i really need to repeat myself
One of option is to build source + runtime ..called binder.
BUT if the runtime core is too multiplatform then is not easy to create binder...
well many users..yeah ..many ...
where are those many ?

You are talking about tacking on an sb app at the bottom of an sb.exe program much simpler to get the sb.exe and run all the apps you like from it, think of all the space you save if you have more than one app.
And suppose the app requires additional files, still have to pack them up with distro anyway.

It's like building a mansion for a dog.
Title: Re: Standalone compiled code, e.g. exe?
Post by: Aurel on May 26, 2021, 06:54:03
No is not ...
It is most elegant way to run interpreted programs and whole bunch of windows
software work on similar way,many interpreted languages from basic mindteq list can do that .
Title: Re: Standalone compiled code, e.g. exe?
Post by: bplus on May 26, 2021, 17:49:07
No is not ...
It is most elegant way to run interpreted programs and whole bunch of windows
software work on similar way,many interpreted languages from basic mindteq list can do that .

Quote
No it is not...
"elegant"

It is literally tacky!

But maybe we should define elegance, otherwise we just throw our opinions at each other.

My definition of elegance is doing a job with the least amount of work and complication.

Tacking on an app at the end of an exe is just allot silly work, just run the app through the interpreter and distribute the interpreter with a ton of apps, you can also update app without having to tack it onto another exe.
Title: Re: Standalone compiled code, e.g. exe?
Post by: Aurel on May 26, 2021, 19:45:30
..and how is not
when you bind your source to interpreter runtime you get one compact exe.
 and what you see problematic there ?
On this way ther are some comercial program made.
Title: Re: Standalone compiled code, e.g. exe?
Post by: lettersquash on May 26, 2021, 21:04:22
No is not ...
It is most elegant way to run interpreted programs and whole bunch of windows
software work on similar way,many interpreted languages from basic mindteq list can do that .

Quote
No it is not...
"elegant"

It is literally tacky!

But maybe we should define elegance, otherwise we just throw our opinions at each other.

My definition of elegance is doing a job with the least amount of work and complication.

Tacking on an app at the end of an exe is just allot silly work, just run the app through the interpreter and distribute the interpreter with a ton of apps, you can also update app without having to tack it onto another exe.
But surely, for the user, having to install an interpreter program and then run the app through it is more work and complication than just getting an exe that they run in the usual way, possibly just unzipping it to a folder.
Title: Re: Standalone compiled code, e.g. exe?
Post by: Aurel on May 26, 2021, 21:19:05
of course it is better, imagine how many people on windows know how to use interpreter ,editor ..
another option ..maybe pack runtime with source ,then when user run runtime.exe then that runtime
load source and execute it ,
OR use .bat file ...
.OR use maybe some packer with autorun feature...
but all that are just ideas ...author must decide ...
Title: Re: Standalone compiled code, e.g. exe?
Post by: bplus on May 28, 2021, 16:00:09
of course it is better, imagine how many people on windows know how to use interpreter ,editor ..
another option ..maybe pack runtime with source ,then when user run runtime.exe then that runtime
load source and execute it ,
OR use .bat file ...
.OR use maybe some packer with autorun feature...
but all that are just ideas ...author must decide ...

OK get started. Show me.
Title: Re: Standalone compiled code, e.g. exe?
Post by: chrisws on May 28, 2021, 23:51:31
There are a few different applications for building installation programs:

https://en.wikipedia.org/wiki/List_of_installation_software

I've previously used NSIS but it looks like "Inno Setup' is fairly popular. Alternatively, I recently found this:

https://pakkly.com/

So basically you'd use one of these tools to build an single installer program. Running this would copy all of your application files into "Program Files" or where ever and then setup a menu entry ready to go.

For a SmallBASIC project, your application files would need to include sbasic.exe and perhaps some module dll's. I'm okay with anyone re-distributing these. Note that sbasicg and sbasici are not ideal for this use-case. I would be great to see something made with the raylib module.

Title: Re: Standalone compiled code, e.g. exe?
Post by: round157 on May 29, 2021, 03:12:45
For a SmallBASIC project, your application files would need to include sbasic.exe and perhaps some module dll's. I'm okay with anyone re-distributing these. Note that sbasicg and sbasici are not ideal for this use-case. I would be great to see something made with the raylib module.

Hello, by the way, I have a question about another thing.

Now there are two versions of SmallBASIC: sbasic.exe(console version) and sbasicg.exe(SDL version). All the current dll module files are used with sbasic.exe. I want to ask a question. Can the SDL features inside the sbasicg.exe file be packed into a dll module file as well? If it is possible for you to pack the SDL features into a dll module file, SmallBASIC users can therefore use the sbasic.exe file with this new SDL dll module file in the future. As a result, sbasicg.exe will not be needed anymore in the future. You only need to make the sbasic.exe file for the next version of SmallBASIC. More convenient for you. Moreover, users will not be confused any more.
Title: Re: Standalone compiled code, e.g. exe?
Post by: Aurel on May 29, 2021, 07:17:59
i think that is not possible to compile SDL library with sbasic.exe...
only if SDL exists as static library then you can compile it into one compact exe.
Hmm that is a problem ..i forget that sbasic depend on SDL ..
well then yes only solution would be packer ...but one
let say which compile (pack ) all files into one coompressed exe
like UPX do.
Title: Re: Standalone compiled code, e.g. exe?
Post by: chrisws on May 29, 2021, 08:03:09
i think that is not possible to compile SDL library with sbasic.exe...
only if SDL exists as static library then you can compile it into one compact exe.
Hmm that is a problem ..i forget that sbasic depend on SDL ..
well then yes only solution would be packer ...but one
let say which compile (pack ) all files into one coompressed exe
like UPX do.

The core code is just plain c with minimal dependencies. There's a bunch of UI code which depends on an internal interface.

Then the FLTK, SDL or Android versions depend on the internal interface.  This design is known as "dependency inversion".

So there could be a DLL which incorporates some of this UI code. It can all be statically linked.
Title: Re: Standalone compiled code, e.g. exe?
Post by: round157 on June 07, 2021, 12:09:04


The core code is just plain c with minimal dependencies. There's a bunch of UI code which depends on an internal interface.

Then the FLTK, SDL or Android versions depend on the internal interface.  This design is known as "dependency inversion".

So there could be a DLL which incorporates some of this UI code. It can all be statically linked.

So you meant that it was possible? Will you plan to make the SDL dll module?
Title: Re: Standalone compiled code, e.g. exe?
Post by: jsalai on June 08, 2021, 22:23:03
In the console version you can pass the -x option

$ sbasic -x foo.bas

This will run foo.bas and also produce foo.sbx

Now you can run:

$ sbasic foo.sbx
sbasicg -r foo.sbx
works too, for programs with graphics
didn't try on android, would be nice if it does - on android the prog doesn't regognize the extension
just a remark, the quoted strings are NOT scrambled and after editing the code still runs.
possible to fix?
cheers
Title: Re: Standalone compiled code, e.g. exe?
Post by: round157 on June 11, 2021, 08:47:34

sbasicg -r foo.sbx
works too, for programs with graphics

It is an astonishing discovery.

Quote
- on android the prog doesn't regognize the extension
just a remark, the quoted strings are NOT scrambled and after editing the code still runs.
possible to fix?

Perhaps only 'chrisws' is able to solve your problem. You need to wait for the help from 'chrisws'. Actually, I am not a real user of SmallBASIC. I am an curious observer of SmallBASIC.

Quote
cheers

Welcome to the forum!
Title: Re: Standalone compiled code, e.g. exe?
Post by: jsalai on June 11, 2021, 10:53:59

Welcome to the forum!
Thanks for your kind welcome post!

Quote
Perhaps only 'chrisws' is able to solve your problem. You need to wait for the help from 'chrisws'. Actually, I am not a real user of SmallBASIC. I am an curious observer of SmallBASIC.

Of course, although it is not a BIG problem, more an accurate observation.
On the other side I assumed, the "junior member" 'chrisws', is the real "administrator" of this small section dedicated to SmallBASIC, so I quoted his message.

And recently here was a discussion about the "old/new" name of the SmallBASIC, mu proposal would be:
VeryLargeBASIC, leaving the SMALL attribute to M$.

Thanks again, and take care... The stupidity conquers the World!

Title: Re: Standalone compiled code, e.g. exe?
Post by: bplus on June 12, 2021, 16:19:55
Hey @jsalai, glad you found us.

Any updates on the file manager program you had going?
Title: Re: Standalone compiled code, e.g. exe?
Post by: jsalai on June 12, 2021, 18:39:13
Hey @jsalai, glad you found us.

Any updates on the file manager program you had going?

Hi, B+,
nothing like that...
recently busy, in this idiotic lockdown times, with my granddaughter mechatronics-college education...
writing programs for statics, beam equilibrium, body/shape/line centroids, momenta of inertia (all complicated calculations) etc, physics and math, and searching and finding some new "bugs" in this, otherwise fantastic SmallBASIC.
Of course those programs have to run on android-phone, where this BASIC is non-plus-ultra, and so being a great help for the kid.
Fortunately all this "bugs" have their workarounds so it is nothing serious.

Hope you are well, I see you publish your masterpieces regularly in this Forum.
Take care,
"I've seen the future, brother, it is murder" - Leonard Cohen - "The Future"
Title: Re: Standalone compiled code, e.g. exe?
Post by: chrisws on June 13, 2021, 07:32:02
Hey @jsalai, glad you found us.

Any updates on the file manager program you had going?

Hi, B+,
nothing like that...
recently busy, in this idiotic lockdown times, with my granddaughter mechatronics-college education...
writing programs for statics, beam equilibrium, body/shape/line centroids, momenta of inertia (all complicated calculations) etc, physics and math, and searching and finding some new "bugs" in this, otherwise fantastic SmallBASIC.
Of course those programs have to run on android-phone, where this BASIC is non-plus-ultra, and so being a great help for the kid.
Fortunately all this "bugs" have their workarounds so it is nothing serious.

Hope you are well, I see you publish your masterpieces regularly in this Forum.
Take care,
"I've seen the future, brother, it is murder" - Leonard Cohen - "The Future"


I've created another open test version of Android SmallBASIC. Here's the list of changes:
- Fixed 'Socket Client doesn't receive byte with value 13' #112
- Fixed RGB handling with IMAGEs
- Fixed TSAVE of arrays includes extra null character. #119
- Fixed array access regression
- Implemented image.draw(), fix image.save in andoid #115
- Removed "requestLegacyExternalStorage" for AppStore compliance
- Removed path navigation to show unified view of available folders
- Removed samsung keypad warning


The 'requestLegacyExternalStorage' item is from something that google are enforcing.
Basically it means that navigating around the file system is no longer supported.


image.draw() is similar to the existing image.save() function. but instead of adding it to a draw stack, it just draws directly onto the screen.
The arguments are x,y and opacity.


It would be good to get some feedback about the navigation changes.

Title: Re: Standalone compiled code, e.g. exe?
Post by: jsalai on June 13, 2021, 11:21:56
Hi @chris,
glad to meet you again...
thanks for your wonderful work...

I wonder, if ALL those extensions you added were in the spirit of  [Small]BASIC, but...

Wish you good health, and take care....

"Get ready for the future, ... it is murder" - Leonard Cohen - "The Future"
Title: Re: Standalone compiled code, e.g. exe?
Post by: round157 on June 13, 2021, 11:35:23

On the other side I assumed, the "junior member" 'chrisws', is the real "administrator" of this small section dedicated to SmallBASIC, so I quoted his message.


Hello, 'chrisws' is the author of SmallBASIC. 'chrisws' always tries to make SmallBASIC better and is hardworking. By the way, several experienced users are frequent visitors to the forum. They are bplus, Aurel and lettersquash.

Title: Re: Standalone compiled code, e.g. exe?
Post by: jsalai on June 13, 2021, 12:55:59

On the other side I assumed, the "junior member" 'chrisws', is the real "administrator" of this small section dedicated to SmallBASIC, so I quoted his message.


Hello, 'chrisws' is the author of SmallBASIC. 'chrisws' always tries to make SmallBASIC better and is hardworking. By the way, several experienced users are frequent visitors to the forum. They are bplus, Aurel and lettersquash.

Hi, thanks for the explanation...

Don't take my comments too seriously. I just hate to use smileys... my avatar explains my nature

btw in illo tempore, somwhere else, I had contacts both with chris and b+, and, maybe, somehow, with all my humbleness, I could be counted into this "experienced users" group, though not very active in discussions recently.

cheers! and take care...
Title: Re: Standalone compiled code, e.g. exe?
Post by: lettersquash on June 13, 2021, 14:04:24
with all my humbleness, I could be counted into this "experienced users" group, though not very active in discussions recently.
Hi jsalai!
...and, in all honesty, I should probably be counted out of both "experienced users" and "frequent visitors to the forum". I've dabbled with a few things, but haven't a clue about all these more advanced issues about stand-alone programs, "wrappers", DLLs and the like.
Title: Re: Standalone compiled code, e.g. exe?
Post by: jsalai on June 13, 2021, 16:58:04
... but haven't a clue about all these more advanced issues about stand-alone programs, "wrappers", DLLs and the like.

Hi, LS,
I don't even try them. Being "experienced" means: Never use anything until it gets obsolete!

If I could find a kind soul to recode and recompile win98se to 64-bit OS, I would never leave it.
It was the ONLY thing ever M$ did right!

Hinds' 6th Law Of Computer Programming
Program complexity grows until it exceeds the capability of the programmer(s) who must maintain it.
SimplePortal 2.3.6 © 2008-2014, SimplePortal