Results 1 to 9 of 9

Thread: Small Visual Basic v1.3.2

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2020
    Posts
    47

    Small Visual Basic v1.3.2

    You can download the latest version of the language from the Releases page:
    https://github.com/VBAndCs/sVB-Small...Basic/releases
    Navigate to the latest version of vSB, expand the Assets list at the bottom of the page, and download the ZIP file
    ***
    Small Visual Basic (sVB) is an evolved version of Microsoft Small Basic with a small WinForms library and a graphical form designer. It tries to achieve 3 goals:
    1. make sVB easy for kids between 6 and 12 years old. I added some animation and rotation methods to the label control besides the Image property to make things funny for kids.
    2. make sVB powerful enough to be an easy entry point for beginners between 13 and 20 years old. They can design forms and create simple games like the cars game in the samples.
    3. Encourage VB .NET programmers to enter the compilers world by studying sVB source code.
    It's an open source project, fully writing in VB .NET and WPF:
    https://github.com/VBAndCs/sVB-Small-Visual-Basic

    The first two goals aim to deliver VB to a new generation of programmers, and the last one aims to help VB programmers to understand Roslyn in a next step, to be able to evolve VB .NET after MS ignored it.

    sVB has many enhancements over SB to make writing apps fast and easy with little code. It brings back the joy and excitement of using vb6 to write RAD applications.
    See the samples folder:
    https://github.com/VBAndCs/sVB-Small...master/Samples.

    SB Code Enhancements:
    I made many improvements to the SB compiler:
    1. Support array initializers:
    You can use the `{}` to set multiple elements to the array at once:
    Code:
    x = {1, 2, 3}
    Nested initializers are also supported when you deal with multi-dimensional arrays:
    Code:
    y = {"a", "b", {1, 2, 3}}
    You can also use vars inside the initializer, so, the above code can be rewritten as:
    Code:
    y = {"a", "b", x}
    And you can send an initializer as a param to a function:
    Code:
    TextWindow.WriteLine({"Adam", 11, "Succeeded"})
    2. `For Next` and `While Wend`:
    SB uses `EndFor` and `EndWhile` to close `For` and `While` blocks respectively. This is still supported in sVB but I allowed also to use `Next` to close `For` and `Wend` to close `While`, as they are used in VB6. I encourage you to use Next and Wend, as they give the meaning of repeating and circulating over the loop. `End` gives the meaning of finishing and exiting, so, it is suitable in `EndIf` and `EndSub`, but confusing in `EndFor` and `EndWhile`, as they can imply that `the loop finishes here`, not just `the block ends here`!

    3. You can use `ExitLoop` to exit For and While loops, and `ContinueLoop` to skip the current iteration and jump back to the beginning of the loop body to continue the next iteration in for loop. Be aware that unlike For, while doesn't have an auto-incremented counter, so be sure you write the suitable code to update the variable that while condition depends on before using ContinueLoop inside the while block, otherwise you may end up stuck with an infinite loop.
    In the case of nested 2 loops of any kind, you can exit the outer loop by using `ExitLoop -`. You can add more `-` signs to exit up levels loops in case you have 3 or 4 nested loops, or just use `ExitLoop *` to exit all nested loops at once. The same rules applies to `ContinueLoop` if you want to use it to continue outer loops.

    4. You can use `Me` to refer to the current Form.

    5. True and False are keywords of sVB.

    6. Subroutines can have parameters now:
    Code:
    Sub Print(Name, Value)
       TextWindow.WriteLine("Name=" + Name + ", Value=" + Value)
    EndSub
    And call this sub like this:
    Code:
    Print("Distance", 120)
    You can use `Return` inside the sub body to exit the sub immediately.

    7. sVB can define functions now. You can supply params to get the function input and use `Return` to return the function output.
    Code:
    Function Sum(x, y)
        Return x + Y
    EndFunction
    And you can use it like this:
    x = Sum(1, 2)
    8. SB doesn't have variable scope, as all variables are considered global, and you can define them in any place in the file and use them from any other place in the file (up or down). sVB has cleaned this mess, which is a break change that can prevent some SB code from running probably in sVB, but it is a necessary step to make the kid organize his code and write clean code. This is also necessary to make sub and function params work correctly, and allow you to use recursive subs and functions. The new scope rules are:
    - Sub and function params are local, and hides any global vars with the same names.
    - The For loop counter(iterator) is local and hides any global var with the same name.
    - Any var defined inside the sub or the function is local unless there is a global var with the same name is defined above of the sub function. If the global var is defined below, then the local var will hide it.
    So, as a good practice:
    - Define all global vars at the very top pf the file.
    - Give global vars a prefix (such as `g_`) to avoid any conflictions with local vars.
    - Don't use global vars unless there is no other solution, instead pass values to subs and functions through params, and receive values from functions through their return values.

    9. The editor auto completes If, For, While, and Sub blocks just after writing a space after them.

    10. The editor has a perfect auto-indentation.

    11. sVB naming conventions:
    - The first naming convention: Any var ends with or starts with a control name (like Form1 or myLabel) will be treated as a Control Object, so you can use the short syntax Control.Property and the auto completion list will appear to help you complete method and properties names.
    Note that you don't need this naming convention when you name the controls you add by the form designer. Name them as you want, and sVB will still know that they are controls thanks to the .sb.gen file generated by the designer.

    - The second naming convention: Any var ends with or starts with the word `Data` is treated as a dynamic object, and you can add properties to, and get auto completion support.
    Code:
    CarData.Color = Color.Red
    CarData.Speed = 100
    x = CarData.Speed
    In fact, sVB converts the above syntax to:
    Code:
    CarData["Color"] = Color.Red
    CarData["Speed"] = 100
    x = CarData["Speed"]
    Note that this naming convention rule ignores var domain rules, to allow you reuse the properties across subs and functions. This is totally safe as it only affects the property names that will appear in the auto completion list, but it has no effect on the variable domain rules when you run the program. You may see property names from a data object from another function, but you still can't read these properties values in code. It is just a way to make coding faster and easier.
    - The third naming convention: Any `Data` var that contains the name of another data var (after trimming the `Data` part of them both) will show the union of their properties in the auto completion list. This allows you to `inherit` other data properties. As an example, if you use the names Car2Data, or myCarData in the above example, they will show the Color and Speed properties (coming from CarData) in the completion list"
    Code:
    Car2Data.Speed = 200
    Car2Data.Acceleration = 10
    And if you use `MyCar2Data` you will inherit all properties from `MyCarData`, `Car2Data` and `CarData`!

  2. #2
    Frenzied Member
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    1,578

    Re: Small Visual Basic v1.3.2

    All additions to the BASIC world should be applauded, especially if it encourages the youngsters.

    I do wish there was an equivalent of the ECMA group for BASIC and then we could all have one evolving BASIC working toward a standard that all could follow with best practice enshrined or at least being the ultimate aim.
    By the power invested in me, all the threads I start are Niya and Olaf free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2020
    Posts
    47

    Re: Small Visual Basic v1.3.2

    Quote Originally Posted by yereverluvinuncleber View Post
    All additions to the BASIC world should be applauded, especially if it encourages the youngsters.

    I do wish there was an equivalent of the ECMA group for BASIC and then we could all have one evolving BASIC working toward a standard that all could follow with best practice enshrined or at least being the ultimate aim.
    I like this idea.
    Thanks

  4. #4

    Thread Starter
    Member
    Join Date
    Apr 2020
    Posts
    47

    Re: Small Visual Basic v1.3.2

    sVB reached v1.8.5 now, with many new features in compiler, editor, and form designer. Check the source code and the Readme out:
    https://github.com/VBAndCs/sVB-Small-Visual-Basic
    Note that the solution now contains the source code of Avalon Text Viewer (written in VB .NET) which is an advanced editor that is used to build the Small Basic code editor. You can use this editor to crate any sort of editor you want. Its source code is in the ToolsFramework project

    You can also download the sVB 1.8.5 release:
    https://github.com/VBAndCs/sVB-Small...eases/tag/v1.8

  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2020
    Posts
    47

    Does VB.NET has a future? Yes of course!

    To those who worry about VB.NET future. Please don't!

    1. VB.NET has a new future with ModVB, a Roslyn-based VS.NET_hosted modern VB compiler that is built on top VB.NET by one of Rolsyn and VB.NET creators:
    https://anthonydgreen.net/2022/08/20/introducing-modvb/

    2. I am trying to attract a new generation to VB.NET by introducing Small Visual Basic to kids, where I am trying to make it easier than SB and more attractive but more productive and educative for children from 6 to 17 years old. Please help me tell children about, and introduce it to tour kids:
    https://github.com/VBAndCs/sVB-Small-Visual-Basic

    3. Small Visual Basic has another purpose, as the SB source code is written in C#, but I converted it to VB.NET, and built sVB on top of it. It is a small compiler, with a small code editor, and a small form designer, so, it is a perfect entry point to learning compilers. It was my playground before trying to enter rthe Roslyn world. VB.NET code in Roslyn exceeds 1 million lines, not to mention common tools and parts with C#! So, I hope some of you try to understand Visual small basic source code, then catch up with Roslyn, to help evolve ModVB.
    4. I used Roslyn source code generators to allow VB.NET to create more advanced records than that of C#. It is a proof of concept that we can extend the language without altering the compiler itself:
    https://github.com/VBAndCs/VB-Record-Source-Generator
    And it also gives you a glimpse about Roslyn syntax tree and semantic model.
    5. And of course there is Mercury: a non-Roslyn version of VB.NET, that takes VB.NET cross platform and supports ASP.NET core, Wasm , and mobile apps:
    https://www.remobjects.com/elements/mercury/

  6. #6
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,072

    Re: Does VB.NET has a future? Yes of course!

    You posted about it here too: https://www.vbforums.com/showthread....this-in-Roslyn

    Please don't post duplicate posts. I've removed it from the linked thread.

    Also this thread is not a Visual Basic .NET question, rather it is a discussion about a BASIC flavored compiler. So I moved this from the Visual Basic .NET forum (which is for Visual Basic .NET questions) to the General Developer forum.

    Edit - I have merged similar threads related to "Small Visual Basic" together.
    Last edited by dday9; Sep 19th, 2022 at 11:42 AM.
    "Code is like humor. When you have to explain it, itís bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  7. #7
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    791

    Re: Small Visual Basic v1.3.2

    I do wish there was an equivalent of the ECMA group for BASIC and then we could all have one evolving BASIC working toward a standard that all could follow with best practice enshrined or at least being the ultimate aim.
    Note that there is an ISO standard for Basic (out of date!):
    https://www.iso.org/standard/18321.html


    There was an ISO working group for Basic (WG8 of SC22) but it has now been disbanded.
    https://en.wikipedia.org/wiki/ISO/IEC_JTC_1/SC_22

    For those interested, perhaps you could re-start that working group?

    For contact details:
    https://www.iso.org/committee/45202.html
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.3.4)

  8. #8
    Junior Member Cristianlt23's Avatar
    Join Date
    Jan 2021
    Location
    Brasil - Cidade de Uberaba
    Posts
    24

    Re: Small Visual Basic v1.3.2

    Quote Originally Posted by 2kaud View Post
    Note that there is an ISO standard for Basic (out of date!):
    https://www.iso.org/standard/18321.html

    For those interested, perhaps you could re-start that working group?

    For contact details:
    https://www.iso.org/committee/45202.html
    Congratulations for the initiative.

    I agree that the BASIC world deserves an equivalent like ECMA mentioned by @yereverluvinuncleber.

    I particularly believe that BASIC needs to have its own ecosystem like:
    IDE, compiler, standardized language taking advantage of the best of all dialects, having its own superset for JS (who knows how to evolve VBhtml?), being on all fronts of development.
    It would also be interesting to have a central channel to ask questions and learn new things (I think VBforums is the ideal place to definitely become the home of the standardized BASIC developer)

    The cost to maintain a dedicated community, on average 4 people to create and evolve this ecosystem can come from the developers and companies themselves, it is much cheaper than changing languages ​​every year, the value can be around 2 to 5 US$ per month as a developer donation and $25-40 per company.

    I even have a name suggestion for a new BASIC ecosystem - "VB++"
    Last edited by Cristianlt23; Sep 24th, 2022 at 01:51 PM.

  9. #9
    Frenzied Member
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    1,578

    Re: Small Visual Basic v1.3.2

    With ECMA, they created ECMAscript, the standard definition that all javascript languages were meant to follow.

    The body, European Computer Manufacturers Association created a standard for javascript because it was so widely used and to prevent someone like MS hijacking it. Perhaps an august body of similar standing has to show interest in BASIC or such an organisation might have to be created in it's stead.

    I strongly doubt any existing body would take any such action being disinterested in BASIC so it would have to be the latter. I propose Wayne Phillips and Olaf Schmidt to the board (no insult meant to any of the other fellow experts here).
    By the power invested in me, all the threads I start are Niya and Olaf free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width