The Power of B4X

I don't know if anyone made statistics regarding how many percent of a language we use.
I remember "upgrading" my Sinclair Spectrum computer to the Atari XE. The hardware was fabulous, but the built-in Atari Basic ruined it for me after the incredibly intelligent Sinclair Basic.
Then came the Atari ST with GFA Basic, which was another very intelligently written language.
Then Delphi, which is also a clean language, but there the programmer started drowning in it. There were endless discussions about the language itself, rather than the tasks it was supposed to make easier.
VB.NET is also friendly, but there again the ocean of a language is more in focus than it should be.
What makes a language, as a tool, good?
It seems to me that in a good language we can achieve the same task as in a worse language, with fewer commands and in a more consistent wording. That is, if you can combine your building blocks in more flexible ways, you don't need so many of them. You use them more often, in more situations.
And this is where Sinclair, GFA and B4X shine. The number of keywords and possible syntactical expressions is "limited", yet we can perform everything that the other languages can, in a simpler way.
B4X's automatic casting, duck typing, the simple List and Map objects can do everything. Simple constants are better than setting up things like:

What we don't need:
  [Flags]

   enum MultiHue : short

   {

      None = 0,

      Black = 1,

      Red = 2,

      Green = 4,

      Blue = 8

   };

Yup, this is how to make a simple definition of five constants dramatic and bombastic without gaining much. Does the above monster make my life really easier? Would I ever miss it from B4X? Not me.
However, a "limited" language can only succeed if its keywords, syntax and solutions are well chosen. This is where science meets art. Nothing can substitute human intelligence, experience and attitude here. Erel is not peppering his creation with useless features that we will never use or use 1% of the time. We don't need to concentrate on the language, but on the job to do with it. And when a new feature finds its way into B4X, it is there to be used often and solve a lot of problems at once. Erel has an enormous talent and just the right attitude to come up with language features sparingly, but in a way that keeps his language attractive, friendly and powerful. This is a unique gift to be admired.

And that is why B4X can be learned by almost anyone, in just a few days(or hours) - and there is nothing it cannot do. I'd rather resort to using JavaObjects on the rare occasion when something extra has to be done than deal with a vast language, 80% of which I will never utilize.

And it makes every B4X program simpler to understand, easier to read(and write) and therefore more pleasant to the eye.

A powerful language like this can shape the programmer's attitude, too. It can keep him on track to concentrate on WHAT he wants to achieve rather than HOW he wants to do it.

That is the power of B4X.
 

LucaMs

Expert
Licensed User
Longtime User
Using a code module that "acts as Enum" is a great idea, I hadn't thought about it.
Another (not perfect) idea: that kind of code modules, "Enum code modules", might provide an AsList method.
You can guess why and how it might be useful.

It has a drawback: the list would contain editable values, the values of the constants. On the other hand, there would also be advantages, such as using the methods of Lists, mainly IndeOf, I think.

And... a comment like: "You shouldn't change the values in this List" might be enough for a shrewd programmer.
 
Last edited:

William Lancee

Well-Known Member
Licensed User
Longtime User
If one wants to use the enumX.property construct for grouped constants there is always this:


B4X:
Sub Process_Globals
    Type enumA(goAHead As Boolean, firstThree() As Int, myName As String)
End Sub

Sub AppStart (Args() As String)
    Dim enum As enumA = newEnumA(True, Array As Int(1, 2, 3), "William")
    Log(enum.myname)
End Sub

'this is automatically created by hovering over enumA - I always rename to "newXXXX"
Public Sub newEnumA (goAHead As Boolean, firstthree() As Int, myName As String) As enumA
    Dim t1 As enumA
    t1.Initialize
    t1.goAHead = goAHead
    t1.firstthree = firstthree
    t1.myName = myName
    Return t1
End Sub
 
Top