Risks of Ruby
It's just another scripting language.
Bruce Tate on InfoQ: Myth versus reality: Rails is a silver bullet.
People have failed with Rails, and many more will fail. If you apply it without the requisite skills, you'll fail too.
On a similar note, if Java's not your problem, Ruby will not be the answer. Most software development problems are not related to technology. If you're thrashing, Ruby on Rails will only help you thrash faster.
Practical Multithreading: Part 2
Live, from St. Louis, it's Dale Wilson!
Today's OCI C++ lunch features Dale Wilson on multithreading. I missed his talk last month on syncrhonization. This month Dale focuses on data sharing.
First person is Dale now.
The problem
The simple function:
int sequenceNumber() {
static int seed;
return seed++;
}
is thoroughly non-thread-safe.
Fix Number One
One fix for the problem is
int sequenceNumber() {
static int seed;
return atomic_increment(seed);
}
where atomic_increment() is implemented by using a hardware instruction that does the right thing.
Fix Number Two
On single processor machines this solution
class Disabler {
Disabler() { cli(); }
~Disabler() { sti(); }
};
int sequenceNumber() {
Disabler safe;
static int seed = 0;
return seed++;
}
works. Here I'm using the RAII (resource allocation is initialization) style to clear the interrupt flag on entry to the function and set the interrupt flag on exit from the function. This is very fast and runs with very low overhead. But it cannot be used on multi-processor system unless the processor affinity of the process is set to a single processor.
The Real Solution
The real solution, of course, is:
mutex seedMutex;
int sequenceNumber() {
mutex::guard(seedMutex);
static int seed = 0;
return seed++;
}
(Starting a thread in constructors is a bad thing.)
Mutex Fundamentals
To protect data with a mutex:
- Identify small sets of coherent shared data. (As small as possible, but no smaller.)
- Protect each set with a mutex.
- Use RAII guard to lock/unlock the mutex.
If you lump three or four sets together, that's fine sometimes. However, the sets should not intersect, or the mutex approach will not work.
Mutexes should be locked for a short period of time. As short as possible, but no shorter: If you need to look at the shared data and make a decision, lock the mutex until you've made the decision and committed to it.
Do not perform operations on the outside world while a mutex is locked. Making CORBA calls while holding a mutex is a bad practice.
Minimize shared data.
Advantages of mutexes:
- Rock solid
- Well understood
- Easy to use
Disadvantages of mutexes:
- Deadlock
- Priority inversion
- Thread starvation
- More powerful than necessary
Recursive mutexes should be avoided, particularly near condition codes. (The designer of the pthreads API put recursive mutex in as a joke.)
If you think you need recursive mutex, then your design is wrong.
ReadWrite Mutexes
There are performance penalties associated with mutexes. Excluding multiple readers can cause major performance problems.
Think the subject index in the UCLA library. It's read many more times than written.
To solve this problem, a ReadWrite mutex can be used. But ReadWrite mutexes is tricky to implement. For example, Boost recalled its ReadWrite mutex.
ReadWrite mutexes that lets you promote a read mutex to a read/write mutex is always suspicious.
Lock-free, wait-free data structures and algorithms
Why can't we use atomic operations all the time?
Answer: Lock-free and wait-free data structure and algorithms.
(Used to be called non-blocking. Later renamed lock-free/wait-free.)
Given a data structure and a set of operations to be applied to it, a lock-free algorithm guarantees that at least one operation will succeed. It avoids some of the mutex overheads. Starvation is still possible.
A wait-free algorithm guarantees that every operation on the data structure will complete within a predictable bounded number of steps. Wait-free algorithms are usually complex and slow. But for certain real-time systems, the timing guarantee requires them. And they do work.
Solving the consensus problem.
Various atomic primitives have different consensus numbers---the number of threads that can simutaneously accessing the feature that can be "sorted out." You want your consensus number to be infinite.
We'll look at three atomic operations:
- Compare and swap (CAS)
- Double compare and swap (DCAS)
- Load Locked/Store Conditional (LLSC)
Compare and swap
Here's what CAS does:
templatebool CAS ( volatile IntegralType &target, IntegralType expected, IntegralType replacement) { ATOMIC: if (target != expected) return false target = replacement; return true; }
One advantage of CAS is that it is available on a variety of platforms. The disadvantages of CAS are that it is barely strong enough to solve the problem, and that it doesn't solve the A-B-A problem.
Double compare and swap
DCAS does a single compare, double swap:
templatebool CAS ( volatile IntegralType &target, IntegralType expected1, IntegralType replacement1, IntegralType expected2, IntegralType replacement2) { ATOMIC: if (target != expected) return false target1 = replacement1; target2 = replacement2; return true; }
The problem with DCAS is that it doesn't exist. There are many papers written that assume the existence of such an operation. There results are beautiful but not practical.
Load Locked/Store Conditional
Here's what Load Locked/Store Conditional looks like:
templateIntegralType LL(IntegralType &target) { ATOMIC: dohicky.lock(); return target; } void SomethingDangerousHappens() { dohicky.unlock(); } ...
Dohicky is a technical term here. LLSC is more powerful than CAS and DCAS. And it actually exists on some CPUs (i.e. Xeon). The disadvantages of LLSC is that "something dangerous" is poorly defined; and there is often only one Dohicky per CPU.
So CAS works and is available on many platforms.
General purpose CAS-based Lock-free algorithm
- All access to the data structure goes through a CAS controled pointer.
- Writer allocate new structure and swap it it./li>
- Need lock-free allocator and lock-free deallocator (a garbage collector)
And any platform that relies on a garbage collector is fundamentally wrong. (Steve Totten: This talk is not only practical multithreading. It's opinionated multithreading.)
Special purpose CAS-based Lock-free algorithms
Practical (but complex!) lock-free implementations exist for:
- Linked lists
- Queues
- Deques
- Maps
The CASContainer
I wrote CASContainer not to fit a traditional data structure into a lock-free algorithm, but try to find the natural data structures for a lock-free algorithm.
I added it to the the Thread Support Library.
As long as you limit yourself to the capabilities it offers, you are fine.
It's essentially a linked list:
- push uses compare and swap until it succeeds.
- swap_list puts a new list into the container and get back what used to be in the container.
- Pop-all swaps an empty list in.
- push_list pushes a list into the container.
I so much wanted to do Pop One. It can be done by pop_all, remove the desired entry, and then push_list the remainder back. This will destroy the ordering of entries in the container if ordering is important. (Other threads might have pushed stuff into the container while you have the list checked out.)
However for a common use case---a single consumer/multiple supplier queue, order is preserved.
A Hybrid approach
An unresolved problem: Lock free algoriths do not synchronize threads.
A hybrid approach has to be used for the dispatching problem from last month's lecture.
The performance numbers are very interesting.
First person is me now.
Dale shows several charts comparing the various approaches on different arhcitecture/operating system. I couldn't catch all the details. But I did hear something alone the lines of "Did I tell you I like the AMD chips." "But my Xeon is more expensive than your AMD."
Using OpenSSH With Cygwin
It works a lot better now.
I have learned a few more things about Cygwin since I posted Ten Steps To Higher Cygwin Productivity 14 days ago:
- I need to add another word smbntsec to my CYGWIN environment variable in order for it to pick up the file permissions from Samba. This fixed a problem I have at work where my home directory is on a Samba share and no matter what I do (chmod 600 from within Cygwin, or change the security settings using Windows properties box) all files on that share are readable by the world. OpenSSH didn't like it because my private key is world readable. The smbntsec word cured that. And now I don't have to fall back to using my passwords to log in to remote systems.
- I read up a bit about the OpenSSH ssh-agent, ssh-add commands and the way the OpenSSH ssh and scp commands interact with them. Here's what it boils down to:
- I can just use ssh without ever bothering with ssh-agent. In this mode I have to type in my key store pass phrase on every invocation of the ssh command.
- ssh-agent creates an in-memory cache of private keys and ssh-add add private keys to the cache managed by ssh-agent. If ssh knows where to look, it will try to look up the private key it needs from ssh-agent's cache. If the key is already there, it won't prompt me for the pass phrase.
- ssh-agent tells the world how to get hold of it through a pair of environment variables: SSH_AUTH_SOCK and SSH_AGENT_PID. If ssh-agent is invoked with an optional command, e.g., ssh-agent xterm, that command (in this case xterm) will be run in an environment where SSH_AUTH_SOCK and SSH_AGENT_PID are set to the correct values. Otherwise, it just prints out the settings in bash script format:
[weiqi@gao] $ ssh-agent SSH_AUTH_SOCK=/tmp/ssh-euTnCkoNOS/agent.3336; export SSH_AUTH_SOCK; SSH_AGENT_PID=3328; export SSH_AGENT_PID; echo Agent pid 3328;
- To make it all work in my setup, I added a line to my startxwin.bat batch file
%RUN% ssh-agent > /etc/profile.d/ssh-agent.sh
right before the xterms are run. This way, by the time the xterms are started, the file /etc/profile.d/ssh-agent.sh is already written and contains the correct environment variables. The bash shell running inside each xterm will source this file as part of the start up process. Consequently they will have the correct environment for ssh, scp and ssh-add to talk with the agent. I still need to run ssh-add (and be prompted for the private key store pass phrase) in one of the xterms to populate the agent's key cache. Subsequent ssh and scp invocations will find the key in the cache and won't prompt me for the key store pass phrase.
[Update Thu Aug 31 19:57:10 CST 2006] (It helps if I tested my script before I posted it.) The above script has two flows: 1) it doesn't kill the old ssh-agent, 2) it should have used Windows file names since startxwin.bat is a Windows batch file. The correct script is
c:\cygwin\bin\pkill ssh-agent del c:\cygwin\etc\profile.d\ssh-ageent.sh c:\cygwin\bin\ssh-agent > c:\cygwin\etc\profile.d\ssh-agent.sh
Reclusive Russian Turns Down Fields Medal
Grigory Perelman wins, declines the Nobel Prize in mathematics.
Lucy Sherriff, writing for the Register: A Russian mathematician has turned down one of the discipline's most prestigious awards because he doesn't want to involve himself in self promotion. He was due to have been presented with the Fields Medal by King Juan Carlos of Spain on Tuesday this week.
Grigory Perelman published an outline of a proof for the Poincare conjecture back in 2003 as part of his work on the Geometrisation Conjecture, proposed by American mathematician William Thurston in the 1970s. This seeks to characterise all three dimensional surfaces.
So far, other researchers working to check and flesh out his idea have not found any flaws. Perelman himself has not spoken publicly about his work, saying that before the checking is completed it would be premature to do so.
John Ball, retiring president of the International Mathematical Union, told the BBC that he had gone to visit the reclusive mathematician in St Petersburg to discuss his reasons for declining the award.
He said that he wouldn't disclose Perelman's statements beyond saying that Perelman said he felt isolated from the mathematical community, and therefore had no wish to appear to be one of its leaders.
"He has a different psychological makeup that makes him see life differently," he added.
I mentioned Poincaré Conjecture on this blog once before when Cao Huaidong and Zhu Xiping announced their completion of Perelman's proof. For the truly interested, their article is available online now.
The First Thing I Would Do When I Get My Hands On Open Source Sun-Java ...
... is to kill the startup delay!
Tim Bray: But while I’m debugging it I’m eating the startup delay all the time, and at the moment, it’s brutal; I mean seriously bad. The JRuby guys have been doing some pretty bold chest-beating about how fast JRuby’s gonna be—bolder than I’d be in their position—but at the moment it’s kind of sucky to develop in.
The Java start-up time is the number one ill of the whole Java phenomenon. This single fault killed the Java applet concept, and spawned the application server market: "Hey, that Java thing starts so slowly, why don't we pre-start a Java process, and cramp all of our applications into that one instance."
It really is unforgivable that after ten years, we are still suffering from the slow-start-ness of Java.
I have a 2.0GHz processor, 1GB RAM, and a 80GB hard drive (A bottom of the line laptop as of July 2006). I want my Java start up time to be cut down to a point where I can't feel it.
Make it go on stand-by mode. Make it hibernate to a 500MB file. Compile the darn thing down to native code (I've JIT it the whole thing millions of times.) Turn off verification (I've verified the whole thing a million times.)
Something can be done, can it?
P.S. I said Open Source Sun-Java instead of Open Source Java because there are already two major Open Source Javas out there: The GNU gcj which ships with Fedora Linux since Core 2, and Apache Harmony, which is shaping up to be a fantastic Java implementation.
Some would say they are not complete and don't pass the compatibility test. And guess what, the Open Source Java that Sun will release won't be complete either. They are releasing pieces of it at a time. And won't contain the whole thing that constitute the current day JDK when they are all done with it early next year.
SSH Filesystem
It's easier than I thought.
When Brian Gilstrap mentioned sshfs to me a couple of weeks ago, I thought "neat." Today, I decided to look into it further. It turns out that it is available from one of the Fedora Core 5 Yum repositories. All I have to do is:
[root@gao-2006] # yum install *sshfs*
which pulled down the fuse, fuse-lib, and fuse-sshfs rpms. I have to add my login weiqi to the fuse group:
[root@gao-2006] # /usr/sbin/usermod -a -G fuse weiqi
Here's a short (53 seconds) screen cast of an sshfs session (You need VLC to view it on Windows or Mac OS X). As you can see, it is quite easy to mount and unmount an SSH filesystem. It's also fast enough for interactive use.
MSDN Library Now A Free Download
Rob Caron: For the first time, we're making the MSDN Library freely available for download from Microsoft Downloads. Previously, the Library was only available for download to MSDN subscribers. The current download is the May 2006 Edition and future editions will also be available when we release them.
Here's the download link. Three ISO images.
Ten Steps To Higher Cygwin Productivity
I always do these when I get on a new Windows box.
Cygwin is an integral part of my life on Windows boxes. It's the first thing I install when I get on a Windows box. If you take a look at the first screenshot from my new laptop that I posted 9 days ago you will see the Cygwin icon
already present.
In many respects, Cygwin is the GNU operating system based on the cygwin1.dll kernel. As a matter of fact, the cyg part of the Cygwin name originally stands for Cygnus, an Free Software support company that was bought by Red Hat; and gnu is embedded Cygnus. However, many of the applications and services that come with Cygwin is not turned on by default. Some of them even needed a little hand configuration. The following is a list of the first ten things that I always end up doing for every Cygwin installation that I use:
- When installing Cygwin, choose Install from Internet instead of the two step Download Without Installing followed by Install from Local Directory. I used to do the two step operations but recognized one day that the only thing I've ever done with the downloaded copies of tar files after the initial installation is to delete them. I also select to install everything because that's the easiest thing to do.
- Add C:\cygwin\usr\X11R6\bin\startxwin.bat to my startup menu so that X is running upon reboot. I use multiple xterms running bash as my command shells. They are far easier to use than the Windows XP CMD.EXE shell. Features that I use in the xterm/bash combination include easier copy and past between xterms, command and file name completion, and command history recall using the Emacs-y C-R <cmdline>. The supplied startxwin.bat opens only one xterm. I usually modify it to open four xterms with proper locations and huge scroll buffers big enough for a day's work:
%RUN% xterm -sl 10240 -sb -geometry 115x29+0+0 -title xterm1 -e /usr/bin/bash -l %RUN% xterm -sl 10240 -sb -geometry 115x29+0-102 -title xterm2 -e /usr/bin/bash -l %RUN% xterm -sl 10240 -sb -geometry 115x29-12+0 -title xterm3 -e /usr/bin/bash -l %RUN% xterm -sl 10240 -sb -geometry 115x29-12-102 -title xterm4 -e /usr/bin/bash -l
- Schedule a daily run of the updatedb program. This program updates the filename database that allows my to locate my files very quickly. I could use the Windows scheduler, but cron is easier to manipulate. Cron depends on a mail transport agent, such as ssmtp:
[weiqi@gao] $ /usr/bin/ssmtp-config (Answer questions) [weiqi@gao] $ /usr/bin/cron-config (Answer questions: yes as a service, no as self, yes ntsec) [weiqi@gao] $ crontab -e MAILTO=mymail@address.com # update the filename database at midnight everyday 0 0 * * * updatedb --localpaths=c:/
For ntsec to work, the environment variable CYGWIN must contain the word ntsec. Once the database is updated, I can find files by their names very quickly:[weiqi@gao] $ locate jvm.dll c:/Program Files/Java/jdk1.5.0_07/jre/bin/client/jvm.dll c:/Program Files/Java/jdk1.5.0_07/jre/bin/server/jvm.dll c:/Program Files/Java/jre1.5.0_07/bin/client/jvm.dll c:/Program Files/JetBrains/IntelliJ IDEA 5.1/jre/bin/client/jvm.dll
- Turn on the openssh daemon so that I can ssh into the box from remote locations:
[weiqi@gao] $ /usr/bin/ssh-host-config (Answer questions: no priv separation, yes as service, etc.) [weiqi@gao] $ net start sshd The CYGWIN sshd service is starting. The CYGWIN sshd service was started successfully.
Cygwin also provides a script (/usr/bin/ssh-user-config) that generate the private and public keys for a user. Since I already generated my keys elsewhere, I can just copy my ~/.ssh directory from another machine.[Weiqi Gao@gao-2007] $ ssh weiqi@gao-2006 Enter passphrase for key '/home/Weiqi Gao/.ssh/id_rsa': Last login: Fri Aug 11 20:51:31 2006 from gao-2007.weiqigao.com [weiqi@gao-2006] $ ssh Weiqi\ Gao@gao-2007 Enter passphrase for key '/home/weiqi/.ssh/id_rsa': Last login: Fri Aug 11 20:55:35 2006 from gao-2006.weiqigao.com Fanfare!!! You are successfully logged in to this server!!! [Weiqi Gao@gao-2007] $
I used to turn telnetd and ftpd on too. With sshd working, I don't need those programs any more.
I still need to learn how to start ssh-agent and put my keys there on reboot so that I don't have to type my passphrase on every ssh connection. - Turn on the PostgreSQL database that is distributed as part of Cygwin. PostgreSQL contains some quite advanced features. As a developer, sometimes it is very handy to have a relational database engine. PostgreSQL relies on a service called cygserver for some IPC support (e.g., shm, etc.):
[weiqi@gao] $ cygserver-config (Answer question: yes as a service) [weiqi@gao] $ net start cygserver The CYGWIN cygserver service is starting. The CYGWIN cygserver service was started successfully.
For the cygserver program to work, the CYGWIN environment variable must contain the word server.
The command sequence:[weiqi@gao] $ /etc/rc.d/init.d/postgresql initdb [weiqi@gao] $ /etc/rc.d/init.d/postgresql install [weiqi@gao] $ /etc/rc.d/init.d/postgresql start
ought to be enough to get PostgreSQL installed and started. But it isn't. I've written about this topic before. I still need to change some permissions manually to get things going. - Turn on (uncomment) the aliases that are predefined in the default ~/.bashrc file. These aliases codify some of the command line switches that are commonly used with certain commands and provide an easier way to access them:
# Aliases # ####### # Some example alias instructions # If these are enabled they will be used instead of any instructions # they may mask. For example, alias rm='rm -i' will mask the rm # application. To override the alias instruction use a \ before, ie # \rm will call the real rm not the alias. # Interactive operation... alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' # Default to human readable figures alias df='df -h' alias du='du -h' # Misc :) alias less='less -r' # raw control characters alias whence='type -a' # where, of a sort alias grep='grep --color' # show differences in colour # Some shortcuts for different directory listings alias ls='ls -hF --color=tty' # classify files in colour alias dir='ls --color=auto --format=vertical' alias vdir='ls --color=auto --format=long' alias ll='ls -l' # long list alias la='ls -A' # all but . and .. alias l='ls -CF' #
The color grep alone is worth the this effort:[weiqi@gao] $ grep seakeasy /etc/ssmtp/ssmtp.conf mailhub=mail.seakeasy.net(I misspelled my mail server address when I was configuring ssmtp, and cron logged an error saying sendmail cannot open mail.seakeasy.net:25.) - Change the default paper size for enscript in /etc/enscript.conf from A4 to Letter. I use enscript to print code listings. It is capable of generating color syntax highlighted PostScript code listings for Java, JavaScript, C++, Perl, Python, Scheme, AWK, and many many more languages. I use the following ENSCRIPT environment variable
export ENSCRIPT="-G2rE --color -C --word-wrap"
to tell enscript to format my code listings with a fancy header, two columns in landscape mode, detect the language, use color syntax highlighting, print line numbers, and wrap long lines at word boundaries. Here's an example output. - Turn on the Apache Web Server. Both Apache HTTP Server 1.x and 2.x are included in the Cygwin setup. To turn on Apache HTTPD Server 2, simply do:
[weiqi@gao] $ cygrunsrv -I httpd2 -d "CYGWIN httpd2" -p /usr/sbin/httpd2 \ -a "-DNO_DETACH" -y cygserver -e "CYGWIN=server" -s TERM -o [weiqi@gao $ net start httpd2 The CYGWIN httpd2 service is starting. The CYGWIN httpd2 service was started successfully.By opening up the http port on the Windows Firewall, I can easily share files to coworkers by simply copying them to the web document directory. I can then email them a URL. It's also a good way of sharing Javadocs and Doxygen docs. - Cygwin is much more than simply a pile of exploded jar files. A couple of Cygwin specific commands are particularly useful.
The first one is the cygcheck command. For the longest time, I thought it is just a command that somehow checks my Cygwin installation. However, reading its man pages convinced me that it is more than that. It is actually a package management system much like rpm or dpkg. For example, earlier today, I wondered about the lpr command from Cygwin. By doing a[weiqi@gao] $ cygcheck -f /usr/bin/lpr.exe cygutils-1.3.0-1
I found out that it belongs to the cygutils package. A follow on command of[weiqi@gao] $ cygcheck -l cygutils /usr/bin/ascii.exe /usr/bin/banner.exe /usr/bin/conv.exe /usr/bin/cygstart.exe /usr/bin/d2u.exe /usr/bin/dos2unix.exe /usr/bin/dump.exe /usr/bin/getclip.exe /usr/bin/ipck /usr/bin/lpr.exe /usr/bin/mkshortcut.exe /usr/bin/msgtool.exe /usr/bin/putclip.exe /usr/bin/readshortcut.exe /usr/bin/realpath.exe /usr/bin/semstat.exe /usr/bin/semtool.exe /usr/bin/shmtool.exe /usr/bin/u2d.exe /usr/bin/unix2dos.exe ...
pointed me to the other commands and documentations of the package.
The second useful command is actually part of this cygutils package. The cygstart command mimics the Windows native start command in that you can say[weiqi@gao] $ cygstart project.sln
to start a Microsoft Visual Studio .NET 2003 solution file. I aliased this command to start so that when other developers come to my Cygwin xterm and do a start project.sln it would still work. - Take advantage of bash's initialization scripting infrastructure for setting up environment variables for user installed software packages. Just like on Linux systems, when a Cygwin bash login shell starts, it executes a sequence of initialization files, including /etc/profile and ~/.bash_profile. The script /etc/profile contains a mechanism for sourcing all *.sh files in the /etc/profile.d directory. So you can cause a script to be sourced on start up by simply putting it there.
Here's my /etc/profile.d/maven.sh (I'm experimenting with Maven's facility to generate IntelliJ and Eclipse project files from pom.xml files)# Maven 2.0.4 initialization script # APP_HOME=/opt/maven-2.0.4 APP_PATH=$APP_HOME/bin if ! echo $PATH | grep -q $APP_PATH then if [ -z "$PATH" ] then PATH=$APP_PATH else PATH="$PATH:$APP_PATH" fi fi export PATH unset APP_HOME APP_PATHIt simply adds /opt/maven-2.0.4/bin to the PATH environment variable. At first it might look like an overkill. However most of the file is boilerplate. When I installed Maven, I simply copied my /etc/profile.d/jdk.sh into maven.sh and changed the APP_HOME=... line. I know I can extract the bulk of the script into an addpath function, I just haven't done it yet.
Java CLASSPATH's can be handled similarly. However, since Cygwin does not convert CLASSPATH into Unix format, when I add to the CLASSPATH I need to do some conversions myself. First convert CLASSPATH into Unix format. Then add my portion (in Unix format) into the converted CLASSPATH. Finally convert the CLASSPATH back to Windows format. You can read the $ANT_HOME/bin/ant file to see how this is done.
I wrote this entry one piece at a time as I'm configuring my new laptop. And I'm doing this as much for myself as for the readers of this blog. The next time I install Cygwin on a new computer, I can just print this article out and follow the steps.
I started using Cygwin almost a decade ago, starting from Beta 16. I still remember a huge (10MB) hidden file that Cygwin created on my Windows 95 hard drive that I simply cannot get rid of. Cygwin has come a long way since then. I'm sure there are other parts of Cygwin that is really handy but I just haven't had the chance to explore yet.
JBPM At The JUG Tonight
Tonight at the St. Louis JUG Raj Patel presented about JBPM, the Java Business Process Management system, now a part of JBoss's offerings.
I have used JBoss 2.0 and 3.0 in past projects. But I haven't been following JBoss's latest maneuvers on their product strategies. So I only have a cursory knowledge about JBPM (I watched the 20 minute video of dragging and dropping and web pages magically appearing, for example.)
Raj's presented at quite a detailed level. He started off with the graphical process designer (JBoss IDE), went through the XML language that underlies the graphics and its major elements, showed Java code that is hooked into the key points in the process where the JBPM API is used to communicate with the engine, and demoed a few processes running inside the container.
Unfortunately, the process Raj built on stage failed to deploy into the container and he had to use a pre-deployed processes as demoes.
I can't say I'm sold on the product. And judging from the questions of the audience, neither are they. Even Raj himself sometimes sounded a little tentative (yet I still prefer this to a vendor's technical sales person's sureness of their new pointy-clicky products). But we are very curious as to the inner workings of the engine. Can it be transactional? Can it be used as the core processing engine of an application? Can a programmer get at the internal states of an instance of a process?
Here's the notes I took during the presentation. I can't make any sense of them now. Maybe someone more familiar with the BPM thing can fill me in on some of the details:
- Business Process Management
- Programming. No more programming
- BPEL
- Process design
- Process execution
- Process monitoring
- Graph oriented programming
- Domain specific languages
- Workflow
- Orchestration
- IdentityContext
- JbpmContext
- Each fork has own set of variables, the first one wins when they join
- pyxie
- jPDL, the native mark up language of JBPM
- Also supports BEPL, strange license
- PageFlow
- States
- Node
- Transition
- Execution
- fork
- BEPL has good error handling
Some chats at the JUG (unrelated to the presentation):
Kyle: How do you think about the turn out
Me: It declined a little
Kyle: Why is that?
Me and Jeff: Java has matured. Some people don't feel the need to come any more. Some may have moved on to other things.
Kyle: Have you been to the Ruby User's Group? It's overflowing with attendees. Just like the JUG when we started at Novell.
Me: Ruby definitely is happening.
Kyle: There are many former Java people at RailsConf. James Duncan Davidson, who invented Ant, kept apologizing for it.
Jeff: Finding good topics for the JUG has also become harder
Kyle: How about "How can Java programmers survive when Java becomes the COBOL?"
Me: That'll be the last talk of the JUG. We started with "Java, What's All the Excitement About?" We might as well end with "Where has all the excitement gone?" :)
That last sentence was a joke. We have plenty of speakers lined up for the JUG: Jeff Brown will talk about Grails next month. Alex Miller will talk about implementing domain languages in Java in October, and Kyle Cordes will talk about scripting in Java in November. Do come!
We has some Mac OS X on Intel Core Duo iMac ==> Windows XP in Parallel ==> VNC in a secure server, ssh tunnelling fun today.
Major Security Hole Found In Rails
Everyone upgrade now!
kjart on Slashdot comments: ...and hundreds die in the resulting crash. When interviewed later the conductor said that he wishes he was told where the hole was so he could've stopped the train in time.
I Need To Get That Book!
Brian Goetz's Java Concurrency In Practice
Bryan Young: I've only made it halfway through, and I feel like the little kid in 'The Sixth Sense' -- I see bugs everywhere.
Bryan is talking about Brian Goetz's new book Java Concurrency in Practice. I have read many of Brian Goetz's columns in various web sites and have always learned something from each article.
I also heard Brian Coyner say that the book is worth a read.
I'm going to get a copy of the book tomorrow.
The Return Of The Turbe C++
And Turbo Delphi, and Turbo C#. Where's Turbo Java?
Paul Krill, InfoWorld: Borland Software will bring back the Turbo product moniker on Tuesday with the introduction of language-specific developer tools.
... The Turbo product set includes Turbo Delphi for Win32, Turbo Delphi for .Net, Turbo C++ and Turbo C#.
Remember Turbo C++ then?
Norton Firewall Trouble
I would have to return the machine as defective had I been a normal user.
The laptop I ordered had finally arrived. And guess what I ran into on the first day?
Let me explain. After receiving the box, which by the way was built at Shanghai, and I love stuff made in Shanghai, I unpacked it, snapped in the battery, hooked up the power adapter and powered it on. The initial setup is very easy. I took all the defaults except for the name, address and time zone information. And then I rebooted, it found my wireless lan and I was browsing the internet. Cool.
I played a DVD, Balzac and the Little Chinese Seamstress, and it looked fantastic. The movie is great too, better if you natively speak Szechuanese.
Then the little bubble popped up telling me "your Windows updates are ready to install. Just click here." I clicked, choosing the Express option as recommended. (Do you know that the phrase "Expression Option (Recommended)" was present in MS-DOS installation screens?) The bubble popped down to the notification area, saying, "Go back and work as usual. Don't mind me. I'll tell you when I'm done."
Hours later. The above screen. The Windows Updates installation had stuck at the "Genuine Advantage Notification" step. Apparently it is trying to talk to the great folks at Microsoft over the internet. And the firewall software was blocking it. I right clicked on the Norton Internet Security tray icon trying to bring up the control center screen. The screen wouldn't fully materialize. That's when I took the screenshot.
And it gets better. I can't close it either. Clicking on the little red "X" on the upper right corner has no effect whatsoever.
This is where a normal user (you know, the kind who wouldn't open their Packard-Bell boxes fearing that it would void the warranty) would have trown the thing back at the store. "It doesn't work" would have been an adequate description of the problem.
But being the power user that I am, knowing a thing or two about WM_QUIT and WM_DESTROY and taskman.exe, I fired up the task manager and tried to kill the process. No. It refused to die that way either.
You know where this is going, don't you? The next thing I tried is to log off the user. BTW, it's "log off" on Windows but "log out" on Linux. (Just thought you'd appreciate the fine distinction of terms here.) No luck. Trying to reboot won't work either.
Time to hit the power button. Thank God that worked.
I have since uninstalled Norton software because it's f***ed up. (For those who don't know me that well, I don't usually use ths sort of language. Imagine hearing these words uttered by someone nice, like, say, Mother Teresa.) (I can see the shock on your face.) I'm running unprotected for now, so don't be sending me any viruses.
I'm open to suggestions on alternative virus protection software for under $40/year.
Quotes Of The Day
Gilad Bracha: It has come to our attention that some people want to program in things other than Java.
Gilad Bracha: Some languages fit naturally into the .NET and Java VM models, and those languages tend to feel like syntactic sugar for the existing VM.
CrossOver Mac: Coming August 2006
Run Windows applications on Intel Mac.
(Brian Gilstrap mentioned this to me today.)
CodeWeavers: CrossOver Mac is Coming!
CodeWeavers' latest Windows-compatability product -- is on its way. Intended for Intel Mac OS X machines, CrossOver Mac will allow Mac users to run their favorite Windows applications seamlessly on their Mac, without the need for a Windows OS license of any kind. Below are answers to some of the questions we are receiving on the product.
How Do You Use Collection.toArray(Object[] a)?
There are two ways to do it. And it took me five minutes to figure out one isn't acctually used.
I'm working on some Java code, using J2SDK 1.4. And I needed to turn a java.util.ArrayList of Foo objects into an array of Foo objects. So naturally I thought about java.util.Collection's
public Object[] toArray(Object[] a)
method. It's been a while since I last used this method. So I surfed over to the Javadoc at Sun's Java website. The first thing that jumped into my eyes is this code sample:
String[] x = (String[]) v.toArray(new String[0]);
That's exactly what I needed (and eventually what I did.) However something else caught my eyes too:
If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection.
What that means is that if my List contains exactly three Foos, then I can either do:
Foo[] foos = (Foo[]) list.toArray(new Foo[0]);
or
Foo[] foos = new Foo[3]; list.toArray(foos);
to achieve the same result. The first alternative also works when we don't know the size of the List. The second alternative works only if I already know the size of the List. And the second way offers any advantage over the first only if the foos array can be reused in multiple toArray() calls. But if I know the size of the collection, I can probably avoid the use of List altogether.
How do you use Collection.toArray(Object[] a)? (I would really like to be educated about real world code where the second alternative wins over the first.)
CodeWeavers' latest Windows-compatability product -- is on
its way. Intended for Intel Mac OS X machines, CrossOver Mac will allow Mac
users to run their favorite Windows applications seamlessly on their Mac,
without the need for a Windows OS license of any kind. Below are answers to
some of the questions we are receiving on the product.