Wish Object-Oriented Programming

Toky Olivier

Active Member
Licensed User
Longtime User
This thread is old but I think still relevant.
I admit that B4X language is simple and powerfull. But I think, will perform more with full OOP features or at least the mos used (inheritance, overriding, polymorphism, ...).
As I posted as wish in the forum, and as we said: It's time to grow. We need to attract developpers! And most developpers come from full OOP world (for iOS, android, java development).
Many of you said, you choose B4X because it's simple. Yes, but why not making the features available and you choose use it or not? And @Erel said in some thread that it isn't difficult to implement it. That's nice. Me too, I think so because all language that B4X are translated to on compilation are already object oriented.
I'm sure, we'll attract more developers with it! And we all want this!
 

Toky Olivier

Active Member
Licensed User
Longtime User
I would like to add: there is also basic language like Cerberus-X (https://www.cerberus-x.com/community/portal/, https://github.com/MikeHart66/cerberus ) which is a fork from Blitz et al. language from the creator Mark Sibly. Sure that they don't have the same notoriety as B4X now but it's because of another reason. I used the origin language Blitzbasic, Blitzmax and the last Monkey2 (https://github.com/blitz-research/monkey2) because of this ease of programming with very modern basic language even with full oop features. They had vibrant community also before and may be a huge competitor of B4X if the creator is like @Erel and didn't change many times his main product and finally drop support in the end.
In addition, I'm also developping softwares with Object pascal (sorry, I should because of many reasons): FPC and Delphi. The language is old and mature BUT there is constantly evolution of the core language. Compiler team improve it every day. World change every day and yes, we need to adapt to, improve...
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
But I think, will perform more with full OOP features or at least the mos used (inheritance, overriding, polymorphism, ...)
Polymorphism is supported through duck typing. You can see many examples, the last one in B4XDialog templates.
Concrete inheritance, which is what you are actually requesting, is considered bad practice by many. Composition is the recommended method.

Concrete inheritance is mainly useful for framework / SDK developers, the Java collection SDK is a good example. This is also supported by B4X framework and is the reason for the special, under the hood, wrapper feature.

There are very useful features in B4X, that look "trivial" but are actually complicated and unique, such as the resumable subs, smart strings, internal wrappers, Array, CreateMap and others.
I don't think that concrete inheritance will make B4X, as a simple and powerful RAD programming language, more productive. On the contrary. A programming language is not a random bag of features and more features are not always better.
 

Toky Olivier

Active Member
Licensed User
Longtime User
There are very useful features in B4X, that look "trivial" but are actually complicated and unique, such as the resumable subs, smart strings, internal wrappers, Array, CreateMap and others.
Yes and I thank you for those unique features.
I understand your point. When I look at wishes of developers in the forum, there are many and may be they didn't ask again because responses are also the same from 2012 or 2014. Many people say here: use Java if you want those stuffs. I don't think It's a good for what we want: attract and maintain developers, make B4X more popular. If it's easy to implement, why not to make them or some of them available and each developers choose use or not them? At least, new developer can port easily their code from C#, Java, Cpp etc (without need to wrap)?
Yes, programming language is not not a random bag of features. But all high level language existing now implementing them didn't do write choices? When we implemented our core libs, when we wrap libs frome another language, we use them for our beloved B4X, why we obliged ourself to not use them? This is only my point and may be I know the response but I tell it here anyway. Is too risky to let also developpers to choose or emit their advice through a poll for example?
 

LucaMs

Expert
Licensed User
Longtime User
Although I am not an expert at these levels (development of programming languages), I am almost certain that adding OOP functionality is not as easy as adding a View in the Designer ๐Ÿ˜„

The reasons for not doing so are: the difficulty and the time required (and "time is money", for someone).

No other reason is really valid, I think, and, on the contrary, the positive aspects are more than one, first of all the fame of B4X (I suppose that many professionals and software houses may mistakenly consider B4X poor because of this lack).
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
But all high level language existing now implementing them didn't do write choices?
Not true. The very new Go programming language doesn't support inheritance. I haven't checked all other languages.

Is too risky to let also developpers to choose or emit their advice through a poll for example?
It doesn't work like this.

No other reason is really valid,
You think that other reasons are not valid. I think differently :)

If I were to add all the features listed in the first post, it will be the end of B4X as a RAD programming language. It would have been Java with different syntax.
Note that there is nothing bad with Java however it is not a simple and powerful RAD programming language.
 

LucaMs

Expert
Licensed User
Longtime User
1590915314255.png




1590915105326.png



If I were to add all the features listed in the first post, it will be the end of B4X as a RAD programming language.
"all the features listed"? I "thought" they was "one", OOP features (I'll read it again).
I think it would be the end of the RAD B4X only if you forced your customers to use OOP (can you do it? ๐Ÿ˜).

I think the "term" RAD was born only to indicate development tools that allowed to quickly create GUIs, not so much related to the language, which I don't think must have particular characteristics in order to be part of a RAD tool.

B4A is clearly better than Android-Java not because OOP is missing but because it (and its IDE) "hides" many complicated things, it simplifies them, automates them. An example, not the best one, is that a B4A programmer could develop his own apps without even knowing that an object called Context exists; this applies to many other objects and "mechanisms".

I read about Inheritance versus Composition and GO (Google) is cited as an example. Indeed the first one could create more problems than the second; on the other hand, programmers have been accustomed to using inheritance for many years.

I repeat my opinion: if adding OOP features doesn't require too much work (but I don't think that's the case) having it at your disposal can only be a Plus for B4X and this could convince many skeptical people about the quality of B4X, those who underestimate B4X only because of the lack of OOP.


Incidentally, I think that B4X is poor because a snippets manager is missing ๐Ÿ˜„ (I'm joking here, of course - also because maybe soon I'll develop one for myself)
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
I have been using Aniwhere Software products for a few years and I can say that even if it does not have everything that is expected of an OOP language, it is very close.

It does not support polyformism, but somehow we can overcome this lack by creating different methods each one that supports the parameters that we need.

The only thing that I would appreciate very much, and that is currently missing, is heredity. This probably, in my opinion, would make a qualitative leap in language, but above all it would be useful in development. There is no need to unleash a developer the benefits of inheritance.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
It does not support polyformism
You are confusing method overloading with polymorphism. Polymorphism means that you can treat different types with the same interface. In the case of B4X it is done with CallSub and SubExist which allow you to ignore the class type.
B4X:
For Each o As Object In Array(Cat, Dog, Snake)
 CallSub(o, "MakeSound")
Next
 

LucaMs

Expert
Licensed User
Longtime User
To be clear: I live very well (only as developer ๐Ÿ˜„ :() even without OOP (especially with B4A - it would be more useful with B4J).
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The terminology in this thread is wrong. Please read: https://en.wikipedia.org/wiki/Object-oriented_programming
B4X is an OOP programming language. This is not a binary feature and there are many aspects to the OOP paradigm.
B4X supports classes, encapsulation, polymorphism, composition and other OOP features. The only real feature that is missing is inheritance which was discussed above.
 

Star-Dust

Expert
Licensed User
Longtime User
To avoid confusion. Polpoliformism also means the possibility that a method has an indefinite number of parameters or types. This is not possible in B4X.

I give an example:
JAVA Sample:
public double area(double base, double altezza) {
    return base * altezza * 0.5;
}
public double area(double x1, double y1,
                   double x2, double y2,
                   double x3, double y3) {
    return 0.5 * (x1*y2 + y1*x3 + x2*y3 - x3*y2 - y3*x1 - x2*y1);
}
Or
Sample 2:
function Add(x, y : Integer) : Integer;
begin
    Add := x + y
end;

function Add(s, t : String) : String;
begin
    Add := Concat(s, t)
end;

begin
    Writeln(Add(1, 2));                   (* Prints "3"             *)
    Writeln(Add('Hello, ', 'Mammals!'));    (* Prints "Hello, Mammals!" *)
end.

For more information, see here and here
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Unfortunately I have too many (negative) things in mind, so I don't remember well what the topic was (which is why I didn't find those posts anymore) but ...

perhaps recently Erel suggested that I implement a certain thing by making a kind of wrapper and I replied that in this way I could not intercept some events (all, probably) of the object to be used.

I write this as a reference to the difference between Inheritence and Composition ("is a ..." - "has a ..."). If I can find those posts maybe I'll open a thread about this.

I also write this with the hope that Erel will find those posts ๐Ÿ˜
 

LucaMs

Expert
Licensed User
Longtime User
However, to anyone who reads these posts and hasn't tried using Android Studio and B4A: B4A is a hundred times better than Android Studio ;)
 

Star-Dust

Expert
Licensed User
Longtime User
However, to anyone who reads these posts and hasn't tried using Android Studio and B4A: B4A is a hundred times better than Android Studio ;)
This is certain for several reasons, not only of greater simplicity of language and speed of development. But AS's IDe environment is too slow and heavy. But we didn't talk about environment but about language.
 

AnandGupta

Expert
Licensed User
Longtime User
To avoid confusion. Polpoliformism also means the possibility that a method has an indefinite number of parameters or types. This is not possible in B4X.
I also am looking forward if this feature is implemented in B4X.
Since I am accustom to such feature, i.e. using multiple parameters in same function/procedure etc. from Clipper time till HMG now. So will be happy if it is implemented, but do not insist as I do not know the development complexity involved for it.

Regards,

Anand
 

LucaMs

Expert
Licensed User
Longtime User
a method has an indefinite number of parameters or types.
There are ways to do that, anyway (workarounds but it is realizable).

Way 1 - pass a Map
Way 2 - pass a custom type object - this is better, probably.
 
Last edited:
Top