Contents
What is Small Visual Basic?Small Visual Basic (sVB) is an educational programming language, created by Eng. Mohammad Hamdy as an evolved version of Microsoft Small Basic (SB). It is meant to be easier and more powerful at the same time, to introduce programming basics to kids and beginners of any age, provided that they can use the English keyboard on the Windows operating system. sVB full reference PDF bookWhen you install sVB, you will find a Try the samples:The sVB folder contains a samples folder that contains various projects. To try any sample, follow these instructions:
You can also open any sample folder in Windows Explorer, right-click any ".sb" file, choose "open with" from the context menu, and choose sVB.exe as the default program to open ".sb" files. After that you can just double-click any ".sb" file to open it in sVB. Using the sVB source code:sVB is an open source project, that is published as a GitHub repo. The source code of MS Small Basic is written in C#, but I converted a copy of it to VB.NET and uses it to create sVB. I am a professional C# programmer, but it seemed inappropriate to me to write a BASIC-family compiler with a C-family language (Not to mention that VB.NET is my favorite language). Furthermore, I wanted to use sVB as a training yard for understanding and working with compilers, both for me and for the VB.NET community. This small compiler with small tools, provides a very easy way to understand how compilers are built and how they work, which can make it easier in a next step to work with the VB.NET compiler (Which is a part of Roslyn). This is a necessary step for the VB community, after MS neglected VB.NET since 2017, and stopped evolving it since 2020. And this is why Anthony D. Green forked Roslyn and start evolving VB.NET under the name ModVB since 2022. Anthony had participated in designing and creating Roslyn and VB.NET in the first place, but he is still one man, and the community must help him maintain and evolve ModVB, if they really want it to live long and prosper. So, here is a small programming language written in VB.NET for you. You can fork it, play with it, and evolve it as you want, and when you feel comfortable with compilers, try to take a look at Roslyn and ModVB. Note that all sVB projects are WPF projects, that target the .NET framework 4.8. You can run the source code in VS.NET 2019 and later. But before running the code, please copy the "Lib" and "Toolbar" folders from the "SmallBasicIDE\SB.Lib" folder to the "SmallBasicIDE\bin\Debug" and "SmallBasicIDE\bin\Release" folders respectively, as obviously "Git" excludes these folders, and I prefer it this way. Why do we need sVB:
One day, Vijaye Raji has read the above article, so he decided to do something to solve that problem. In his spare time in Microsoft, he created the Small Basic as an educational programming language for 7 years old kids and above, and Microsoft had released it in 2008. I haven't read this article, nor even knew that Small Basic exists, when I tried to teach VB.NET to my 13 years old nephew, which was not easy for him! By the way, his name is Mohammad Hamdy Ghanem too, as my brother is named after my father, and his son is named after me ?. So, I found myself asking a similar question: Why can't Mohammad code? There are tons of fundamental facts about VB.NET that he needs to learn before producing any thing useful. He kept asking me about who would use such simple samples in the real world, and he was absolutely right! I had to build a simple car racing game to get his attention, but things wasn't that easy for him! User controls, objects, and inheritance?! He's absolutely got overwhelmed! I recall that the classic Visual Basic was much easier to start with, even for someone without any programming background, but VB.NET got complicated over years while it was getting more powerful. When I discussed this with the VB community, one developer suggested to teach him Small Basic instead, and that was the first time I hear about. I tried to do that in the next year with my younger nephews, Ali and Omar, and they already got interested with Small Basic. Small Basic is really small, containing only 14 keywords to perform the basic programming instructions like "Sub", "If", "For", "While" and "Goto" statements. Small basic is a dynamic language, as it doesn't declare variables of certain types. You just assign a value to a valid identifier and SB will declare it as a Primitive variable, which can hold a string, a number, or an array. This makes the language very easy to learn and use for kids. So, Ali and Omar were happy with SB, until they reached the graphics window drawings that depend on the sine and cosine functions, which were hard to them, because they were still in the 4th grade without any trigonometry background! The PDF book that comes with SB makes it hard y focusing on drawing shapes by using trigonometric functions (it even contains a fractals sample!) This is not the best way to introduce programming to kids. A black command window (the Text Window) is easy but boring, while using vector graphics or drawing using the turtle on the Graphics Window is amazing but can be quite hard. The good news is that the Controls class allows you to draw a TextBox, and a Button on the Graphics Window, deal with their properties and handle their events. But, unfortunately, the kid has to design the form blindly while adding controls by code. Furthermore, the code used to communicate with these controls is verbose, because SB doesn't have objects, so, you can only store the name of the control in a variable, then send it to static/shared methods to change its properties or perform its tasks. For example:
This is not the kind of code you want to show to a kid! In fact it will be easier to teach him Visual Basic, so he can drag a button form the toolbox, drop it on the window, set it's name and caption from the properties window, double-click it to go to it's click event handler in the code editor, and just write:
And that's it. A fast, clean, easy and short code, that made us love programming! It is unbelievable that SB complicated such an easy task, in the name of being simple and easy to learn for kids! I tried some SB alternative IDEs, but they are either:
I published the a sVB prerelease on GitHub in January 2021, and invited the SB team to use the idea to evolve SB, but they didn't seem interested! For about 5 months, I had no intension to do anything further, but in June 2021, my beloved grandmother Om Wahba died, God rest her soul, so, I decided to complete sVB to honor her. Also in that time, my nephew Mohammad Mohsen started to see my YouTube videos about SB, and I wanted to spare him the SB issues I explained above, so I worked hard to release the first sVB stable version in July 2021, which had only 3 controls in the toolbox! I kept updating the language over the next two years, until it hit v2.8 with the release of this book. That was the story of the three years journey from Small Basic to Small Visual Basic. It is also a Small Visual Basic .NET!You can say that: Small Visual Basic = Small Basic + Visual Basic: but this in not the whole truth! sVB is meant to be a middle step in between SB and VB.NET, so, its syntax combines the best of SB, VB, and VB.NET languages! It is also as easy as Windows Forms, but also has some advanced WPF graphical features! Let's look a little deeper into that: sVB and Small Basic:sVB is built on top Small Basic IDE, compiler and library. In most cases, SB code works in sVB, but there are a few breaking changes that we will explain in the next paragraphs. sVB also introduces some enhancements in to SB, such as:
sVB and Visual Basic: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. To do that, sVB contains a small WinForms library and a form designer that allows you to add many forms to the project and only one global module. You can drag controls from the toolbox, drop them on the form and double-click any control to get its default event handler created for you, where the ControlName_EventName naming convention is used to recognize the event handlers. You can also add event handlers from the upper dropdown lists, by choosing the control name from the left list (say "Button1"), and click the event name from the right list (say "OnClick"), so this sub will be added for you in the code editor:
Like SB, sVB is a dynamic language, that uses the same syntax rules of Visual Basic syntax when you use these two statements at the top of the VB code file:
sVB also has some other VB syntax features that are not supported by SB, like:
But note that there are a few syntax differences between SB/sVB and VB, such as:
sVB and Visual Basic .NET:sVB in fact can be called sVB.NET, because it supports some VB.NET syntax features like:
Also, this operator can be used to add dynamic properties to arrays, like the Expando Object in VB.NET, but sVB provides auto-completion dynamic properties, and you can even use comments to provide intellisense info about them:
The above code is the short form of this code:
The above example may not be so important to you, but it can be when sVB infers the variable type from an expression or a method return value, especially when the method returns a form or a control, so that sVB can treat the variable as a control, which makes it easier to deal with its methods and properties directly:
This somehow puts sVB in between of dynamically-typed and statically-typed languages! 8. The source code of sVB itself is written in VB.NET, and sVB projects are compiled to IL code, the same as VB.NET and C# projects! This means you can use any reflector to decompile any exe created by sVB back to a C# project! 9. The sVB WinForms controls and their methods are so close to those of the VB.NET WinForms. 10. sVB has a small UnitTest framework that allows you to write and run test functions to test your project. 11 sVB can create its own class libraries, in addition to the ability of using VB.NET and C# to create libraries for sVB. sVB IDE and VS.NET IDE:sVB editor is built on top of SB editor, with many enhancements that make it more like a small VS.NET editor, such as:
sVB and WPF:sVB is built using the Window Presentation Foundation (WPF) framework, to have advanced IDE features. For example, the form designer allows you to easily create advanced visual effects, like rotating and skewing controls, and the color dialog allows you to use solid brushes, linear and radial gradient brushes, and tile and image brushes to draw the control's boarder, background and foreground, which allows you to change the form and controls shapes. For example, when you run the FormShape project from the samples folder, you will see this elliptical form, where its transparent ages really don't exist, so you so can click any other windows through them! when you run the ListBox2 project from the samples folder, you will see these elliptical buttons: Besides you can use the Control.SetResourceDictionary and Control.SetStyle methods to load a resource dictionary from an external xaml file, to apply advanced styles on the form and any other controls you want to target! sVB for kids:It is fair to wonder about how to introduce sVB to kids, while it seems very big compared to SB. In fact sVB can be too easy for kids. All you need is to prepare some attractive images, use the color dialog to display them in labels, and use the animation methods to write some short and funny applications that interests small kids (see the animation and Jerry projects in the samples folder). You can start with codeless apps, use the form designer to display some shapes and images, use the color dialog to change their back colors. In the next step you can add some buttons to the app, each with a single code line that can animate the shape location, color or transparency. In the next step you can introduce variables, but avoid If statements and loops until the kid gets comfortable with the language. In fact I published a course to teach sVB for kids on YouTube, but it is in Arabic. It contains about 60 videos (10 minutes in average), and I think it is easy for developers and teachers to view them even they don't understand Arabic, as the visual design and the little sVB code used, with the aid of this book, will be easy to comprehend, so, you can get the idea and build upon. I encourage youtubers to introduce such a course in English and other languages, and they are free to reuse any ideas from my course without worrying about copyrights. Conclusions:
|