Hostages of Their Own Source Code: When Technical Debt Becomes a Business Model
How a pioneering Brazilian software company turned technological compatibility into both an engineering burden and a commercial advantage.
There is a peculiar irony in the software industry: sometimes, the architectural decisions that make a product difficult to modernize are precisely the ones that make it difficult for customers to abandon.
Few companies illustrate this contradiction as well as TOTVS, formerly known as Microsiga, and its flagship ERP product, Protheus.
I had the opportunity—or, depending on the day, the misfortune—of working with Protheus in the late 2000s, during my tenure at CCAA, also known as Waldir Lima Editora.
What I encountered was a fascinating example of how decades of technological compromises can accumulate into an architecture that becomes extraordinarily difficult to escape.
But before discussing my experience, we need to understand how Microsiga got there.
A Brilliant Business Decision in 1983
In 1969, Ernesto Haberkorn founded SIGA, a Brazilian computer services company operating in an era when computers were expensive machines accessible primarily to large organizations.
By the early 1980s, a young programmer named Laércio Cosentino saw the writing on the wall: microcomputers were going to fundamentally change the business landscape.
He proposed establishing a company dedicated to developing business software for these smaller machines.
In 1983, Microsiga was born.
The name itself reflected the technological transition: SIGA for microcomputers.
It was an excellent business decision. Companies that could never afford traditional centralized computing infrastructure could suddenly purchase computers of their own and automate their operations.
Microsiga positioned itself to serve that emerging market.
Eventually, its technological foundation would include Clipper, a programming language and development environment that became enormously popular among business application developers during the 1980s.
At the time, Clipper was an entirely reasonable choice.
I certainly cannot criticize Microsiga for adopting a technology that many of us were using ourselves.
The problem was not choosing Clipper.
The problem was what happened when the rest of the industry moved on.
When Windows Changed Everything
The early 1990s were an extraordinary period in software development.
Windows was becoming the dominant desktop environment. Local networks were becoming increasingly accessible. Relational database engines were moving beyond the exclusive domain of large corporations.
Microsoft introduced Visual Basic in 1991. Visual Basic 3 arrived in 1993, followed by Visual Basic 4 in 1995, supporting both 16-bit and 32-bit application development.
Borland introduced Delphi that same year.
Computer Associates, which had acquired Nantucket, the developer of Clipper, attempted to bring its existing developer community into the Windows ecosystem through Visual Objects.
Those of us who remember Visual Objects will understand why that particular migration path was not especially attractive.
Microsiga, however, chose a different path.
Rather than migrating its applications to an established Windows development ecosystem, it decided to build much of its own.
According to TOTVS’s corporate history, the company spent seven years developing ADVPL—Advanced Protheus Language—which it officially launched in 1999.
From a commercial perspective, I can understand the appeal.
Microsiga wanted to preserve its existing software, its accumulated business knowledge, its customers’ customizations, and its developers’ expertise. It also wanted greater independence from external development platform vendors.
Those were legitimate concerns.
But seven years is an extraordinary amount of time to spend developing a technological ecosystem merely to avoid migrating away from another one.
By the time ADVPL was officially launched, Microsoft had already released Visual Basic 6, Borland had released Delphi 4, and the software industry was well into the client-server era.
Microsiga had committed itself to maintaining not only an ERP but also the technological universe in which that ERP could continue to exist.
The Road Not Taken
Imagine an alternative history.
Microsiga begins migrating its applications to Visual Basic 3 in 1993. Existing Clipper applications continue operating while new modules are developed for Windows.
Carefully avoiding excessive dependence on third-party VBX components, the company transitions to Visual Basic 4 and 32-bit applications in 1995.
By 1998, it is developing with Visual Basic 6, ADO, COM components, and increasingly sophisticated relational database technologies.
Then comes .NET in 2002.
Granted, the transition from VB6 to VB.NET was not painless. Those of us who experienced it firsthand remember that perfectly well.
But migration tools, COM interoperability, compatibility libraries, and incremental replacement strategies provided viable transition paths.
It was considerably less painful than rewriting everything from scratch.
Microsiga would have faced difficult engineering decisions at every stage. No technological ecosystem guarantees effortless modernization.
However, Microsoft would have been responsible for developing and maintaining the compiler, runtime, development environment, debugging tools, and much of the database connectivity infrastructure.
Microsiga could have concentrated its resources on what its customers were actually paying it for: enterprise management software.
There is also an important chronological consideration.
By the late 1990s, Microsiga had thousands of customers, many with customized installations and routines. Abandoning compatibility at that point would have been enormously disruptive.
But Microsiga was not nearly as large when it began developing ADVPL in the early 1990s.
It may well have spent seven years creating the very circumstances that made abandoning its proprietary ecosystem economically impractical.
Would the alternative history necessarily have produced a better commercial outcome? We cannot know.
But it would have distributed the technological burden very differently.
There is a fundamental distinction between preserving business knowledge and preserving the source code in which that knowledge happens to be expressed.
Microsiga appears to have placed enormous strategic importance on the latter.
SQL Server: The World’s Most Expensive DBF Engine
For readers unfamiliar with Clipper, a brief technical explanation is necessary.
Clipper inherited its database access paradigm from dBASE and the broader xBase ecosystem.
A database was essentially a collection of records stored in files, commonly using the DBF format. The programmer navigated those records using commands such as:
GO TOPGO BOTTOMSEEKSKIPGOTO
Processing records sequentially was a perfectly ordinary programming technique.
A simplified Clipper-style routine might look like this:
GO TOP
DO WHILE !EOF()
nTotal := nTotal + FIELD->VALUE
SKIP
ENDDOThis made sense when accessing indexed files directly.
Relational databases, however, offered an entirely different paradigm.
Instead of retrieving individual records and processing them one at a time, developers could express operations over entire sets of data:
SELECT SUM(VALUE)
FROM Records;The database engine could determine an efficient execution strategy, process the records internally, and return the result.
Microsiga eventually needed its Clipper-derived applications to work with these modern relational database engines.
Its solution was a compatibility layer.
Known in the Protheus ecosystem as TOPConnect, and subsequently DBAccess, this technology allowed the application to retain its traditional record-oriented database access model while using relational databases underneath.
I remember researching the origins of that compatibility technology during my time at CCAA.
As I recall, the underlying technology originated as a personal project developed by an independent programmer. Microsiga licensed technology from an external developer and subsequently adapted it to its own purposes.
I distinctly remember finding the website of a developer who explicitly warned that his original implementation was incompatible with Microsiga’s modified version.
Unfortunately, nearly two decades later, I cannot remember his name or the original product’s name, and I have been unable to independently reconstruct that part of the story.
Nevertheless, if my recollection is accurate, the original developer deserves considerable credit. Making existing Clipper applications communicate with relational databases without requiring their source code to be rewritten was an ingenious engineering accomplishment.
The questionable decision was treating that compatibility mechanism as a long-term architectural foundation rather than a transitional technology.
What I can describe with considerably greater certainty is what I personally observed when I attached a SQL Server analyzer to our Protheus database.
Every time the application executed a SKIP operation, I saw another SQL query.
Yes.
Another SQL query.
Consider what happens when an application needs to process 100,000 records using a conventional Clipper loop.
Instead of submitting a single SQL statement and allowing the database engine to process the records internally, the application can end up generating approximately 100,000 separate database requests.
Each request introduces potential overhead associated with network communication, query execution, result processing, and record-pointer management.
Even assuming an overhead of only two milliseconds per operation, that represents more than three minutes spent merely navigating records.
Before performing any meaningful business logic.
The application was navigating a relational database as though it were navigating a DBF file.
Microsiga had acquired access to the capabilities of a modern relational database engine while retaining a programming paradigm that prevented many of those capabilities from being fully exploited.
They had effectively turned SQL Server into the world’s most expensive floppy disk drive.
The Thirty-Minute Invoice
This brings me to my experience at CCAA.
The company generated between five and seven thousand invoices per day using an internally developed system. Those invoices needed to be imported into Protheus.
An implementation consultant was working on-site to develop the integration using ADVPL.
He eventually produced something that worked.
It took approximately thirty minutes to import one invoice.
One.
And his implementation dealt primarily with the happy path. Unusual invoice configurations and edge cases were another matter entirely.
Let us examine the numbers.
At thirty minutes per invoice, importing five thousand invoices sequentially would take approximately 104 days of uninterrupted processing.
Unfortunately, CCAA generated those five thousand invoices every day.
This was not merely a performance problem.
It was a failure to satisfy the most elementary operational requirement of the integration.
The first question the consultant should have asked, before writing a single line of ADVPL, was how many invoices the company generated per day.
A program capable of processing only 48 invoices in 24 hours was never going to satisfy that requirement.
Eventually, I reached the limits of my patience.
I knocked on the IT director’s door.
“Boss, I can’t take it anymore. Let me do something.”
“Fine. Go for it.”
Finally.
Reverse Engineering by Actually Doing Engineering
I collected a substantial pile of invoices, deliberately selecting as many different configurations and edge cases as possible.
Then I identified the Protheus database tables involved in invoice processing and installed triggers to record modifications to them.
Over the following days, I manually entered the invoices into Protheus.
One by one.
Different invoice types. Different configurations. Different circumstances.
I wanted Protheus itself to demonstrate what it did when presented with each situation.
Once I had collected enough data, I examined the logs and reconstructed the relationships between the invoice characteristics and the database operations performed by the application.
Only then did I start developing the importer.
I wrote it in C#.
The program reproduced the database effects I had observed, bypassing the record-navigation abstraction.
The result?
Five thousand invoices were imported in approximately ten minutes.
| Metric | Consultant’s implementation | My implementation |
|---|---|---|
| Average time per invoice | 30 minutes | 120 milliseconds |
| Invoices per minute | 0.033 | 500 |
| Time for 5,000 invoices | 104 days | 10 minutes |
| Time for 7,000 invoices | 146 days | 14 minutes |
A performance improvement of approximately 15,000 times, based on the reported processing times.
The numbers for seven thousand invoices are extrapolated, but the five-thousand-invoice result was what I observed.
I am not claiming that C# is inherently 15,000 times faster than ADVPL. Nor am I claiming that direct database manipulation is universally appropriate for ERP integrations.
The difference was architectural.
I was able to investigate the actual business behavior of the existing system and develop an implementation designed around the underlying database rather than its legacy navigation abstraction.
The consultant was operating within an ecosystem that carried decades of technological baggage.
And CCAA was paying for that baggage.
The Archaeology of Enterprise Software
Our service-level agreement with TOTVS granted us certain privileges, including access to portions of the application’s source code.
I remember opening some of that code and groaning.
The creation date of one function?
Now, there is nothing inherently wrong with a function written in 1988 still operating correctly decades later.
In fact, in my previous article about finished software, I argued that a system capable of delivering business value for decades with minimal intervention should be regarded as an engineering success.
The problem is not old code.
The problem is old architectural limitations that continue to dictate how new code must be written.
And the source code came with its own peculiarities.
Anyone who has worked with programming languages of that era probably remembers the decorative comment blocks that developers occasionally inserted into their programs.
I was guilty of that myself, although I would argue that my offenses were misdemeanors.
In the Protheus development environment, however, the IDE itself encouraged the practice.
Selecting the menu option to add a function prompted the developer for its name, author, and other information, generating something resembling this:
******************************************************************
******************************************************************
******************************************************************
******************************************************************
***************
*************** Program: XPTO
***************
*************** Author: Jeff
***************
*************** Creation Date: 1988
***************
******************************************************************
******************************************************************
******************************************************************
******************************************************************A veritable geological formation of asterisks.
Microsiga had industrialized the production of decorative comments.
At least the asterisks were backwards compatible.
Why Does My Publishing Company Need a Tire Manufacturer’s DLL?
Another particularly memorable experience was watching consultants install Protheus updates.
As files were copied to our servers, I would notice filenames such as:
Pirelli.dll
Bradesco.dllCCAA was a language-school franchiser and publishing company.
We did not manufacture tires.
We were not a bank.
Unless management was planning a rather ambitious diversification strategy between English lessons, I could not imagine why libraries bearing those names needed to be anywhere near our servers.
I never inspected those libraries sufficiently to establish exactly what they contained. They could have represented customer-specific customizations, integrations, shared functionality, or something else entirely.
Nevertheless, their presence struck me as a rather peculiar deployment practice.
If these were indeed unrelated customer customizations, it would suggest a release process in which the accumulated requirements of multiple customers were distributed beyond the environments that actually needed them.
That is another form of complexity: distributing software because it exists, rather than because the recipient requires it.
And this was happening long before Kubernetes, microservices, cloud-native architecture, and Agile transformations became fashionable.
The software industry has always been quite capable of manufacturing its own complexity.
Nearly Two Decades Later
I have not worked directly with Protheus since that period, and it would be intellectually dishonest to assume that everything I observed then remains unchanged today.
So I looked at TOTVS’s more recent technical documentation.
In January 2025, TOTVS published a support article describing TLPP—TOTVS Language Plus Plus—an evolution of ADVPL.
Among the improvements highlighted were:
Long variable and function names.
Explicit data typing.
Namespaces.
Improved organization of source code.
Yes.
Long variable and function names.
To appreciate the historical significance—and absurdity—of that particular improvement, younger programmers need a brief lesson in software archaeology.
The Ghost of the DOS Filename
Clipper originally emerged as a compiler for the dBASE programming language.
In the original dBASE environment, programs were interpreted from .PRG files. These files contained sequences of commands that could execute other program files using the DO command.
For example:
DO INVOICE
DO CUSTOMER
DO TAXCALCThese commands could invoke files such as:
INVOICE.PRG
CUSTOMER.PRG
TAXCALC.PRGThose programs lived on DOS filesystems, which imposed the notorious 8.3 filename convention: eight characters for the filename and three for the extension.
For younger readers, imagine trying to organize an entire enterprise application when a source filename could not exceed eight characters.
Names such as:
CustomerInvoiceValidation.prgWere out of the question.
Something resembling this would have to suffice:
CSTINVLD.PRGThose of us who developed software during that period became rather proficient at inventing abbreviations that made perfect sense to us on the day we wrote them and considerably less sense to us six months later.
Clipper inherited another characteristic of the xBase ecosystem: only the first ten characters of certain identifiers, including variable names and traditional function names, were significant.
The eight-character DOS filename restriction and the ten-character identifier restriction were distinct technical limitations, although both belonged to a programming environment in which brevity was often a necessity rather than a stylistic preference.
Consider these two variable names:
nInvoiceTotalGross
nInvoiceTotalNetTo a modern programmer, these are obviously two different variables.
But in a context where only the first ten characters are significant, both resolve to the same identifier:
nInvoiceToCongratulations.
Your gross and net invoice totals now collide.
The programmer must instead invent names that differ within the significant portion of the identifier:
nGrossTot
nNetTotThis limitation was understandable in the technological environment of the 1980s.
Memory was expensive. Storage was limited. Development tools operated under constraints that would seem almost comical today. Compatibility with existing dBASE applications was an important commercial consideration.
What is considerably more difficult to justify is carrying such a limitation into an enterprise programming environment in the twenty-first century.
Four Decades of Backward Compatibility
According to TOTVS’s own technical support documentation, ADVPL permits programmers to declare memory variables with names longer than ten characters, but considers only the first ten characters when locating their stored values.
This is not merely a stylistic convention inherited from older programmers.
It is a language limitation.
Consider the implications for developers attempting to write self-documenting code.
Modern programming practices encourage descriptive variable names. A programmer should be able to understand the purpose of an identifier without consulting a separate document or deciphering an obscure abbreviation.
Yet in ADVPL, developers must remain conscious of whether two otherwise perfectly descriptive names share the same first ten characters.
The situation becomes particularly entertaining when we remember that Visual Basic 6, released in 1998, supported identifiers of up to 255 characters.
More than two decades later, TOTVS was still documenting restrictions inherited from the xBase ecosystem.
And now, with TLPP, developers are being offered the revolutionary capability of giving their variables and functions meaningful names without worrying about those historical identifier collisions.
Explicit typing.
Namespaces.
Long variable names.
Features that programmers working with mainstream development environments have taken for granted for decades.
To be clear, the publication date of a support article does not establish when these features were first introduced. TOTVS documentation discusses TLPP capabilities as early as 2023, and the language itself predates those articles.
The point is not that TOTVS necessarily invented namespaces in 2025.
The point is that eliminating these legacy limitations remains a sufficiently important distinction between ADVPL and its successor that TOTVS continues to document it.
Those of us who spent the 1990s moving away from such restrictions can perhaps be forgiven for finding this somewhat surreal.
Modernization Without Escape
An official TOTVS support article from August 2023 explains how ADVPL can invoke TLPP functions through namespaces, thereby accessing functionality with longer identifiers.
However, within the ADVPL environment, its original identifier-length restrictions continue to apply.
The old world and the new world must coexist.
Even more revealingly, TOTVS support documentation also addresses a limitation involving source files with identical filenames stored in different directory paths.
ADVPL and TLPP compilation cannot distinguish such files solely through their directory paths. The documentation explains that changing this behavior would interfere with other functionality dependent upon it.
Think about that for a moment.
A modern enterprise software vendor cannot readily change how its development ecosystem identifies source files because other parts of that ecosystem depend on the existing behavior.
The problem is no longer simply that a particular piece of code is old.
The problem is that other pieces of code have been constructed around its limitations, and still other pieces of code have been constructed around those.
Remove one limitation, and you risk destabilizing everything that has come to depend upon it.
Every generation of development inherits the architectural compromises of the previous generation.
And every new compatibility mechanism potentially creates another obligation for the generation that follows.
TOTVS has modernized its platform. It supports newer programming capabilities and continues to evolve its technology.
What I cannot establish from public documentation is whether the particular SQL navigation behavior I observed nearly two decades ago persists in current releases.
Nevertheless, the broader strategy remains recognizable: modernization through successive extensions of a proprietary ecosystem while preserving compatibility with its predecessors.
The technological limitations of the 1980s have become the compatibility requirements of the 2020s.
The ghost of Clipper has not entirely left the building.
The Best Salespeople in the Business
Now comes the part where I must give Microsiga—and subsequently TOTVS—considerable credit.
Their salespeople are exceptionally good.
That is not sarcasm.
Whatever reservations I may have about the engineering decisions behind Protheus, there is no denying the commercial achievement of transforming a small Brazilian software company into a major enterprise technology vendor.
TOTVS understands the Brazilian market.
It understands Brazilian taxation, accounting practices, labor legislation, invoicing requirements, and the seemingly endless regulatory peculiarities that businesses operating in this country must accommodate.
That knowledge has enormous commercial value.
A beautifully engineered ERP that cannot correctly handle Brazilian fiscal requirements is considerably less useful to a Brazilian company than an architecturally imperfect ERP that can.
Customers do not necessarily purchase the best-engineered software.
They purchase software that satisfies their business requirements—or that they are persuaded will satisfy them.
And once that software becomes embedded in their organizations, something interesting happens.
Technical Debt as a Competitive Moat
Consider what happens after a company has been using Protheus for ten or fifteen years.
It has accumulated customizations.
Its employees have been trained.
Its consultants understand the proprietary ecosystem.
Its internal applications have been integrated with the ERP.
Its accounting procedures have adapted to the software.
Its operational processes depend on it.
Its management reports are built around it.
Replacing the ERP now involves much more than purchasing another product.
It requires migrating data, rebuilding integrations, reproducing customizations, retraining employees, validating financial processes, and managing the operational risks of changing a business-critical system.
The costs of switching can be extraordinary.
And here lies the commercial paradox.
The same proprietary architecture that makes Protheus difficult for TOTVS to modernize also contributes to making Protheus difficult for its customers to replace.
TOTVS has two forms of technological lock-in to contend with:
Its customers are tied to its proprietary ecosystem.
TOTVS is tied to the compatibility requirements of that same ecosystem.
One can generate recurring revenue.
The other generates recurring engineering obligations.
What constitutes technical debt for the engineering department can constitute a competitive moat for the commercial department.
This does not establish that Microsiga deliberately created technical debt to trap customers. Such a claim would require evidence that I do not possess.
The more interesting explanation is that a series of commercially understandable decisions produced a system in which architectural complexity and customer retention became intertwined.
No conspiracy was necessary.
The incentives emerged from the architecture itself.
When Independence Becomes Captivity
Developing a proprietary technological ecosystem can offer genuine advantages.
You control its roadmap. You are less dependent on external vendors. You can tailor your tools to your specific requirements.
But that independence comes at a cost.
Every technological transition becomes your responsibility.
Every compatibility problem becomes your responsibility.
Every limitation inherited from your previous implementation becomes your responsibility.
When mainstream development ecosystems introduce new capabilities, you must either develop comparable functionality yourself or explain why your users do not need it.
Eventually, the very technological independence you originally sought can become another form of captivity.
There is a difference between owning your technology and being owned by it.
There is a difference between preserving your intellectual property and becoming its hostage.
And there is a difference between keeping old software running because it continues delivering value and keeping an entire obsolete programming paradigm alive because abandoning it has become economically impractical.
The first is good engineering.
The second is a strategic problem.
Consider the irony of the situation.
Microsiga was founded because someone recognized that the technological foundations upon which an established computer company operated were about to become obsolete.
The company owed its very existence to someone’s willingness to abandon an established technological paradigm in favor of an emerging one.
Yet its subsequent engineering strategy revolved around preserving its own established technological paradigm as successive generations of technology emerged around it.
The revolutionary had become the establishment.
The Lesson for the Rest of Us
This is not merely an article about Microsiga or TOTVS.
It is a cautionary tale for every software company making architectural decisions today.
The decision to build a proprietary framework instead of using an established one.
The decision to develop an internal programming language.
The decision to introduce an elaborate abstraction layer rather than migrate an existing application.
The decision to preserve compatibility indefinitely.
Any of these can be justified under the appropriate circumstances.
But they must be evaluated not only according to their immediate benefits, but also according to the obligations they create for the next five, ten, or twenty years.
Compatibility layers should have exit strategies.
Proprietary abstractions should justify their lifetime maintenance costs.
Business logic should be sufficiently separated from its technological implementation to survive changes in the underlying platform.
And technical debt should not be mistaken for an asset merely because customers have become accustomed to paying for it.
Microsiga made a brilliant business decision in 1983.
It recognized an emerging technological revolution and built a company capable of exploiting it.
The question is whether its subsequent architectural decisions preserved that pioneering spirit or gradually sacrificed it in the name of compatibility.
Nearly two decades ago, I sat in front of SQL Server, watching it execute another query every time a Clipper-derived application wanted to move its record pointer.
Then I wrote a program that imported five thousand invoices in ten minutes instead of 104 days.
I did not need to develop a proprietary programming language.
I did not need to develop a compatibility layer.
I did not need to reinvent the relational database.
I merely needed to understand what the existing system was doing and allow SQL Server to do what SQL Server had been designed to do in the first place.
Sometimes, modernization does not require introducing another layer of technology.
Sometimes, it requires having the courage to remove one.
Sources and Further Reading
Corporate and historical background
TOTVS Investor Relations — History and Profile:
https://ri.totvs.com/en/the-company/history-and-profile/TOTVS Investor Relations — Histórico e Perfil:
https://ri.totvs.com/a-companhia/historico-e-perfil/Terminal de Informação — Interview with Ernesto Haberkorn, co-founder of TOTVS, March 9, 2021:
https://terminaldeinformacao.com/2021/03/09/entrevista-ernesto-haberkorn-empresario-fundador-do-erpflex-e-cofundador-totvs/
Technical documentation
CA-Clipper Language Reference — FUNCTION:
https://vivaclipper.wordpress.com/tag/function/TOTVS Technical Support — ADVPL memory variable identifier limitations:
https://centraldeatendimento.totvs.com/hc/pt-br/articles/360050378114TOTVS Technical Support — Using TLPP functions within ADVPL:
https://centraldeatendimento.totvs.com/hc/pt-br/articles/16705515938711TOTVS Technical Support — TLPP language features:
https://centraldeatendimento.totvs.com/hc/pt-br/articles/28424631692055TOTVS Technical Support — Source filename and directory limitations:
https://centraldeatendimento.totvs.com/hc/pt-br/articles/56864688925843
The account of the CCAA invoice integration, observed SQL Server behavior, source-code annotations, and update installations is based on my personal professional experience in the late 2000s. Performance comparisons are based on the processing times I recall from that period. The alternative technological trajectory presented in this article is a counterfactual engineering analysis, not a claim about what would necessarily have happened.

Comments
Post a Comment