• 静思
  • 吴言片语
    • 吴言
    • 片语
    • 杂七杂八
  • 死于青春
    • 一路走好
  • 乌合麒麟
  • 纪念
    • 5.12
    • 3.23
  • GitHub
    • A List of Post-mortems
    • The Art of Command Line
  • 关于
    • Privacy Policy

程序员的信仰

金鳞岂是池中物,一遇风云便化龙

HOME » 技术生活 » Joshua Bloch咏Tiger诗八首

Joshua Bloch咏Tiger诗八首

2005 年 9 月 8 日 @ 下午 4:59 by Jay | 被踩了 2,109 脚

TOC

Toggle
  • 咏Tiger
  • 咏Enhanced for Loop
  • 咏Autoboxing/Auto-Unboxing
  • 咏Varargs
  • 咏Static Import
  • 咏Enumeration
  • 咏Metadata
  • 咏Generics

“Ease of Development”是J2SE 1.5的主要卖点。为此,这一版本加入了七种新的语言特性——Enhanced for Loop、Autoboxing/Auto-Unboxing、Varargs、Static Import、Enumeration、Metadata和Generics。使用这些特性,可以让编写出来的程序更简练、更清晰、更不容易出错,从而简化开发的过程。

Joshua Bloch(《Effective Java》的作者,J2SE 1.5的主要开发人员之一)效仿William Blake(1757-1827,英国诗人)的《Tiger》一诗,为这些特性撰写了这样一组诗篇:

咏Tiger

Tiger, Tiger burning bright
Like a geek who works all night
What new-fangled bit or byte
Could ease the hacker”s weary plight?

 

这一首是总说Tiger中的能使开发变得简单的各种新语言特性。

咏Enhanced for Loop

While Iterators have their uses
They sometimes strangle us like nooses
With enhanced-for”s deadly ray
Iterator”s kept at bay

 

这一首单表Enhanced for Loop机制提供了一种更简单的遍历数组、Collection和其它实现了java.lang.Iterable接口的对象的方法。

咏Autoboxing/Auto-Unboxing

When from the collections ints are drawn
Wrapper classes make us mourn
When Tiger comes, we”ll shed no tears
We”ll autobox them in the ears

 

这一首单表Autoboxing机制/Auto-Unboxing提供了一种更简单的整合两套不同的类型系统(基本类型和引用类型)的机制。

咏Varargs

O joyless nights, o joyless days
Our programs cluttered with arrays
With varargs here, we needn”t whine;
We”ll simply put the args inline

 

这一首单表Varargs机制提供了一种更简单的传递个数可变的实参的方法。

咏Static Import

And from the constant interface
We shall inherit no disgrace
With static import at our side
Our joy will be unqualified

 

这一首单表Static Import机制提供了一种更简单的访问静态成员的机制。

咏Enumeration

The int-enum will soon be gone
Like a foe we”ve known too long.
With type safe-enum”s mighty power
Our foe will bother us no more

 

这一首单表Enumeration机制提供了一种更简单的定义“类型安全的枚举类”的方法。

咏Metadata

As for noble metadata
I”ll have to sing its praises later
Its uses are so numerous
To give their due, I”d miss the bus

 

这一首单表Metadata机制提供了一种更简单的定义“机器可读的说明信息”的机制。

咏Generics

To the most despised collections” cast
We”ll bid a fond farewell at last
With generics” burning spear
The need for cast will disappear

 

这一首是说用Generics机制,可以免去很多强制类型转化的步骤的事情。Generics机制还有些其它用法,在这里没有提到。


-- EOF --

除非注明(如“转载”、“[zz]”等),本博文章皆为原创内容,转载时请注明: 「转载自程序员的信仰©」
本文链接地址:Joshua Bloch咏Tiger诗八首

分享

  • 点击分享到 Facebook (在新窗口中打开) Facebook
  • 点击以分享到 X(在新窗口中打开) X
  • 更多
  • 点击分享到Reddit(在新窗口中打开) Reddit
  • 点击分享到Telegram(在新窗口中打开) Telegram
  • 点击以在 Mastodon 上共享(在新窗口中打开) Mastodon

赞过:

赞 正在加载……

相关

Today on history:

【2025】思想殖民——美国认知战的手段、根源及国际危害
【2011】Learn Vim Progressively
【2009】老上海,儿时的记忆 [zz]
【2007】我的软件列表(二)
Posted in: 技术生活 Tagged: java, oo, tiger
← MSN Space的几个新插件
交作业啦:五个特殊嗜好 →

android (9) apple (20) augmentum (9) Beijing (21) bt (8) career (28) coding (38) firefox (10) google (36) hibernate (11) ibm (11) iphone (10) java (93) linux (16) m$ (26) mac (58) macos (27) nazca (9) olympics (8) oo (8) playstation (10) rip (8) Shanghai (39) spring (9) tips (45) tommy emmanuel (8) ubuntu (12) usa (23) windows (9) 北航 (17) 博客 (29) 吐槽 (8) 周末 (9) 和谐社会 (26) 小资 (11) 愤青 (40) 方言 (10) 朋友 (77) 歌词 (8) 烟酒不分家 (18) 爱国 (19) 爱情 (8) 犯二 (15) 破解 (8) 足球 (11)

烫手山芋

  • 再谈苹果的输入法:这一次是靠OS X自带的输入法来翻身的~ - 被踩了 27,831 脚
  • 生活,就是一个期待跟着一个期待 - 被踩了 21,390 脚
  • 星巴克饮品缩写大全(Starbucks Drink ID Codes)[zz] - 被踩了 18,484 脚
  • 从一个全角冒号说一下我为什么不感冒iOS - 被踩了 14,420 脚
  • 有关Character.isLetter()和Character.isLetterOrDigit() - 被踩了 13,625 脚

刚拍的砖

  • leo 发表在《再谈苹果的输入法:这一次是靠OS X自带的输入法来翻身的~》
  • 花 发表在《再谈苹果的输入法:这一次是靠OS X自带的输入法来翻身的~》
  • 无名氏 发表在《从一个全角冒号说一下我为什么不感冒iOS》
  • Jay 发表在《Mac OS geek级问题》
  • Wei Wang 发表在《再谈苹果的输入法:这一次是靠OS X自带的输入法来翻身的~》

随便看看

  • 死于青春(序)15 年 ago
  • 一劳永逸设置最大文件打开数13 年 ago
  • Object Modeling Strategies (IV)9 年 ago
  • 冰壶规则4 年 ago
  • 开始Ubuntu17 年 ago

文以类聚

光阴似箭

其他操作

  • 登录
  • 条目 feed
  • 评论 feed
  • WordPress.org

Copyright © 2025 程序员的信仰.

Jay's Omega WordPress Theme by Jay

 

正在加载评论...
 

    %d