Introducing RDCore: RD-VBA Language Platform v0.1.0-alpha

Close-up of a weathered dark coin featuring a raised duck emblem and partial lettering
V I V A T ❤️ C U C U M I S
[English version follows]

Rubberduck renaît

La plateforme RDCore franchit aujourd’hui une étape importante avec sa première version alpha publiée officiellement. Cette pré-version peut être téléchargée et installée dès maintenant, et fonctionne sous Windows, Linux et macOS. Pour le moment, seules les plateformes 64 bits sont prises en charge.

La plateforme accueille RD‑VBA, une implémentation de la spécification MS‑VBAL corrigée sur certains points, enrichie sur d’autres, qui permet notamment d’utiliser PEEK et POKE dans le mode BASIC, ajoute les constantes de précompilation #If Linux et #If Linux64, et compile vers l’IL de .NET 10.

Téléchargez la version alpha ici : https://github.com/rubberduck-vba/RDCore/releases/tag/v0.1.0-alpha

RD-VBA

Le cœur du langage réside dans le SDK (NuGet : v0.1.2‑alpha). Il définit une variante de VBA ainsi qu’une implémentation complète de sa bibliothèque standard capable de s’exécuter partout où .NET est disponible, sans dépendre du tristement célèbre environnement d’exécution Microsoft Visual Basic ni d’une application hôte quelconque. La plateforme fournit son propre environnement d’exécution.

Automatisation COM

VBA a toujours été capable d’automatiser des objets COM sans être hébergé dans le processus concerné. C’est exactement ce qui se produit lorsqu’une variable reçoit un New Excel.Application ou qu’un appel à CreateObject(“Excel.Application”) est effectué.

Comme RD‑VBA s’exécute en dehors des applications Microsoft Office, cette approche devient désormais la méthode normale d’interaction avec COM.

rdc build

En contrepartie, vous gagnez la possibilité de compiler du code RD‑VBA en exécutables autonomes. Les commandes rdc build et rdc run font exactement ce que leur nom laisse entendre.

Serveur de langage

Le cœur du langage n’est qu’un modèle. Ce qui lui donne vie, c’est l’architecture client/serveur LSP qui constitue la plateforme. En son centre se trouve le serveur de langage, qui coordonne les échanges entre l’hôte d’exécution, le client ou l’EDI et les extensions de la plateforme.

Le serveur fournit l’implémentation du protocole LSP 3.17 par l’intermédiaire d’OmniSharp 0.19. Les erreurs de syntaxe, de compilation et, lorsque possible, d’exécution sont signalées sous forme de diagnostics dès la phase de conception.

Les listes d’autocomplétion sont disponibles pour les mots-clés et les identificateurs, et prennent en charge la recherche par bosses PascalCase : saisir « mb » permet par exemple de retrouver MidB et MsgBox.

La plateforme elle-même n’inclut pas d’EDI*; cependant, rdc.exe agit également comme client LSP autonome et lance une console interactive RD‑VBA/BASIC lorsqu’il est exécuté sans argument.

*mais attendez, ce n’est pas tout!

RDCore.HexIDE

Sans faire directement partie de la distribution RDCore, ce module complémentaire pour HexIDE agit comme client LSP. Il télécharge la plateforme si nécessaire, avec votre consentement, puis assure la liaison entre l’EDI et le serveur de langage.

Pour installer RDCore.HexIDE, téléchargez le paquet signé depuis sa publication GitHub, extrayez-le dans un dossier qui lui est propre sous le dossier addins de HexIDE, puis redémarrez HexIDE.

HexIDE est né comme projet d’EDI VB6 accompagné d’un interpréteur expérimental. Avec RDCore comme moteur, il devient naturellement l’environnement de référence pour les espaces de travail RD‑VBA.

Importation de code source MS‑VBA

Les utilisateurs de Rubberduck dans le VBIDE connaissent probablement déjà les fonctionnalités d’exportation et de synchronisation de projets destinées au travail sous gestion de versions.

Sinon, exportez simplement les modules de votre projet dans un dossier dédié puis ouvrez ce dossier comme espace de travail dans HexIDE. RDCore génère un fichier .rdproj qui recense tous les éléments appartenant au projet, qu’il s’agisse de code source ou non.

Votre espace de travail peut ainsi contenir des fichiers README.md, des images, des ressources localisées ou tout autre actif chargé à l’exécution.

Le code MS‑VBA qui suppose la présence d’un hôte devra être adapté pour recourir à l’automatisation COM externe. Le code qui utilise déjà cette approche devrait fonctionner tel quel.

Importation d’un projet VB6

Les projets VB6 existent déjà sous forme de fichiers et sont décrits par un fichier .vbp. Lorsqu’un tel espace de travail est ouvert dans RDCore, le fichier .rdproj correspondant est généré automatiquement à partir du projet VB6 existant.

Là encore, la compatibilité devrait être largement transparente, avec quelques réserves.

Applications graphiques

RDCore héberge nativement MSForms 2.0 sur les postes Windows qui disposent de cette bibliothèque en version 64 bits. En revanche, il n’héberge pas les formulaires VB classiques, même si tous les symboles associés sont définis au moment de la compilation.

Le projet RDForms est actuellement en développement et sera publié pendant le cycle alpha. Cette infrastructure d’interface utilisateur reposera sur le rendu multiplateforme Avalonia et sur le moteur d’exécution RDCore.

L’objectif est de réunifier les formulaires VB classiques et MSForms dans une seule plateforme moderne capable d’importer les fichiers historiques .frm et .frx, tout en offrant une API événementielle familière pour le code existant et une API MVVM pour les nouveaux développements.

Un concepteur XAML pour HexIDE fait également partie du programme.

D’ici la publication de RDForms, les interfaces utilisateur interactives restent limitées aux systèmes Windows disposant de MSForms 2.0 en version 64 bits.

Applications console

Les applications ne nécessitant aucune interface graphique peuvent s’exécuter partout où .NET est disponible.

Sous Windows, MsgBox utilise une boîte de dialogue Win32 native. Sur les autres plateformes, la fonction est fournie par l’environnement hôte (rdc) et affiche une boîte de dialogue simulée en mode texte dans la console. InputBox suit le même principe.

Lorsqu’une application est exécutée avec rdc run –unattended, toute tentative d’interaction avec l’utilisateur provoque une erreur d’exécution mettant fin au processus.


À vous de jouer!

RDCore entame son cycle alpha avec une implémentation LSP déjà remarquablement avancée. Les fonctionnalités essentielles attendues d’un environnement moderne sont présentes aujourd’hui et continueront d’évoluer au cours des prochains mois.

C’est donc le moment idéal pour explorer RDCore et HexIDE.

Et si vous ne savez pas par où commencer, le dépôt RDCore.Demo.NavalBattle constitue la vitrine officielle de la plateforme. Cette adaptation RD‑VBA du code MS‑VBA original publié sur ce blogue propose une interface MSForms sous Windows et une interface console sur toutes les autres plateformes.

Consultez le site de documentation utilisateur pour découvrir tout ce qu’il faut savoir sur RDCore.


[English]

Rubberduck, reborn.

The RDCore platform has officially released a tagged alpha build: a pre-release that you can download and install, and that runs on Windows, Linux, and macOS. For now, it is only available on 64-bit systems.

The platform is the home of RD-VBA, an implementation of the MS-VBAL specification, corrected in places and enhanced in others, that lets you PEEK and POKE at memory space in BASIC mode, adds #If Linux and #If Linux64 precompiler constants, and compiles to .NET 10 IL.

Download the alpha release here: https://github.com/rubberduck-vba/RDCore/releases/tag/v0.1.0-alpha

RD-VBA

The language core lives in the SDK (NuGet: v0.1.2-alpha) and defines a version of VBA and an implementation of its standard library that runs everywhere .NET runs, without the infamous Microsoft Visual Basic runtime and outside of any host application: the platform provides its own host.

COM Automation

VBA was always able to automate COM without needing to be hosted inside the COM process in question – it’s what you do whenever you set an object variable to a New Excel.Application, or when you CreateObject(“Excel.Application”). RD-VBA running outside a Microsoft Office host means you must do things that way now.

rdc build

What you gain in exchange is the ability to build standalone executables from RD-VBA source code, so CLI commands like rdc build and rdc run do exactly what they sound like they’re doing.

Language Server

The language core alone is just a model. What brings it to life is the LSP client/server architecture of the platform and its components, at the center of which we find the language server, which acts as a coordinator between the host and runtime, the client/IDE, and the platform extensions.

The server delivers LSP 3.17 through OmniSharp 0.19, progress reporting included. Syntax and compilation errors, and run-time errors whenever possible, are reported as design-time diagnostics. Completion lists are triggered for keywords and identifiers, and match PascalCase humps, so “mb” gets you “MidB” and “MsgBox”.

The platform itself doesn’t include an IDE*, but rdc.exe itself is a standalone LSP client that runs a fun RD-VBA/BASIC shell when executed without any command-line arguments.

*but wait, there’s more!

RDCore.HexIDE

Not directly part of the platform bundle, this LSP client is a HexIDE add-in that downloads the RDCore platform, with your consent, if it’s not already installed, and then becomes the bridge between the IDE and the language server.

To install the RDCore.HexIDE add-in, download the signed package from its GitHub release, extract it into its own folder under HexIDE’s addins folder, and restart HexIDE.

HexIDE started as a VB6 IDE project with a toy interpreter – with RDCore as a backend, it becomes the natural home of RD-VBA workspaces.

Importing MS-VBA source code

If you’re using Rubberduck in the VBIDE, you’re probably already familiar with the export project and synchronize folder features, which were intended for working with source control.

Otherwise, export your project’s modules to a dedicated local folder, and open that folder as a workspace in HexIDE: RDCore generates a .rdproj file that enumerates all the files that belong to the project, whether they’re source code or not – so your workspace can contain a README.md file and additional assets (images, resource strings, etc.) that source code loads at run-time.

MS-VBA source code that presumes a host must be adapted to automate COM from the sidelines. MS-VBA source code that already does this should work as-is.

Importing a VB6 project

VB6 projects already exist in the file system, and a .vbp file describes the project: opening such a workspace in RDCore will automatically generate the .rdproj file from the .vbp, and again should work as-is… with a few caveats.

GUI Applications

RDCore hosts native MSForms 2.0 on a Windows desktop that has the 64-bit library. It does not host VB Forms despite having all the symbols defined at compile time; hosting VB forms requires reengineering pieces that belong to Microsoft, and RDCore does not do that.

RDForms is under development and will ship during the alpha cycle; it is the UI framework that RDCore will ultimately be using: Avalonia cross-platform rendering with RDCore runtime support will be combining Classic VB Forms and MS-VBA’s MSForms into a unified, modern UI framework that seamlessly imports legacy .frx and .frm, and then exposes a familiar event-based API for legacy workloads, and an MVVM API for the new ones. A XAML designer for HexIDE is also part of the deal.

Until RDForms releases, interactive UI in RDCore remains limited to Windows machines that have Microsoft’s 64-bit MSForms 2.0 library installed.

Console Applications

An application that doesn’t need to display a UI can run anywhere .NET runs. On Windows, MsgBox is a native Win32 message box; otherwise, the function is implemented by the environment host (rdc) and draws a text-mode message box in the console; InputBox is in a similar condition.

When executed with rdc run with the –unattended switch on, code that requires such user interactions throws at run-time, failing the process.


Playtime!

RDCore launches its alpha cycle much further along its LSP implementation than most other LSP projects would: everything you expect is there and already works, and both the SDK and the platform will keep evolving in the next few months.

This makes the next few months the perfect time to play with RDCore and HexIDE, and if you don’t know where to start, there’s always the RDCore.Demo.NavalBattle repository, which is the platform’s showcase demo: it runs an MSForms UI on Windows, and a console UI everywhere else, and it’s an RD-VBA port of the original MS-VBA code initially published on this blog.

See the user documentation site for everything you need to know.