如何用各种编程语言解决一条龙

阅读前注意

  1. **此文章来源: **https://blogs.oracle.com/roumen/entry/how_to_kill_a_dragon

  2. 原文中已注明:

    This funny text comes from Ibon from the dream team who got it from a Spanish blog.

    标明 博主的文章来源 并非 此文章 的 真正来源。

  3. 原文位于此博文底部,如需查看英语原文请翻至最底部。

  4. 中文译文部分已经博主格式化;英语原文没有做任何改动

  5. 著作权归原作者所有


中文正文

如何用各种编程语言解决一条龙

注意: 这篇有趣的文章翻译自一篇西班牙博客。
有一位美丽的公主,被关押在一个城堡中最高的塔上。一条凶恶的巨龙看守着她,需要有一位勇士营救她……
下面是各种语言如何想办法将公主从巨龙手中营救出来的:

  • Java – 赶到那里,找到巨龙,开发出一套由多个功能层组成的恶龙歼灭框架,写几篇关于这种框架的文章……但巨龙并没有被消灭掉。
  • .NET – 赶到那里,看到了 Java 程序员的做法,完全复制过来,试图去杀掉巨龙,可惜巨龙把他吃掉了。
  • C - 赶到那里,对巨龙不屑一顾,举起剑,砍掉巨龙的头,找到公主…… 把公主晾在一边,去看看有没有最新提交的 Linux 内核代码。
  • C++ – 先打造出一根针,然后在上面添加各种功能特征,直到最后汇聚成一把复杂的剑,这把剑复杂到只有他能理解其中的功能……他能杀死龙,但他过桥时遇到了麻烦,因为内存溢出了。
  • COBOL - 赶到那里,看到巨龙,认为自己太老了,杀不死这条巨龙,营救不出公主,于是离开了。
  • Pascal - 他花10年时间开发出一套巨龙歼灭系统…… 当战斗开始时,他发现这套系统只能关住蜥蜴。
  • VB - 使用各种组件开发出一套巨龙毁灭武器,他跳到巨龙的后面,在最关键的时刻,他发现这种武器只能在雨夜里工作……
  • PL/SQL – 分析其它屠龙者的数据,创建出具有多维数据、N 向关系的数据表模型、OLAP。花15年时间分析这些数据…… 当结果出来时,公主已经变成了同性恋者。
  • Ruby - 盛大出征,号称自己不管做什么都是最强的,当面对巨龙,他亮出了一张画有他杀死一条瘸腿的巨龙的图片…… 巨龙懒洋洋的吃掉了他。
  • Smalltalk - 赶到那里,分析巨龙和公主,转身走了,它们是次要问题。
  • Shell* - 创造一个超级强大的灭龙武器…… 但当面对龙的时刻,他忘了如何使用它。
  • Assembler - 他认为他的方法是正确的,而且是最高效的…… 但他把D写成了A,杀死了公主。
  • Fortran - 赶到那里,开发出来一套 4 万 5 千行的解决方案,杀死巨龙,与公主见了面…… 但公主认为他是懦夫,反而倾心于高富帅的 Java 程序员。
  • FOX PRO - 开发出一套杀龙系统。外表看起来华丽好用,但实际内部到处补丁,所以,当开始运行这套杀龙武器时,他才发现忘了给 DBF 加索引。
  • Lisp - 这是一位著名的游侠骑士,在跟很多的屠龙专家交谈后,将他们的技巧模型化,他开发出这套系统,当开始运行系统时,他认识到,他少写了一个括弧。
  • HTML - 用各种著名的杀龙的剑拼装成一个网页,但他忽视了 W3C 标准。在跟龙相遇的时刻,他发现他的代码跟浏览器不兼容,于是他变成了赤手空拳。巨龙把他当成小甜点吃了。
  • Prolog - 他认为需要有一件杀龙的武器。于是在一个有 182014 件武器的目录里搜索。截止到公主死的那一年,他的成就包括:通晓了各种武器的制造方法,从索引 A 开始:Atomic Bombs, Anti-Air Weapons, Arches, Ammunition, Axes……
  • PHP - 开发出一个 Web 网页,当这个运行时,它能通过一个 Apache 服务器从一个 MySQL 武器数据库里检索出武器消灭掉$dragon。然而,他在 DELETE 语句里忘了写 WHERE 语句,于是杀死了公主,巨龙,女侍,女巫,魔法师,和程序员自己。
  • JavaScript - 他创建了脚本网页,当网页运行时,脚本会除掉巨龙,他一加载页面,一些美丽的少女就向他抛来了鲜花,发出来尖叫。不幸的是,他没有认真分析这个类似蜥蜴的怪物——也被称作 Mozilla,他得到的只是让控制台里填满了 Error 信息,《Book of Mozilla》记载了他是如何被吞掉的。
  • BASIC - 他开发出来一种能够杀死纸龙的武器,但不论他如何改进,他发现,他都不能杀死一只比卷毛狮子狗大的龙。
  • Matlab - 他写出循环语句能计算出用巨箭射死巨龙的弹道。这个程序运行的完美无瑕疵。现在需要的是人能有这样大的力量按这种精度发射这支巨箭。
  • 游戏开发者** - 用了两年时间编写了一个拥有 最先进的光影 和 其它所有 的剑。当杀龙的时候降临,他发现,有半数的骑士没力气举起剑来。于是他编写了一个补丁,揭示了公主和 希拉里 · 克林顿 的(富强民主文明和谐)场面,使其成为丑闻。

英语原文

How to kill a dragon with various programming languages

By Roman Strobl on IX 20, 2007

This funny text comes from Ibon from the dream team who got it from a Spanish blog.

There’s a beautiful princess, prisoner in the highest tower of a castle, guarded by a mighty dragon, and a fearless knight must rescue her…

This is how each language would manage to rescue the princess from the hands of the dragon

  • Java - Gets there, finds the dragon, develops a framework for dragon anihilation with multiple layers, writes several articles about the framework… But doesn’t kill the dragon.
  • .NET - Gets there, sees the idea of the Java developer and copies it. Tries to kill the dragon, but the monster eats him.
  • C - Arrives, looks down at the dragon, pulls out his sword, beheads the dragon, finds the princess… And ignores her to see the last checkins of linux kernel cvs.
  • C++ - Creates a basic needle, and gathers funcionality until he has a complex sword that he can barely understand… He kills the dragon, but gets stuck crossing the bridge because of memory leaks.
  • COBOL - Arrives, sees the dragon and thinks that he is too old to kill a monster that big and rescuing the princess, so he leaves.
  • Pascal - He prepares for 10 years to create a dragon anihilation system… When the moment comes, he discovers the program can only take lizards as an entry.
  • VB - Builds a dragon destruction weapon based on several components, jumps to the back of the dragon and in the most critical time he discovers that the sword works only on rainy nights…
  • PL/SQL - Gets data from other dragon slayers, creates tables with n ternary complexity relations, tridimensional data, OLAP, takes 15 years to process the information… And by then, the princess became a lesbian.
  • Ruby - Arrives with massive fame, saying he is the best at anything and when he faces the dragon, he shows a lame motion picture of himself killing a dragon… The dragon eats him out of boredom.
  • Smalltalk - Arrives, analyzes the dragon and princess, turns around and leaves, they are way too inferior.
  • shell - Creates a very powerful dragon slaying weapon… But in the moment of truth, he can’t remember how to use it.
  • shell(2)- The guy approaches the dragon with a two line script that kills, cuts, disembowels, impales, chops to pieces and packs the beast, but when he runs it the script grows, it fattens, irritates and puts alcohol in the fire of the dragon…
  • Assembler - He thinks he’s doing the right and most efficient things… But he writes an A instead of a D and kills the princess to end up f***ing the dragon.
  • Fortran - Arrives and develops a 45-thousand-code-line-solution, kills the dragon, meets the princess… But she calls him a weakling and runs after the Java programmer who was elegant, and also rich.
  • FOX PRO - Develops a dragon killing system. It’s gorgeous and works on the outside, but it’s really patched inside, so when he runs the dragon anihilator, he realizes he forgot to index the DBFs.
  • PROCESS ANALYST - Approaches the dragon with two tons of documentation, develops the unified dragon-killing process, he develops a DFD to free the princess and marry her, convinces the dragon that it’s the best for him and it won’t hurt. When he executes the process, he estimates the effort and the damage he will cause with a plan signed by the Pope, Buddha and Michael Jackson. Then he buys a couple of nukes, 45 cannons, an aircraft carrier and hires 300 heavily armed men… When all he needed was the sword he was holding in his hand in the beginning…
  • CLIPPER: Sets up a routine that loads a codeblock array to insult the dragon, serenade the princess, load the sword in memory, beat the crap out of the dragon, clean the mess, prepare a raspberry milkshake for the princess, make love to her, take a bath, start the car, put it some gas and come back home. When he runs it, he gets a “Bound Error: Array Access” and the dragon eats him with fries.
    Lisp, where the famous knight-errant, after speaking with numerous experts in dragon-killing, and modeling the knowledge they posess, he programs the system, and when he runs it he realizes he forgot a bracket (bender the offender).
  • HTML: Mounts a web on famous swords used to kill dragons, but he ignores the W3C standards. When he meets the dragon, he finds out the code isn’t compatible with his browser, so he’s left swordless. The dragon eats him as an appetizer.
  • Prolog: Thinks he needs a weapon to kill the dragon. Searches in a catalog for 182014 weapons. By the time the princess dies of her age, he’s achieved to know how to make every weapon starting with A: Atomic Bombs, Anti-Air Weapons, Arches, Ammunition, Axes…
  • PHP: Creates a web page that when he executes it would eliminate the $dragon selecting from a weapons databese in MySQL over an Apache server. Nevertheless he forgot the WHERE in the DELETE query and kills the princess, the dragon, the peasants, the witch, the sorceror and the programmer himself.
  • JavaScript: The programmer tries to kill the great green dragon that spits fire throug his mouth. He creates a script that will delete the dragon when he loads a webpage, to create seconds after, some damsels to throw him flowers and make clapping sounds. Unfortunately he didn’t take into account the DOM structure of the lizard, also known as Mozilla, and the only thing he gets is to fill his console of errors and that the Book of Mozilla tells how he was devoured.
  • ActiveX: The programmers create a tunnel to enter the dragon’s lair from the castle and run a program that will kil the dragon from a safe and prudential distance. The dragon discovers the tunnel, eats the workers who dug, the dragon slayers, and enslaves every servant in the castle. The castle becomes a dragon-breeding place, full of little dragons that the dragon sends in pop-ups to other castles. The untasty remains of the knights are put in cans of Spam and sent to other castles as well as a warning. (aquelquesiente)
  • Basic. He creates a weapon able to kill paper dragons, but no matter how they improve it, they discover it’s not good enough to kill any dragon bigger than a baby poodle.
  • Matlab: They create a loop that calculates the trajectories to shoot a giant arrow at the dragon. The program works flawlessly. What they need now are the voluntaries caoable to launch tha arrow with the necessary strength and accuracy.
  • Videogame Programmer : Spends two years programming a state-of-the-art sword with shaders and all. When the time comes to kill the dragon, he finds that half the knights aren’t strong enough to raise the sword. Then someone programs a patch that reveals the sex scenes with the princess and Hillary Clinton makes it a scandal.

  • *: 英语原文中有 2 个 “shell”,此处仅翻译第一个。
  • **: “游戏开发者” 这一项并不是程序语言,仅仅是调侃部分程序媛(误