Quick post on AI coding


Author: Dave
Date: 01.19.26 - 1:07pm



I am going to do a quick informal post on AI coding.

So to give it a shot, I wanted to try a rather involved project. My personal needs had me wanting a custom-built JavaScript engine from scratch, and a new Scintilla wrapper OCX control. Both would be done in VB6.

After playing with several AIs, I settled on Claude.AI as my favorite.

Both projects were quite involved and came out very well:

https://github.com/dzzie/js4vb
https://github.com/dzzie/sci4vb

I will mostly talk about the JS engine since it’s the bigger project and more complex.

To start, I have been a VB6 developer for 20+ years. It’s still my main language.

I know the theory behind the stages of developing a JS engine, but I do not have the experience to write one from scratch and am not a master of the JS ES5 specification. I am leaning on Claude’s knowledge hard here.

First some history - The 25-Year Road to js4vb

If you're curious how we got here and why I bothered to build a custom engine from scratch... it’s because I’ve been hitting a wall for over two decades. This project is the culmination of years of trying to "bolt on" scripting to VB6 with varying degrees of success.

1. The MS Script Control (1998): The starting point for everyone. It works, but it’s stuck in the ES3 spec (ancient syntax) and lacks any real debugging support. I wanted more control.
2. IActiveScript & Citrus: I tried to use the raw IActiveScript debugger interfaces in VB6. It was brutal and never fully worked right. Ken Foust had his Citrus debugger in C++, but at the time, that level of C++ was beyond me.
3.Script Basic & First Debugger Success (2014): I experimented with the Script Basic engine. It had a debugger interface that let me play relatively easily. I tried bolting on COM integration, but my additions were rough and crashy — script errors could easily be fatal to the host. This was however my first win getting C-to-VB in-process callbacks for script debugger control.
4. Duktape: Next was Duktape, a nice, small C engine. I wrapped it into an OCX and used it for years. It was stable, but my COM integration was still a bit clunky (requiring custom JS classes and resolvers). The biggest dealbreaker was that JS has no true 64 bit number support. For the tasks that I do, JS standard 53 bit numbers was a head ache.
5. Py4vb: Next I tested Python integration with VB6. Thanks to Mark Hammond’s pywin32, COM access was seamless. Python however requires 30MB+ of run times, has messy internals, and embedding is clearly an after thought for the language. I had to hack the main execution loop just to add an abort mechanism.

After 25 years, I knew exactly what I wanted:

  • Native VB6: Built specifically for embedding.
  • Seamless COM: Native IDispatch support.
  • Integrated Debugger: No more hacky C-wrappers.
  • Full 64 bit Number Support: No more 53 bit insanity

Problem, I just didn't have the 1,000+ hours required to hand-code it. Now with new tech, AI finally gave me the power to execute on a vision I've had since the late 90s.

First, I started by creating a JS AST parser. This is the foundation for a script interpreter and is a whole project all on its own. We built this up iteratively. I used jquery.js as my test suite and we kept working until it could be parsed successfully. We designed hundreds of tests and added tons of debugging output as we went. We finally got it stable. I then asked about corner cases and other common gotchas and we worked through these.

Turns out this is a perfect target for AI:

  • clear JS specifications
  • tons of known test cases
  • dozens of stable implementations
  • lots of literature written on the task.
  • theres no way to hide junk code: it will blow up spectacularly.
These factors made this a very efficient problem set for Claude to work through.

Once the AST parser was solid, we then got to work on the interpreter and we started incrementally adding features.

Claude knew what order to add features and wrote extensive test case at each stage. I grilled it and added design decisions along the way. (The Git repo unfortunately does not represent this building process.)

We then started adding some fancy features like true 64-bit numbers (in a host language that doesn’t support them!) and seamless COM support. We even had to write some C DLLs for things that I would not attempt in VB6 itself.

We even went a little crazy adding an IDispatch proxy mechanism so VB6 could access native JS objects through the VB6 Object type.

Check out the project readme. The features are actually pretty impressive! This was about 50 hrs of coding, which is simply not a possible timeline in any other way regardless of team size, budget, or expertise. This level of productivity is only possible through AI. This should have taken a team of 4 a year solid.

So what did I learn?

  • #1 holy shit – super impressed!
  • Work in testable chunks and test the hell out of each element
  • Use copious amounts of debug output so you can paste it back into the AI for analysis
  • Psych it up, you must tell it you are building pro-grade software or it will be lazy
  • You are the architect. If you don’t like what you’re seeing, correct it
  • I preloaded it with the code components I knew we needed like a VB6-compatible 64 bit math lib
  • You will find model weaknesses that will create repeatable classes of bugs you must warn it about
    • Do not Dim As New in a loop expecting new objects
    • It does not handle the Declare mechanisms well; you must train it per context
    • Do not let it try to use regex – at all
  • It will magnify what you’re capable of, but it will produce a mountain of shit if not guided
  • It can very easily duplicate code. It won’t remember what it did before in large contexts
  • There are some types of bugs it simply can’t solve. You may need to intervene and probe deeply
  • Some AI context instances will prefer to just show you edits to make . This can get very dangerous trying to weave in edits without enough surrounding context. ask for more!
  • It will likely atrophy brains and make people lazy
  • Code integrity will absolutely suffer trying to test code we don’t fully understand.
  • Younger coders will never really learn to code as well as the older ones who had to suffer to learn
  • complex problems may need to be run by other AI for consensus (fresh eyes applies!)

Ok, so now on to some practical concerns. To code this JS engine I easily burned through 18 different contexts. Each context has a length limit. As it gets “tired” or “full” it will start tweaking out. You need to recognize this and switch at a logical stop/start point.

When starting a new context you need to:

  • reload all of the information it needs upfront
  • instruct it to ask for more info as needed
  • reinterate overall project goals and demand professionalism
Note: If not properly reloaded, it will be very happy to make assumptions and hallucinate previous code.

So how do you reload a context without overwhelming it?

I have a code helper add-in for the VB6 IDE that I added some features to:

  • Right-click replace function (with Unix2DOS built in)
  • Right-click replace code module (with Unix2DOS)
  • Go to line (VB IDE does not have this)
  • Copy all public properties/methods/events

These features are a minimum for efficient work. The add-in already had enhanced search-all and code navigation capabilities.

When I start a new context, first thing I would do is dump all of the classes and their public prototypes. Then I would upload the relevant files and tell it exactly what we are working on.

As the files got bigger, it noticed it would only study the parts I asked about. It actually would not try to understand elements outside of that. It appears to try to protect its own context limits.

You have to keep a running map of the entire project in your head and a fair understanding of its architecture and what each class does. You can’t trust it to make all the decisions for you. It does a really good job, and was able to weave in some amazing features in very little code, but you still have to know what’s going on and make the proper suggestions and rejections.

It was a painful process and I had to be at the top of my game that entire time to pull it off, but it really came out well. I am actually amazed by it.

There were a couple parts I knew were possible, but were above my direct ability, such as the CallByNameEx and IDispatch proxy. Claude really nailed them. Accessing JS objects through IDispatch was particularly hairy to implement!

The danger with this is I was almost dealing in black magic. When operating outside your core capabilities, you lose the power of foresight and are (temporarily) at the mercy of the AI capabilities.

We ran into a bug deep into the heart of this code that AI could not solve. It had to do with updating a JS value through the COM proxy while still having it live in the JS engine. Finally I had the insight to not create a new CValue object, but instead update the existing one the JS engine already had a reference to.

Another danger: Imagine your kitchen table filled with a pile of paperwork covering every inch, several feet high. AI can instantly generate massive blobs of text where you have no idea what’s inside there. It’s overwhelming. It made lots of decisions you will never know about. It’s essentially a black box. You may grow familiar with it as you make additions. In the beginning it’s just a blob, but its got electrolytes. Depending on your use case this can be very dangerous.

Danger #3: there were things that it totally skipped or used placeholder stubs for that I only found much later. For example it decided to not implement any of the compound assignment or increment operators other than += and ++.

I only found this out once I started actually using the engine and had a for loop trigger an endless loop as the implementation did nothing. You will have no warning things like this don’t exist! You can only find them through testing.

Overall it was a very rewarding process. I now have the JS engine I have always wanted. This was a 20-year pain point for me. Finally relief!

Some other posts that may be of interest:

This post is brought to you by Carl's junior




Comments: (3)

On 01.19.26 - 4:58pm Dave wrote:
Next goal post a drag and drop form designer w/ event sinks? VB7 with a js heart???

On 01.21.26 - 7:31am Dave wrote:


So in review:
  • it can kick out amazing complex code that works
  • it can do it ridiculiously fast
  • it can be an absolute time bomb sitting there and you will have no idea
  • the bigger the project the more dangerous
  • prompting skill and expertise in the subject matter are both absolutely required
  • some bugs it cant fix on its own
  • it will try to take shortcuts and doing stupid things - its on you to see it and stop it
I dont really have the same pride or accomplishment in the generated code. Its not mine. I kind of take it for granted. Its great I have a new toy but its almost like using someone elses library i pulled into my project.

I can feel myself getting lazy already. Its so much easier to have AI kick out a function for me rather than think or type it out myself. Even if its just an initial AI scaffold i refine later.

I am mixed on it. On one hand i dont want to go back to hand coding every little thing. On the other I dunno bleh. Im not sure you can afford not to use it time wise, and good enough wise.

Do we really benifit from operating at this non-human pace? Because the technical debt is going to snow ball in insane ways and few people will have the skills or discipline to create critical infarastructure project that are safe in this manner.

Unwise management will try to compress dev cycles and use lesser trained employees to do more. It will kinda work..until it doesnt. Then they will have to hire the grey beards they fired to come back in as consultants for twice the rate to fix it.

On 01.22.26 - 8:44am Dave wrote:
heres another undersold danger..foresight and innovation requires deep domain knowledge.

If you are working beyond your core with AI, you might be able to pull it off, but you did not develop the domain knowledge.

the 2nd order consequence beyond not having foresight for the current task, is that you will never be able to reach that next level of insight either.

If you study teh code and become the expert AI helps you to be, only then could you understand what the next level of insight may be and progress.

In this manner it may lead to stagnation and strangulation of insight.

 
Leave Comment:
Name:
Email: (not shown)
Message: (Required)
Math Question: 35 + 39 = ? followed by the letter: Q 



About Me
More Blogs
Main Site
Posts: (year)
2026 (1)
     Quick post on AI coding
2025 (6)
     js4vb vtComObj
     Vb6 CallByNameEx
     js4vb
     COM dynamic proxy
     go get lost
     Courier Regular Win11 Missing
2024 (3)
     VB6 JSON
     ffmpeg voodoo
     RegJump Vb
2023 (9)
     VB6 Virtual Files
     File handles across dlls
     python abort / script timeout
     py4vb
     VB6 Python embed w/debugger
     python embedding
     VB6 IDE Enhancements
     No Sleep
     A2W no ATL
2022 (4)
     More VB6 - C data passing
     Vb6 Asm listing
     Byte Array C to VB6
     Planet Source Code DVDs
2021 (2)
     Obscure VB
     VB6 IDE SP6
2020 (4)
     NTFileSize
     BSTR from C Dll to VB
     Cpp Memory Manipulation
     ActiveX Binary Compatability
2019 (5)
     Console tricks
     FireFox temp dir
     OCX License
     Extract substring
     VB6 Console Apps
2018 (6)
     VB6 UDTs
     VB6 Debugger View As Hex tooltips
     VB6 - C Share registry data
     VB6 Addin Missing Menus
     VB6 Class Init Params
     VB6 isIn function
2017 (6)
     Python and VB6
     Python pros and cons
     download web Dir
     vc rand in python
     VB6 Language Enhancement
     Register .NET as COM
2016 (22)
     VB6 CDECL
     UDT Tricks pt2
     Remote Data Extraction
     Collection Extender
     VB6 FindResource
     CDO.Message
     DirList Single Click
     Reset CheckPoint VPN Policy
     VB6 BSTR Oddities Explained
     SafeArrays in C
     BSTR and Variant in C++
     Property let optional args
     Misc Libs
     Enum Named Pipes
     Vb6 Collection in C++
     VB6 Overloaded Methods
     EXPORT FUNCDNAME Warning
     VB6 Syncronous Socket
     Simple IPC
     VB6 Auto Resize Form Elements
     Mach3 Automation
     Exit For in While
2015 (15)
     C# self register ocx
     VB6 Class Method Pointers
     Duktape Debug Protocol
     QtScript 4 VB
     Vb6 Named Args
     vb6 Addin Part 2
     VB6 Addin vrs Toolbars
     OpenFile Dialog MultiSelect
     Duktape Example
     DukTape JS
     VB6 Unsigned
     .Net version
     TitleBar Height
     .NET again
     VB6 Self Register OCXs
2014 (25)
     Query Last 12 Mos
     Progid from Interface ID
     VB6 to C Array Examples
     Human Readable Variant Type
     ScriptBasic COM Integration
     CodeView Addin
     ScriptBasic - Part 2
     Script Env
     MSCOMCTL Win7 Error
     printf override
     History Combo
     Disable IE
     API Hooking in VB6
     Addin Hook Events
     FastBuild Addin
     VB6 MemoryWindow
     Link C Obj Files into VB6
     Vb6 Standard Dlls
     CStr for Pascal
     Lazarus Review
     asprintf for VS
     VB6 GlobalMultiUse
     Scintilla in VB6
     Dynamic Highlight
     WinVerifyTrust, CryptMsgGetParam VB6
2013 (4)
     MS GLEE Graphing
     printf for VB6
     C# App Config
     Tero DES C# Test
2012 (10)
     VC 2008 Bit Fields
     Speed trap
     C# Db Class Generator
     VB6 vrs .NET (again)
     FireFox Whois Extension
     git and vb6
     Code Additions
     Compiled date to string
     C# ListView Sorter
     VB6 Wish List
2011 (7)
     C# Process Injection
     CAPTCHA Bots
     C# PE Offset Calculator
     VB6 Async Download
     Show Desktop
     coding philosophy
     Code release
2010 (11)
     Dll Not Found in IDE
     Advanced MSScript Control
     random tip
     Clipart / Vector Art
     VB6 Callback from C#
     Binary data from VB6 to C#
     CSharp and MsScriptControl
     HexDumper functions
     Js Beautify From VB6 or C#
     vb6 FormPos
     Inline Asm w VB6
2009 (3)
     The .NET Fiasco
     One rub on computers
     Universal extractor