Small Basic と「Goto」キーワード

彼らは,コードから goto 文を全て消し去れば,構造化プログラミングの神秘を携えたダイクストラが降り立つに違いないと信じているのかもしれない。

radiumsoftware.com

をネタもとにした、Goto と カーゴカルトの雑文についた、mogiさんにコメントで教えて頂いた、Small Basic and the "Goto" keyword – Small Basic

初心者向けの言語のデザインについては、クジラ飛行机さんの「ひまわり」において、あえて関数を用意しないプログラミング言語が 初心者にとって優しい(だって規模の問題にぶち当たらなければ、Goto のデメリットにも苦しめられない)という方針が「あり」という話は目新しいものではなかったのですが、ビギナーの先に進もうとする人にとっても Goto のある言語は有意義である と言う視点は ちょっと新鮮でした。


* * *

SMALL BASIC AND THE "GOTO" KEYWORD

SMALL BASIC と 「GOTO」キーワード

For the past 40 years, there have been on-going debates in the programming world about the utility and usage of the keyword, Goto. While it’s been generally accepted that uncontrolled (no pun here) usage of Goto leads to unmanageable and spaghetti code, many, including Donald Knuth, believe that Goto is essential and when used with care will actually lead to clearer and more manageable code.

プログラミング界では 過去40年前にわたって Gotoキーワードの実用性と使用法について議論が継続しています。一般的に、コントロールされていないGotoの使用法は 管理不能でスパゲティなコードを誘発すると認識されていて、ドナルド・クヌースを含む多くの人が、 http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdfGoto は エッセンシャルで、Gotoをより注意深く使うことにより、見通しがよく管理されたコードを実現できると信じています。

When designing the Small Basic language, I had the beginner programmer in mind. Some of them would graduate and move on to other more powerful languages, while some won't. Those that won't, will be content having learned a bit of programming and will remain hobbyists forever. The addition of concepts to the language had to be very carefully done between these two sets of audience.

Small Basic 言語をデザインするとき、わたしは ビギナープログラマーを念頭に置きました。彼らのうちの幾ばくかは、Small Basic を卒業して他のパワフルな言語に移るでしょう。また別の幾ばくかは、プログラミングを一口だけ習得して、ホビイストとしてずっと残り続けるコトに満足するでしょう。言語へのコンセプトの追加は、これらの2つのユーザの間でとても注意深く 行う必要があります。

For those that are taking the first step into the world of programming, there isn’t an easier and crisper way of teaching branching. Goto is such a clear and easy to explain this concept that I felt was necessary to include for a beginner.

彼らビギナーにとってのプログラミングの世界への最初の一歩として、分岐を教える簡単で完結な方法はありません。一方 Goto は そのコンセプトを説明するのが明瞭かつ簡単で、だからわたしはビギナーにとって Goto を言語に含むことが必要だと痛感しています。

Now, CS purists would argue that this is setting a bad trend for beginners that might become professional programmers later on and carry with them the bad practice. I believe that it is better to learn, understand and forget a bad habit than to be ignorant. Every structured programming language has some version of restricted Goto in the form of break, continue, etc. Understanding that fundamental concept is crucial for professional programmers. Besides, if they’re graduating from Small Basic, they’re going to run into unrestricted Goto in at least 7 out of the top 10 programming languages.

これについてCSピュアリストは、プロフェッショナルプログラマになろうとする彼らに悪いプラクティスを刷り込み、あげく業務に持ち込ませる、悪いトレンドだと主張するでしょう。でもわたしは 悪習を理解した上で忘れることは、無知でいるよりベターな学習法だと信じています。全ての構造化プログラミング言語は、break や continue といった 制限された Goto を持っています。それらの原理的なコンセプトを理解することは、プロフェッショナルプログラマにとって重要です。そのうえ、Small Basicを卒業した彼らは、少なくともプログラミング言語トップ10のうち なんと7つで、無制限なGoto に遭遇するのです。

Coming back to the Small Basic audience, here’s my theory. Those that are content being hobbyist programmers in Small Basic, don’t really care about the nuances of using Goto. And those that graduate on to more advanced programming from Small Basic, would be able to appreciate why unrestricted Gotos are “bad.”

さて、Small Basic のユーザに立ち返りましょう(わたしの持論はここにあります)。Small Basic での ホビープログラマに満足する彼らにとって、Goto の 使い方の ニュアンスについて、実際に気を配ることはありません。そして、 より高度なプログラミングに向け Small Basic を卒業する方々も、無制限なGotoがなぜ「悪いか」を理解できていることでしょう。

PS: Here’s a thread with Linus that I found was interesting.

追伸 :リーナスのこのスレッドに興味津々


* * *


訳には自信がないです。ほんと中学生レベルの英語力ですね、わたし..orz

正直、「個体発生は系統発生を繰り返す」式学習の大半は、系統発生と共に個体発生できた幸せな世代の傲慢だとおもうのですが、そうはいっても自分もやっちゃうんですよね。たとえばOOPの研修で、まず構造化プログラミングで書いてから、リファクタリングOOP的にしていくアプローチとか。

だから、これについても、もっと上手い方法はあるはずだ、と思いつつも、それがある程度有効そうだなぁ、とも思ってしまう。すくなくとも、スパゲティの苦しみを我が身で味わうことは、確かに Gotoカーゴカルトのカウンタとして有効かも、と思ったり。