BLADE is an outstanding new feature of BricsCAD V18.2. Standing for BricsCAD LISP Advanced Development Environment, BLADE is the new Visual LISP IDE for BricsCAD.

Bricsys has not just caught up with Autodesk, but has provided a host of extra functionality that is so far ahead of Autodesk’s 1999-vintage VLIDE that it’s unlikely Bricsys will ever be caught. Yet it remains highly compatible.

I had the chance to see this IDE privately in then-unnamed pre-release form when I attended the Bricsys 2017 Conference in Paris. I was surprised and delighted at the functionality demonstrated by its creator, Torsten Moses. I recently had the chance to interview Torsten about his creation.

Torsten, I understand it was difficult to create a LISP IDE for BricsCAD because of the way BricsCAD’s LISP works. Can you explain that?

BricsCAD LISP uses the OpenLisp core system, from French developer Christian Jullien. This is the only LISP engine still under development; the others I found stopped development in the mid-90s.

OpenLisp is a very modern implementation, not comparable to the old XLisp dialect used by AutoLISP. Even object-oriented features are supported. Therefore the internal representation of LISP expressions is different from the textual representation as seen in a LISP file.

So the AutoLISP code I write isn’t the code that BricsCAD executes?

That’s right. A number of typical AutoLISP constructions were implemented by a kind of emulation, which drives the internal versus textual representation differences even further. That makes it a major challenge to synchronize the internal OpenLisp expression execution with the related textual representation in order to provide any debugging functionality.

Besides the plain technical details, which seemed to be virtually unresolvable, there was the expected heavy effort to implement a full-blown GUI. This was not just a plain editor, but the entire IDE GUI.

It would have been a disaster, a major disgrace, if we had provided a VLIDE that was just up to AutoCAD standards. That was great in its time, but it’s 20 years later now.

The idea of creating a LISP IDE for BricsCAD seemed so filled with difficulties that we put it off for a long time.

How did you finally manage to overcome these difficulties?

First, it was a pure coincidence. [laughs] By luck, I discovered a hidden detail in OpenLisp – any LISP symbol (and expressions are a kind of anonymous symbols) can hold unlimited, attached custom data, very similar to XData in DWG database objects. I even knew about that for many years, but never worked out the shortcut to ‘misuse’ this for the LISP expression execution to editor and debugger bidirectional connection. Some initial quick tests showed that this approach was very suitable.

By another coincidence, I discovered that WxWidgets (our cross-platform system, not only for GUI) already includes support for the famous Scintilla editor, an OpenSource editor engine, widely used by many editors. WxWidgets even provides two levels of wrappers – a plain, core wrapper, and a high-level wrapper class system. This fits perfectly into the WxWidgets logic.

But still, that is only plain editor support – not a GUI. Then I found a very suitable, extensible editor and GUI implementation, based on that WxWidgets Scintilla system – as Open Source under the WxWidgets license. Hence, we are allowed to use that source code in a commercial application. That editor is called wxStEdit.

I verified that this source was suitable for our LISP IDE, and put in a lot of extra work to extend it. wxStEdit development finished in around 2008, and it still was compiling and working mostly fine. Nevertheless, in the course of extending that GUI, I found and fixed a lot of defects at all related levels (Scintilla, WxWidgets Scintilla wrapper and wxStEdit).

So it was this set of coincidences that suddenly opened both wings of a big gate!

I’ve noted before that BricsCAD execution of AutoLISP and Visual LISP is several times faster than AutoCAD’s. How does the new technology affect that performance?

All the new BLADE-related stuff doesn’t really affect normal LISP execution outside the IDE and debugger. The connection is made by a few callbacks, which take zero time in normal processing. Therefore there is also no chance of breaking things.

The BLADE implementation is very safe, and performance remains high for normal usage.

For the debugger and the synchronization, it is all home-brewed stuff, optimized for best performance even when debugging, and minimum system and LISP memory usage.

In the course of implementing the debugger and internal versus external synchronization, I also removed most emulations and implemented that as core OpenLisp functionality. That has the side-effect that the (repeat), (foreach) and (vlax-for) functions now run about five times faster at the loop construction. So rather than slowing things down, creating BLADE has actually speeded things up!

Will the Mac and Linux versions also get this feature?

Yes, it is fully compatible. This is due to the implementations of WxWidgets and my own stuff. I have already verified BLADE running under Linux. There are no differences; even the implementation code has no Windows-specific stuff.

Can you give a simple example of the workflow of a debugging session?

First, don’t pre-load any LISP file into BricsCAD. Such code loaded outside the debugger is fully functional, but it can’t be used for debugging. The special connection between internal and external representation is only established when loading the LISP code under a debug state.

Next, in BLADE open an existing FAS or VLX project, and/or a “Named Session”, or simply any LISP file you want to start debugging with.

Now you can select Start Debugging from menu or toolbar, or hit the F8 hotkey. The special Debug Toolbar will appear. You can either activate AutoBreak, which stops at first executable code, or activate the LISP source where you want to start debugging and place some breakpoints.

Then load the dedicated LISP file, either by the normal Load into BricsCAD function, or from the Load button in the Debug Toolbar. Now that loaded code is debug-enabled and you will see the file and debug-enabled functions in the two right tabs.

When the debugger halts at the first breakpoint, all debug-step modes are enabled in the toolbar, and you have all the usual debug step modes. More than in AutoCAD’s VLIDE, actually. You can set the watches (observed and tracked variables) as “Data Break Point” by activating the checkbox. Then, whenever that value changes, the debugger also stops automatically at the related LISP statement.

What if your code calls code in other files you haven’t loaded?

Don’t worry about that. The debugger recognizes this and will ask to load the related LISP file on-demand. In normal LISP, you would get an unknown function error but the debugger catches this upfront. In fact, this is one of the high-end features – only load the primary LISP file, any further debugging into other files resolves by loading during the debugging session. This is very handy for dealing with complex apps – there’s no need to preload any other LISP source.

I’m sure you’ve experienced Murphy’s Law, where the particular function you need is the one that’s not loaded. You won’t have that problem in BLADE.

Where to from here? Is this job done or is there still room for improvement?

As BLADE is still a very young product, there is definitely a lot more to come. So far, the main target was to provide good debugging features, and a somewhat reasonable handling of projects, but not so much focusing on plain editor capabilities.

My to-do list still has a number of major key features to be implemented. We want to add a hotkey editor, because every developer loves his own keystrokes and learning others is a nightmare! We also want cross-reference checking on a per-file and per-session basis, mainly for bigger LISP applications.

Then, over time, the editor capabilities will be extended and improved, providing more features. One example is to provide an editor tooltip that shows a function signature and short help when hovering over a LISP function name.

And of course, I’m aware that when people start using this in production, a lot of feedback will arrive from developers in the form of wishes, hints for improvements and bug reports. It’s very likely there will be many wishes to implement several details to make BLADE resemble AutoCAD’s VLIDE more closely. This could be a bit difficult sometimes, and is also not the main target. I hope that developers will be open to a slightly different workflow, given the big advantages they get in return.

In general we are very open to developer ideas, needs and requirements, as we are with BricsCAD itself. In the end, it’s the developer who needs to work with BLADE, as easily and productively as possible.

Even the initial release of BLADE is based on important feedback from beta testers such as Martin Drese (CAD Wiesel).

BricsCAD V18.2 is available today!

When you see the level of dedication that our Development team devotes to the BricsCAD Platform, you’ll agree that it’s the clear future of .dwg-based CAD. As a BricsCAD user, the value you get from your license is growing year-over-year. It’s a win-win-win situation for everybody involved. If you’re not using BricsCAD today, you should be.

Try BricsCAD V18.2 free for 30 days

NOTICE:  Because we consider it important to hear different voices and opinions, we publish regular guest posts. Each author writes in his own name and is responsible for the content of the text. This interview was originally published in two parts on Steve’s blog nauseam site