Announcement: VitTransform is released

Announcement: VitTransform released

Seven years in the making. VitTransform rewrites Clarion source — safely.

What It Does (Out of the Box)

Point it at your .clw and .inc files, and it automatically hunts down and fixes:

  • Unused variables
  • Dead code
  • Unread assignments
  • Missing or incorrect AUTO attributes
  • The legacy code smells every codebase collects over time

It also immediately makes your program do less work by:

  • Eliminating unnecessary clip() statements.
  • Analyzing your logic to automatically choose better alternatives.
  • Stripping out the extra work your code was doing for no reason.

The Safety Guarantee

This is the part worth reading twice. VitTransform respects your code:

  • Your comments stay.
  • Your blank lines stay.
  • Your indentation stays exactly as you wrote it, unless you explicitly want it changed.
  • It never deletes dead code. It comments it out and tells you why, so you make the final call.
  • If it can’t prove a change is safe, it does nothing at all.

Opt-In Performance Tuning

What it won’t do without your permission is rewrite code purely for speed at the expense of readability. That is one switch away.

Flagging --style=optimised:

  • Stops your program from building a whole copy of a string just to compare it and throw it away.
  • Turns single-character searches into lightning-fast byte searches.

It’s faster, but perhaps harder for some to read—which is precisely why that is your decision, not ours.

Fully Customizable Rules

VitTransform ships with two ready-to-use rule sets, but the real power is under the hood: the rules are just a text file.

  • Every transform is data, not compiled-in behavior.
  • If you find a pattern your codebase repeats a thousand times that isn’t in the shipped rules, you can add a new rule and fix all thousand in one go.
  • No Clarion code required.

What’s Included

Two programs ship together to give you complete control:

  • VitStyle: A visual UI. Tick the transforms you want, watch a live before-and-after preview, and save it as a profile.
  • Command-Line Tool: Replay your saved profile automatically across your entire project.

Both come as ready-to-run EXEs, plus full source code.

Note on Compiling: You can run the EXEs immediately out of the box. If you choose to compile it yourself, you will need Capesoft’s StringTheory, which powers VitTransform’s string handling under the hood.

By Geoff Robinson. Free of charge. MIT licensed. Source and releases on GitHub:
GitHub - Geoff-Robinson/VitTransform: A general-purpose, rule-driven source-to-source transformer for Clarion. · GitHub

Is that the only thing it does?

It sounds good.

no it does heaps more but I didn’t want to reproduce what the readme is for :grinning_face:

so have a look at the readme on the github page - or fork it or download etc.

thanks - have a good look as there are lots of options. You can use it simply or get as deep "down into the weeds"as you like - eg. write your own transformation rules rather than just use the provided ones.

Have a look at VitRules.txt to see the current main rules file.

Also have a look at the FAQ for some quick answers to (guessed) common questions.

cheers
Geoff R

Small point

--group=cosmetic-keywordcase-title

Wouldnt the word Capitalise be a better word to use?
Title makes it seem like a title eg Mr, Mrs, Miss, Ms…

Is there an option to make some keywords Upper and some Capitalise?

I tend to upper some small keywords like IF, OR, AND, ELSE, CASE, OF, OROF just to make them stand out and capitalise the rest of the keywords.

I have used AI to add new features and search for and fix bugs etc. I started with Gemini but ended up deciding Claude was the better choice (for me at least - YMMV)

I get too many hallucinations with any Ai on my template builder. This is where the poor documentation keeps Ai out…

Just to clarify…
B.2 Overloaded methods

To be clear, its just counting the number of parameters detected and not looking at the data type?

The return type belongs to the overload, not to the name, so VitTransform picks the overload by the number of arguments at the call site.

So this would fail…

JoinToks Procedure(LONG p1, LONG p2, String p3),Byte
JoinToks Procedure(*Cstring p1, LONG p2, String p3),Byte

Sounds brilliant Geoff :smiley:

I have an app I’d love to try it on but I have the feeling there would be nothing left! :rofl:

Have you used it on any of the Clarion example apps?

EDIT: I’ve just had a quick read through the Read.me Geoff, this is obviously a major work, congratulations on the quality of the documentation.

Maybe - but perhaps Capitalise could be interpreted as all caps - as in UPPERCASE. Although Clarion programmers would be familiar with it from its use elsewhere in the language. I’ll consider it as an alternative rather than a replacement - I know other people use “Pascal case” or “Heading case” or some such. I have already put one alternative spelling in for our US friends - optimise can be mispelt “optimize” and still work.

no not at the moment - but I can take it on notice for a future version - but I have my hands full right now with some fixes so it probably won’t be in the next version.

I think Claude has improved a lot over, say, the last 6 months so it might be worth re-trying with Opus 5 or whatever the latest model is.

reading a little further: Where the count alone cannot decide - two forms that both accept it and disagree about the return type - the argument types break the tie. But your example has the same return type so I would need to check as it may refuse to transform (which is its fallback safe option when it is unsure - a bit like The Hippocratic Oath).

ha ha - I am sure that would not be the case

no not yet - please feel free to try but maybe hold fire for the next version - @Mark_Sarson has kindly done a thorough review and sent me a list of fixes he (and I think Claude or another AI) came up with which I am working through methodically and testing/merging now - so hopefully a new improved version will be out today or in the next day or two.

Thanks Geoff - I would like to take the credit but in fact the docs are largely Claude’s work! I mentioned to Richard that AI has come a long way very quickly recently so it will be interesting to see where it is next year (and beyond). I am being very polite with the AI even when it makes stupid errors just in case it holds a grudge :grinning_face:

OK just a heads up that Version 1.0.2 is now released incorporating 28 fixes from @Mark_Sarson

Thanks Mark - greatly apprecieated :clap:

see:

Could it handle code like this?

                                                 COMPILE('****',_C110_)
SomeVariable LONG
                                                 '****'
                                                  OMIT('****',_C110_)
SomeVariable SHORT
                                                 '****'

Taken from this Thread

Well it can handle compile/omit if that’s the question.

Please just try it and see how you go. And report if you have problems.

I’ll have a look at your requests including Capitalise instead of Title in an upcoming release.

Cheers

Geoff R

I havent got time ATM. I still havent looked at your RegEx class.

OK just a heads up that VitTransform Version 1.0.3 is now released with extra fixes of things Claude found and a couple of minor edits resulting from a discussion with Carl (thanks!).

I still have more work to do on the alignment of comments which is still not 100% but is getting better - and a lot of things on my to-do list. So visit regularly and always grab the latest version.