http://www.javaeye.com/news 2.1 JavaScript2.0 :抢先尝鲜
的一样,如今JavaScript没有class的东西:
// Current JavaScript 1.x "Class" Definition
function MyClass()
{
this.member1 = "a string";
this.member2 = 10;
}
var myClass = new MyClass(); // class instantiation
// JavaScript 2.0 Class Definition
class TrueClass
{
this.member1 = "a string";
this.member2 = 10;
}
var trueClass = new TrueClass(); // class instantiation
当对象的构造函数和他们类型角色一起的时候,构造函数会翻倍。使用new 调用函数的时候会创建一个新对
象,而后你就可以使用被bind到这个对象的本地关键字this来调用这个函数。函数的原型决定了这个对象的原
型。不管什么类型的值赋予一个对象的原型,那么它都会被他所有的实例和汉字共享。使用原型 ,JavaScript
可以模拟许多基于class的特性,尽管有些古怪。举个例子,在下面的代码中,myOtherDog尝试去重载父类
Dog的getBreed() 函数。虽然myOtherDog的getBreed()函数是能够实现的,但是他没有重载成功——给
了myOtherDog两个面包。
function Dog(name)
{
this.name = name;
this.bark = function() { alert('Woof!'); };
this.displayName = function() { alert(this.name); };
};
var myDog = new Dog('Killer');
第 38 / 137 页
39.
http://www.javaeye.com/news 2.1 JavaScript2.0 :抢先尝鲜
myDog.displayName(); //Killer
myDog.bark(); //Woof!
Dog.prototype.getBreed = function()
{
alert("Mutt");
};
myDog.getBreed(); //Mutt
myOtherDog = new Dog('Bowzer');
// this hides getBreed() from other Dogs
myOtherDog.getBreed = function()
{
return "Lhasa Apso";
};
alert(myOtherDog.getBreed()); //Lhaso Apso and Mutt!
alert(myDog.getBreed()); //function is undefined
强类型
像大多数的脚本语言一样,JavaScript也是弱类型的。解释器会在运行时,基于值来决定某变量的数据类型。这
种松散性使得开发者可以很灵活的重用和比较变量。在后种情况,使用强制类型转换就可以比较两种不同数据
类型的值;JavaScript会自动在比较之前将他们转化成相同的类型。
alert( "42" == 42 ); //true
alert( ("42" == 42) + 1 ); //2. the boolean true evaluates to 1.
alert( "I live at " + 99 + " Renolds street."); // the 99 int is converted to a string.
相反的,JavaScript2.0会强类型化了些,这就意味着必须显式的申明变量的类型,脚本引擎不会强制类型转换
第 39 / 137 页
40.
http://www.javaeye.com/news 2.1 JavaScript2.0 :抢先尝鲜
了。类型可以赋予属性、函数参数、函数返回值、变量、对象、数组的初始化对象。如果没有定义类型,那么
变量或者属性被设置为默认的Object类型,这是所有的数据类型层级的基类。使用:后跟类型申明的是赋类型
的语法:
var a:int = 100; //variable a has a type of int
var b:String = "A string."; //variable b has a type of String
function (a:int, b:string)//the function accepts two parameters, one of type int, one of type strin
function(...):int //the function returns a value with a type of int
为了进行上述的比较,你需要转换类型:
alert( int("42") == 42 ); //true
alert( int("42" == 42) + 1 ); //2
alert( "I live at " + string(99) + " Renolds street.");
程序单元体
借鉴了各种流行js框架,程序单元体是很有用的代码模块,它可以在运行时导入。当框架和自定义库数量越来越
多的时候,这些已经成为web程序不可或缺的组成部分。设想下,包含了成千上万行代码的库们,一次性下载
他们已经不合时宜了。这是伪代码:
use unit Effects "http://mysite/lib/Effects";
use unit Utils "http://mysite/lib/Utils";
var panel = new Panel();
panel.setTime(Util.getFormattedTime());
编译时的类型检查
第 40 / 137 页
http://www.javaeye.com/news 7.1 8月编程语言排行榜:Object-C 挤进前20
7.1 8月编程语言排行榜:Object-C 挤进前20
发表时间: 2009-08-03
Tiobe公布了2009年8月的编程语言排行榜,Object-C继上个月排名第21的良好上升势头,本月终于跃升前
20,位居第19位。
Position
Aug 2009 Position
Aug 2008 Delta in Position Programming Language Ratings
Aug 2009 Delta
Aug 2008 Status
1 1 Java 19.527% -2.04% A
2 2 C 17.220% +1.04% A
3 4 C++ 10.501% +0.44% A
4 5 PHP 9.390% +0.04% A
5 3 (Visual) Basic 8.486% -2.37% A
6 6 Python 4.489% -0.49% A
7 8 C# 4.443% +0.75% A
8 7 Perl 4.028% -0.67% A
9 10 JavaScript 2.812% -0.08% A
10 9 Ruby 2.490% -0.43% A
11 11 Delphi 2.337% -0.39% A
12 13 PL/SQL 0.982% +0.30% A
13 14 SAS 0.817% +0.27% A
14 27 RPG (OS/400) 0.752% +0.52% A
15 26 ABAP 0.739% +0.51% A
16 16 Pascal 0.675% +0.26% A-
17 12 D 0.662% -0.69% B
18 17 Lisp/Scheme 0.630% +0.25% B
19 41 Objective-C 0.612% +0.51% B
20 25 MATLAB 0.560% +0.32% B
第 71 / 137 页
72.
http://www.javaeye.com/news 7.1 8月编程语言排行榜:Object-C 挤进前20
让我们来看看榜单的前10名,在2005年,1999年以及1984年时的排名情况:
Programming Language Position
Aug 2009 Position
Aug 2005 Position
Aug 1999 Position
Aug 1984
Java 1 1 3 -
C 2 2 1 1
C++ 3 3 2 11
PHP 4 5 - -
(Visual) Basic 5 6 5 4
Python 6 8 - -
C# 7 7 19 -
Perl 8 4 4 -
JavaScript 9 9 10 -
Ruby 10 25 - -
居于21-50位的编程语言:
Position Programming Language Ratings
21 Lua 0.485%
22 ActionScript 0.471%
23 COBOL 0.441%
24 Logo 0.423%
25 Ada 0.416%
26 Fortran 0.400%
27 Scratch 0.334%
28 FoxPro/xBase 0.319%
29 Erlang 0.310%
30 Transact-SQL 0.294%
第 72 / 137 页
http://www.javaeye.com/news 8.1 KDE 4.3 正式版发布
支持更多种类的应用程序
* KDE Network Applications
* KDE Multimedia
* KDE Graphics Tools
* KDE PIM Suite (for personal information management and communication)
* KDE Educational Applications
* KDE Games
* KDE Utilities
* KDE Software Development Platform
第 97 / 137 页
http://www.javaeye.com/news 8.2 Top 5 Web Operating Systems
8.2 Top 5 Web Operating Systems
发表时间: 2009-08-18
当大家都在等待Google推出自己的Google Chrome操作系统时,看看目前最炫的5款 web Operating
Systems吧。web os最大的好处是,能够通过互联网拥有一个自己的虚拟桌面,以最灵活的方式传输和管理文
件和数据。
1. icloud
icloud 是一个外观漂亮,拥有很多成熟应用的web os,而且提供50GB的在线空间。提供以下服务:
• 在线文件系统,支持任何文件格式
• WebDAV-support 支持访问云空间
• 有用的应用比如 – Write, Calendar, Mail (compatible with all your email accounts plus a free
icloud account), Contacts, ToDo, Calculator, Notepad, Unzip
• 处理相片和多媒体文件
• IM 和 web browser
第 100 / 137 页
101.
http://www.javaeye.com/news 8.2 Top 5 Web Operating Systems
2. Glide OS 3.0
Glide OS 3.0 是一个免费的云计算解决方案,还能够俩解移动手机,提供10GB空间。
第 101 / 137 页
102.
http://www.javaeye.com/news 8.2 Top 5 Web Operating Systems
• 10GB of virtual disk space
• Office tools – word processor, presentation creator, calculator, calendar
• Photo editor
• Website creator
• Glide webmail
• Synchronization and file sharing
第 102 / 137 页
103.
http://www.javaeye.com/news 8.2 Top 5 Web Operating Systems
3. G.ho.st
G.ho.st 虚拟计算机提供几乎所有现实PC所能提供所有应用和操作。
• 15GB professionally hosted and backed-up disk space
• Sharing and collaboration
• Office suite – you can create and edit documents, spreadsheets and presentations using
G.ho.st integrations with Zoho
• Mail
• Web browser
第 103 / 137 页
104.
http://www.javaeye.com/news 8.2 Top 5 Web Operating Systems
4. Jolicloud
Jolicloud 这是一个专门的为netbook开发的 Web OS,专注于网络应用。
第 104 / 137 页
105.
http://www.javaeye.com/news 8.2 Top 5 Web Operating Systems
5. eyeOS
eyeOS 是一个开源云计算web桌面,同时提供个人和团体使用。
第 105 / 137 页