We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SmallBasic Open Edition
#11
Hello everyone.

I know I shouldn't remember these anymore, but back in the day when I got excited about programming, the options for home computers were GWBasic, BASICA or MSX-Basic.

Pascal and C and a few others had of course already appeared, but 95% of the home programmers of that time used Basic.

For example, in GWBasic, the type of variables was indicated right at the end of the name.

Code:
$: String variable
%: Integer variable
!: Single-precision variable
#: Double-precision variable


Regarding naming, there were otherwise very much the same rules as now in SmallBasic. And the Basics of that time didn't require variables to be initialized separately anyway, instead a variable could be activated by simply entering a value for it. And if I remember correctly, a variable that wasn't even created yet always gave a value anyway. String "" and numeric variables with a value of 0.

As long as the size of the code remains in the tens or at most a couple of hundred lines, this is usually not a problem. But as the program grows, it very soon becomes a problem.

I started to make the game described above, where the player was controlled in a changing environment while the computer-controlled guys moved there. In the game, you could shoot with a few different weapons, the field of view was limited by the walls etc. in the terrain.

SmallBasic would have been able to function as an engine in that game, but the programmer, i.e. me, simply lost my nerve. Naming variables and tables took more time and effort (read pain) than figuring out the calculation needs of the game engine itself. The fact that all variables were always globally visible made it worse.

Programming is the same, whether you use Basic, C or even JavaScript. It is "talking" to the computer in a specific language. And the majority of languages work very much the same way.

In my opinion, perhaps too much is being thought about today, which is the best language for a beginner. I think the whole question is completely wrong. One should ask "how do we teach logical and mathematical thinking to a person interested in programming?"

I personally like the way variables are used in JavaScript. They must be initialized separately and followed by the suffix "$", but the type of the variables is free. That is, the same variable can be either a string, double, integer or even an object.

Probably some sort of hybrid model would be best, at least initially.

Option SB at the beginning of the code would try to emulate SmallBasic as best as possible. A bit like, for example, FreeBasic can be used in different "modes" by entering parameters to the compiler. Even if "-lang qb".

Code:
#option SB
a = 1
MySub()
TextWindow.WriteLine(a)
Program.End
Sub MySub
  a = a + 1
EndSub

Output: 2

Without the option, things wouldn't work the same way.

Code:
a = 1
MySub()
TextWindow.WriteLine(a)
Program.End
Sub MySub
  a = a + 1
EndSub

Output: 1

MySub does not have visibility into the variable 'a' named in the main program, so it creates a new variable for itself with an initial value of 0. When returning from the subprogram, the original variable a is used.

But I still have some work to do to get the error checking done, bug fixes and variable typings right with the library, so these thoughta can be left to simmer in the background for now.

However, it's nice to note that there are still enough enthusiastic people around SmallBasic.
[-] The following 1 user Likes KristianVirtanen's post:
  • AbsoluteBeginner
Reply
#12
Hi again.

The library itself is practically ready. I got it done in the evenings and the documentation also written, so I think this progressed even better than expected.

In practice, two more things need to be done.
  • Testing code for each class in C#. I have already written these in a couple of classes, but many are still missing.
  • Explanation of the key differences between smallbasic.dll and SmallBasicOpenEditiondll.dll


And hey litdev, if you want to keep your forum just for the original SmallBasic, just let me know. I don't want to force myself here with my own project.
Reply
#13
(10-18-2024, 08:41 AM)KristianVirtanen Wrote: And hey litdev, if you want to keep your forum just for the original SmallBasic, just let me know. I don't want to force myself here with my own project.

No, go for it here - there is definitely interest and keen to see how it progresses.  I always felt that Small Basic was a great introduction to programming, but should encourage folk to take the next steps - the next logical being C# probably.
[-] The following 2 users Like litdev's post:
  • AbsoluteBeginner, jrmrhrb00
Reply
#14
Kristian,  

Not that I am a pessimistic person, but why do all of this when we already have SB-Prime? In SB-Prime you can already do a decompile to c# which is, as I understand, will get you to where SmallBasic Open Edition will get you to. With a decompiled program which is in c# you can already see and learn how to program in c#.

I don't want to discourage you, but truthfully, I don't see the point.

JR
Reply
#15
Hi JR,

Like probably everyone else here on the forum, I truly appreciate the work that has been put into SB-Prime.

I remember when I explored it first time out of curiosity, it was easy to see the level of effort and enthusiasm involved. SB-Prime is undoubtedly a valuable tool for anyone working with the original SmallBasic.

That being said, SmallBasic Open Edition has a different focus and goal.

The purpose of my project is to create a standalone, open-source converter that translates SmallBasic code directly to modern C# using .NET 8.0. This approach offers a few distinct advantages:
  • Independence: It doesn’t rely on the original SmallBasic environment or its future development, providing more flexibility and long-term viability.
  • Modern Framework: SBOE is built with the latest long-term support .NET 8.0 Framework. With the source code fully available, adapting and evolving it to fit future frameworks becomes much more straightforward.
  • Reliability: While decompilation can be a helpful learning tool or useful for converting smaller applications, it’s not always reliable for exact reproduction of the original source code—especially for larger, more complex projects. My project aims to provide a cleaner, more dependable solution.
  • Internal Development Flexibility: The original SmallBasic was designed to follow certain rules, and even though those could theoretically be modified at the source level, doing so would be a huge task at this point.


While both projects use C#, they serve different purposes and cater to different needs within the community.

Personally, I think SmallBasic is in a situation somewhat like QBasic was about 20 years ago with its DOS dependency. It’s time for an upgrade to more modern frameworks.

Regardless of whether my translator becomes widely used, I believe any work that helps keep this nice and comfortable language alive is a positive contribution.

- Kristian
[-] The following 3 users Like KristianVirtanen's post:
  • AbsoluteBeginner, jrmrhrb00, litdev
Reply
#16
.net 8 don't work in my windows 8.1 the most worst thing of ms to remove older version when new come
our sb libs targeting.net 4.5 may not work
ZS
Reply
#17
I guess the idea is that it is a conversion from SB to C# that reproduces the standard library functionality using natural C# code and types (not Primitive types and more conventional array/lists for example).

Comments:

  1. It won't handle SB extension code unless it uses of Primitive type for these
  2. I would use fully normal C# types (String, Int, Double, Decimal etc and maybe Var for declarations), rather than dynamic (this is not how C# code would normally be written and the idea I think is to show users what C# code would normally look like rather than a direct reflection of SB)
  3. The hardest part of course will be writing a fully compatible (apart from extensions) code syntax converter - not using reflection (using classes, event handling etc that shows how good C# should be written).
  4. I don't see any reason to use .Net Core (8) for this, all can be done welll more compatibly in .Net framework (4.8) - A user can always increase .Net version (harder to reduce it - always use the lowest most compatible version of .Net that can achieve your objectives)
Reply
#18
Hello.

Now I want to clarify that this is not a re-creation of the SmallBasic environment as it is now, but a compiler with a library that converts SmallBasic code to C# and compiles it.

SBOE.dll supports and uses all appropriate data types, string, int, boolean and so on.

If the SmallBasic code to be compiled does not have a separately defined variable type, the compiler marks it as a dynamic variable.

[sb-code]
'This is ok.
a = 1
a = 2.3
a = "text"
[/sb-code]

[C# code]
dynamic a;
a = 1;
a = 2.3;
a = "text";
[/c#-code]

[sb-code]
' But you can also do this.
int a
a = 1
a = "This causes error"
[/sb-code]

[C# code]
int a;
a = 1;
a = "This causes error"; // As expected, this causes error.
[/C#-code]

I fully understand that those who have used SmallBasic for years would want an exact replica of the language itself, the editor, extensions and so on, but that is not the goal.

Some things are left out completely, some things change and some things come as new additions.
Reply
#19
Ok got it I am currently making a simple traspilier for js that will traspile a basic like but powerful language which I call skull script.
I will also write if I got time in it smallbasic.js for converting sb to online js html code.
The most of the work of it is over just finishing left.
I could give a example :
PHP Code:
let x "hello world from skull script!!"
Console.log(x)
if 
b
    Console
.log("a > b")
end 
It's just like typescript converts to js but typescript offers some great features while skull script is as powerful as js but not more than typescript.
Well see how it goes if we got some community we could extend it more.
Currently I made its transpilier in csharp but I will make one more copy of it in cpp or c for cross platform support and if got time a js version.
ZS
Reply
#20
Hi z-s.

JS was my first language of thoughts when i planned to make some kind of translator/converter. but i ended up to C#.

I hope you succeed with your project.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)