B4J Code Snippet [B4X++] Breakout Example: Exploring OOP on top of standard B4X

Hi everyone,​


I would like to share a small example I am currently working on for B4X++ (https://github.com/soinalastudio/B4XPP), a proof-of-concept preprocessor / transpiler that adds some OOP-oriented syntax on top of standard B4X.

BTW, new realease here: https://github.com/soinalastudio/B4XPP/releases/tag/v0.3.5

The goal is not to replace B4J, B4A, B4i or the B4X language. The idea is closer to how TypeScript works with JavaScript: write a slightly richer source syntax, then generate regular B4X code that can still be opened, compiled and debugged with the official B4X IDEs.

For this new example, I created a small but runable Breakout game in B4J + XUI.

1782933299472.png


The game is intentionally simple, but it demonstrates how OOP can make some projects easier to organize.

Why Breakout?​

Breakout is a good example because it has several natural “objects”:

  • a ball
  • a paddle
  • bricks
  • a brick grid
  • a score board
  • a game controller
  • reusable collision / math helpers
In classic B4X, we can of course write all of this in modules and classes manually. But with B4X++, the idea is to make the structure more expressive and reduce repeated boilerplate when building libraries, components or reusable logic.

Example class structure​

The example uses a base class:

B4X: Copy
#Class GameEntity Abstract Implements IRenderable



#Property X As Float = 0

#Property Y As Float = 0

#Property Width As Float = 10

#Property Height As Float = 10

#Property Color As Int = 0

#Property Visible As Boolean = True

Then specialized classes extend it:

B4X: Copy
#Class Paddle Extends GameEntity Final



#Class Ball Extends GameEntity Final



#Class Brick Extends GameEntity Final

This keeps common behavior in one place: position, size, bounds, rendering helpers and rectangle collision logic.

For example, GameEntity contains common methods such as:

B4X: Copy
Public Sub Left As Float

    Return getX

End Sub



Public Sub Right As Float

    Return getX + getWidth

End Sub



Public Sub CollidesWithBox(aOtherLeft As Float, aOtherTop As Float, aOtherRight As Float, aOtherBottom As Float) As Boolean

    Return BreakoutMath.Overlaps(Left, Top, Right, Bottom, aOtherLeft, aOtherTop, aOtherRight, aOtherBottom)

End Sub

Then Ball, Paddle and Brick can focus only on their own behavior.

Cleaner responsibilities​

The example is divided like this:

GameEntity
Common position, size, visibility, rectangle helpers and default rendering.

Paddle
Mouse-controlled paddle movement.

Ball
Ball velocity, wall bounce, reset position and rendering as a circle.

Brick
Brick state, score value and hit logic.

BrickGrid
Creates and manages all bricks, checks ball/brick collisions.

ScoreBoard
Score, lives, running state and messages.

BreakoutGame
Main game orchestration: XUI surface, canvas, update loop, collision checks and drawing.

This is the main advantage I wanted to show: the code becomes easier to reason about because each class has a focused responsibility.

Property syntax​

One thing I found important while building the example is readability.

Instead of writing generated setter calls manually, B4X++ allows source code like:

B4X: Copy
#Constructor(aX As Float, aY As Float, aWidth As Float, aHeight As Float, aColor As Int)

    X = aX

    Y = aY

    Width = aWidth

    Height = aHeight

    Color = aColor

    Visible = True

#End Constructor

The transpiler then generates normal B4X code:

B4X: Copy
setX(aX)

setY(aY)

setWidth(aWidth)

setHeight(aHeight)

setColor(aColor)

setVisible(True)

So the .bx source stays readable, while the generated .bas remains compatible with the B4X IDE.

Inheritance, but flattened output​

B4X++ supports syntax such as:

B4X: Copy
#Class Ball Extends GameEntity Final
The generated .bas file is flattened, because standard B4X does not have this kind of inheritance between class modules.

That means the final output is still regular B4X code. The inheritance exists at the B4X++ source level, then the transpiler copies / adapts the inherited members into the generated class.

This is especially useful for library authors, where repeated code across several components can become hard to maintain.

Override and specialization​

The base class can define a default renderer:

B4X: Copy
Public Sub Render(aCvs As B4XCanvas)

    If getVisible = False Then Return

    aCvs.DrawRect(EntityRect, getColor, True, 0)

End Sub

Then Ball overrides it:

B4X: Copy
#Override

Public Sub Render(aCvs As B4XCanvas)

    If getVisible = False Then Return

    aCvs.DrawCircle(CenterX, CenterY, getRadius, getColor, True, 0)

End Sub

So the common logic stays in the parent class, while the child class only changes what is specific to it.

Static helper code​

The example also uses a static helper module:

B4X: Copy
#StaticCode BreakoutMath
With helpers such as:



This keeps reusable math / collision logic separated from the game objects.

Why this is interesting​

For small apps, classic B4X is already very productive.

But for larger libraries, custom views, games or reusable components, some OOP features can help with:

  • reducing duplicated code
  • grouping related behavior
  • making examples easier to understand
  • keeping a clean separation of responsibilities
  • making reusable B4XLib components easier to maintain
  • experimenting with inheritance and overrides without changing the B4X language itself
Again, this is only a proof of concept. It is not meant to make B4X more complex or force a new programming style. It is just an optional layer that generates normal B4X code.

Current status​

B4X++ is still experimental. While building this Breakout example, I had to handle several B4X-specific realities carefully:

  • avoiding B4X reserved words as method names
  • avoiding variable names that conflict with module names
  • generating safe setter calls for properties
  • flattening inherited fields and methods correctly
  • avoiding type assumptions that do not exist after flattening
  • keeping the generated code readable and debuggable in B4J
That is actually one of the goals of the project: learning where the limits are, and making the generated code as friendly as possible for the official B4X IDE.

Conclusion​

This Breakout example shows how B4X++ can make a B4J + XUI project more structured while still producing standard B4X code.

The interesting part is not the game itself, but the organization behind it: entities, inheritance, properties, overrides, helper modules and generated .bas files that remain compatible with B4J.

I would be happy to hear feedback, especially from B4XLib authors and custom view developers. The project is still a proof of concept, so nothing is final yet.

Regards,
Toky
 

Attachments

Toky!!! This is beautiful, cant wait...
Thank you, need to have a good foundation for all components. But native B4XLib component will not work on the WYSIWYG Editor as each component need to have 2 parts: runtime (b4x++ language like normal b4x componet with some adjustments) and design-time (js language to be used directly without transpilation on the designer). Design-time part is need to draw the component on the designer. But good thing, it can be easily generated with AI (work on a SKILL for it). One thing really good is that all contents can be edited on the designer: for example, for an Accordion, each accordion frame can be edited to add as much as component you need like a new layout and all will be saved. Full OOPs and WYSIWYG are things I waited with B4X and may be we can achieve this with B4X++ with B4J/BANano.

ALL ARE COMPILED WITH B4J AND BANANO TO PRODUCE A READY TO USE WEB APPS...


1783800714558.png
 
Last edited:
Thank you, need to have a good foundation for all components. But native B4XLib component will not work on the WYSIWYG Editor as each component need to have 2 parts: runtime (b4x++ language like normal b4x componet with some adjustments) and design-time (js language to be used directly without transpilation on the designer). Design-time part is need to draw the component on the designer. But good thing, it can be easily generated with AI (work on a SKILL for it). One thing really good is that all contents can be edited on the designer: for example, for an Accordion, each accordion frame can be edited to add as much as component you need like a new layout and all will be saved. Full OOPs and WYSIWYG are things I waited with B4X and may be we can achieve this with B4X++ with B4J/BANano.

ALL ARE COMPILED WITH B4J AND BANANO TO PRODUCE A READY TO USE WEB APPS...

View attachment 172345
So in this instance you open a layout converted to json file?
 
No. Directly a new B4XPPLayout (I didn't look yet at bjl/bal/bil file formats, they are binaries and I don't want to spend time to analyse them, I see that you have already worked on it but I'll see later) wich we generated to BX file and then transpiled to bas files, directly usable by B4X. I opted for this for now to have WYSIWYG capability.
1783808018870.png


Edition of accordion Frame1:
1783808069158.png


Result:
1783808093233.png

NB: This version of B4X++ with designer is not released yet. Stay tuned...
 
Please disregard this; pretend it doesn't even exist, don't even consider it.


I even think it's fantastic that such a tool exists, to the point that should be consider opening a section for it in the forum, similar to B4W (Basic for Web), where everything related to the web is discussed.

So that the bots & IAs that visit the forum can differentiate the content; the code according to the platform.


This is just a simply message to my students in the feature future.


WebDevs have this fascination with worshipping programming paradigms like OOP And above all, to sell WBPLPA (Web Based Pattern & Liturgy Programming Approach) 4 all.

If there were just one of you who could give me one, and only one, good reason (and not one taken from the manual of a sales manager who doesn't know how to program but needs to make money with programming) why everything should be OOP and WBPLPA... I would stop professing that AI will replace them all.
Just imagine if a company could have 14 layers of managers instead of programmers, approximately 4800 employees.
Paragraph 11 of the announcement

While I understand transpilation, (to me) It's very dangerous in this era of vibe coding and agentic programming.
But what i really i don't understand this idea of worshipping a paradigm & Programming Approach as if it were The solution to all our problems, when the problem is precisely due to that; Today we need 64 Gb RAM, 8 cores, a constant 10 GB internet connection and 2 RTX6090 Ti, just to open an IDE, and if the program takes too long to open... Just update the clock. Example 1 & Example 2
Alice: I have a problem
Bob: did you shoot him?
Alice: Yes
Bob: is it solved?
Alice: No
Bob: Well... You didn't shoot enough.

While there are written rules regarding programming (I'm not referring to legal ones), the paradigms, structure, architecture, and flows respond to BREPs/Restrictions external to all of that, and are bindingly specific to the project.
Programming itself... shouldn't be transpiled (code generation). This opens up the eternal debate: code 'purisms/ts' > Visual Programming > low code > no code > prompting > vibe code > do this (whatever it means today).

For any programmer (non WBPLPA): an exception is an unhandled and unforeseen error, because when everything is an exception... nothing is a exception, because it's become the norm.
So your code ends up being a bunch of conditionals and try-catch blocks.
Unused GPIO pins on an ESP32 must have a defined reference (PullDown || LOW output) to prevent erratic readings, EMI interference, and startup failures. A floating pin acts as an antenna: it picks up noise, generates false triggers, and can disrupt strapping states during startup. Designing with pulldowns is preventative by design and avoids many difficult-to-reproduce errors.
Not everything needs or should live in memory: (Heap/Satck, malloc, Mutable/Inmutable, Buffer, ByVal/ByRef, etc). How much space does a Bool occupy in memory? And a Char, int32, int64? How many resources, try-catch blocks, and if statements do you need to infer data types? Who cares! that's why i use String.

Real devices are not servers: Most don't have a GPU farm, nor multi-core & multi-processors, even the 9999..... GB of RAM for the strings that need to live in memory; some don't even have an internet connection (and it never will).

The WBPLPA is for Web and just for Web: Windows 11 can explain it better than i.
Increased productivity, less boilerplate code, intuitive syntax, more with less, enter at 8:00 and leaves at 8:15, The graphs don't lie!!!!; the green arrow is upward & look how happy is that programmer in the photo!.

Name me a single framework, pluguin or AI that doesn't tell you something like that.
"Just 1 line of code to get your button pumping out an blinking with sound"
ERROR #4015: line 2039 of 1 = "CallCthulhu" Method; "A blood sacrifice was expected, but instead, a gluten-free whole wheat loaf was received".
Wait... What!? Line 2039 of 1, and who called Cthulhu & why gluten-free?
ERROR #4016: line 2050 to 3800 of 1 = "LoadAll_AndHopeThatRuns" Method; "300 of 1289 libraries and 32 of 98 plugins were not loaded".

And wait until APIs, OS, and IDEs become smarter and prevent you from loading or run apps that has dependencies with CVEs. (What a great day to be a programmer!)

You just need to ask yourself:
  • Why there is (and is needed) a pattern for an anti-pattern to avoid falling into a pattern???.
  • If OOP is "The Solution"... Why exist a problem called God Object????.
  • If WBPLPA is the "Law" that i must follow or i will be doing it wrong (very wrong)... Why doesn't this Golden Hammer solve my problem but creates 20 more?.
  • Why an exception like override is the norm?.
  • If decoupling & SOR through interfaces is the best thing in the universe, why does everything break when I modify it?
Does this mean I must first learn OOP before writing that single line of code that will make my dream come true?

Damn! It was supposed to be a RAD & that a single line of code would make my project run everywhere.

While there is no single agreed list of "all" paradigms (classifications vary by author and context), i’ll name several.
Use this list as a reference, because many languages are multiparadigm; You’ll notice conceptual overlaps, that's why some of them appear in multiple categories.

ParadigmCategoryKey featuresWhen to useExamples / Languages
ImperativeCoreExplicit commands that change program stateLow-level control, performance-critical codeC, Assembly
Procedural / StructuredImperativeSubroutines, control structures, modular codeAlgorithms, scripts, embedded systemsC, Pascal
Object‑Oriented (OOP)AbstractionEncapsulation, inheritance, polymorphismLarge codebases, domain modeling, GUIsJava, C++, C#
Prototype‑based OOPOOP variantObjects inherit from other objects (no classes)Dynamic object composition, lightweight inheritanceJavaScript, Self
FunctionalDeclarativePure functions, immutability, higher‑order functionsConcurrency, correctness, data transformationsHaskell, F#, Elixir
DeclarativeHigh‑levelDescribe what, not how; focus on intentConfiguration, queries, rule systemsSQL, HTML, Terraform
Logic / Rule‑basedDeclarativeFacts, rules, inference engineAI, constraint solving, expert systemsProlog, Datalog
Constraint programmingDeclarativeVariables with constraints solved by solverScheduling, optimization, configurationMiniZinc, CLP languages
Event‑drivenReactive / ImperativeHandlers respond to events; callback styleUIs, embedded systems, asynchronous I/ONode.js, GUI frameworks
Reactive / DataflowReactiveStreams, propagation of change, backpressureReal‑time data, UIs, streaming pipelinesRxJS, ReactiveX, Elm
Dataflow / Stream processingData‑centricNodes transform streams; pipeline compositionSignal processing, ETL, streaming analyticsApache Flink, LabVIEW
Concurrent / ParallelSystemsThreads, locks, shared memory or message passingHigh‑performance computing, multicore taskspthreads, OpenMP
Actor modelConcurrencyActors exchange messages, no shared stateDistributed systems, fault‑tolerant servicesErlang, Akka (Scala)
Generic / ParametricAbstractionType or algorithm parameterizationLibraries, reusable componentsC++ templates, Java generics
Metaprogramming / MacrosCode generationCode that writes or transforms code at compile/run timeDSLs, performance optimizations, boilerplate reductionLisp macros, Rust macros
Reflective programmingMetaprogrammingIntrospection and runtime modification of programFrameworks, dynamic tooling, ORMsJava reflection, Python
Aspect‑oriented (AOP)Cross‑cuttingSeparate cross‑cutting concerns (logging, security)Large systems needing orthogonal concernsAspectJ, Spring AOP
Data‑oriented design (DOD)PerformanceLayout and access patterns optimized for cacheGames, high‑performance systemsC, C++ (DOD style)
Array / Vectorized (APL‑style)Data‑centricOperations on whole arrays/vectors as primitivesNumerical computing, matrix opsAPL, J, NumPy (Python)
Domain‑Specific Languages (DSLs)SpecializedSmall languages tailored to a problem domainConfiguration, business rules, pipelinesSQL, Regex, Makefiles

Although the most commonly used (in jargon) are: Functional, Procedural, Imperative, OOP, Reflective, DSL & DOD.
And you have to memorize this & write it behind your eyelids so that even when you close your eyes... you'll be able to remember it:
  • Paradigms are tools, not commandments. Real systems mix paradigms where each fits best; use this table to reason about trade‑offs, and not to; join a side and kill the bad guys because you're one of the good guys.

Remember! It's not the paradigm or the language, it's the programming knowledge.
I really don´t have even the most minimal idea why.

Because if i have to be honest: If it's about a readable, short, and error-free syntax, with full optimization and secure... I'd make a transpiler with Functional paradigm, with a syntax as close as possible to F#

But even so (even though I love the functional paradigm), I always find myself using OOP, Procedural and Imperative most of the time (in the same solution), because each one serves a purpose and solves a problem.

You can do OOP, Procedural, Imperative & Functional with B4X (without the need for a very complex stuff || "Artifundio mucho muy complejo").

But the transpilation technique takes away your control over it, because 1 line can be equal to 2040 on 20 different files/modules, but... Of what?.

Because, in some way or another, it forces/imposes a programming mode/model where you have no control over anything, and you often end up having to perform contortions (overrides in OOP) to make it work the way you want.

That's why abstractions & toolchains dependencies are always a feature future tech debt.


Lets take a look on how OOP actually "behaves" (Actually... how interfaces, inheritance & overrides are misused in most cases), how a functional transpiler (F#‑style) approaches address the same need, how B4X classic + B4XPages can solve it today, and the marketing vs reality takeaway.

For small apps, classic B4X is already very productive.

But for larger libraries, custom views, games or reusable components, some OOP features can help with:
  • reducing duplicated code
  • grouping related behavior
  • making examples easier to understand
  • keeping a clean separation of responsibilities
  • making reusable B4XLib components easier to maintain
  • experimenting with inheritance and overrides without changing the B4X language itself
Again, this is only a proof of concept. It is not meant to make B4X more complex or force a new programming style. It is just an optional layer that generates normal B4X code.

Claims​
OOP​
Functional​
B4X​
True​
Reduce duplicated codeUses inheritance/interfaces to share code; adding interface methods breaks implementors; overrides hide duplicationsComposition + HOFs remove duplication without inheritance; types and generics enable reuse safelyModules, subs and Pages let you extract shared code; no special runtime magicMarketing: “solves duplication” — Reality: helps ergonomics but can create fragile coupling and mass churn on API changes
Group related behaviorClasses colocate state+behavior; inheritance groups but can create God Objects; overrides alter behavior at runtimeRecords/ADTs + modules group data and pure functions; pattern matching makes responsibilities explicitB4X Classes/Modules and Pages group UI lifecycle; keep domain & business logic in modules for clarityMarketing: “natural grouping” — Reality: grouping works but responsibility creep and hidden overrides are common features futures costs
Make examples easier to understandObject metaphors are intuitive; examples may hide to many side effects and lifecycle complexity via overridesPipelines and small functions produce concise, explicit examples; less hidden stateB4XPages gives uniform UI examples; domain & business examples depend on module disciplineMarketing: “more readable examples” — Reality: OOP examples are familiar (in some cases) but mask complexity; functional examples are railway & clearer about effects
Keep separation of responsibilitiesInterfaces and classes can enforce boundaries; inheritance and overrides can blur them if misused (almost always)Immutability and pure functions enforce separation; effects are explicit (Result/Option)B4XPages separates UI lifecycle; modules enforce domain & business boundaries if followed correctlyMarketing: “enforces SRP” — Reality: language features "help" (until override becomes the norm), that's why discipline and design matter more than syntax
Make reusable libraries easier to maintainvirtuals/overrides enable extension but changing interfaces causes breaking changes and binary incompatibilitiesSmall composable and ADTs are easier to refactor and test; type safety reduces regressionsB4XLibs via modules/classes and Pages can be maintained; provide shims and document breaking changes (easy piecy)Marketing: “plug‑and‑play libs” — Reality: reuse is real, but API evolutions and overrides create maintenance debt, unless...
Experiment with inheritance/overrides without changing languageTranspilers/syntactic layers let you prototype OOP but generate flattened code; debugging maps to generated output and toolchain dependencyWhy in the world you need to experiment with Uranium-235?You can prototype patterns with native B4X classes and B4XPages; no transpiler required for most designs. (straightforward on railway mode)Marketing: “it will save you time” — Reality: syntactic sugar helps ergonomics, but does not remove runtime, debugging, test & compatibility costs

If you paid attention to the table, it doesn't matter which paradigm is used; the most important thing always is, and always will be; discipline in its application, and that is achieved through knowledge—more precisely, mastering the language and the paradigm.

Otherwise, nothing will work as it should. (If you don't know how to use a gun... you'll most likely end up with a gunshot on the foot).

The software industry has made a mess of the web, abusing programming; its famous CI/CD has only filled the internet, platforms, systems, and devices with bloated, ineffective, and inefficient software.

It's not the paradigm, it's not the language, nor the quality of the hardware, because literally today a microcontroller (the most basic one) has more technology and quality than the hardware that went to the moon... and back.




While is true when says that:
Again, this is only a proof of concept. It is not meant to make B4X more complex or force a new programming style. It is just an optional layer that generates normal B4X code.

Imposition and adoption are two very different things, but in a practical sense, the line that divides them is too blurred, even invisible.

"Better a known drunk than an anonymous alcoholic!!!". People will always choose the familiar over the unknown, because "there's no mystery in the familiar".

Now considering the number of WbDevs or software engineers there are, as well as the ability/possibility of "doing what I've been doing my whole life", there's no imposition at all, but the mass adoption itself create that "virtual/soft imposition".

It's like Whatsapp! No one is forcing you to install and use it, but if you don't have it... you practically don't exist. Regardless of the thousands of other options available, with more features.

When an exception becomes the norm... There's no going back. I saw how the web world and WebDevs appropriated .NET and C# to the point that code portability between platforms and systems was reduced to a legend.


Today (as of this post) it is very difficult to find a multi platform/paradigm framework and language with the correct level of abstraction as well as a course, tutorial or example, that is not WBPLPA with IA (Obviously).

Not to mention the quality, quantity and examples of code of various kinds (Android/iOS phone/tablet/tv + Windows/Linux/MAC Desktops/Laptops + Embedded & Raspberry Pi, etc).

Especially with regard to each device, platform, system, version and problem/dilemma that each of them presents in particular.

[So I can, more or less... imagine the day that you read this post.]


Foot note: Functional programming is not about putting lambda functions everywhere you can (or not & dont).

There are 3 main reasons:
I saw how .NET was taken over by the Web and WebDev world (Feature by Feature), to the point of turning it into a sect where "no one enters and no one leaves", so much that talking about events automatically made you a heretic, and anything that wasn’t web… Had to be stoned.

I watched the inquisition demonize and let Xamarin and F# die, saw the community age until it vanished amid patterns and liturgies, and how orthodoxy killed every spark of thought, imagination, invention and reinvention.
With more o less luck... some are migrating (today) to a version that’s already out of service (.NET 8).

I also see how software industry rape programming; To the point that the internet is now full of bugs, debugging a web system/app is an impossible task due to the large number of dependencies and abstractions.

You constantly have to be changing equipment, because each update needs more and more resources, and not necessarily because it has quantum optimization, but quite the opposite.
The number of "software engineers" is overwhelming compared to other fields, and when they migrate to one of those other fields, they don't do so with the intention of learning new paradigms, platforms, systems, architectures, etc. Instead, they "bring their experience in the industry" (aka: everything can be solved with WBPLPA).

M Code, G Code, IEC 61131-3 (PLCs like Ladder, FBD, etc), Matlab, etc. can be transpiled from JS/Python. (You can't even imagine the things I've encountered in critical environments).
I'm studying to become a technology teacher, and next year I'll begin an informal teaching project with a group of classmates in a low-income (very very low) neighbourhood.

We'll teach AC/DC electricity, electronics, robotics, and programming (B4X), fostering other skills such as math, reading, writing, critical thinking, common sense, research, development, and innovation.

We'll use a "classroom-workshop" approach, where we'll work on projects involving home automation, greenhouses, measurement and telemetry, signal processing (analog and digital), regulations, safety and hygiene, 3D design (architectural and industrial, plus additive manufacturing), machining, CNC cutting and carving (plasma, oxy-fuel, laser, waterjet).

And obviously the use of AI as a support tool.

It is not intended as a "job opportunity" (since there are practically no industries to apply), but rather it is intended (more than anything) to provide practical & theoretical knowledge as an essential tool to "find a way to get ahead and break into the market by adding value to the product and/or service they provide".
Like everything in life, doing the easiest thing... is the most easiest thing! Until it gets complicated (very complicated).

And like any enthusiast (anxious), you want to see the robot walk, the LED blink, the motor work, the app work, the doorbell recognize you and say "welcome master", and the telemetry be correct mesured and send/receive without problems.

And if there's a TOOL that can do everything with just one line of code... It's utopian!

But you don't want your API to break due to poor design, or anyone with a WhatsApp audio can open the door, or data will not be received/sent because the connection status isn't measured properly or event is missing, or the motor/pump rotate in the opposite direction, or the wrong LED blink.

Whether we like it or not... We (humans) are children of rigor; there are things we don't learn until we experience them firsthand; like debugging a transpiled code, that work on desktop with 8 cores, 64 Gb RAM and 2 RTX6090 Ti, but not on a ESP32 or Android GO.

Give someone a hammer and everything they come across... Will be a nail.
 
Please disregard this; pretend it doesn't even exist, don't even consider it.


I even think it's fantastic that such a tool exists, to the point that should be consider opening a section for it in the forum, similar to B4W (Basic for Web), where everything related to the web is discussed.

So that the bots & IAs that visit the forum can differentiate the content; the code according to the platform.


This is just a simply message to my students in the feature future.


WebDevs have this fascination with worshipping programming paradigms like OOP And above all, to sell WBPLPA (Web Based Pattern & Liturgy Programming Approach) 4 all.

If there were just one of you who could give me one, and only one, good reason (and not one taken from the manual of a sales manager who doesn't know how to program but needs to make money with programming) why everything should be OOP and WBPLPA... I would stop professing that AI will replace them all.
Just imagine if a company could have 14 layers of managers instead of programmers, approximately 4800 employees.
Paragraph 11 of the announcement

While I understand transpilation, (to me) It's very dangerous in this era of vibe coding and agentic programming.
But what i really i don't understand this idea of worshipping a paradigm & Programming Approach as if it were The solution to all our problems, when the problem is precisely due to that; Today we need 64 Gb RAM, 8 cores, a constant 10 GB internet connection and 2 RTX6090 Ti, just to open an IDE, and if the program takes too long to open... Just update the clock. Example 1 & Example 2
Alice: I have a problem
Bob: did you shoot him?
Alice: Yes
Bob: is it solved?
Alice: No
Bob: Well... You didn't shoot enough.

While there are written rules regarding programming (I'm not referring to legal ones), the paradigms, structure, architecture, and flows respond to BREPs/Restrictions external to all of that, and are bindingly specific to the project.
Programming itself... shouldn't be transpiled (code generation). This opens up the eternal debate: code 'purisms/ts' > Visual Programming > low code > no code > prompting > vibe code > do this (whatever it means today).

For any programmer (non WBPLPA): an exception is an unhandled and unforeseen error, because when everything is an exception... nothing is a exception, because it's become the norm.
So your code ends up being a bunch of conditionals and try-catch blocks.
Unused GPIO pins on an ESP32 must have a defined reference (PullDown || LOW output) to prevent erratic readings, EMI interference, and startup failures. A floating pin acts as an antenna: it picks up noise, generates false triggers, and can disrupt strapping states during startup. Designing with pulldowns is preventative by design and avoids many difficult-to-reproduce errors.
Not everything needs or should live in memory: (Heap/Satck, malloc, Mutable/Inmutable, Buffer, ByVal/ByRef, etc). How much space does a Bool occupy in memory? And a Char, int32, int64? How many resources, try-catch blocks, and if statements do you need to infer data types? Who cares! that's why i use String.

Real devices are not servers: Most don't have a GPU farm, nor multi-core & multi-processors, even the 9999..... GB of RAM for the strings that need to live in memory; some don't even have an internet connection (and it never will).

The WBPLPA is for Web and just for Web: Windows 11 can explain it better than i.
Increased productivity, less boilerplate code, intuitive syntax, more with less, enter at 8:00 and leaves at 8:15, The graphs don't lie!!!!; the green arrow is upward & look how happy is that programmer in the photo!.

Name me a single framework, pluguin or AI that doesn't tell you something like that.
"Just 1 line of code to get your button pumping out an blinking with sound"
ERROR #4015: line 2039 of 1 = "CallCthulhu" Method; "A blood sacrifice was expected, but instead, a gluten-free whole wheat loaf was received".
Wait... What!? Line 2039 of 1, and who called Cthulhu & why gluten-free?
ERROR #4016: line 2050 to 3800 of 1 = "LoadAll_AndHopeThatRuns" Method; "300 of 1289 libraries and 32 of 98 plugins were not loaded".

And wait until APIs, OS, and IDEs become smarter and prevent you from loading or run apps that has dependencies with CVEs. (What a great day to be a programmer!)

You just need to ask yourself:
  • Why there is (and is needed) a pattern for an anti-pattern to avoid falling into a pattern???.
  • If OOP is "The Solution"... Why exist a problem called God Object????.
  • If WBPLPA is the "Law" that i must follow or i will be doing it wrong (very wrong)... Why doesn't this Golden Hammer solve my problem but creates 20 more?.
  • Why an exception like override is the norm?.
  • If decoupling & SOR through interfaces is the best thing in the universe, why does everything break when I modify it?
Does this mean I must first learn OOP before writing that single line of code that will make my dream come true?

Damn! It was supposed to be a RAD & that a single line of code would make my project run everywhere.

While there is no single agreed list of "all" paradigms (classifications vary by author and context), i’ll name several.
Use this list as a reference, because many languages are multiparadigm; You’ll notice conceptual overlaps, that's why some of them appear in multiple categories.

ParadigmCategoryKey featuresWhen to useExamples / Languages
ImperativeCoreExplicit commands that change program stateLow-level control, performance-critical codeC, Assembly
Procedural / StructuredImperativeSubroutines, control structures, modular codeAlgorithms, scripts, embedded systemsC, Pascal
Object‑Oriented (OOP)AbstractionEncapsulation, inheritance, polymorphismLarge codebases, domain modeling, GUIsJava, C++, C#
Prototype‑based OOPOOP variantObjects inherit from other objects (no classes)Dynamic object composition, lightweight inheritanceJavaScript, Self
FunctionalDeclarativePure functions, immutability, higher‑order functionsConcurrency, correctness, data transformationsHaskell, F#, Elixir
DeclarativeHigh‑levelDescribe what, not how; focus on intentConfiguration, queries, rule systemsSQL, HTML, Terraform
Logic / Rule‑basedDeclarativeFacts, rules, inference engineAI, constraint solving, expert systemsProlog, Datalog
Constraint programmingDeclarativeVariables with constraints solved by solverScheduling, optimization, configurationMiniZinc, CLP languages
Event‑drivenReactive / ImperativeHandlers respond to events; callback styleUIs, embedded systems, asynchronous I/ONode.js, GUI frameworks
Reactive / DataflowReactiveStreams, propagation of change, backpressureReal‑time data, UIs, streaming pipelinesRxJS, ReactiveX, Elm
Dataflow / Stream processingData‑centricNodes transform streams; pipeline compositionSignal processing, ETL, streaming analyticsApache Flink, LabVIEW
Concurrent / ParallelSystemsThreads, locks, shared memory or message passingHigh‑performance computing, multicore taskspthreads, OpenMP
Actor modelConcurrencyActors exchange messages, no shared stateDistributed systems, fault‑tolerant servicesErlang, Akka (Scala)
Generic / ParametricAbstractionType or algorithm parameterizationLibraries, reusable componentsC++ templates, Java generics
Metaprogramming / MacrosCode generationCode that writes or transforms code at compile/run timeDSLs, performance optimizations, boilerplate reductionLisp macros, Rust macros
Reflective programmingMetaprogrammingIntrospection and runtime modification of programFrameworks, dynamic tooling, ORMsJava reflection, Python
Aspect‑oriented (AOP)Cross‑cuttingSeparate cross‑cutting concerns (logging, security)Large systems needing orthogonal concernsAspectJ, Spring AOP
Data‑oriented design (DOD)PerformanceLayout and access patterns optimized for cacheGames, high‑performance systemsC, C++ (DOD style)
Array / Vectorized (APL‑style)Data‑centricOperations on whole arrays/vectors as primitivesNumerical computing, matrix opsAPL, J, NumPy (Python)
Domain‑Specific Languages (DSLs)SpecializedSmall languages tailored to a problem domainConfiguration, business rules, pipelinesSQL, Regex, Makefiles

Although the most commonly used (in jargon) are: Functional, Procedural, Imperative, OOP, Reflective, DSL & DOD.
And you have to memorize this & write it behind your eyelids so that even when you close your eyes... you'll be able to remember it:
  • Paradigms are tools, not commandments. Real systems mix paradigms where each fits best; use this table to reason about trade‑offs, and not to; join a side and kill the bad guys because you're one of the good guys.

Remember! It's not the paradigm or the language, it's the programming knowledge.
I really don´t have even the most minimal idea why.

Because if i have to be honest: If it's about a readable, short, and error-free syntax, with full optimization and secure... I'd make a transpiler with Functional paradigm, with a syntax as close as possible to F#

But even so (even though I love the functional paradigm), I always find myself using OOP, Procedural and Imperative most of the time (in the same solution), because each one serves a purpose and solves a problem.

You can do OOP, Procedural, Imperative & Functional with B4X (without the need for a very complex stuff || "Artifundio mucho muy complejo").

But the transpilation technique takes away your control over it, because 1 line can be equal to 2040 on 20 different files/modules, but... Of what?.

Because, in some way or another, it forces/imposes a programming mode/model where you have no control over anything, and you often end up having to perform contortions (overrides in OOP) to make it work the way you want.

That's why abstractions & toolchains dependencies are always a feature future tech debt.


Lets take a look on how OOP actually "behaves" (Actually... how interfaces, inheritance & overrides are misused in most cases), how a functional transpiler (F#‑style) approaches address the same need, how B4X classic + B4XPages can solve it today, and the marketing vs reality takeaway.


Claims​
OOP​
Functional​
B4X​
True​
Reduce duplicated codeUses inheritance/interfaces to share code; adding interface methods breaks implementors; overrides hide duplicationsComposition + HOFs remove duplication without inheritance; types and generics enable reuse safelyModules, subs and Pages let you extract shared code; no special runtime magicMarketing: “solves duplication” — Reality: helps ergonomics but can create fragile coupling and mass churn on API changes
Group related behaviorClasses colocate state+behavior; inheritance groups but can create God Objects; overrides alter behavior at runtimeRecords/ADTs + modules group data and pure functions; pattern matching makes responsibilities explicitB4X Classes/Modules and Pages group UI lifecycle; keep domain & business logic in modules for clarityMarketing: “natural grouping” — Reality: grouping works but responsibility creep and hidden overrides are common features futures costs
Make examples easier to understandObject metaphors are intuitive; examples may hide to many side effects and lifecycle complexity via overridesPipelines and small functions produce concise, explicit examples; less hidden stateB4XPages gives uniform UI examples; domain & business examples depend on module disciplineMarketing: “more readable examples” — Reality: OOP examples are familiar (in some cases) but mask complexity; functional examples are railway & clearer about effects
Keep separation of responsibilitiesInterfaces and classes can enforce boundaries; inheritance and overrides can blur them if misused (almost always)Immutability and pure functions enforce separation; effects are explicit (Result/Option)B4XPages separates UI lifecycle; modules enforce domain & business boundaries if followed correctlyMarketing: “enforces SRP” — Reality: language features "help" (until override becomes the norm), that's why discipline and design matter more than syntax
Make reusable libraries easier to maintainvirtuals/overrides enable extension but changing interfaces causes breaking changes and binary incompatibilitiesSmall composable and ADTs are easier to refactor and test; type safety reduces regressionsB4XLibs via modules/classes and Pages can be maintained; provide shims and document breaking changes (easy piecy)Marketing: “plug‑and‑play libs” — Reality: reuse is real, but API evolutions and overrides create maintenance debt, unless...
Experiment with inheritance/overrides without changing languageTranspilers/syntactic layers let you prototype OOP but generate flattened code; debugging maps to generated output and toolchain dependencyWhy in the world you need to experiment with Uranium-235?You can prototype patterns with native B4X classes and B4XPages; no transpiler required for most designs. (straightforward on railway mode)Marketing: “it will save you time” — Reality: syntactic sugar helps ergonomics, but does not remove runtime, debugging, test & compatibility costs

If you paid attention to the table, it doesn't matter which paradigm is used; the most important thing always is, and always will be; discipline in its application, and that is achieved through knowledge—more precisely, mastering the language and the paradigm.

Otherwise, nothing will work as it should. (If you don't know how to use a gun... you'll most likely end up with a gunshot on the foot).

The software industry has made a mess of the web, abusing programming; its famous CI/CD has only filled the internet, platforms, systems, and devices with bloated, ineffective, and inefficient software.

It's not the paradigm, it's not the language, nor the quality of the hardware, because literally today a microcontroller (the most basic one) has more technology and quality than the hardware that went to the moon... and back.




While is true when says that:


Imposition and adoption are two very different things, but in a practical sense, the line that divides them is too blurred, even invisible.

"Better a known drunk than an anonymous alcoholic!!!". People will always choose the familiar over the unknown, because "there's no mystery in the familiar".

Now considering the number of WbDevs or software engineers there are, as well as the ability/possibility of "doing what I've been doing my whole life", there's no imposition at all, but the mass adoption itself create that "virtual/soft imposition".

It's like Whatsapp! No one is forcing you to install and use it, but if you don't have it... you practically don't exist. Regardless of the thousands of other options available, with more features.

When an exception becomes the norm... There's no going back. I saw how the web world and WebDevs appropriated .NET and C# to the point that code portability between platforms and systems was reduced to a legend.


Today (as of this post) it is very difficult to find a multi platform/paradigm framework and language with the correct level of abstraction as well as a course, tutorial or example, that is not WBPLPA with IA (Obviously).

Not to mention the quality, quantity and examples of code of various kinds (Android/iOS phone/tablet/tv + Windows/Linux/MAC Desktops/Laptops + Embedded & Raspberry Pi, etc).

Especially with regard to each device, platform, system, version and problem/dilemma that each of them presents in particular.

[So I can, more or less... imagine the day that you read this post.]


Foot note: Functional programming is not about putting lambda functions everywhere you can (or not & dont).

There are 3 main reasons:
I saw how .NET was taken over by the Web and WebDev world (Feature by Feature), to the point of turning it into a sect where "no one enters and no one leaves", so much that talking about events automatically made you a heretic, and anything that wasn’t web… Had to be stoned.

I watched the inquisition demonize and let Xamarin and F# die, saw the community age until it vanished amid patterns and liturgies, and how orthodoxy killed every spark of thought, imagination, invention and reinvention.
With more o less luck... some are migrating (today) to a version that’s already out of service (.NET 8).

I also see how software industry rape programming; To the point that the internet is now full of bugs, debugging a web system/app is an impossible task due to the large number of dependencies and abstractions.

You constantly have to be changing equipment, because each update needs more and more resources, and not necessarily because it has quantum optimization, but quite the opposite.
The number of "software engineers" is overwhelming compared to other fields, and when they migrate to one of those other fields, they don't do so with the intention of learning new paradigms, platforms, systems, architectures, etc. Instead, they "bring their experience in the industry" (aka: everything can be solved with WBPLPA).

M Code, G Code, IEC 61131-3 (PLCs like Ladder, FBD, etc), Matlab, etc. can be transpiled from JS/Python. (You can't even imagine the things I've encountered in critical environments).
I'm studying to become a technology teacher, and next year I'll begin an informal teaching project with a group of classmates in a low-income (very very low) neighbourhood.

We'll teach AC/DC electricity, electronics, robotics, and programming (B4X), fostering other skills such as math, reading, writing, critical thinking, common sense, research, development, and innovation.

We'll use a "classroom-workshop" approach, where we'll work on projects involving home automation, greenhouses, measurement and telemetry, signal processing (analog and digital), regulations, safety and hygiene, 3D design (architectural and industrial, plus additive manufacturing), machining, CNC cutting and carving (plasma, oxy-fuel, laser, waterjet).

And obviously the use of AI as a support tool.

It is not intended as a "job opportunity" (since there are practically no industries to apply), but rather it is intended (more than anything) to provide practical & theoretical knowledge as an essential tool to "find a way to get ahead and break into the market by adding value to the product and/or service they provide".
Like everything in life, doing the easiest thing... is the most easiest thing! Until it gets complicated (very complicated).

And like any enthusiast (anxious), you want to see the robot walk, the LED blink, the motor work, the app work, the doorbell recognize you and say "welcome master", and the telemetry be correct mesured and send/receive without problems.

And if there's a TOOL that can do everything with just one line of code... It's utopian!

But you don't want your API to break due to poor design, or anyone with a WhatsApp audio can open the door, or data will not be received/sent because the connection status isn't measured properly or event is missing, or the motor/pump rotate in the opposite direction, or the wrong LED blink.

Whether we like it or not... We (humans) are children of rigor; there are things we don't learn until we experience them firsthand; like debugging a transpiled code, that work on desktop with 8 cores, 64 Gb RAM and 2 RTX6090 Ti, but not on a ESP32 or Android GO.

Give someone a hammer and everything they come across... Will be a nail.
Thank you for taking the time to share such a detailed perspective.

I think there may be one important misunderstanding about the intention behind B4X++: the goal is not to replace B4X, redefine how B4X applications should be written, or force users to adopt OOP, inheritance, patterns, or any particular programming paradigm.

B4X++ (or whatever the name) is, at least for now, only a proof of concept -- and it may remain just that, which would be perfectly fine.

Over the years, some B4X users have asked for features such as inheritance, protected members, overrides, properties, and better ways to reuse code between related classes. Since these features are unlikely to be added directly to the B4X language, B4X++ is simply an experiment that allows interested developers to try them without modifying B4X itself.

Developers who are happy with classic B4X (99% of users may be) should continue using classic B4X. For many applications, it is already simpler, clearer, and more productive than adding another abstraction layer. B4X++ is not intended to suggest otherwise.

I also agree with the broader principle that paradigms are tools, not rules. OOP is not the solution to every problem, just as functional, procedural, event-driven, or data-oriented programming are not universal solutions either. A real project may benefit from several approaches at the same time.

The purpose of B4X++ is therefore not to promote “everything must be OOP.” It is to provide an optional tool for specific situations where developers believe these features may help them, particularly when creating reusable libraries, Custom Views, wrappers, games, or groups of related components.

Regards,
Toky
 
it may remain just that, which would be perfectly fine.
Personally I dont agree that it will be fine.

In my thread post where I introduced myself to b4++ via the video overview, I talk about how my code base was decreased by a large percentage by using b4++ just on one class.


Deciding which tool to use is always a personal choice and no one is forced to use or adopt a tool they dont want.

Over the years, some B4X users have asked for features such as inheritance,
As far as 2011 if I recall correctly.

It is to provide an optional tool for specific situations where developers believe these features may help them, particularly when creating reusable libraries, Custom Views, wrappers, games, or groups of related components.
Exactly and it will fit perfectly with my methodologies and the repetitve nature of creating b4xlibraries.
 
Thank you for taking the time to share such a detailed perspective.

I think there may be one important misunderstanding about the intention behind B4X++: the goal is not to replace B4X, redefine how B4X applications should be written, or force users to adopt OOP, inheritance, patterns, or any particular programming paradigm.

The purpose of B4X++ is therefore not to promote “everything must be OOP.” It is to provide an optional tool for specific situations where developers believe these features may help them, particularly when creating reusable libraries, Custom Views, wrappers, games, or groups of related components.

I know it perfectly & that's why i write "Please disregard this"...

Because I know perfectly well that advanced programmers are aware of all the trade-offs that we make when programming. I know how tedious it is to do a full DDD, especially when working locally and in the cloud.

But next year, when I start teaching, the vast majority of the kids won't be able to handle their anxiety and they will "want everything now". And just knowing the theory of absolutely everything doesn’t guarantee that it will work properly when they try to apply it.

And we all know perfectly well that the principle of least action governs the universe. They won’t hesitate to use AI and the mamushka frameworks and libraries out there. There will be those who question the use of B4X compared to other frameworks (especially web ones), because there is a ton of information, code, courses, tutorials, and AIs are trained in JS (and they still suks).

The general idea of my previous post is that when nothing works, everything is broken, and they can't even find the Cthulhu method... That's when they start to learn. Like happened to each of us at some point (remember when we used to copy from Stack Overflow???).

The software world has evolved a lot, but habits haven't, and we all know there are things that matter when programming, like Reflection, We all know what it is and blah blah blah... But when it comes time to apply it (in a specific language), nothing works as it should (if it even does).

And like I said at the beginning, the idea is that when nothing works and they don't know where the mistake is or why it happened... I'll redirect to this post.

Because learning is personal; everyone learns in their own way and at their own pace, even different from others.
But education is an act that happens between two or more people, and it involves other types of content; culture, economy, society, environment, etc.

Thanx for your tool, because it's really an incredible help, especially for me, since I don't make a lot of websites.
 
Personally I dont agree that it will be fine.

In my thread post where I introduced myself to b4++ via the video overview, I talk about how my code base was decreased by a large percentage by using b4++ just on one class.


Deciding which tool to use is always a personal choice and no one is forced to use or adopt a tool they dont want.


As far as 2011 if I recall correctly.


Exactly and it will fit perfectly with my methodologies and the repetitve nature of creating b4xlibraries.
I will continue. May be update objectives etc but I will continue.

Now, we have a very good foundations and when we release the next version, we will have full functional Designer for BANano/B4J. Main goal for 0.7-alpha is to have full designer for BANano/B4J and make easy to components writer to write runtime and design-time components easily (for Visual or Non Visual components).

1783975739915.png


And ouput:
1783975777785.png


Regards,
Toky
 
Excellent initiative.

Thanks for creating and sharing it, Toky.

I'll be studying it all soon (hopefully).

I just have one small point: you used the... "wrong class"! 😁 You posted this in "B4J Code Snippets" (ok, there's the "Breakout"), but this whole topic should be in the "B4J Libraries & Classes" thread.
 
Back
Top