Monday, August 25, 2025

Watch out for hypes in ICT

Hypes

 ICT has a rich history of hypes where people thought that this would be a panacea for all problems. These hypes lasted for some time like paradigms in Thomas Kuhn's theory about evolution of science. From the top of my head we had the following hypes in the past:

  • relational / SQL databases (70's)
  • structural design
  • object oriented design (80's)
  • component based development (90's)
  • design patterns (1995)
  • scrum / agile (2001)
  • AI (2022)

 Many of these hypes were initially promising but not to the extend of solving all problems. They are now part of the current solution domain. We also know now that there are still problems to tackle. 

 Let's see what AI will bring us in the future. For now it's on the level of coding assist but not on the level of designing whole systems. In that part it still cannot replace programmers. There are already studies mitigating the effect of using AI.  It also still makes mistakes. From personal experience it can introduce errors in a code base if you let it run without crosschecking.

 Scrum has brought nothing to ICT except misery. The company I work for took a major loss after embracing it. 

Saturday, August 16, 2025

Careful with AI tooling

AI tooling

 Since some period I started working with AI tooling. Mostly I use Claude, Gemini and Visual Studio's Copilot. The experience is a bit of mixed feelings about this. Claude can send you around the world with all kinds of suggestions. You have to separate signal from noise. Gemini had some good suggestions but also failed many times. Copilot has good code completion suggestions but misses the mark also occasionally. Copilot's function name suggestions are very welcome.

 Some examples of AI tooling failing are listed here:

  • I asked Gemini for camera sharpness algorithm. It came up with a good algorithm but the actual OpenCV function calls and parameters were incorrect.
  • I asked Gemini to get the real sample time from an 'IMediaSample'. It hallucinated and suggested to use the non existing 'GetSampleTime'. There is a 'GetMediaTime' function but this returns the stream time; i.e. the time since the graph was running and not the time from the start of the video. 
  • I asked Gemini of conversion from UCS-2 to UTF-16. It wrongly suggested to use wstring_convert but wstring_covert is hardbound to std::string as byte_string
  • I asked Gemini for a natural sort algorithm. It came up with a good implementation and a clever trick to circumvent the conversion from string to integer numbers. It lacked though the removal of leading zero's which is essential for the clever trick to work.
  • I had to work on CMake lately but suggestions were often contradictory or using old conventions. In the CMake world things have shifted and perhaps the AI models are not updated and trained on old data.
  • I measured that the memory wasn't fully released when using ippFree on Linux in a test function. Claude came up with a whole story that most likely IPP was using a custom allocator. However spying the assembly one could see that it would invoke free after a couple of statements. The actual reason had more to do that glibc sticks to its memory after the second allocation call and probably keeps it standby.
  • I asked Google if there is an ATL variant for PROPVARIANT. Its AI bot answer was yes there is CComPropVariant. However this does not exist in ATL but in a third party library.
  • We asked Claude for guiding us through WinSxS technology. First I asked if it is still a viable technology and Claude assured it was the correct solution for our problem despite being old. After several prompts Claude couldn't get it working. Worse my colleague was convinced it wouldn't work having a fatal error. I fed Claude with the error and it also came to the conclusion that WinSxS wouldn't work for us and that only Microsoft would be able to alter the SxS store. At home I tried Gemini and it came up with a solution. I confronted Claude and it apologized and changed its mind.

 AI tooling can suggest plain bugs. I was implementing a swap of width and height and Copilot's code complete came up with the following code snippet:

// NOTE: incorrect 
Size sz = ...;
if (sz.GetWidth() < sz.GetHeight())
{
   sz.SetWidth(sz.GetHeight());
   sz.SetHeight(sz.GetWidth());
}

This doesn't swap but sets the width and height on the old height value.

 Positive

 I have also some positive experience:

  • Gemini guided me successfully through a WinSxS installation. It couldn't retrieve though the publicKeytoken algorithm.
  • I asked Gemini for a syntax coloring control and it came up with some good suggestions. I choose CRichEditCtrl. There were some issues (like replacing tab with spaces) which it could solve as well.

 Conclusion

 AI tooling can be very helpful and I use it now as a better Google search. They are still not on the level to be trusted blindly. They also have limited scope for software engineering; e.g. code blocks; algorithms and functions. I am not aware if they can help in refactoring and extending architecture wide solutions.

Debugging GDI drawing

GDI debugging

 The other day I had to debug a hard to track drawing bug. The application is built with the MFC framework so it still uses GDI on places to draw custom controls.

 The incorrect drawing artifact was displayed after an invocation of 'DrawText' with the flag 'DT_CALCRECT'. This was unexpected since with the flag the function doesn't draw and only measures the size. Eventually I realized that GDI batches invocations so perhaps the buggy overdrawing had already taken place before. What was needed to prove this hypothesis:

  •  suppress GDI's caching mechanism through 'GdiSetBatchLimit'.
  •  use direct drawing; so no memory device context

 With this in place indeed it could be seen that the mistake happened earlier in the code and that the 'DrawText' invocation was merely a flush of the GDI batch.

 Be aware that suppressing  GDI's batch might not always work. When the window where the drawing took place was on the primary monitor the batch mode could be turned off but on the second monitor it still cached its calls.

Watch out for YouTube commenting

YouTube comments  I am quite hooked to YouTube movies and share sometimes my thoughts or opinion in the comment section. I am always factual...