Writing a (valid) C program without main()

Coder says you can skip “main,” and the comments instantly turn into a nerd civil war

TLDR: A tutorial showed how to make a C-based executable run without the usual `main()` starting point by digging into how programs are built under the hood. The real fireworks came from commenters arguing over whether that makes it clever, misleading, or not really “C” at all.

A programming tutorial tried to pull off a very online magic trick: make a C program run without the usual starting function, main(). The article walks readers through how a simple “Hello, world” gets turned into a real app step by step, showing that the familiar starting point isn’t some sacred gift from the universe. It’s a backstage process involving the tools that build and launch the program. For curious readers, it’s a neat peek behind the curtain. For the comments section? It was blood in the water.

The biggest fight was over one loaded word in the title: “valid.” One camp basically yelled, “Absolutely not, your honor!” Commenters argued that by the official rulebook, this doesn’t count as a proper standard C program at all. Another side shrugged and fired back with the classic engineer response: if it runs, it runs. That split turned the thread into a philosophy brawl over whether “works on this machine” is good enough, or whether the language lawbook still rules the land.

And then came the bonus chaos: one commenter dismissed the whole thing as not really making a C program at all, but using C and assembly tools to stitch together an executable. Another torched the article’s claim that C is the closest thing to the operating system, calling it an “urban myth” and dragging in computing history for receipts. In other words, what started as a tutorial became a very internet spectacle: part lesson, part semantic cage match, and part “well, actually” Olympics.

Key Points

  • The article uses a hello-world C program to explain the full compilation pipeline from source code to executable on Linux.
  • It states that `gcc` acts as a driver that invokes multiple tools, including preprocessing, compilation, assembly, and linking stages.
  • The tutorial demonstrates preprocessing with `gcc -E`, showing how macros and includes are expanded into a larger intermediate file.
  • It demonstrates generation of assembly with `gcc -S` and explains that the output depends on the target architecture, such as x86_64.
  • The article compares assembly output at optimization levels `-O0`, `-O2`, and `-Os` using a loop example to show how compiler optimizations transform code.

Hottest takes

"not a 'valid' C program according to the standard" — eska
"Most interesting C programs violate the standard" — asveikau
"That is an urban myth" — pjmlp
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.