twinBASIC Update: May 19, 2025

Highlights include increased compile speed for large projects and a sample twinBASIC project for implementing Windows "Toast" notifications.

twinBASIC Update: May 19, 2025

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 Monday week, 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, please leave a comment below.

Here are some links to get involved with the project:


Highlights

Performance Improvements

BETA 776 improved the "efficiency of the final codegen stages of the compiler, leading to 30% reduction in build times, and snappier F5/Run." The difference is most notable in very large codebases, such as for PhotoDemon.

Discord Chat Summary

* Auto-generated via Claude-3.7-Sonnet

Overview

This week saw significant performance improvements in the twinBASIC IDE, with build and run times reduced by approximately 40% for larger projects. Discussions centered around memory management techniques, type conversion utilities, and COM interface compatibility. The community also explored advanced programming patterns like jump tables and generic helper functions.

Performance Improvements

  • The latest beta (v776) delivers impressive performance gains with F5-Run times reduced from 1.6s to 1.0s and EXE build times cut from 2.5s to 1.5s for large projects like PhotoDemon (reported by Wayne Phillips).
  • These optimizations particularly benefit larger codebases, enhancing the development experience for complex applications.

Memory Management & Type Conversion

  • Wayne Phillips shared a generic helper function GetMem(Of T) that safely reads memory from a pointer address into any type, addressing a common need for low-level memory operations.
  • The community developed a more flexible type conversion utility DCast(Of T, T2) that enables direct memory casting between different types without the limitations of CType.
  • Discussion clarified that CType(Of UDT) behaves like a cast to a UDT pointer in C, not dereferencing the pointer until a field is accessed.

COM Interface Compatibility

  • A discrepancy was identified between VB6 and twinBASIC regarding interface GUIDs in arrays of objects, with tB always returning IID_IDispatch regardless of the actual interface type.
  • Wayne quickly addressed this in beta 775 for ReDim statements, with further fixes needed for Dim statements.
  • The new internal function GetDeclaredTypeIid(Of X) was introduced to provide a cleaner way to obtain interface GUIDs at compile time.

Language Features & Patterns

  • Wayne demonstrated how to implement jump tables in twinBASIC using delegates and arrays, providing a modern alternative to the legacy On X Goto syntax from VB6.
  • Discussion around public constants in classes highlighted the constraints imposed by COM/IDL compatibility, with explanations of how types and enums are exposed in type libraries.

Conclusion

This week demonstrated twinBASIC's continued evolution with significant performance optimizations and enhanced low-level programming capabilities. The quick response to identified compatibility issues shows the team's commitment to maintaining VB6 compatibility while introducing modern programming patterns. The community continues to explore the boundaries of what's possible with twinBASIC, particularly in areas of memory management and COM interoperability.

Around the Web

Windows Toast Notifications: twinBASIC Sample Code

Posted by VanGoghGaming in Discord show-and-tell:

Just finished importing my VB6 ToastNotifications project into twinBASIC. No TypeLib is needed, I've included the WinRT interfaces as a package instead.

Download it from this thread in the vbForums, CodeBank section:
twinBASIC - Simple ToastNotification with Interactive Elements (WinRT XML interfaces)-VBForums
This is the twinBASIC version of my VB6 ToastNotifications project (click the link to read the full description). I’ve tested it in both 32-bit and 64-bit, it’s working great so far. Make sure you have the latest tB version (v775 as of now) since Wayne has just fixed a bug that was preventing it from running. 194806 Here is the demo project: 194807 Requirements: Windows 10 or later!

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.

AI-Generated Changelog Summary

* Auto-generated via Claude-3.7-Sonnet, sorted in order of its opinion of "most impactful changes."

  • Added: Find/Replace improvements - New 'Current Project' scope for find/replace operations and a cancel button when the panel is floating, giving users more control during search operations.

  • Fixed: Array handling issues - Resolved issues with Get/Put statements when working with fixed-length array fields in UDTs and fixed a debugging crash when hovering over array elements after using Split function.

  • Improved: Build performance - Efficiency improvements in final codegen stages leading to 30% faster build times and more responsive F5/Run execution.

  • Fixed: Control and interface issues - Corrected several problems with ActiveX controls, form controls collection ordering, and interface type handling.

  • Added: Better error handling - New compiler error B5250 for public constants in classes (improving VB6 compatibility) and IDE verification to ensure project saves complete successfully.

  • Improved: Project settings - Simplified handling of Data Execution Prevention (DEP) and Large Address Aware (LAA) settings, removing redundant IDE options and using project settings as the authoritative source.


WARNING: The following issues are present in BETA builds 623 - 778 (the latest build as of publication):

  • IMPORTANT: This is an interim/experimental release. It includes significant changes, so some instability is to be expected. [Editor's Note: Rolling back to BETA 622 may be necessary if any of the KNOWN ISSUES below affect your project.]
  • KNOWN ISSUE: Controls are not being destroyed properly by the form designer, causing big memory leaks (broken in this build)
  • there are known memory leaks in these versions, so memory usage will be higher than at the Version 1.0 release

BETA 769

  • added: IDE self-verification check to ensure project save request was completed within 5 seconds, else an error is presented to the user [ fafalone, discord ]
  • fixed: (regression) potential crash in handling WM_CLOSE in recent releases [ Joe Philli, discord ]
  • added: 'Cancel' button to the Find/Replace panel (when floating)

BETA 770

  • fixed: intermittent build failures in large projects like PhotoDemon [ fafalone, discord ]

BETA 771

  • fixed: some false-positive "IDE Save Project Failed" messages appearing since BETA 768
  • improved: first attempt to save an unsaved project could result in a question dialog rather than a save-project path dialog [ sokinkeso, discord ]
  • added: compiler error B5250 "Constants in a class cannot be Public" [ https://github.com/twinbasic/twinbasic/issues/2105 ]
  • removed: IDE option 'IDE: Data Execution Prevention (DEP)', now the project DEP-aware setting is authoratitive
  • removed: IDE option 'IDE: Large Address Aware (LAA compiler)', now the project LAA setting is authoratitive
  • improved: 'DEP' and 'LAA' are now indicated on the compiler info line in the CALLSTACK panel

BETA 772

  • fixed: codegen errors reported in the DEBUG CONSOLE for classes using VB_GlobalNameSpace without VB_PredeclaredId [ Rob Wubs, discord ]
  • fixed: UserControls in nested packages would often cause "Error 9405: Failed to deserialize form" in the root project [ Rob Wubs, discord ]

BETA 773

  • fixed: (regression since BETA 770) dissassembled view of references (type libraries) not available in the IDE
  • improved: support for malformed AX controls that don't respond to IUnknown::QueryInterface for their own default interface, yet still work in VB6 [ KarlSevenSeven, private ]
  • fixed: (regression since BETA 770) ActiveX control codegen issue causing classfactory issues when attempting to use the control [ fafalone, discord ]

BETA 774

  • fixed: (regression) Report designer would crash when changing an enum value in the property sheet
  • fixed: Form.Controls collection ordered menu controls in a different order to the visible display [ KarlSevenSeven, private ]

BETA 775

  • fixed: generic GetDeclaredTypeIid(Of X) wasn't working on typelib interfaces [ VanGoghGaming, discord ]
  • fixed: ReDim statement was not populating the preamble GUID correctly for interfaces sub types [ VanGoghGaming, discord ]

BETA 776

  • improved: efficiency of the final codegen stages of the compiler, leading to 30% reduction in build times, and snappier F5/Run

BETA 777

  • fixed: Get/Put statement support for outputting fixed-length array fields directly from contained UDTs [ https://github.com/twinbasic/twinbasic/issues/2125 ]
  • fixed: Dim statement was not populating the preamble GUID correctly for interfaces sub types [ VanGoghGaming, discord ]

BETA 778

  • fixed: hovering over an array element accessor whilst debugging could cause a crash [ https://github.com/twinbasic/twinbasic/issues/2126 ]
  • fixed: after hitting IDE Stop button, next F5-run could trigger immediate interruption with breakpoint at IdleMessageLoopBreakpoint
  • fixed: some edge cases around OLE drag drop handling

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