September 23, 2021, 18:38:46

Author Topic: Standalone compiled code, e.g. exe?  (Read 2040 times)

Offline lettersquash

  • Jr. Member
  • **
  • Posts: 96
    • Lettersquash Blog
Standalone compiled code, e.g. exe?
« 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.
I'll have you know, I'm coding all the right commands, just not necessarily in the right order.

Offline bplus

  • Full Member
  • ***
  • Posts: 221
Re: Standalone compiled code, e.g. exe?
« Reply #1 on: May 13, 2021, 00:13:27 »
I might be able to convert something and compile for you in QB64. Is it very long?

Offline lettersquash

  • Jr. Member
  • **
  • Posts: 96
    • Lettersquash Blog
Re: Standalone compiled code, e.g. exe?
« Reply #2 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,
¬~
I'll have you know, I'm coding all the right commands, just not necessarily in the right order.

Offline chrisws

  • Full Member
  • ***
  • Posts: 117
    • SmallBASIC
Re: Standalone compiled code, e.g. exe?
« Reply #3 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.

Offline round157

  • Sr. Member
  • ****
  • Posts: 469
Re: Standalone compiled code, e.g. exe?
« Reply #4 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)

Offline chrisws

  • Full Member
  • ***
  • Posts: 117
    • SmallBASIC
Re: Standalone compiled code, e.g. exe?
« Reply #5 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.

Offline lettersquash

  • Jr. Member
  • **
  • Posts: 96
    • Lettersquash Blog
Re: Standalone compiled code, e.g. exe?
« Reply #6 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.
I'll have you know, I'm coding all the right commands, just not necessarily in the right order.

Offline bplus

  • Full Member
  • ***
  • Posts: 221
Re: Standalone compiled code, e.g. exe?
« Reply #7 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?

Offline round157

  • Sr. Member
  • ****
  • Posts: 469
Re: Standalone compiled code, e.g. exe?
« Reply #8 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!  :)

Offline lettersquash

  • Jr. Member
  • **
  • Posts: 96
    • Lettersquash Blog
Re: Standalone compiled code, e.g. exe?
« Reply #9 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.
I'll have you know, I'm coding all the right commands, just not necessarily in the right order.

Offline bplus

  • Full Member
  • ***
  • Posts: 221
Re: Standalone compiled code, e.g. exe?
« Reply #10 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 ;-))

Offline lettersquash

  • Jr. Member
  • **
  • Posts: 96
    • Lettersquash Blog
Re: Standalone compiled code, e.g. exe?
« Reply #11 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
I'll have you know, I'm coding all the right commands, just not necessarily in the right order.

Offline round157

  • Sr. Member
  • ****
  • Posts: 469
Re: Standalone compiled code, e.g. exe?
« Reply #12 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.

Offline round157

  • Sr. Member
  • ****
  • Posts: 469
Re: Standalone compiled code, e.g. exe?
« Reply #13 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.

Offline lettersquash

  • Jr. Member
  • **
  • Posts: 96
    • Lettersquash Blog
Re: Standalone compiled code, e.g. exe?
« Reply #14 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. :))
I'll have you know, I'm coding all the right commands, just not necessarily in the right order.

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal