Java 2 & Hotspot on Linux in 2000 239
djKing wrote to us with the news that
Sun will be releasing a "Java2-compliant JVM for Linux that brings the performance, functions, and Java HotSpot
features of the latest Java specifications to the Linux community", which will be announced at the Java Developers' Conference. As well, IBM will be announcing the free general availability of a JSDK 1.18-compliant JVM, with performance better then that of Windows NT JVMs.
Re:Is there a need for Java? (Score:1)
Yes (Score:1)
Re:Is there a need for Java? (Score:1)
Bravo! Absolutely. In some cases, though, maybe four or five years. My (recently deceased) AMD K6-2 PR300 (real clock 233Mhz I think) wasn't that much faster than an AMD K6 75Mhz at running Java. 4x clock speed won't necessarily translate into 4x execution speed because of other bottlenecks.
IBM JDK 1.1.8 for Linux works great (Score:1)
I have had a lot of problems with JFC under Gnome, but it works properly with KDE and fvwm2. I found issues with the Triteal CDE itself with my latest kernel upgrades, but that affected everything -- not just the JDKs.
The only "bug" I found with IBM's JDK is present on both the NT and Linux versions: it gave me warnings/errors on code that had been compiling clean for months. When I looked into the errors, I found out the IBM compilers were correct, and Sun's and Borland's hadn't been detecting and reporting the problem properly.
My only complaint with IBM JDK 1.1.8 for Linux is that it's performance is comparable to Borland's 1.1.6 on NT, taking about 3-4 times as long as their NT version to run the same application code. My guess is that the problem is my use of CPU-intensive long-running threads -- there might be an issue with the way threads are managed on Linux.
Speaking of CPU-intensive threads, I found I had to drop the thread priority to minimum in order to keep the GUI responsive under NT, but under Linux the GUI remains responsive even if I bump up the priority higher than default.
Re:Is there a need for Java? (Score:1)
Re:Wow, thats admirable.... (Score:1)
Ah, as I suspected. A very big difference. As I said in another post, real-world Java processes usually last more than 9 seconds, so start up time is insignificant. Also, to repeat myself, if you wrap the whole code in a for loop with 200 iterations the JIT should kick in more, especially if it's Hotspot, and it should get much closer to C's speed for 200 iterations.
Re:Dear Clueless (Score:1)
sun is a business. they have shareholders and quarterly profits to make. generally speaking they are ok in my book - java is cool, its _relatively_ open (see IBM) and it will never reach teh level of ubiquity of ms. keep your eyes on reality...
Re:Wow, thats admirable.... (Score:1)
Again, it goes to show that with a minimal amount of profiling and a decent knowledge of the libraries you can really speed up slow Java code quite a bit.
Re:Where is fscking JIT? I've been waiting 3 years (Score:1)
You gotta figure that the recent turnover in Sun Java management is probably part of the recent decision to support Linux. Until the 1.2 pre-releases, the Blackdown VM didn't even include a compiler!
Overall, having Hotspot on Linux, backed by Sun, is a very positive step.
Re:Don't blame Microsoft about CORBA (Score:1)
Re: Tim Bray (Score:2)
James Clark writes about 50/50 in C and Java.
When you say "[Java] certainly isn't slower than Perl/PHP/CFML/etc" you are actually saying "[Java] certain is faster than Perl/PHP/CFML/etc" (just reverse the "isn't slower" into "is faster"). That's not the experience I and a lot of companies I've consulted for have had. YMMV.
perl -e 'print scalar reverse q(\)-:
Re:Uhh. What efforts? (Score:1)
Microsoft's "Java 2" VM is only 1.1.4 compliant. Apple's best release so far I believe is 1.1.6 -- so while I 'm glad Sun is making announcements, I'm even more thankful that there are people like those at Blackdown who are working to make Linux a more viable platform. Java 2 servlet support has been a big boost to the Apache team as well.
Re:Talk is cheap - perl is faster than Java (Score:1)
Java Advocacy (Score:3)
Sun's implementation of the spec may be closed, but it is still more open than a lot of other closed software. Their community source licence, if not that great, is at least a step in the right direction, and if other companies took this step, we would be decidedly better off. It takes time for the corporate world to embrace, understand, and experiment with open software...Sun is heading it the right direction. Keep in mind, they have to make money to survive. Eventually, given the same time C/C++ has had, there will be many good open implementations.
Java being an open specification, with independant, and open implementations, makes it as open as anything else in this world. Just because there are closed implementations, doesn't make Java closed. If Sun started charging $10,000 for their Java implementation tomorrow...what would happen? The whole community would start working on Kaffe, and you can bet IBM (with all they have invested) would do a cleanroom and open source it, but basically, life would go on without Sun. What would all the Visual Basic programmers do if MS started charging $10,000 for VB? Look at how many people use VB! (Don't even get me started on comparing them)
As for Java changing "every five minutes" as some people like to quote, or about it being unstable and buggy. Well, that's true, or at least it has been in the past. But Java is a really new language!!!! I'll say it again...it's new! Java, like Linux in some ways, has been pushed into the spotlight before it's time, because it fills the need better than any of the alternatives. I think Sun has done a great job of moving the languages features forward quickly enough that MS can't hijack it by adding missing/needed features that will in turn tie Java to Windows. Being a full time Java developer, I could never go back to C++/Win32, despite the bugs, and a _few_ missing bits here and there, Java is a _great_ language to work with. Stability and speed, and more open implementations, these will all come with time. Actually, Swing is becoming useable, and the new JIT's are actually quite fast on "reasonable" hardware.
Java is just now really starting to become a viable platform. Linux is in the same vote, it's a relatively new operating system, and is still evolving at a pace at least as quickly (or more) than Java in areas such as multimedia, multitrack digital recording, DVD, USB, component architectures (KOM/Open Parts), etc.
Most importantly, Java is the only real chance Linux has of putting down windows in the enterprise. Even once all the productivity apps are in place on Linux, and the interface (Gnome/KDE) blows away Windows, and it's easy enough for grandma to install, the MS installed base is going to be the problem. Java gives companies a way to easily migrate from Windows to Linux. Java is the link that will let this happen. Normally, convincing a MS based company to develop their inhouse software on Linux would be impossible. But Java is a good language for _MANY_ other reasons than being cross platform, which will get companies to use it, even if it's only on top of Windows. Then one day, when they discover Linux, they will find that they can slowly (or quickly) throw away their Windows boxes without spending a trillion dollars migrating a myriad of software all at once. Without Java, it will never happen.
That is why Linux and Java are a good match.
Re:IBM is likely the motivating force here... (Score:1)
IBM JDK Stability (Score:2)
I know there are some serious problems with native threads on anything less than kernel 2.2 and glibc 2.1.
-=-=-=-=-
Re:Is there a need for Java? (Score:1)
>something useful. Perhaps I sound naive, but I've
>never seen it deployed beyond annoying applets or
>slow as molasses games in COS246 (Java Programming)
Well, the company I work for has a rather large internet app (read millions of users) that is run entirely with Java and Oracle. While much of the development is done in linux, all of the servers are solaris, primarily because of the superior jvm. A great jvm would go along way to further our arguments to try out linux on the production side.
chris
Re:Uhh. What efforts? (Score:1)
I dunno (Score:2)
I'm withholding judgement on JITC'd Java as I haven't found at JITC that will run everything. Kaffe will run my little toy tests, but it dies when trying to run a real app like NetBeans (which is apparently pretty evil, they recommend not running with a JITC). NetBeans under the interpreter runs like it was on a 386. I just downloaded the IBM JDK 1.18. I'd really like to port some Java stuff to C++ and compare for speed. Anyone know of any similar benchmarks that have already been done?
You bet your sweet a** there is (Score:2)
Sometimes we have regrets, but I had those in C and C++ too. On the whole, java has been a great step forward. It could be a heck of a lot better but it is more than usable right now.
Re:Is there a need for Java? (Score:2)
Such as
Didn't think so...
Seems to me that multithreaded Java apps seem to scale pretty well just from throwing more and faster processors at them as long as you're actively using multiple threads, from a single-processor laptop for development to a dual-processor Linux box for testing to a multiprocessor Sun for deployment it's pretty linear.
-=-=-=-=-
Re:Where is fscking JIT? I've been waiting 3 years (Score:1)
http://www.borland.com/about/press/1999/jitlinu
which can be downloaded
Re:Excellent news... (Score:1)
So, ZDNet Labs, this would be that central repository of patches you were looking for? Oh, wait, let me jump to the Office page to get those patches, then the IE 5 page...
--
Re:Yes - you missed a couple... - I can beat that (Score:1)
FreeBuilder [freebuilder.org] - An IDE in Java.
Argo/UML [uci.edu] - A UML editor with cognitive support
Re:Can we stop the feud now? (Score:1)
And dont come mentioning names of programmers, do you think Joy and Gosling are idiots?
Re:But what's wrong with that? (Score:1)
Sun also has to make a buck. However, as I see it, Sun has a history of making a buck by giving the world new and useful technologies. This is in contrast to Microsoft's history of disabling and destroying new and useful technologies, like CORBA. (This is why Microsoft is the devil.)
Sun has to walk a fine line between too open and too closed regarding Java. If too open, Java fragments. If too closed, Java withers. It is certainly debatable as to whether or not Sun is following the right path. Many, such as HP and yourself, portray Sun as Java control freaks. And I admit, you are in a better position to judge than I am.
But to me, it looks like they have done a reasonably good job shepherding Java. The rate of progress in terms of functionality, stability, and performance has been tremendous over the past four years. The documentation is comprehensive, the tools are free, and the source is available.
Maybe I'm naive, but I wouldn't be surprised at all if, when Java stabilizes over the next few years, that Sun hands off the responsibility for Java to some standards body like ANSI. Let's not forget some of Sun's other contributions like NFS. Let's also not forget that Sun is primarily a hardware company.
Re:Speed (Score:1)
Which is in line with what I said (a couple of posts above) about most prgrams being I/O bound more often than CPU bound -- most GUIs spend the majority of their time waiting for input. Of course, fast or no, I'd still like to see cleaner redrawing -- I often have windows that aren't redrawn because some action is being performed. (Yeah, I know I could start the action off in its own thread, but sometimes that's overkill...)
--
Re:He chose a SUN OS to run JAVA (Score:1)
Re:Japhar (Score:1)
whining (Score:1)
copyrighted != closed (Score:1)
Re:Kaffe is fast? Back up your statements, please (Score:2)
At any rate, given significant changes to the JVM and threading model, the Volano results aren't totally applicable.
---
Maybe that's just the price you pay for the chains that you refuse.
finally (Score:1)
Quake V written in JAVA?!? (Score:1)
Re:IBM is likely the motivating force here... NOT! (Score:1)
They first said that it was easy to use Java on the OS/390 (err, MVS...) and CICS. Understand that there were thousands of legacy COBOL programs and CICS transactions that we could not afford to break in switching over to a new architecture. The Java implementation would also have to talk to our databases (ancient VTAM) in order to maintain legacy conversion. But, we asked IBM for an example on how to do this. They could not provide one. We then asked for when Java would even be available as a CICS language (write the Java base and have a CICS-transaction wrapper). Well, in order to do this, IBM said that we needed to write a C-wrapper around the Java code so that our legacy COBOL code could continue to talk to the functions (i.e. COBOLJava is not supported). Not an acceptable answer. We went around and around while we got shuffled from division to division. No concrete answer ever appeared from IBM. We finally came to the realization that IBM wants nothing to do with Java... Any solutions would have to be off-the-shelf (and not IBM).
The poor guy who was talking with IBM kept trying and got the run around. One day, he'd tell his bosses that we can do it, the next, he'd have to report that IBM said it couldn't be done.
That said, I would not be shocked to see IBM support it in their lower-level servers, but from my experience this summer, they do not want anything to do with Java on their enterprise-class mainframes.
Justin
Hmmm.... (Score:1)
Wonderful (Score:2)
Oh, and - It's about freakin' time :)
-----------
"You can't shake the Devil's hand and say you're only kidding."
This would be nice. (Score:1)
"Honestly Closed" is better than "Falsely Open" (Score:1)
I have to disagree - I would rather have Java closed without comprimises than open with such glaring, crippling comprimises.
When it comes to licenses, I'm a stickler - it has to jive with the open source model certification.
Otherwise, you get on a slippery slope...with virtually closed licenses proclaiming to be open.
Embedded systems? (Score:1)
I was also surprised by the anti-NT stance the story takes; it's and IDG story after all. Have I been misjudging them?
Okay, so that was questions rather than statements. Sorry. Won't happen again.
We have an Open Source one. Who cares about Sun? (Score:4)
Transvirtual and the Kaffe Core Team have released Kaffe 1.0.5 (finally!). It's got a new JIT, new processor ports, a clean-room RMI implementation, kernel threads, and much more. For more information see http://www.kaffe.org/ [kaffe.org]
Transvirtual Technologies, Inc. today released Kaffe OpenVM 1.0.5, the only complete Java implementation available with a true Open Source license.
The release heralds a major improvement in the reliability and performance of open source Java implementations. Tests conducted with various Open Source server side Java applications, including the popular Apache/JServ webserver and the Enydra Java/XML Application Server, demonstrate Kaffe out performs its Java Linux rivals by as much as 300%. Kaffe also proves more reliable than other Java implementations which simply hang when running under heavy load.
Transvirtual targets Linux as their primary server-side, desktop and embedded environments. Kaffe, developed using the Open Source model, once again demonstrates how Open Source can offer a better, cheaper, faster and more reliable product than proprietary alternatives.
This new release of Kaffe also offers a number of new features, including:
* Bundling of the KJC Java compiler from Decision Management Systems (http://www.dms.at/kopi) - a complete JDK 1.2 Open Source compiler suite.
* A complete Remote Method Invocation implementation written in collaboration with the GNU Classpath project (http://www.classpath.org).
* Support for the the popular Cobalt Network Web Servers.
* Support for the MIPS and StrongARM processors (Kaffe already supports Pentiums, Sparcs, Alphas and Motorola processors).
For more details on Transvirtual Technologies see their web site [transvirtual.com].
For more details on the Kaffe Open Source Project see The Kaffe Project Web Site [kaffe.org].
All names and trademarks are the property of their respective owners.
Speed (Score:1)
Java can also be natively compiled, though there are few available compilers (commercial or otherwise). As a compiled (or JIT-compiled) language, the major speed bottleneck is garbage collection -- performance is comprable to C/C++ with a garbage collection package.
Of course, the AWT package (for graphics) is not particularly impressive, either in speed or in basic window management such as redrawing.
Also, remeber that execution speed is not the only measure of a program. Java is easier to write and maintain than the C variants (from anecdotal evidence). From personal experience I tend to agree -- I know C++ better, but I'm still faster to develop and debug in Java. Most programs do not use the CPU 100% of the time anyway; there is often some I/O bottleneck.
--
Re:Is there a need for Java? (Score:2)
End-of-Thread
-=-=-=-=-
Dear Clueless (Score:1)
Re:Where is fscking JIT? I've been waiting 3 years (Score:1)
Re:This is good news. (Score:1)
My guess would be that they are probably counting on having the best Java tools. Also, with a flattened software landscape that they essentially control, it will be easy for all of the shops using NT to move on over to SUN hardware for better performance.
Re:Is there a need for Java? (Score:1)
It would be better to keep the platform dependence part of things hidden inside the JVM/JIT. Sun, the people who build the machine and are intimately familiar with its capabilities, should do the performance tweaking for you inside of the JVM.
then (Score:1)
Re:Why should Sun care about Linux anyway? (Score:1)
It makes sense for Sun to push Java on all the low end platforms. Since there are invariably parts of the business that do not run on Java, it is clear that people could migrate to Sun hardware/Solaris/Java more easily from Linux/Java than from NT/Java simply because Linux shares a common Unix denominator with Solaris.
Re:He chose a SUN OS to run JAVA (Score:1)
I'm generally using Java as a replacement to VC++/MFC and VB, so I'm not particularly worried about Swing. WFC is quite fast (considering it's just wrapped ActiveX controls).
I'm betting that MS won't include a Swing form builder in VJ++ 7, but will rather including AFC (Application foundation classes), which IMHO look and work much better than swing. They're also written in 100% java, and have all the windows type functionality that swing lacks. (someone needs to teach sun about GUI design).
Inefficient code (easy to spot the problems) (Score:2)
Can you post the input data too? And the perl version? It's trivial to make modifications to this Java code to speed it up by 5-10 times.
This code doesn't prove anything about Java's execution speed. It just proves that buffered I/O is more efficient than reading a byte at a time.
Any Java programmer who has more than a few months experience will immediately spot the
problems.
1) Doesn't use buffered I/O at all. A trivial one line fix adding either BufferedReader or BufferedInputStream would boost speed tremendously.
2) Usage of StreamTokenizer on an interactive stream. A bug in JDK1.0-1.2.1
http://developer.java.sun.com/developer/bugPara
3) Usage of synchronized Vector and Hashtable operations instead of ArrayList and HashMap.
4) Usage of StreamTokenizer! Use BufferedReader and indexOf() or StringTokenizer instead.
Like Linux vs NT, let's not post "cooked" or "biased" benchmarks. The only real way to run these sorts of benchmarks is to have a contest between C++, Java, Pyhton, Perl, and C coders, and have the final result judged on speed of execution, speed of development, clairity, and ease of reuse and maintainability.
not longer in java, not c++ (Score:1)
C++ on the business enterprise server? Sure, it exists, but, uh, it didn't really work out too well. That is why this Java thing is pretty popular... it's the successor to the server-side languages that DID work. [Though i'd argue that the successor to Java should ironically be Smalltalk , but, that's for another time]
NetBeans (Score:1)
It's a decent speed.
for compiled Java code, try Borland JBuilder... it's a memory hog, unfortunately.
Re:This is good news. (Score:1)
Why? Because, while Sun wants people to be able to leave M$-land, they want them to leave it for Sun-land, and that generally doesn't mean going to Linux.
Re:IBM is likely the motivating force here... (Score:1)
Sun doesn't like linux (Score:1)
Of course I could just be too paranoid but I doubt it. Lots of folks see MS as the big evil threat but I think that Sun is also doing stuff, just not as obvious...
And remember that MS doesn't have the large system market, those are solaris machines we're going up against when Linux scales better. (And I can get a 16 processor AMD card
Now if I could just figure out IBMs motives..
bobm
Re:Is there a need for Java? (Score:1)
IMHE(xperience), the programmer resources are vastly more expensive than the iron (if they are not then your dollars are being spent in the wrong places -- or you have management which excels in getting great programmers for cheap prices (in which case they aren't getting as good a deal as they think)). Re-engineering code for a move to a new platform because you NEED to move to the new platform is very expensive.
Good management will hire good people to do it right the first time (portable, with the right algorithms, and rock solid code) and deploy it on the right systems with an eye towards potential changes in platforms down the road.
One might argue that isolating platform-dependent code into its own "module" (depending upon what a module is in your language of choice) is the solution -- your server-dependent tweaks go there, and that's what changes in the future. Point taken, but then why are we arguing about not using Java then: that's exactly what JNI was designed for.
Java and linux = Bring me the enterprise baby! (Score:1)
Reason being, we deploy Oracle Applications Release 11.0, as do thousands of other enterprise companies, and thier is no way for clients to currently connect as there is no good java VM nor is there a working plugin.
amazing alot of enterprise features need java, a pure java vm would make it easier for Veritas to port its file systems & management software over, oracle applications could work, and just a bunch of business reporting and system software could fall in.
Can't wait! i'd say in the next 6 months, linux will have a system with all the features, and be able to innovate more instead of play catchup.
Re:Speed (Score:1)
> particularly impressive, either in speed or in
> basic window management such as redrawing.
The AWT may be slow, but it's a beautifully designed API. Our company does a lot of UI prototyping (UIs that need to be driven by massive amounts of actual data); each of our UI toolkits is built for rapid development, flexibility, and visual snazziness. These toolkits go through several iterations every year as they are tuned and refined -- without the simplicity and elegance of the AWT's rendering model, we'd be pretty screwed.
Granted, none of this stuff is intended for massive deployment on anything other than an intranet that's within the tight grip of a professional IT manager. The clumsy manner in which the JVM must be invoked under most OS's (mucking about with classpaths, command line invocation, the crappiness of netscrape- and ie's JVM) and, yes, the abysmal speed of more complex Java UIs severely hampers the wide distribution of Java user interface applications to Joe User.
Just YAAWSHSTP (Yet Another Area Where Sun Has Screwed The Pooch).
whoops (Score:1)
Re:I use it ;) (Score:1)
just ignore everything i've said (Score:1)
Java used almost everywhere for new development (Score:3)
In terms of academia and research, if you look at the IETF and W3C, almost all "new" protocols start out with Java prototype implementations. This is particularly true of the W3C. Jigsaw, XML, XSL, P3P, SVG,
If you look at commercial websites, E-Trade and Datek come to mind, you'll see Java on the backend.
My own free pop/webmail/antispam service msgto.com) uses Java for everything, JSP, servlets, SMTP, POP server, etc. It's also
faster and more responsive than Hotmail.
Yesterday, two spammers took "revenge" on our site by redirecting spam bounces to my site. In a
10 hour period, about 1 million bounced messages were received and discarded on a lowly dual-processor Solarisx86 box. Even now, we are getting about 10 messages per second but 'top' shows only 10% CPU utilization for the JavaVM and 30M memory used. Java definately scales.
Solarisx86 was used for only two reasons. One, when development was started, JDK1.2 wasn't available on Linux, and our servers use JDK1.2 heavily for its new garbage collection/memory management features and fine grained security.
Second, Solaris can scale to thousands of threads across multiple processors. Only TowerJ on Linux allows massive numbers of threads (by not using kernel threads), and Java's I/O mechanism relies on launching large numbers of threads. But TowerJ is not JDK1.2 compliant: bummer! Otherwise, I would love to have a bunch of rackmounted VA Research boxes.
The only place Java really failed was on the desktop application area. But I'm of the opinion that the general trend is that we are moving away from desktop applications and more towards web-based applications. So in a sense, most new desktop apps will fail, regardless of the programming language they are written in, and especially those that try to compete with areas Microsoft dominates. When was the last "killer-gotta-have-it-client-side app created" I can't think of many besides games, browsers, and other multimedia related utilities.
In the past, if you wanted to manage an address book, or a database, someone would ship you a VB or some other 4GL based app, that displays forms on your desktop and inserts them into the DB. Nowadays, most of these apps can be done on the network. This covers most business uses.
What's left for the desktop apps is multimedia. Music, Games, animation, art.
This Sun/IBM announcement is great news. I only wish that IBM would come out with a JDK1.2 compliant VM, because IBM seems to be alot better at optimizing VMs.
-Ray
Re:Is it IBM vs. Sun?? Does Netbeans work? (Score:1)
I installed the 1.1.8 final for win32 and Linux. The win version runs Netbean 2.1.1 fine, but the Linux version won't.
Have I installed wrong? Help.
Re:Speed (Score:1)
tell that to an end user that is waiting. They don't care about that. They just wonder why is that so slow.
I have done a little Java programming, and think that it is a really nice language to program in. IHave you tried Tcl/Tk thou? It is a scripting language that is similar to the Java programming language, only not with as many methods available.
Re:He chose a SUN OS to run JAVA (Score:1)
Instant compiling...takes 2 seconds, not 20 seconds to compile tens of classes.
Intellisense, detects installed packages and lists methods and properties as you type etc etc.
Hell, intellisense even extends to javadoc blocks in java, so you type @ and it'll like @param @comment etc etc.
Code fixed - new timing results... (Score:1)
Jdk 1.1.8:
Original Code - 7.30 seconds
Revised Code - 9.23 seconds
Jdk 1.2.2 (Current production release)
Original Code - 5.05 seconds
Revised Code (com.sun...collections) - 5.38 seconds
Revised Code (java.util collections) - 5.0 seconds
Jdk 1.3 (Beta release)
Original Code - 3.79 seconds
Revised Code (com.sun...collections) - 4.40 seconds
Revised Code (java.util collections) - 4.20 seconds
Analysis:
This surprised me a bit. As seen above, my "enhancements" actually slowed down the program a bit! I think this might be partly due to my replacing the for loops and get(int) calls with iterators, which is easier on the coder but didn't lend itself much to JIT based enhancements. This goes to show that no matter how smart you think you've been, you should always run an optimizer over your code from time to time and figure out why it is slow in some areas you would not expect slowness...
It also seems to show that syncronized calls are not really hurting us much, though that might be reading too much into the results.
But what should be very obivous and exciting (nad even quite relevant to this article) is the DRAMATIC speedup from the 1.1.x VM to the 1.2 or 1.3 VM!! About a factor of two in this case. I think that should help demonstrate why we want a stable 1.2 VM on Linux quickly.
Here's the code for those interested - note that to use the 1.1 collections package you just need to import com.sun.java.util.collections.* at the top of the code. That's how easy it is to switch upwards as well, everyone should start using the new collections package right away!
----------------------
/* Copyright (C) 1999 Lucent Technologies */
/* Excerpted from 'The Practice of Programming' */
/* by Brian W. Kernighan and Rob Pike */
import java.io.*;
import java.util.*;
class Chain3 {
static final int NPREF = 2;
static final String NONWORD = "\n";
HashMap statetab = new HashMap();
Prefix3 prefix = new Prefix3(NPREF, NONWORD);
Random rand = new Random();
void build(InputStream in) throws IOException
{
Reader r = new BufferedReader(new InputStreamReader(in));
StreamTokenizer st = new StreamTokenizer(r);
st.resetSyntax();
st.wordChars(0, Character.MAX_VALUE);
st.whitespaceChars(0, ' ');
while (st.nextToken() != st.TT_EOF)
add(st.sval);
add(NONWORD);
}
void add(String word)
{
ArrayList suf = (ArrayList) statetab.get(prefix);
if (suf == null) {
suf = new ArrayList();
statetab.put(new Prefix3(prefix), suf);
}
suf.add(word);
prefix.pref.remove(0);
prefix.pref.add(word);
}
void generate(int nwords)
{
prefix = new Prefix3(NPREF, NONWORD);
for (int i = 0; i nwords; i++) {
ArrayList s = (ArrayList) statetab.get(prefix);
if (s == null) {
System.err.println("Markov: internal error: no state");
System.exit(1);
}
int r = Math.abs(rand.nextInt()) % s.size();
String suf = (String) s.get(r);
if (suf.equals(NONWORD))
break;
System.out.println(suf);
prefix.pref.remove(0);
prefix.pref.add(suf);
}
}
}
class Prefix3 {
public ArrayList pref;
static final int MULTIPLIER = 31;
Prefix3(Prefix3 p)
{
pref = new ArrayList(p.pref);
}
Prefix3(int n, String str)
{
pref = new ArrayList();
for (int i = 0; i n; i++)
pref.add(str);
}
public int hashCode()
{
int h = 0;
Iterator i = pref.iterator();
while ( i.hasNext() )
{
h = MULTIPLIER * h + i.next().hashCode();
}
return h;
}
public boolean equals(Object o)
{
Prefix3 p = (Prefix3) o;
Iterator i = pref.iterator();
Iterator i2 = p.pref.iterator();
while ( i.hasNext() && i2.hasNext() )
{
if (!i.next().equals(i2.next()))
return false;
}
return true;
}
}
class Markov3 {
static final int MAXGEN = 10000;
public static void main(String[] args) throws IOException
{
Chain3 chain = new Chain3();
int nwords = MAXGEN;
chain.build(System.in);
chain.generate(nwords);
}
}
Re:But what's wrong with that? (Score:1)
Re:Is there a need for Java? (Score:1)
Where you might argue with more force (or at least as much force as an AC argument can have) is to say "Sun will try to always produce Java features quickly enough that only Solaris can have a good VM and thus people will want the Sun box". Now that might be closer to the truth, but there are enough other people producing good VM's (IBM, Kaffe) and working with Sun in specifying standards that I just don't buy that argument as working for Sun even if that is their plan.
So I guess my stance on that would be that even if you are correct and Sun has an evil plan in mind, that it won't work anyway so it doesn't matter - the programmers always win in the end. I personally don't think Sun has an evil plan so much as it wants to promote UNIX in general.
Re:This is good news. (Score:2)
It continued to be such a joke and a failure on the client side for so long that they had to play up this server side story for it. They've completely lost sight of what Java was going to do for them.
There was once a coherent strategy in pushing Windows off the desktop in favor of thin-clients, but now, well, it's hard to imagine that you could field a thin-client that could compete with commodity thin-client hardware based on PC components. So, even if, and it's a HUGE if, you could displace Windows (and Linux) on the desktops, you'd still have to talk to PC hardware being used as thin-clients. Seems like a win for Intel or StrongArms maybe, but not for Sun.
So, Sun turns toward the server and middleware for Java dominance. This seems like a move of desparation, to show SOMETHING for their Java investment. If they succeed at flattening the server side with write-once-run-anywhere Java applications, they will have succeeded in commoditizing the server side.
In such an environment, you'll have IBM, HP, Windows NT and some large number of commodity server Java boxes (made in the far east) to compete against. Why would Sun, who have done so well in differentiating themselves on the server side with the best compilers, best RAS, most scaleability want to flatten out the software landscape? It just doesn't make sense from the standpoint of strategy.
Sun is being pulled around by the nose by a Java Strategy that's taken on a life of it's own. They pay $500,000,000 for the world's most popular Java application (StarOffice, which BTW uses C/C++ on the server side) only to give it away apparently in a desparate attempt to legitimize Java on the desktop. They now have to support the development of Java on their biggest up-and-coming competitive environment, Linux, to make sure that the phenomenal growth of Linux doesn't marginalize their precious Java. It seems crazy.
At the end of the day, what large server side applications will be written entirely in Java? All of those systems will have working C/C++ compilers, after all. With C/C++ you should be able to get much greater performance, stability, more immunity to environmental changes, less developmental headaches (no nervously watching evolving Java standards) and more qualified programmers (most good Java programmers are good C++ programmers, but not vice versa).
I can see Java used like stored DB procedures, and for various kinds of utility programs, middleware glue, quick projects, you know, all those things that Perl does quite adequately already, but take over the server side? How? If anybody dares to field a commercial package written in Java, someone else could beat them up with one written in C/C++.
This is the essential point that people don't seem to understand about C/C++. Your operating systems are written in them for a reason. Because your operating systems are written in them, they will always be the most stable and mature compilers available. Because this is true pretty much everywhere, they will be the standard in portability. Maybe not the kind of VM portability where you can compile it here and it will migrate over to execute somewhere else, but what does that buy you over just having good C/C++ compilers everywhere (which you already do, see above).
Java is probably a better language than C++ because of garbage collection alone (and there are other significant advantages), but you need more than just better to displace a truly ubiquitous language like C/C++.
From my perspective, I see far more developers using Java than users for the forseeable future.
When some wide-eyed Java fanatic tries to tell me that everyone will be using Java next year, I'm reminded of the Amway guy who told me 10 years ago that I could be making $90,000/yr. in just 90 days with Amway, much more in 6 months. I told him to go away and come back in 90 days if he was making $90,000/yr. Needless to say, he wasn't. Java was supposed to be really big next year for the last 3 years now. It's getting tired.
Weren't we supposed to be using Java for SOMETHING by now? People using the Hot Java browser, raise your hands! Let's see, it's not good for browsers, nobody would dream of writing an RDBMS like Oracle in it and in the middle, it competes with Perl, Python, C/C++ and Tcl/Tk. Seems like a squeeze to me.
I see where Lotus got out of the Java client business just the other day. Corel got out awhile back too. StarOffice and their free product is not much of a showcase of a vibrant Java marketplace.
Don't point me at Java support in Oracle or Java support in some ORB or another. All of those environments have quite stable and working C interfaces too, thank you. Show me large numbers of users using Java day in and day out. I bet those same users use about 20 times more C/C++ in their OS alone to support this one app. For every one user who is using a Java app today, I'll give you 50 VB/VBA users and 100 users of apps written in C/C++. There may be growth in Java today, but is it like the growth of Linux where almost no Java is used?
I'm not a Sun hater, nor am I anti-Java. I really like Java as a language. I was turned off years ago by it because I didn't want to jump on while they were changing it so rapidly and it seems that it's just now starting to stabilize.
Maybe Java will be really big someday, but I don't see that someday from where I stand.
Re:No benchmark covers all cases... (Score:2)
I got to be pretty familiar there with just about every sort of odd cross-platform compatibility problem one could run into.
I also did a lot of C++ work as well, which was great... as long as you use RougeWave collections and DB packages, along with Great Circle or Purify (to make your program stable enough to run without Great Circle).
But there is no way that even at my peak of use of any of these languages, even using Emacs as an editor, that I could approach the speed of Java development. It's not quite as fast as it might first appear as you have to spend a little more time optimizing for performance over other langauges, but you more than make up for the in the stability, portability, readability, and documentation gains you get. I go back to C or C++ when I have to (for instance to write a JNI wrapper for a C or C++ library) but I think you'd have to be mad to try and write some of the software I'm working on now in anything but Java.
Cygnus GJC? SOAP/XML_RPC? (Score:2)
Re:Yes! - Re:Is there a need for Java? (Score:1)
Java (with JIT) performance poor - stats follow (Score:1)
The test is based on a Markov chain algorithm - stats on p. 81.
The results are on a 400Mhz PII
C - 150 lines of code, 0.3 seconds to run
Java - 105 lines of code, 9.2 seconds to run
C++/STL/dequeue - 70 lines of code, 11.2 seconds to run
C++/STL/list - 70 lines of code, 1.5 seconds to run
Awk - 20 lines of code, 2.1 seconds to run
Perl - 18 lines of code, 1.0 seconds to run.
Note that Perl performs very well considering how few lines of code it has.
The Java performance is not terribly encouraging (C++ is even worse, considering the pain it takes to write).
great for Java apps like jMax too (Score:1)
Re:Kaffe reported to be 2X as fast as HotSpot (Score:1)
it has a _looooong_ way to go before it is as good as the 1.2 Blackdown JDK (which in turn is nowhere near as good as the 1.1.7 Blackdown JDK, which is in turn crap compared to the windows JDK). Kaffe is one of the lowest rungs on the totem-poll.
Unless they have been keeping lots of cool changes out of their snapshots..
Re:We have an Open Source one. Who cares about Sun (Score:2)
Re:This is good news. (Score:2)
K&R C, I can believe. But there are still proprietary OSes out there whose one-and-only compiler doesn't even grok exceptions, and I'd hardly call that impoverished language C++.
This is a troll, right? C and C++ are half-marked minefields, and the industry has spent the last decade or so proving that getting reasonable robustness with them requires such superhuman diligence that you actually get more money if you don't even bother to try.
Ah yes, the joys of DLL Hell.
Instead you can wistfully watch the evolved C++ Standard and wonder which parts your vendors might bother to support.
This is an artifact of C++ having arisen first. Most good C++ programmers have learned Java for the same reason they'd learned C++ - it's better than what they had before. Most Java programmers who didn't already know C++ are too inexperienced to be good (the rest were doing amazing things in Smalltalk instead).
IMHO the notion of code that's married forever to one machine is the next piece of cultural baggage we're getting rid of, and Java (the first widely-deployed language that can safely receive and run untrusted code from elsewhere) will be the centerpiece.
Kaffe is fast? Back up your statements, please (Score:2)
For real, 3rd party benchmarks, check out the Volano report at:
http://www.javaworld.com/javaworld/jw-10-1999/j
In terms of speed, Kaffe rated a 389, while IBM's JDK got a 1770. Yup, the IBM kit was more than 4 times as fast. On top of that, Transvirtual doesn't pass Java compatibility tests, so if you develop on their VM, you have no reason to believe that your code will work on a real JVM.
Open source is not necessarily equal to best of breed.
--JRZ
Re:Where is fscking JIT? I've been waiting 3 years (Score:2)
Re:Is there a need for Java? (Score:2)
Now I am working on all server side Java stuff. The whole company is doing almost everything in Java, as are many others.
This is not a flavour of the month kind of event, this has been slowly building for a long time and there looks to be no end in sight. A strong VM on Linux means that at any time, you can swap out that Solaris or HPUX or AIX EJB server for a Linux box if it meets your criteria for the hardware you need. It will be the force that finally shakes loose any doubt of Linux being an equal in the corperate world. It's a shame that Java VM development on Linux has been so slow, but at last we are seeing good progress...
Re:Question: Cross platform compiled Java? (Score:2)
Real benchmarks (Score:2)
Re:Is there a need for Java? (Score:2)
This is largely in line with comments made by others; that programmer resources are more expensive than hardware in the long run. I also believe that the hardware is so changing so quickly that language decisions made on the basis of performance are generally meaningless within a couple of years.
Few big companies are going to build large multi-user applications from scratch; Java is like the "4GLs" in that they have a huge respository of useful things that are just standard. It is better than the 4GLs in that it is faster and more generalised - and it works everywhere.
It is great to be able to combine the two "obvious" (to me anyway) trends of the future, java and linux.
Just MHO of course.
Re:Hmmm.... (Score:2)
"Sun is also working with the Blackdown Porting Group to bring Java2 to Linux."
-----------
"You can't shake the Devil's hand and say you're only kidding."
This is good news. (Score:2)
Is there a need for Java? (Score:2)
The article really sounded as though there is a pressing need to support Java better on Linux machines, but for some reason I thought the general feeling among Linux users was that Java is slow and not really as useful as traditional programming languages.
I'm wondering if anyone out there uses Java for something useful. Perhaps I sound naive, but I've never seen it deployed beyond annoying applets or slow as molasses games in COS246 (Java Programming) And java support in Netscape seems to be lacking to put it nicely.
I've done some reading about servlets and Jserver pages which seem quite interesting. Does anyone have any experience with them or experience with gnu-jsp?
Re:Yes! - Re:Is there a need for Java? (Score:2)
"That's typically what people in here decry - the fact that there is so much hype for so little delivery."
Those people generally seem to be unaware of anything else but applets. One of the reasons there are so many Java products at this moment is because its a profitable business. I.e. people actually buy and use stuff like JBuilder, Visual Age, etc.
You are right that SUN is repositioning Java all the time. They have to because there's a lot changing. A year ago XML was just a spec. Now it's the latest hype. Java is right in the centre providing tools, parsers etc. I don't think that's bad.
Then Jini, I really like the ideas behind that. Its something truly innovative. It doesn't seem to hurt other things in Java so what's your problem with Jini?
"...no tool can satisfy all these diverse needs as easily as Sun would have you believe"
Sun doesn't want you to believe that. They're offering different versions of their JDK now. A standard version, an enterprise version, a micro edition (coming in five flavors if I remember correctly). Each is targeting a different portion of the market.
I'm sorry the world is spinning too fast for you these days.
This is a Good Thing (tm) (Score:4)
The direction middleware (such as application servers, transaction monitors, messaging servers, etc) is going is Java, like it or not (I happen to like it quite a bit). Enterprise Java is getting even more hype in these areas than Linux itself *grin*.
As I've personally just been doing an overview of a systems architecture for a large (fortune 50 or so) company's internal functions, I can tell you that Java support is really holding back a lot of the enterprise middleware products that are available for NT, Solaris, AIX, etc. I had to recommend not using Linux because these enterprise applications are not available for Linux. Hopefully, this move from Sun and IBM's great work on Linux JVM's will help to remedy this situation.
Plus, with the Apache Jakarta code finally having dropped (thanks again Sun!) it will be nice to have a fast, stable 1.2 JVM. I've heard that the Blackdown port is relatively stable, but the Volano benchmarks show it to be relatively slow.
IBM is likely the motivating force here... (Score:3)
But what's wrong with that? (Score:2)
Sun didn't want anyone to change Java, so that it would be a "write once, run anywhere" language. OK, that's a reasonable goal. But they did that by prohbiting anyone but Sun from making changes in Java. They should have done it by establishing a Java standard, with trademarks attached to it and a certification program, instead of casting the software in concrete and prohibiting any innovation by people outside of Sun. And now, they've lost. Their big expensive lawsuit against Microsoft means nothing, because Microsoft simply bought their Java VM from someone other than Sun.
Graft the Kaffe JITC onto Blackdown (Score:2)
With Java designed the way it is, it should be a truly no-brainer hack to graft the Kaffe JITC onto Blackdown. If a hack it would be at all. Perhaps the relative hooks in the JITC should be exposed with CORBA, if they aren't already, that is.
Re:Is there a need for Java? (Score:2)
The article really sounded as though there is a pressing need to support Java better on Linux machines, but for some reason I thought the general feeling among Linux users was that Java is slow and not really as useful as traditional programming languages.
The language itself has a conceptually very clean design placing it in the popular class of things that are easy to learn and do simple things with.
The standard libraries support a disgusting number of things, so again, simple tasks are often a mere matter of programming.
Java has decent support on various different platforms, especially those that are poor in programming tools.
Hardware's "cheap".
I personally thought Java was the greatest until I became familiar with Unix.
sklein
InfoWorld problems and state-of-the-JVM (Score:2)
The current 1.2 JVMs for linux aren't really all that good. There are speed problems, functionality problems... a lot of problems. They're certainly not ready for a real deployment in anywhere near a mission critical situation. Fun to play with, but not business ready yet.
Remember that many of the difficulties encountered when porting this around are due to the very SolarisThreading-centric 'reference' implementation provided by Sun -- unless they're willing to do something about that, they're in the same mess that Blackdown/IBM/HP/etc are.
Is it IBM vs. Sun?? (Score:3)
The IBM JDK does need a kernel 2.2/glibc-2.1-based machine, but if you're "into" Java, you're going to want to be on those versions anyway for the improved native thread support. (read: "working native thread support.")
We'll have to see how things turn out in a few months regarding a Java2 JDK, but I'd put my money on IBM. Sun's good at talking the talk, but IBM has proved themselves to also be good at walking the walk. (And it seems like the poor Blackdown guys have just been getting the shaft...)
-=-=-=-=-
Re:Question: Cross platform compiled Java? (Score:2)
Note that it is very much a commercial product and rather pricey IMHO.
-=-=-=-=-
Re:Java (with JIT) performance poor - stats follow (Score:2)
What all that means is, if you wrap a for loop with say 200 iterations around each program, the Java code should be relatively faster per iteration, because after a while the optimisations will trip in - and the initial overheads will be constant, thus less significant.
Re:Is it IBM vs. Sun?? (Score:2)
Thats interesting that you've had success with the IBM JDK 1.1.8. I had lots of problems even running IBM tools for DB2 under their release, although they ran well under Blackdown 1.1.7v3.
Weird. I hope they get all those revisions sorted out and everyone just gets behind a nice, solid v1.2.
And a little more speed can't hurt.
Hotnutz.com [hotnutz.com]
Excellent news... (Score:2)
Re:Is there a need for Java? (Score:3)
Some of the things that I personally think make it ideal for server-side programming are: excellent database API (JDBC), native support for http and ftp xfers, multithreading, a very easy to use exception handling mechanism, and the object-oriented programming model can be mapped very well onto things like database and file objects. When you're not trying to do interactive graphical apps, speed is very good and only a few percent behind compiled apps with most things I've seen.
The cross-platform-ability also makes it easy to develop on Windows or Linux boxes, then take the same code and drop it on your Sun E10000 to deploy. You just have to make sure your Windows-based developers aren't using MS J++ and writing incompatible code...
-=-=-=-=-