Now that we've seen this one way, let's see this from a different perspective.
[Brendan Eich, CTO, Mozilla] [Wes Weimer, Professor, University of Virginia]
Let me ask you a question that's actually of personal interest and curiosity to me.
I'm teaching in this class a number of elements of functional programming,
list comprehensions in Python, filtering a list to retain only some required elements,
and I noticed that in JavaScript you included the ability to create
an anonymous function with the function keyword.
And for students initially, that might be a little bit confusing because
declaring a function at the top level also uses the function keyword,
but we can get past that with the grammar.
I'm curious, why did you think it was important to include the ability
to have anonymous functions?
JavaScript had to live in the shadow of Java,
but it was its own language, and the original pitch--
the sort of fraudulent pretense for getting me to Netscape--was to do Scheme.
Now, I didn't have time to do Scheme, and I didn't do anything as pretty as Scheme,
but JavaScript is a language with first class functions,
and functions are the main building block, so it's important not simply to have
function declarations and require you to name them and put them at a certain level
in nesting but to allow you to express them freely as anonymous functions
or even named function expressions, and this is incredibly popular today.
This is used in lieu of modules and to make sort of super constructors
and class systems in JavaScript today
using functions and function expressions.
これまでは一方向からの話をしてきましたが 別の視点から見てみましょう
私の個人的な興味と好奇心で質問させてください
私はこの講義で 多くの関数型プログラミングの要素や
Pythonのリスト内包表記 リストのフィルタリング方法を教えてきました
あなたはJavaScriptにfunctionを使って 無名関数を生成する機能を加えていますね
トップレベルで関数を宣言する際も functionを使うので
受講生は混乱するかもしれません
だからこそ文法を学ぶのですが
なぜ無名関数を含めることを重要視したのですか？
JavaScriptはJavaの影に隠れていましたが 独立した言語です
私がNetscapeにいた時 Schemeを作る目的で作りました
実際にはSchemeに取り組む時間は ありませんでしたが
JavaScriptは第一級関数を扱う言語で 関数は主要な構成要素です
ですからただ関数を命名し 入れ子にして配置するだけでなく
関数名を指定せず 自由に表現できることも重要です
今はこれが一般的になっています
この手法を使ってモジュールの代わりに 関数や関数式が使用され
JavaScriptのスーパークラスのコンストラクタや クラスの仕組みが作られています
Agora que vimos isso de uma maneira, vamos ver isso por uma perspectiva diferente.
[Brendan Eich, CTO, Mozilla] [Wes Weimer, Professor, University of Virginia]
Deixe-me fazer a você um pergunta qye é realmente de meu interesse e curiosidade pessoal.
Eu estou ensinando em aula vários elementos de programação funcional,
como list comprehension, em Python, filtragem de elementos de