Hi: As the title said, the following is a piece of handout from one of Stanford U. Computer Science course ************************************************************* CS193i, Stanford University Handout #30 Spring, 2000-01 Nick ParlanteJava Introduction This is the outline for the Java section going over all the language basics in one session.Java Qualities Compiled to bytecode Interpreted at runtime -- potentially slow Interpreters are slower than compiled code, but they enable true portability Modern systems are not true interpreters -- they use some form of Just-in-time- Compile to build native code at runtime. Sun's "hot spot" system does this in a sophisticated way at runtime.Realistically, not as fast as C, but getting closer. Java's dynamic features: safe pointers, garbage collection, etc. extract a penalty vs. C code.PortableRuns the same everywhere without even a re-compile. Very true for the core language. Less true for first GUI library, AWT, but the new GUI library Swing has fixed this.Robust/Safe Hard to crash, hard to write viruses Structured -- typed Java has a formal type system that must be obeyed at compile-time and run-time. This is helpful for larger projects, where the structure helps keep the various parts consistent. Contrast to Perl, which as more of a quick-n-dirty feel.C/C++ Syntax Fool the C/C++ programmers into thinking this is not much of a change OOP The best way to structure code Official "Blessed" libraries for common problems Common classes: String, Collection, Date ... GUI libs (AWT, Swing)Threaded Supports multiple threads of control built in to the languageDynamic Types/behaviors are determined at run-time (most flexible, at the cost of some efficiency).Automatic garbage collector takes care of memory management.************************************************************************* Point: Somewhat slow + portable + programmer efficiency features ************************************************************************** Programmer Efficiency Faster Development Building an application in Java takes about 30% less time than in C or C++Libraries Code re-use at last -- String, ArrayList, ... (C++ can also do this to an extent)Memory errors Memory errors largely disappear because of the safe pointers and garbage collector. I suspect the lack of memory errors accounts for much of the increased programmer productivity.Java Niche CPU time vs. Programmer time tradeoffPortability Send code from one place to another Avoid vendor lock-in Microsoft hates this feature (in any domain, it's natural for the largest vendor to dislike portability, while the small vendors and the customers like portability).Applets Java code, runs in the browser in a "sandbox" Did not work that well Not well implemented the first time -- AWT not well done, in-the-browser concept is fragile Microsoft not helping Custom server side applicationsA good match for Java qualities -- robust/safe, programmer efficient, portable (e.g. develop on NT, deploy on Solaris, Linux, ...)
我的一位同事是搞JAVA的,从他身上,我就看到了JAVA的很多优点。
在我从事Windows开发时,时不时都要关切操作系统是如何运作的,考虑消息循环、继承的复杂性、何时用指针何时用引用等等,然后再保证自己的程序的合理性,但我的同事却从不要考虑,就能实现我的程序的功能。
如果换一个操作系统,我要去重新熟悉这个操作系统的机制再开始编程,而我的同事这时就可以把他从前的程序原封不动移过来——他可以在旁边喝茶了。
不过JAVA的速度虽然是个问题,但绝不是个大问题。
哈哈,当然,我还是喜欢C/C++,还想搞搞ASM.
当然还有一些其它的好处
安全的
高效的
中性的
健壮的
……这些好处可以在JAVA“白皮书”上找到http://java.sun.com:80/doc/language_environment,若找不到就搜索吧
现在的软件发展方向是为企业提供一个解决方案,这时语言所倡导的理念就很重要了,好EJB.对语言的基础应用其实都是差不多的,主要区别就是在处理大型系统的时候的逻辑分析,程序的健壮,编程的效率,代码的重用......呵,我不是搞JAVA的,但我在尝试了C的N多痛苦时候才发现,C/C++要做企业级解决方案真是......
JAVA FAN
Java 只是一种精简化的 OO 语言,去掉了 OO 中的一些复杂的概念, 对面相对象的支持比不上 C++,更比不上 Small talk, Effel 等等比较纯的 OO 语言。
不过带来的好处是巨大的。 Java 所标榜的跨平台性, 但许多系统对 Java 虚拟机的支持并不好,
HP对 Java的支持很糟糕, 这是公司放弃最终软件在HP上运行的最大的原因。
不知道为什么, Windows 平台上的许多 Java 编译器
都有BUG, 包括 Sun 的一些冬冬。 可能是虚拟机的原因,我发现Windows平台下的纯Java应用程序有时候会莫名其妙的当掉。 工具是死的,什么方便适用用什么呗!犯不着为这个争吵。
我只说一次
BEST JAVA!!!!!!!!!!!!!!!!!!!!!!
国外JAVA 也是很有市场的
反正用java感觉,很累人.
但有时候,还是想用.
{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String sourceURL=new String("jdbc:odbc:test");//test時資料來源
DBConn=DriverManager.getConnection(sourceURL);
statement=DBConn.createStatement();
statement.executQuery("select * from .....);
}
catch(ClassNotFoundException e)
{System.out.println(e);}
catch(SQLException e)
{System.out.println(e);}
}在Jbuilder中可以直接用控件連接,代碼不用寫自己給出,
具體去看看Jbuilder中Help->Dataexpress Refrence中有例子,還有圖,非常清楚,自己看吧
各有各的好!!!
只要你不用JNI(Java Native Interface),你写的Java程序理论上来讲可以原封不动在许多平台上执行,而且相对而言,Java是门比C++比较乾净的OO语言,前途应该是很光明
As the title said, the following is a piece of handout from one of Stanford U. Computer Science course
*************************************************************
CS193i, Stanford University Handout #30
Spring, 2000-01 Nick ParlanteJava Introduction
This is the outline for the Java section going over all the language basics in one session.Java Qualities
Compiled to bytecode
Interpreted at runtime -- potentially slow
Interpreters are slower than compiled code, but they enable true portability
Modern systems are not true interpreters -- they use some form of Just-in-time- Compile to build native code at runtime. Sun's "hot spot" system does this in a sophisticated way at runtime.Realistically, not as fast as C, but getting closer. Java's dynamic features: safe pointers, garbage collection, etc. extract a penalty vs. C code.PortableRuns the same everywhere without even a re-compile. Very true for the core language. Less true for first GUI library, AWT, but the new GUI library Swing has fixed this.Robust/Safe
Hard to crash, hard to write viruses
Structured -- typed
Java has a formal type system that must be obeyed at compile-time and run-time. This is helpful for larger projects, where the structure helps keep the various parts consistent. Contrast to Perl, which as more of a quick-n-dirty feel.C/C++ Syntax
Fool the C/C++ programmers into thinking this is not much of a change OOP
The best way to structure code
Official "Blessed" libraries for common problems
Common classes: String, Collection, Date ...
GUI libs (AWT, Swing)Threaded
Supports multiple threads of control built in to the languageDynamic
Types/behaviors are determined at run-time (most flexible, at the cost of some efficiency).Automatic garbage collector takes care of memory management.*************************************************************************
Point: Somewhat slow + portable + programmer efficiency features
**************************************************************************
Programmer Efficiency
Faster Development
Building an application in Java takes about 30% less time than in C or C++Libraries
Code re-use at last -- String, ArrayList, ... (C++ can also do this to an extent)Memory errors
Memory errors largely disappear because of the safe pointers and garbage collector. I suspect the lack of memory errors accounts for much of the increased programmer productivity.Java Niche
CPU time vs. Programmer time tradeoffPortability
Send code from one place to another Avoid vendor lock-in
Microsoft hates this feature (in any domain, it's natural for the largest vendor to dislike portability, while the small vendors and the customers like portability).Applets
Java code, runs in the browser in a "sandbox" Did not work that well
Not well implemented the first time -- AWT not well done, in-the-browser
concept is fragile
Microsoft not helping
Custom server side applicationsA good match for Java qualities -- robust/safe, programmer efficient, portable (e.g. develop on NT, deploy on Solaris, Linux, ...)
你用用就知道了,真的,以前我也是学C++(现在也在学),现在用JAVA,觉得它别有一种风味,呵呵。
:)
手机等设备大都用JAVA编写:)