The Chaotic History of "GOTO" (and How I Learned It on an IBM PS/2)

작성자

카테고리:

← 피드로
DEV Community · Christopher Semler · 2026-09-03 개발(SW)

Every programming language has that one feature everyone warns you about.
In QBASIC, C, C++, and C#, that feature is goto.

It’s the original source of spaghetti code, infinite loops, debugging nightmares, and childhood trauma. And yes — I learned it the same way many of you did:

On an IBM PS/2 with a 286 CPU, running DOS, with QBASIC baked right in.

This post is a mix of history, nostalgia, and a reminder that sometimes the best way to learn control flow is to break everything.

🧱 C — The Original Chaos Engine (1972)
C introduced goto because early systems programming needed raw, unfiltered control over execution. No exceptions. No structured error handling. Just: jump here, jump there, jump anywhere and try not to crash the kernel

In C, goto is fast, simple, and dangerous. It literally moves the instruction pointer to a labeled location.

This is the birthplace of infinite loops and spaghetti code.
C didn’t discourage it. C basically said:

“Here’s a chainsaw. Don’t cut your leg off.”

Spoiler: everyone cut their leg off.

🧱 C++ — The Sinner With Classes (1985)
C++ inherited goto from C because backward compatibility mattered. But C++ also introduced: exceptions, RAII, ~destructors, and structured control flow

So goto became less necessary and more of a “you probably shouldn’t” tool.

Still valid. Still dangerous. Still used in: kernel code, embedded systems, performance‑critical loops, and error cleanup paths

But in normal C++ code?

“If you see goto, someone is either a genius or a criminal.”

🧱 C# — The Modern Language That Kept It (2002)
C# kept goto for two reasons:

✔️ 1. Switch‑case control
C# doesn’t allow implicit fallthrough like C/C++.
So you can do:

csharp
case 1:
goto case 3;
This is actually legit.

✔️ 2. Label jumps inside methods
C# allows:

csharp
START:
Console.WriteLine("Menu");
goto START;

But the official vibe is:

“We put it here for completeness. Please don’t use it unless you’re doing something weird.”

It’s rarely used outside: switch navigation, state machines, code generation, intentionally cursed demos, and nostalgia trips

🧱 QBASIC — Learned on an IBM PS/2 Because It Literally Came With It
Here’s the part that matters to me — and maybe to you too.

I learned goto on an IBM PS/2 with a 286 CPU — one of those chunky CRT‑powered machines that booted straight into DOS. The PS/2 came with QBASIC because DOS came with QBASIC, so all you had to do was type QBASIC at the prompt and suddenly you were writing code that should’ve been illegal.

The glow of that CRT, the hum of the power supply, and the clack of the Model M keyboard made every GOTO STARTMENU feel like real magic. QBASIC didn’t teach me good habits, but it taught me how control flow really works — and how to debug spaghetti nightmares decades before I ever touched C#.

This was programming in the wild.
No functions.
No structure.
Just labels, jumps, and pure DOS‑gremlin energy.

🧠 What I Learned From All This

It’s not a keyword I use in real production code — but it’s a keyword that shaped how I think about code.

And honestly?
I’m glad I learned it the messy way.

🔚 Conclusion
goto is one of the oldest, weirdest, most controversial features in programming languages. It’s been around for 50+ years, survived multiple generations of languages, and still exists today — even if most people pretend it doesn’t.

And for many of us, it started on machines like the IBM PS/2.
With a CRT.
With DOS.
With QBASIC.
With a blinking cursor and a dream.

If you’ve got your own goto stories, debugging nightmares, or childhood programming chaos — drop them in the comments. I’d love to read them.

원문에서 계속 ↗