twinBASIC Update: November 5, 2023

Highlights include a major overhaul of twinBASIC's internals, support for "destructuring assignment", and a VBA UserForm to tB converter.

twinBASIC Update: November 5, 2023

On April 23, 2021, I helped Wayne Phillips introduce the world to twinBASIC at the Access DevCon Vienna conference.  I boldly predicted that twinBASIC (along with the Monaco editor) would replace VBA and its outdated development environment by 2025.  With that goal in mind, this weekly update is my attempt to keep the project fresh in the minds of the VBA development community.

Every Sunday, I will be providing updates on the status of the project, linking to new articles discussing twinBASIC, and generally trying to increase engagement with the project.  If you come across items that should be included here, tweet me @NoLongerSet or email me at mike at nolongerset dot com.

Here are some links to get involved with the project:


Highlights

Descriptions for Functions in the VBA Package

As announced by Wayne:

All standard functions in the VBA package now have some initial attached descriptions, courtesy of chatGPT.  For sure, they are not all perfect and will need some work.  As a first shot, seems better than nothing.

In addition to the VBA standard library, Err and Collection object members also have descriptions.

"Destructuring Assignment" Support Added

Back in 2021, wqweto lodged the following language design request:

The problem being solved is returning more that one result like in modern languages like in golang we have
    max, min = maxmin(a, b)
. . . or for error handling with
    message, err := greetings.Hello("")
    if err != nil {
        log.Fatal(err)
    }

As of BETA 416, that feature is now available in twinBASIC.

Massive Changes to twinBASIC Internals

BETA 416 involved a lot of changes (see changelog below).  One of the most fundamental of those changes, though, was to strip all of the internal libraries (VBA, WindowsControls/CustomControls Designers, Unit test library) out of the twinBASIC core and into twinBASIC packages.

This has a few benefits:

  • VBA and VBRUN compatibility packages can now individually be disabled via the settings references list
  • "The full rebuild compile time for tB (the time to compile the tB compiler itself) is better than halved (actually about 60% reduced)" [which speeds up development time for Wayne Phillips]
  • Likely an important first step toward cross-platform compatibility (just my personal guess)

Discord Chat Summary

* Auto-generated via Claude-2-100k on poe.com

General Channel

Here is a summary of the key points from the General channel transcript from the twinBASIC Discord server:

Intro

The transcript covers general discussion about the development of the twinBASIC programming language over the past week. twinBASIC is a new open source BASIC language that aims to be a modern revival of Visual Basic 6.

Summary

  • A new beta release (416) was made with major improvements, including full support for VBA compatibility functions and greatly reduced compile times. Many members expressed excitement about the new features.

  • The new release included initial documentation strings for many standard functions, generated by ChatGPT. These will need to be reviewed and refined, but provide a good starting point.

  • Several bugs were reported and discussed, including indentation issues when pasting code and problems with some COM declarations. Most were resolved or have open issues on GitHub.

  • ChatGPT was discussed as an aid for generating code snippets and documentation. It can be useful but requires oversight as output often needs correction.

  • Work was done on porting a JSON parser module and other code from VB6/VBA to twinBASIC. The collection implementation differences were analyzed.

  • Progress was made toward getting the PhotoDemon app to run, though some crashes remain. It now loads if twinBASIC is restarted after the first crash.

  • There were detailed technical discussions around structure alignment, padding, and sizing, for both x86 and x64 targets.

  • The language syntax for adding multithreading after v1.0 was raised as something to decide on soon, before collisions occur with user code.

Conclusion

Good progress was made this week, with new features and fixes released. Community involvement remains high, with lots of feedback, bug reports, and code ported to twinBASIC. The project continues to move closer to the v1.0 release.

Around the Web

VBA UserForm to tB Form Converter

GCUser99 posted about a VBIDE add-in he created that converts VBA UserForms to twinBASIC forms:

GitHub - GCuser99/VBA-UserForm-to-twinBASIC: A VBIDE add-in for exporting VBA UserForms to twinBASIC
A VBIDE add-in for exporting VBA UserForms to twinBASIC - GitHub - GCuser99/VBA-UserForm-to-twinBASIC: A VBIDE add-in for exporting VBA UserForms to twinBASIC

Here's a visual comparison of the before and after of a UserForm (left) being converted to twinBASIC (right):

twinBASIC-Compatible JSON Parsing/Dumping

From wqweto in Discord:

I just tweaked my mdJson module to work in TB:
JSON parsing/dumping functions with JSON path support for VB6 and VBA
JSON parsing/dumping functions with JSON path support for VB6 and VBA - mdJson.bas

Sample usage instructions are available on VBForums.

Changelog

Here are the updates from the past week.  You can also find this information by visiting the GitHub twinBASIC Releases page.

Releases · WaynePhillipsEA/twinbasic
Contribute to WaynePhillipsEA/twinbasic development by creating an account on GitHub.

ChatGPT Changelog Summary

* Auto-generated via ChatGPT, sorted in order of ChatGPT's opinion of "most impactful changes."

Based on your extensive list, here is the condensed version focusing on the most impactful changes:

  • Added: Destructuring assignment support, allowing for multiple returns, improving code readability and error handling. View Discussion
  • Improved: Support for VBA and VBRUN compatibility packages, which can now be individually disabled via the settings references list, providing more customization.
  • Updated: All internal libraries including VBA, WindowsControls/CustomControls Designers, and Unit test library are now exposed via packages, enhancing accessibility and modularity.
  • Added: Several new attributes for advanced procedure management such as [MustBeQualified], [DebugOnly], [RedirectToStaticImplementation], and [EnumId], offering more control and optimization possibilities.
  • Enhanced: Intellisense and hover descriptions for all VBA standard library functions, Err object members, and Collection object members, improving clarity and guidance for developers.
  • Fixed: Various issues with IDE text wrapping, case correction, and compiler crash, enhancing the development experience.
  • Improved: Optimization by removing HRESULT (error handling) around some builtin functions that don't throw errors, boosting runtime efficiency.

WARNING: The following issue is present in BETA builds 202 - 3xx (the latest build as of publication):

  • there are known memory leaks in these versions, so memory usage will be higher than normal

BETA 416

  • removed: Debug Console notifcations "[INTELLISENSE] Caching intellisense..."
  • fixed: problems with nested packages, where package priority was needing to be changed unnecessarily
  • added: support for [PreserveSig(False)] attribute on DLL Declares, to allow for HRESULT return values (VBA package usage)
  • added: support for [ConstantFoldable] attribute on DLL Declares (VBA package usage)
  • added: support for Property Get/Let/Set on DLL Declares (VBA package usage)
  • fixed: VBA.Financial.IRR library method could cause a runtime crash (edge case)
  • fixed: VBA.Strings.Filter implementation edge cases
  • changed: all internal libraries (VBA, WindowsControls/CustomControls Designers, Unit test library) are now exposed via packages
  • improved: VBA and VBRUN compatibility packages can now individually be disabled via the settings references list
  • added: destructuring assignment support via Array() syntax [ https://github.com/twinbasic/lang-design/issues/28 ]
  • added: [MustBeQualified] boolean attribute (default False) for Modules and procedures within them [ used in Unit test library ]
  • added: support for string concatenation, line continuation, and vbCrLf, in [Description()] attributes
  • added: [DebugOnly] boolean attribute for Sub procedures to indicate that calls to it should be excluded from final built executables [ used in Unit test library ]
  • added: [RedirectToStaticImplementation] string attribute for redirecting an interface member to a standard module function [ used for internal package optimizations ]
  • added: [EnumId] attribute for associating GUIDS to Enums

BETA 417

  • improved: (optimization) removed HRESULT (error handling) around some builtin functions that don't throw errors
  • fixed: case correction of VBA.IIf (from Iif) to match VBx [ wqweto, discord ]
  • improved: (IDE) all VBA standard library functions now have some initial descriptions and examples that will appear in hovers and intellisense [ chatGPT ]
  • fixed: (IDE) wordwrap in hovers and intellisense, and tweaked formatting

BETA 418

  • improved: all Err object members now have initial descriptions attached [ chatGPT ]
  • improved: all Collection object members now have initial descriptions attached [ chatGPT ]
  • fixed: (regression in BETA 416) (IDE) text wrapping was occurring on IDE code lines in some instances [ fafalone, discord ]
  • improved: (IDE) tweaked the CSS for intellisense and hovers

BETA 419

  • fixed: new documentation from BETA 418 not always showing for Err members
  • fixed: compiler crash when editing tbShellLib [ fafalone, discord ]

BETA 420

  • added: initial documentation for VBRUN classes PropertyBag and DataObject
  • fixed: some function-constant-folding issues with non-HRESULT based API calls since BETA 417, when project level function-constant-folding turned on [ https://github.com//issues/1710 ]
  • fixed: private UDTs can now be accessed via their component qualifier from within component methods, as per VBx [ https://github.com//issues/1705 ]
  • improved: private Enums can now be accessed via their component qualifier from within component methods for consistency with UDT handling [ https://github.com//issues/1705 ]
  • fixed: (IDE) auto-correction/prettifier should no longer prevent block completion from also occuring when enter key is pressed [ https://github.com//issues/1504 ]

All original code samples by Mike Wolfe are licensed under CC BY 4.0