Re: js4vb Javascript Engine w/Debugger and COM
In fact, I suggest that you open source every version, which is better.
Maybe it can be extended to become a node. JS VB version implementation, which supports web sockets and cookies. Session login session management, which becomes a web page background like PHP. Dynamic script
The initial version was smaller and had less code.
Sometimes some people need it. The fewer functions, the better, which is the core function.
Like twinbasic, alas, every day a version is all open. github
Re: js4vb Javascript Engine w/Debugger and COM
If you have time, you can also implement a VB script parser.
Maybe in the project code.When programming, try to make the parts with the same function into a different module..
Your project may go from 6 modules to 30 modules.If there are no duplicate API declarations, you can just merge them into a final module.There is no way to merge this class file.
Each separate set of functions is divided into separate source code files.The main thing is to make it easier for ai to fix it with a smaller context, or to add some functionality.
Otherwise, one module exceeds 30kb. A few thousand lines of code for ai to fix, ah, wastes more money and more time.
I once looked at one person's implementation of the Epe compiler.Just like entering some simple VB6 code, you can generate exe directly. You can parse expressions and make calls to the windowss API.Through the API to create windows, controls, thus achieving a complete window program. Each line of code can then be debugged and compiled into an exe.
Re: js4vb Javascript Engine w/Debugger and COM
For example, if we want to execute VB. Net code on Linux, we need to install a net. It takes 200 megabytes to run.
Vb6 code or VBS is the most difficult thing to execute on Linux.
The three most mature options are. Powershell, VB. Net, Python () can this also execute VB code?
Also gamebas IDE () like VBS
This is an open source project.
YABASIC source code, vc6.0 engineering, classic source code
You have a lot of experience in this area. How to use VB6 itself to implement a basic parser, it should be simpler.
There are a small number of basic parsers implemented in VC + + or other languages. . If you compile it into a DLL, you can also play its role.
But most of us can't modify its source code or add new functions.
It may take months or years.
And you complete a script engine parser in a few days.
Re: js4vb Javascript Engine w/Debugger and COM
One nuance i just noticed, but I am actually ok with...the engine is not case sensitive, so myVal and myval are the same.. just be aware!
also no function aliasing yet. print(typeof alert) //undefined so test = alert doesnt work..
Im actually ok with that too but may need to add it later for compatibility.
Re: js4vb Javascript Engine w/Debugger and COM
im considering adding something like the following...
Code:
engine.extend(myComObj, "jsFunc", function() {return 1})
it could be useful occasionally to extend COM objects and add js only functions onto them like helper methods or things that are intrinsically easier to do in js, but you want still attached to your main COM object. It actually should be fairly easy to do.
I am consider this because the 64 bit number support in vb is still a bit of a chore and some things are easier done on the js side.
thoughts?
Re: js4vb Javascript Engine w/Debugger and COM
so...it worked. You can do it from JS or from the vb6 host side. you can also override COM methods with it.
https://github.com/dzzie/js4vb/commi...0e128e943ed011
Code:
var wsh = new ActiveXObject("WScript.Shell");
// Add a JS helper that uses the actual COM method
wsh.safeExpandEnv = function(varName) {
var result = this.ExpandEnvironmentStrings("%" + varName + "%");
if (result === "%" + varName + "%") {
return "(undefined)"; // Variable doesn't exist
}
return result;
};
console.log(wsh.safeExpandEnv("PATH")); // Returns expanded path or "(undefined)"
form.taco('dude')
or from the host side:
Code:
intrep.AddCOMObject "form", Me
intrep.AttachCOMHelper "form", "taco", "function(cmd){print('its tuesday ' + cmd + '!');}"
and a bonus ability to still call the original COM method even if you overrode it with a js function
https://github.com/dzzie/js4vb/commi...d0cdea34b69d98
Code:
wsh.Run = function(cmd) {
console.log("[LOG] " + cmd);
return this._Run(cmd, 1, true); // Calls original COM Run
};
wsh.Run("C:\\Windows\\SysWOW64\\notepad.exe")
fancy...
Re: js4vb Javascript Engine w/Debugger and COM
It looks very interesting.
I'll work on it.
Good job.
Re: js4vb Javascript Engine w/Debugger and COM
heres a brief discussion on it. its really kind of a parlor trick but was a great addition.
https://sandsprite.com/blogs/index.php?uid=11&pid=583
In other news, I also started playing with a way to forward events to the scripts. It works for vb6 classes and ocx controls, but not for intrinsic vb6 form controls like buttons or textboxes. There would be a way to force it, but Im not getting into it.
It would be kind of amusing to make a form engine and designer so js scripts could popup a windows form and receive events. Its a super bloated feature though for my needs just day dreaming...
https://github.com/dzzie/js4vb/commi...79980aaa74e2c1
Re: js4vb Javascript Engine w/Debugger and COM
so...i have a crazy idea thats kind of fun..i asked claude.ai if he could design a visual from editor like the vb6 ide we all know and love, he kicked out some stuff which i havent tested yet but will be working on.
imagine if we can wire this js engine up to a forms engine with drag and drop form creator with events support.
kind like vb7 but with js syntax, full com support no need for windows api access, just write an activex dll
we can include a basic set of classes in it like a flat fso model and maybe easy curl access.
like autoit with forms. or node with full desktop access and forms.
it would be single thread and interpreted, and specifically built for common end user rad tasks not enterprise software or trying to do everything,
just for standard pc users. what was vb6 strongest suit.
just a fun twist on an old thought...
Re: js4vb Javascript Engine w/Debugger and COM
I like how the slop piles up :-))
Btw, wondering how can this perform reasonably if everything is a giant CValue in current implementation?
Code:
Public vType As ValueType
Public numVal As Double
Public strVal As String
Public boolVal As Boolean
Public objVal As Object
Public int64Val As Currency
Public arrayVal As Collection
Public objectProps As Collection
Public objectKeys As Collection
cheers,
</wqw>
Re: js4vb Javascript Engine w/Debugger and COM
the slop is a piling!
dunno, dont care, just playing :)
python guts are abhorrant, i have zero shame
basically i needed this engine for my own scripting tool with specific needs thats been evolving for like 20 yrs.
ive always been curious about how to write a drag drop form designer.
no mistakes, failed and dirty experiments are fine
might as well toss them all into a bowl and see what we get. I am in the fa2fo phase lol
ironically even at peak slop 0 fore thought levels we would be smaller and tighter than python and .net
Re: js4vb Javascript Engine w/Debugger and COM
What a coincidence, I'm also working in js4vb, he wants to connect.
With my node system or workflow.
It's still very early, but a lot of the behind-the-scenes work is done.
As always, delighted to see your work.
https://imgur.com/a/IqLIgsy
Attachment 195635
Best regards
Re: js4vb Javascript Engine w/Debugger and COM
very neat reminds me of a plc programming model i saw once. :)
Re: js4vb Javascript Engine w/Debugger and COM
Another thing I was wondering is if it's feasable for LLMs to translate C codebase (like Micro QuickJS) to VB6?
Obviously there are language features not available in VB6 so a lot of "creativity" has to be used to achieve this.
cheers,
</wqw>
Re: js4vb Javascript Engine w/Debugger and COM
that would be an interesting experiment to try. Id probably start the test with some largish C function without bit shifting and see where how its base translations hold up.
With a multifile source, you would have to get most or all of it into the context at once. or at least the relevant parts for conversion run X.
context length limits are the tricky part. If it doesnt have a function in context, it will silently make assumptions about what it does and how it operates without asking.
This can probable be overcome with strict prompting.
Building this project, and the sci4vb project it was helpful that it was building from scratch and had a large corpus of similar projects. It knew the design patterns
and its own inclinations and guesses about how previous contexts had done things played over. I caught it guessing, but its guessed names were very close to what had
actually used in the previous context.
Switching contexts was a little tricky, I had to reload it to give it a snapshot, but i couldnt overload or refill it or the usable context window would get very short. In the classview addin i added a right click feature to copy all public prototypes for all files in a project. This way i could stuff all of the class interfaces, public methods, and properties into the context in a condensed format without implementation bulk.
pointers and string parsing nuances would probably the thing to check for the conversion. It would be worth a shot, bug generation could be intractable.
I think it could kick out massive boiler plate to wrap a C library functions quickly. Claude was not rock solid on vb declare mechanics / C data passing. It would need specific rules in a strict prompt to help it out and guide it away from some of its tendencies. Ironically it did amazing at knowing the COM interface rules and passing data through COM methods. It also had a quirk always trying to Dim as new in a loop and expecting a new object each time vrs set x = new, had lots of bugs there. I think the weaknesses could be fixed through proper preemptive prompting.
I have been thinking about writing a doc on what i found so far about how to work across context limits and what tools I developed as I went to make it easier to integrate with. Like the classview addin i also added right click options to replace the entire source file (with unix to dos built in) or to replace specific functions from clipboard (with unix to dos) or goto line number. Since the vb6 iDE isnt integrated with AI tools directly its meat bag relay the whole way. Also you will see very heavy debug out messages in teh code so i can paste runlogs into the ai and it can see whats happening for hairy bugs.
Its very interesting what its capable of pumping out and mapping its strengths/weaknesses.
Re: js4vb Javascript Engine w/Debugger and COM
I would probably start with a hand written AGENTS.md which explains what to use and what not to use in VB6. Something like a crash course on VB6 and/or coding conventions like generating and using FUNC_NAME and MODULE_NAME consts etc.
It might be helpful to first let LLM generate GUIDLINES.md which will contain an overview of the project -- list of output binaries with list of classes and with functions and/or some high-level strategies how to approach conversion.
cheers,
</wqw>
Re: js4vb Javascript Engine w/Debugger and COM
thats smart. Id think id also want to figure out how to break it into testable units. convert it by blocks of functionality which I could individually test heavily. of course for that you would need to understand the original design first.
probably something like helper functions, then ast parsing, then intrepreter. building with a template.
instrumentating a copy of the c source first with lots of debug output on a known input that you could compare later might be valuable.
but also i created this whole thing in like 50 hours from scratch. it knew what to do. so the question is are its translation skills faster than its raw green field creation skills.
I have no data on that.
here is claudes take on the question:
prompt: (note: its internal hour estimates are always way off on the high side)
so we implemented a js engine from scratch in vb6 in about 50 hours. Do you think that it would have been faster to get you to translate a c js engine: https://github.com/bellard/mquickjs
response:
Honestly? I don't think the translation route would have been faster, and the end result would likely have been worse. Here's my thinking:
**The C-to-VB6 translation problem is brutal:**
- QuickJS (even mquickjs) relies heavily on NaN-boxing with tagged pointers - packing type information into IEEE 754 NaN bits. Translating that to VB6's Variant system would be a complete redesign, not a translation.
- Pointer arithmetic everywhere. Every `p++` and `*ptr` needs rethinking in VB6 terms.
- The GC model (refcounting + cycle detection) would need fundamental changes for VB6's COM-based lifetime management.
**Even mquickjs is substantial** - probably 10-15k lines of dense, optimized C. I'd estimate 80-120 hours of translation work with constant back-and-forth debugging subtle issues like signed/unsigned conversions, integer overflow semantics, struct packing differences.
**The bigger issue: you'd end up debugging code you didn't write**, in a paradigm that fights VB6 at every turn. With the from-scratch approach, you understand every line and it uses VB6 idioms naturally - Variants, Collections, COM integration, the bidirectional object wrapping.
**Feature mismatch too** - QuickJS has a bytecode compiler, full ES2020 compliance, tons of stuff you don't need. What you *do* need - deep COM integration, WMI automation support, the VB6 object synchronization - isn't in QuickJS anyway.
The 50 hours got you a tailored tool. Translation would've given you a Frankenstein fighting its host language.
Re: js4vb Javascript Engine w/Debugger and COM
Sounds like it understands it’s not as simple as VB6 to C translation. Nice!
Re: js4vb Javascript Engine w/Debugger and COM
I finally got around to do a blog post on AI coding tips and tricks: https://sandsprite.com/blogs/index.p...=584&year=2026
Re: js4vb Javascript Engine w/Debugger and COM
Very good article.
Claude has been a huge help to me on huge projects.
What I don't like is that I have to repeat everything so many times.
After a while, he starts inventing functions and variables.
And I'm already getting lazy :p.
sounds interesting drag and drop form designer w/ event sinks? VB7 with a js heart.
Best regards