Claude or me: who is better at coding?

After reading about Claude’s code on Xojo Forums, I tried it out:

Sent to Claude:
Programming language: Xojo
A code snippet: a mathematical subroutine of 100 lines of Xojo code.

Claude replied correctly:
Perfect! I can see this is a statistical computation routine for calculating expected scores - looks like psychometric analysis code. Let me create a comprehensive style evaluation for your Xojo code.

Claude’s assessment:
Your Xojo code shows solid understanding of the language and handles complex statistical calculations well! The main areas for improvement are around naming consistency, documentation, and code organization.
This looks like Item Response Theory code - pretty sophisticated stuff! The mathematical logic appears sound, but adding more comments would help other developers (and future you) understand the psychometric calculations.
The 7.2/10 score reflects good technical competence with room for polish in code maintainability and readability practices.

Naming Conventions 6/10
Fair
Mixed adherence to Xojo naming conventions. Some variables follow camelCase, others use abbreviated names.

Code Structure 8/10
Good
Well-organized with clear logical sections and appropriate use of control structures.

Documentation 4/10
Needs Work
Minimal comments. Complex mathematical operations lack explanation.

Error Handling 5/10
Needs Work
Some bounds checking but missing comprehensive error handling.

Xojo Conventions 8/10
Good
Proper use of Xojo syntax, data types, and control structures.

My assessment of Claude’s assessment:

  1. Naming conventions: Yes, these are bad. This code originated in 1987.
  2. Code Structure: Yes.
  3. Documentation: Yes, minimal.
  4. Error Handling: Yes, deliberately minimal to maximize code speed
  5. Xojo conventions: “Good” is surprising! The code is converted from VB6 with only enough changes to run correctly

Sent to Claude: Please make this code faster

Claude replied:
[ revised code snippet ]

Here are the key performance optimizations I made based on current Xojo performance best practices for mathematical computations Compilers 107 – Optimizer Loop Unrolling – Xojo Programming Blog +2:
Major Performance Improvements:

  1. Better Control Flow
  2. Reduced Function Call Overhead
  3. Memory Access Optimization
  4. Mathematical Optimizations
  5. Compiler-Level Optimizations

Expected Performance Gains:

20-40% faster for typical cases due to reduced function calls
Up to 60% faster for dichotomy cases due to early exits
Better cache performance from improved memory access patterns
Reduced CPU overhead from optimized branching logic

The optimized version maintains identical mathematical behavior while significantly improving execution speed, especially for the statistical calculations in your psychometric analysis code!

My look at Claude’s code:

  1. Claude added comments after End Sub
  2. Claude changed integer constants to real constants in floating-point computations
  3. Claude removed code that prevents floating-point overflow in the middle of long expressions because it looks redundant
  4. Claude cached values that arrived in the subroutine Call parameter list
  5. Claude exited the subroutine early when possible - (I prefer only one exit point)

My Comparison of Claude’s and my run time and results after millions of calls of the subroutine in a production situation: the same! - Surprising, if only because Claude should be faster after removing apparently redundant mathematical operations

My verdict: Producing the same results is excellent, but the same time suggests that the Xojo compiler is already doing most of the optimizations that Claude suggests.

Does your experience differ? - Do you get the 20-40% faster?

1 Like

How should one compare them? It depends on so many factors. Such as the programmer’s experience, the type of algorithm used in the code, the focus (or lack thereof) on stability vs. performance, the required precision of the result, and so on…

My expectations of the LLM’s are probably quite realistic, and therefore I probably use it quite often where it’s really helpful. My experiences are actually different. The LLM (Claude.ai in my case) helps me identify potential errors earlier, and comment the code more clearly and comprehensively, or better.

I also learn new things every day and acquire better programming patterns by analyzing my code, which I’ve restructured using the LLM.

1 Like

Try something more simple, like do the refactoring first, then analyse yourself where the algorithm is slow and then give the AI more context about what you expect. Also the AI is a communication and not a “do this and finished” method.

1 Like

Thanks, Sascha.and Beatrix.

I’m impressed by Claude’s conversion of Fortran to Xojo code. A few minutes of Claude would have saved me days of converting and debugging. None of those silly typos and oversights. Claude also suggested an alternative, more Xojo-friendly, data organization.

When you see how quickly LLM support is evolving, especially in the development area, I’m more and more surprised every day that Xojo Inc. isn’t doing anything about it.

I wish more of us would upvote the feature request: https://tracker.xojo.com/xojoinc/xojo/-/issues/79189

2 Likes

+1

1 Like

we all know that xojo reaction time for IDE modifications can be quite long
as the LLM are evolving so fast, I’m not surprised that xojo does nothing
they don’t have time to implement that a new era of llm arrive and change the previous ideas.
their best move IMHO would be today to add mcp server capabilities to xojo IDE…

2 Likes

An mcp server is more complex than an API that would allow any LLM to manipulate the editor content as it sees fit.

And Xojo would make the IDE more open to anything else that might come along.
The idea isn’t to integrate an LLM anywhere, just provide external tools with access to the editor content.

That would open up fantastic possibilities and, honestly, can’t be that difficult to implement, right?

Could “Claude Code” in the terminal help for this? (Using with a Xojo text project)

1 Like

Perhaps, but Xojo data files use a very vulnerable structure. The LLM can easily introduce errors into the files that could be fatal or difficult to detect.

It would be enough for me if I could open a command prompt in the Xojo editor that allows interaction with the code in the editor.

I imagine it would work like this: I could enter something like “Search for potential problems and optimize the code for maximum performance” into the prompt, and the LLM could then load/read and overwrite the code in the editor. If necessary, of course, only the selected text, etc.

1 Like

I tried that with eddie electronic. I asked to add a birthdate to the customer detail, having saved the project in xml. it kind of worked, but was tedious and the date field was misplaced… etc, needs a lot of improvements to be practical.

1 Like

I primarily use it to find potential problems, such as missing error checks or loops that could freeze the UI. I also use it to split large code segments into smaller ones and restructure them. The LLM is a huge help here. However, I don’t let it touch the UI. Xojo is too foreign to the LLM for that, and Xojo itself isn’t open enough.

I also get help with post-release commenting, writing changelogs, and instructions. The LLM significantly accelerates my work.

At the same time, I’m constantly learning through the LLM. It often suggest approaches i might not have considered. Even when the LLM’s solution isn’t perfect, it can introduce me to APIs, design patterns or strategies i weren’t aware of. Also, the LLM can quickly generate starting points for solutions, which i can then rewrite and adapt to our my needs.

1 Like