278KB Todo App Sparks Debate on Modern Windows Development and Binary Size Optimization

BigGo Editorial Team
278KB Todo App Sparks Debate on Modern Windows Development and Binary Size Optimization

A simple Windows todo application built with C and Win32 API has sparked an extensive technical discussion about binary size optimization, modern GUI development practices, and the evolution of Windows programming. The application, described as modern by its creator, weighs in at 278KB according to comments, though many developers expressed surprise at this file size for what they consider a relatively basic functionality set.

The todo app demonstrates core Windows GUI programming techniques using the Win32 API without any frameworks or modern UI libraries. It includes features like creating, editing, and deleting todo items, marking tasks as complete, persistent storage in AppData, system tray integration, and an auto-start option.

Binary Size Optimization

One of the most discussed aspects of the project was its binary size. Many commenters expressed surprise that the executable was 278KB, suggesting that similar functionality could be achieved with a much smaller footprint. Several developers offered optimization techniques that could dramatically reduce the file size.

I tried to reproduce this binary to see what the 278 KB was being taken up by... Using x86_64-15.1.0-release-win32-seh-msvcrt-rt_v12-rev0.7z as the toolchain. This produces a 102 KB .exe file. Right off the bat we are doing much better than the claimed 278 KB... We can improve this by passing some switches to GCC... gcc -s -Oz -flto => 47 KB

The discussion revealed that much of the binary bloat likely came from static linking of the C runtime library. Developers debated the merits of static versus dynamic linking, with some pointing out that while dynamic linking produces smaller executables, it requires distributing DLLs with the application unless they're already part of the operating system.

Size Optimization Techniques Mentioned

  • Compiler flags for size optimization:
    • -Os - Optimize for size
    • -Oz - More aggressive size optimization
    • -flto - Link-time optimization
    • -s - Strip symbol tables
  • Linking options:
    • Dynamic linking to system DLLs vs static linking
    • Using MinGW's default MSVCRT.DLL as the C runtime
  • Executable compression:
    • UPX mentioned as a historical technique (with anti-virus concerns noted)

Project Features

  • Written in pure C using Win32 API
  • Todo item management (create, edit, delete, mark complete)
  • Persistent storage in %APPDATA%\TodoApp\todos.dat
  • System tray integration
  • Auto-start with Windows option
  • Maximum 100 todos capacity

Modern Windows Development Practices

Many commenters questioned the application's claim of being modern, pointing out that it lacks features like high-DPI support, modern UI styling, and tab navigation between controls. Several suggested adding a Windows application manifest to enable modern UI styling and other contemporary Windows features.

The discussion highlighted how Windows development practices have evolved over time. While Win32 API programming in C was once the standard approach, most Windows developers moved to higher-level frameworks and languages like C++, Visual Basic, and Delphi by the Windows 95 era. Today, even Microsoft's own documentation recommends C++ over C for Windows development.

Nostalgia and Learning Value

Despite criticisms, many commenters expressed appreciation for the project's educational value and nostalgic appeal. Several developers reminisced about their early Windows programming experiences with similar approaches, noting that this style of development helps programmers understand what's happening close to the metal.

The project sparked discussions about the evolution of development practices over the decades, with older developers recalling when executable sizes were measured in kilobytes rather than megabytes. Some humorously compared the 278KB application to the constraints of programming for systems with far more limited resources, like the 6502 processor.

The project demonstrates that while modern development practices have moved toward higher-level abstractions and larger binaries, there's still value in understanding the fundamentals of operating system APIs and efficient programming. For beginners looking to learn Windows GUI programming or experienced developers wanting to revisit the basics, projects like this provide an accessible entry point to understanding how Windows applications work at a lower level.

Reference: Simple Todo (C / WinAPI)