js_good_parts_1

贡献者:jxk 类别:英文 时间:2017-03-31 10:13:49 收藏数:9 评分:0.5
返回上页 举报此文章
请选择举报理由:




收藏到我的文章 改错字
When I was a young journeyman programmer, I would learn about every feature of the
languages I was using, and I would attempt to use all of those features when I wrote.
I suppose it was a way of showing off, and I suppose it worked because I was the guy
you went to if you wanted to know how to use a particular feature.
Eventually I figured out that some of those features were more trouble than they were worth.
Some of them were poorly specified, and so were more likely to cause portability problems.
Some resulted in code that was difficult to read or modify. Some induced me to write in a
manner that was too tricky and error-prone. And some of those features were design errors.
Sometimes language designers make mistakes.
Most programming languages contain good parts and bad parts. I discovered that I could be
a better programmer by using only the good parts and avoiding the bad parts. After all,
how can you build something good out of bad parts?
It is rarely possible for standards committees to remove imperfections from a lan- guage
because doing so would cause the breakage of all of the bad programs that depend on
those bad parts. They are usually powerless to do anything except heap more features
on top of the existing pile of imperfections. And the new features do not always interact
harmoniously, thus producing more bad parts.
But you have the power to define your own subset. You can write better programs by relying
exclusively on the good parts.
JavaScript is a language with more than its share of bad parts. It went from non- existence
to global adoption in an alarmingly short period of time. It never had an interval in the lab
when it could be tried out and polished. It went straight into Netscape Navigator 2 just as
it was, and it was very rough. When JavaTM applets failed, JavaScript became the "Language
of the Web" by default. JavaScript’s popu- larity is almost completely independent of its
qualities as a programming language.
1 Fortunately, JavaScript has some extraordinarily good parts. In JavaScript, there is a
beautiful, elegant, highly expressive language that is buried under a steaming pile of good
intentions and blunders. The best nature of JavaScript is so effectively hidden that for
many years the prevailing opinion of JavaScript was that it was an unsightly, incompetent
toy. My intention here is to expose the goodness in JavaScript, an out- standing,
dynamic programming language. JavaScript is a block of marble, and I chip away the
features that are not beautiful until the language’s true nature reveals itself. I believe
that the elegant subset I carved out is vastly superior to the language as a whole,
being more reliable, readable, and maintainable.
This book will not attempt to fully describe the language. Instead, it will focus on the
good parts with occasional warnings to avoid the bad. The subset that will be described
here can be used to construct reliable, readable programs small and large. By
focusing on just the good parts, we can reduce learning time, increase robustness,
and save some trees.
Perhaps the greatest benefit of studying the good parts is that you can avoid
the need to unlearn the bad parts. Unlearning bad patterns is very difficult.
It is a painful task that most of us face with extreme reluctance.
Sometimes languages are subsetted to make them work better for students.
But in this case, I am subsetting JavaScript to make it work better for professionals.
声明:以上文章均为用户自行添加,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。
文章热度:
文章难度:
文章质量:
说明:系统根据文章的热度、难度、质量自动认证,已认证的文章将参与打字排名!

本文打字排名TOP20

登录后可见

用户更多文章推荐