twinBASIC Update: July 24, 2022

Highlights include implementation of the form Controls collection, initial publication of the twinBASIC Guiding Principles, and the potential to write device drivers with tB.

twinBASIC Update: July 24, 2022

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

Form Controls Collection Added

Controls collection is now populated as of BETA 78.
- Wayne Phillips

Open Project in twinBASIC IDE from Command Line

As of beta version 80,

"the IDE executable (twinbasic.exe) can now be passed a command line argument to open a project file at startup."

In the associated Github issue, Ben Clothier provided the groundwork for adding an Explorer context menu shortcut to create new twinBASIC Projects:

Around the Web

Guiding Principles for twinBASIC

The twinBASIC Guiding Principles:

  1. Backward compatibility trumps everything
  2. Community is essential
  3. Solving problems is the point
  4. The B in Basic stands for Beginners, still
  5. Readable code is better than terse code
  6. Transparency rocks
  7. Consistency matters
  8. Fewer ways are better than many ways
  9. Refactoring and testing should be natural
  10. Documentation is important
  11. Pure and simple: YOUR Code

Check out Andrew Mansell's (mansellan) comment for instructions on how to propose changes to the guiding principles document.

Creating Device Drivers in twinBASIC?

From Wayne:

In BETA 82, there is now a project setting for Project: Native Subsystem. On it's own this is not particularly useful, as we also need to be able to override the entry point before being able to create kernel mode drivers.

While it's not yet possible to actually build device drivers in twinBASIC, the possibility is intriguing.  Several commenters pointed out that this would be functionality that you simply CANNOT GET in managed languages, including .NET, Python, Java, etc.

Building low-level device drivers with TB would be a nice feature for marketing.  
- wqweto
[O]ne of the things that's made me such a big fan of VB6 is how it allows you to use high level language features to get things done at that level, but allows you to drop down into lower levels as needed... which .NET throws up big roadblocks to.
- fafalone
Heh, I'm on record as being a big C# fan. But I would be overjoyed if twinBASIC could do something that C# can't.
- mansellan

Including an Optional TimeZone Parameter in Now() Function

Mark Burns opened a request for an enhanced version of Now():

Change the definition of NOW() to mirror:
Public Function Now(optional TargetTimeZone as vbTimeZones = vbMachineLocalTimeZone) as datetime
Where specifying a Target Timezone returns the Now() datetime for that specified timezone.
Omitting the parameter results in exactly the same behavior as the existing now() function.

A vibrant discussion of the pros and cons of that approach ensued.

Personally, I'm with Ben Clothier on this one:

IMPOV, this seems like a good idea that may lead to more problems down the road. ...

Here's why: the Date data type has no time zone information. ... That requires us to go to extra length of making wrong code look wrong...

I assume Ben's comment is alluding to this classic gem from Joel Spolsky, "Making Wrong Code Look Wrong."

Adding this feature would mean that some developers would create timezone-aware dates, while other developers might not.  The problem with such a situation is that you can't be sure what type of developer you're dealing with when reading code.  In my article, "Don't Write Clever Code," I warn about the two assumptions you make when writing "clever" code:

  1. Every person who reads your code knows what you are doing
  2. Every person who reads your code will know that you knew what you were doing when you wrote it

Imagine every time you saw a Date in twinBASIC if you had to wonder whether or not that date is timezone aware.  As others suggested in the discussion, I think there are better alternatives.

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.

BETA 82

  • fixed: some properties not effective on Frame contained controls [ https://github.com//issues/1004 ]
  • added: project setting flag of 'Project: Native Subsystem' to allow building device drivers soon [ https://github.com//issues/1013 ]
  • fixed: turned off trimAutoWhitespace monaco setting due to interference with prettifier [ https://github.com//issues/1016 ]

BETA 81

This appears to have been the merge of a pull request for fixing a typo in the Readme.md file that, I assume, was mis-tagged as beta-81 within Github.

BETA 80

  • improved: the IDE executable (twinbasic.exe) can now be passed a command line argument to open a project file at startup [ https://github.com//issues/1000 ]
  • fixed: codegen error in some Erase statements involving UDTs [ baka, discord ]
  • fixed: some further file-get/put edge cases [ baka, discord ]

BETA 79

  • fixed: prevent IConnectionPointContainer from passing through to Implements-Via fields as it causes ActiveX UserControl issues when no events are defined [ https://github.com//issues/997 ]

BETA 78

  • added: form Controls collection [ https://github.com//issues/992 ]
  • improved: error codes and descriptions for UBound/LBound now match VBx [ https://github.com//issues/986 ]
  • fixed: edge cases involving enumeration value shadowing of some built-in functions [ https://github.com//issues/991 ]
  • fixed: enumeration values no longer accept and ignore arguments attached to them [ https://github.com//issues/991 ]
  • improved: CustomControls Form now also requires vbModal argument to match WinNativeForms version [ https://github.com//discussions/981#discussioncomment-3130572 ]
  • improved: enforced full form repaint after form resize [ baka, discord ]
  • improved: closing a project left open Search result documents

BETA 77

  • fixed: codegen issues around fixed-length strings [ baka, discord ]

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