Showing posts with label AI. Show all posts
Showing posts with label AI. Show all posts

Thursday, October 1, 2026

No code reuse anymore

Since writing software was expensive, one of the basic principles of software engineering has been to reuse code whenever possible. If someone had already implemented and debugged something, it usually made more sense to reuse it than to build it again.

Imagine inheriting a 50,000 line legacy application with poor architecture, obsolete libraries, duplicated code, and little documentation. Traditionally, you would either keep modifying the mess or undertake an expensive and risky rewrite.

With AI coding agents, there is a third option.

You can ask AI to analyze the existing software and extract its requirements, behavior, architecture, edge cases, and tests. You can then create a new specification that combines the useful behavior of the old system with new functionality and quality requirements, and have AI implement a completely new version. In other words:

Legacy code → specification → new implementation

rather than:

Legacy code → more legacy code

The valuable asset is not the millions of lines of code accumulated over the years, but the functionality, domain knowledge, assumptions, and tests hidden inside them.

Thursday, October 24, 2024

chatGPT 4o vs o1-preview

I normally use chatGPT 4o because it is much faster than o1-preview. Today I asked 4o the following:

Write a function that performs the following 2 byte hex to 2 byte signed int transformations:
0x801D --> -29
0x811D --> -285
0x821D --> -541
0xFF1D --> -32541
0x001D --> 29
0xAA1D --> -10781
0x101D --> 4125

It wrote a function that resulted in the following, mostly wrong, output:

-32739
-32483
-32227
-227
29
-21987
4125

I fed this output back, and it apologized and rewrote something slightly different, but the output was still wrong. I repeated the steps, and I got responses like 'I see the issue more clearly now' and 'Thank you for your patience,' but the output remained incorrect. When I fed the same prompt to o1-preview, it solved the problem in a single iteration. Here is the final python function (sign-magnitude representation):

def hex_to_signed_int(N):
    isNegative = N & 0x8000 # equivalent to "N >= 0x8000"
                            # 0x8000=1000 0000 0000 0000
    if isNegative:
        magnitude = N & 0x7FFF # 0x7FFF=0111 1111 1111 1111
        return -magnitude
    else:
        return N

test_values = [0x801D, 0x811D, 0x821D, 0xFF1D, 0x001D, 0xAA1D, 0x101D]

for val in test_values:
    print(f"0x{val:04X} --> {val:05} --> {hex_to_signed_int(val)}")