2009-12-25

Browsers usage share


Remind me, what did they said about the most used browser? My Google Analytics is sure that the most popular browser is Firefox with almost 55%, than Chrome with 23.7%, and only then IE. And I am happy at last Konqueror got into list, with 0.67% share.

Homegrown projects: versioning


From time to time you need to set up some project at home. There are plenty of reasons: you are starting new opensource project, want to write few HelloWorlds with new frameworks, or you just don't want to go to office today.

And of course you want to use some VCS with your project, because it allows you to perform development in steps, plus standard VCS features like revert/diff.

I worked with CVS, SVN, Perforce and a tiny bit with VSS. And few days ago I tried Mercurial. Mostly because great support from NetBeans. But now Mercurial is total winner for home usage, only two simple steps and your repository is up and ready to be used from your favorite IDE. With Mercurial you don't need to start servers, use network connection, configure some system files using root privileges, just install and init project. And enjoy lightweight source control system that will provide you with all benefits of versioning.

2009-12-24

JPA 2.0 migration experience

Java EE 6 specification released not so long ago, and now includes release of JPA 2.0 specification. Obviously, you'd like to use JPA 2.0 for your new project. But the problem is, how to choose good implementation and where to get it?

First you will go to Sun's persistance page. You'll read a bit and click on "download" link that will take you on Glassfish Persistance page. But the problem is, you will not find JPA 2.0 reference implementations on that page.

Ok, next step - ask google. Google sais that EclipseLink is reference implementation for JPA 2.0, and wikipedia confirms. Let's go to EclipseLink downloads. Yea, there are some files to download, but again everything is packed into single huge JAR with dozens of features we don't really need (yea, I have "classpath paranoia"), and the main component is missing - sources for JPA 2.0 API, that can be added to NetBeans libraries to read javadocs and to help it with method argument names (do you remember that Library Manager in NetBeans?).

We must not give up. Let's go to JSR page and take a look. Wikipedia states it's JSR 317. After clicking on "Download" link we can see another link, that will direct us to "EclipseLink's Reference Implementation Downloads". After downloading both and taking a look inside of each package we can see that "EclipseLink 2.0.0 - minimal bundles that are shipped in the Java EE6 RI" is what we really need. Finally, everything we may need and packed in separate small JARs, so we can include only features we need.

Now, let's make it work. I have project that used JPA 1 with EclipseLink 1.2.0. I removed all EclipseLink libraries, added javax.persistence_2.0.0.v200911271158.jar (JPA 2.0 API) and org.eclipse.persistence.jpa_2.0.0.v20091127-r5931.jar (one that contains org.eclipse.persistence.jpa.PersistenceProvider). First few starts of application ClassNotFound were reported, I searched for required classes and added their JARs. Finally, here is the full list of JARs you need to work with standard JPA 2.0 feature set:
javax.persistence_2.0.0.v200911271158.jar
org.eclipse.persistence.jpa_2.0.0.v20091127-r5931.jar
org.eclipse.persistence.core_2.0.0.v20091127-r5931.jar
org.eclipse.persistence.asm_2.0.0.v20091127-r5931.jar
org.eclipse.persistence.antlr_2.0.0.v20091127-r5931.jar

and files to add to Sources tab (NetBeans will be able to show you sources, javadocs and read method argument names from those sources):
javax.persistence.source_2.0.0.v200911271158.jar
org.eclipse.persistence.jpa.source_2.0.0.v20091127-r5931.jar
org.eclipse.persistence.core.source_2.0.0.v20091127-r5931.jar
org.eclipse.persistence.asm.source_2.0.0.v20091127-r5931.jar
org.eclipse.persistence.antlr.source_2.0.0.v20091127-r5931.jar

That's all. Use JPA 2.0 with pleasure, support new versions and software evolution, because otherwise we all will become stupid monkeys and will return back on palms.

2009-12-15

GWT EventDispatch and widgets width and height


When you're constructing Widget in GWT - it's size is 0 until it's rendered. It's different from Swing, Swing assumed that you're working in EventDispatcher and calculated all sizes instantly. It is not announced but looks like GWT have it's event dispatcher too, and you can use DeferredCommand class to place Command into events loop. Using this approach you can construct Widget, place it into some Container, and then add some Command to DeferredCommand to work with widget's size after current construction operation will be complete and Widget will get it's size.

It looks like problem of all young widget toolkits, like Swing itself many years ago. They are showing it, its simple, its cool. But when you start coding real application using that toolkit - you'll get many problems, many different "hidden" features and many tricks and workarounds. After many years they'll tell you about EventDispatcher, then they'll implement different kinds of BackgroundWorkers, and different rules how to "use correctly" this toolkit. You can remember situation with "EventDispatcher rule" of Swing and how it was changed from Java5 to Java6 (while nothing inside was changed). Now we can see similar situation with JavaFX, and GWT goes the same way.

2009-12-11

NetBeans 6.8 has come


NetBeans 6.8 is just released, introducing many new features. It's pity there is nothing interesting for me as for Java-GWT developer. And even nothing interesting for other guys I worked with - they are still using MyFaces 1.1 for some reason, OpenJPA 0.9.7 bundled with WebLogic 10.0.0.0.0, and other EE4 or EE5 stuff. New JIRA plugin can't authentificate into my JIRA server, and I'll better wait for next GWT4NB version, which I hope will support GWT 2.0 and NetBeans 6.8.

Honestly, it's a pity that the most powerful Java IDE/editor is not improving it's Java stack, but working on some thirdparty features like Kenai, PHP, Ruby...

2009-12-10

Internationalization in UI toolkits


I have some experience with many different UI toolkits. The most with Swing, QtJambi, GWT, and some with SWT and Echo2. Some of them providing you with their own i18n techniques. Let's take a closer look...

Swing is the most comfortable tookit because it gives you full Java API, with source code, possibility to dive deep into it's internals and no external libraries or dependencies. And it gives you standard Java i18n engine: ResourceBundle. It's simple, powerful and effective. And it's customizable (if you know Java of course).



Qt Jambi gives you Qt's native internationalization engine. It works in other manner than ResourceBundles. API is clean and simple, every Qt widget have method tr(String) where you can specify default value, but not the key as ResourceBundle suggested. From one point of view it's good because you're hardcoding default values, and you will be sure that on any system it will at least show default version. From the other side - those messages can take a lot of space in your source files, plus they are actually keys in internationalization files, similar to properties files. Having keys like this is not very good, because modifying single char you have to modify all resource bundles, while in ResourceBundle you can leave code "as is", modifying only value but not key.

GWT is totally different. It's using properties files too, but you have to extend Constants interface, and add all your keys as String methods to interface. As for me GWT is the total winner, because you have properties files with key-value pairs and IDE support, and you have compile-time safety because you're getting those strings from Java class. In ResourceBundle you're operating mostly with Strings, and simple typo can waste lots of your time, while using GWT approach you must ensure your keys only once, then you're totally saved from any kinds of typos using Java methods to get your internationalized messages.

GWT 2.0: almost 6000 downloads in 33 hours


GWT 2.0 released yesterday, but almost reached 6000 downloads already!



Well, I am agree that GWT is pretty cool thing, especially if you must do something for web browsers, but 6000 in 33 hours... Can you remember any other toolkit with same download rate? Even Java developers are not bothering themselves with downloading of new versions.


2009-12-09

GWT 2.0 released, HTML drawbacks as new feature


Few minutes ago I read about release of GWT 2.0. It's great new release, with many useful features. Except one: UiBinder. HTML and XML both have their problem - they are page-oriented. You can't just replace some widget as long as it's Widget subclass. You need to repaint all page if you want to layout it in some other manner. GWT allowed you to avoid those drawbacks, providing you with great feature-rich component-based framework. You could do everything in plain Java, and as for me it's big advantage, because average quality of GWT project were relatively high (you at least need to know Java, and maybe some component-based framework like Swing, right?). And now any novice HTML coder can feel something native and ugly using GWT, lowering average code quality and writing another crappy application with cute HTML-like interface. Impossible to debug, impossible to apply any Java techniques, and even making harder to use version control system (I hope you noticed that modern DIFF algorithms are not very good with XML?).

2009-11-27

Stupid frameworks are forcing you to do stupid things


I am working with GWT+GXT right now. And I have strange problem - I can't save some user object. Just can't. When user logined to the system I want to save user object, containing his name, mail, role, group and other things. But as soon as F5 pressed - all static is cleared from the application, so even static fields can't help me. Cookies can help me, but they're limited to String only...

Of course my imagination works fine, and I can implement some GWT RPC service and get user from the server (where I have user's session, and I can save User object into that session). But it's stupid, isn't it?

2009-11-26

NetBeans and Safari


On my Windows box I am using Safari to read javadocs. Because of fonts antialiasing of course. And just noticed strange effect - NetBeans starts to lag when Safari is opened. Sources parsing is slower, autocomplete waits visibly longer before suggest something... Do you know where is the problem?

2009-11-25

GWT2 Firefox plugin download


First release candidate of GWT2 released on November 17, it can be downloaded here. One of the first changes you'll notice - they removed their "hosted browser" and added plugins for some browsers that will help browser (Firefox?) to do the job of "hosted browser". The first time you'll run application - it will suggest you to download plugin. But what can you do it you want to copy your project on workstation with strict or no internet? Or it you're planning to clean Firefox profile from time to time?

I asked question about where can I get those plugins on Google Groups for GWT, but 7 days passed and no answers...

So here is the small guide how you can get it manually.
1. Find folder where firefox storing it's plugins. For me it was C:\Documents and Settings\Username\Application Data\Mozilla\Firefox\Profiles\5zchoudq.default\extensions\gwt-dmp-ff35@gwt.google.com (yes, yes, I am still using Windows on my job).
2. Open install.rdf in text editor. After reading it for some time the only interesting line you'll find looks like this: http://google-web-toolkit.googlecode.com/svn/trunk/plugins/xpcom/prebuilt/update.rdf in em:updateURL tag.
3. Open that link in browser and read that file. Now you can see the link where you can get that extension, can't you? Here is it: https://dl-ssl.google.com/gwt/plugins/firefox/gwt-dev-plugin.xpi.
4. Now you can save it for farther usage.

2009-10-13

Tablet on VirtualBox guest


If you're Linux user and you have Wacom Intuos3 tablet - it's obvious that GIMP will not satisfy your needs. Solution exists: you can download and install free VirtualBox, install WindowsXP as guest system and work with your tablet in guest system, installing your favourite graphics application on Windows guest.
I did those steps: installed VirtualBox 3.0.8 on my SUSE Linux 11.1, installed WindowsXP as guest. But I couldn't configure it - checkbox to turn on tablet in guest system was disabled (grayed out).
I spent few hours reading different forums and bugreports, most of them suggested to mount tablet as usbfs to your system, but it didn't worked for me. When I found solution - it was fast and simple:
1. Open your /etc/udev/rules.d/10-vboxdrv.rules as root. You will see something like this:
KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="root", MODE="0600"
SUBSYSTEM=="usb_device", GROUP="vboxusers", MODE="0664"
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", GROUP="vboxusers", MODE="0664"

2. Modify third line like this (adding name):
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", NAME="VirtualBox/$env{BUSNUM}/$env{DEVNUM}", GROUP="vboxusers", MODE="0664"

3. Restart your system to be sure.

That's it! Now checkbox will be enabled and you will be able to turn on your USB tablet for guest system. VirtualBox will fail with error (something like couldn't create usb proxy device) but only 2 times, when pressing third time - tablet will be recognised by guest system and you will be able to use it. Of course you should also disable mouse integration and your tablet will no longer be available to your host Linux system, but what for do you need it there anyway?

2009-10-08

Problems of small opensource projects

Being Java developer and fan of OpenSource I am writing lots of stuff. Mostly for myself, tools that I am missing or to get some experience with something. But of course there are projects that I think others will like and use if they will know more about it. Few examples:
  • Once I wrote small tool for Swing apps to choose LookAndFeel in runtime. It was JLAFChooser and I hoped it will become popular very soon. But days passed and downloads count was small. I thought that mostly it's downloaded by different search engines, nobody cares about it. And I just forgot about it, didn't planned to make it better. Download rate is about 1.001 per day. No bugs, no feature requests, no thanx or private mails. Nothing. Maybe this project had it's future, but now it's as good as dead. And even java.net registration did nothing to improve the situation.
  • Then came p4nb. I did it for myself anyway, I am still using it at work because it's the best available Perforce plugin for NetBeans IDE. It's just enough for me. And nobody cares. Looks like nobody using NetBeans and Perforce at once. I can implement vast amount of features, including changes browsing, changelist management and many other. But I have more interesting projects for myself, and nobody else asks for it. Why should I do it?
You will ask what's the point of that moaning? But the point is, once one guy mailed me with words like "hey, I added few features to your p4nb plugin, maybe you need it?". That day I understood that I am not the only user of that plugin, there are at least another man using it. It was the new beginning for p4nb, it got completely rewritten with new and better feature set and better usability. And then it was forgotten again, because all users were glad with what they had, no bugs and no change requests fired.
Today I got a mail from one guy who is using JLAFChooser, he asked about launching it from Java WebStart. Of course I answered him, but why so late? I have no interest in that peace of software now, and I will not get back to it's development. It's dead for me, because no one really needed it when it was interesting for me.
  1. How many projects died like this? What kind of project they were, maybe we lost something really interesting?
  2. What should I do to prevent it in future? Post to slashdot? Buy Google Ads? Tell me what I did wrong to fix it in future.
Thanx for your attention, and I hope this post will not be just ignored in the same sad manner.

2009-08-11

Using license with NetBeans project



When you're using GPL or LGPL with your project - you should add license statement to every source file of your project. Using NetBeans it's not that simple - you have to use PROJECT/nbproject/project.properties file to add project.license=default_2 for example, using file name of your license template (but not template name itself). To make your life even harder - GPL and LGPL statements are using name of your project three times. Because of this I created separate templates for each of my (L)GPL projects to include project name. Because of this is took a time to set a complete new project. Now I found solution how to make NetBeans use single GPL template for all projects:

1. use ${project.name} for name of your project. For example: "This file is part of ${project.name}.".
2. in file PROJECT/nbproject/project.properties add project.license=default_1 (or any other file name for your license).
3. in same file (PROJECT/nbproject/project.properties) add project.name=MyNewProject

Now create new Class file and check license header of your file. Hope you'll enjoy!

2009-07-23

KDE 4.3 RC3


You may already know that KDE 4.3 RC3 released, and release delayed for a week. I can't stand that news, I thought that is will be released this Monday, but another 2 weeks... And of course I want to try it without harming my every day system with KDE 4.2.4 and only stable packages. In that moment I remembered about kde4live CDs, that I used some time before SUSE 11.1 released. And of course I found it fast enought using Google. And there are good news - on top of the page there is message that KDE 4.3 RC3 already packed to LiveCD and can be downloaded from SUSE's repositories. Well, Kubuntu users, don't you feel betrayed that your favourite "KDE-oriented" distro is far behind great and green OpenSUSE?

2009-07-09

Kompare - the only valuable diff for M$Windows


I used KDE and Linux for many years, and of course I was shocked when I had to switch to Windows in new office and I didn't found all those little but important tools KDE guys made for us all. Today I will tell you about Kompare.

My history as Kompare user
While being developer from time to time you need to diff between two files. Of course almost any IDE and other development-oriented tool have own diff UI. Of course I used many of them, some are more useful than others. For example older Eclipse diffs were so ugly that it was hard to look at, IDEA had horizontal 3-way comparison, older NetBeans versions - vertical 3-was comparison, KDiff3 showed too much of not required data and also was ugly enought. Only SmartSVN and Kompare used two-way clean and informative diff, but while SmartSVN was written in Swing - Kompare used all possible KDE features including font antialiasing, user's colouring and icon theme and of course smooth comparison blocks. While being feature-rich it was only comparison tool with great UI, so I stuck with it.

Switching to Windows
Of course after I got used with pretty tool like this - it's hard to move to something ugly and not so usable. When on the new job I had use Windows - I went to wikipedia to search for another file comparison tool. And what do you think, I downloaded every free-to-download tool and tried it - and it failed. Some of them took 3-4 steps before show you actual diff, others were overloaded with features, others had ugly UIs. I couldn't make myself use them. I've been lucky and by that time NetBeans team swithed to 2-way diff, and I used NetBeans for even smallest comparison operations.

kde4win salvation
I was lucky enought not to die before kde4win project released with Kompare ported to Windows. Of course few first releases didn't helped me also, but starting with 4.2.0 release Kompare was fully functional. And not with kde4win you can use this great tool if file comparison operations is critical for you.

installing
It's not hard. You don't even have to compile something. Only few steps:

  1. Go to gnuwin32 diffutils, download and install.

  2. Download kdewin installer and launch it.

  3. After installing kde4win - start kompare and in "Diff" section show him where your diff.exe (from gnuwin32 diffutils) is located.

  4. Restart Kompare and it's ready to use!

Now you can enjoy your life without feeling the pain of uncompared files on your system.

PS: Kompare can be used even for folders comparison - and it's much more powerfull than you can expect from simple file manager!


2009-07-06

Yet another opinion in Mono case


There were many Mono debates on Tuxmachines for last few weeks. Of course I have my own opinion on this topic. I will not blame Mono right now, just my thoughts about distributing it with Linuxes.

Default distribution
As far as I know, all those debates started when Debian guys thought about including Mono into default installation. But what it default installation? Isn't it related to target users? It's obvious that when you installing Ubuntu - you target home desktops, SLED or Mandrake - office, SLES or Slackware - servers. Depending on that choice "defaults" are very subjective. But is there any distribution problem? I don't see it. Being SUSE user I have my distribution on DVD media, lots of stuff could be fitted there, why not include Mono? If you're single CD distribution - you should think twice and count all Mono-based software you'd like to install. If it's just single application - it will be funny to install mono because of it.

Next, most of Mono apps are made for GNOME. I see no reasons to install it with KDE-based distribution, or console installations.

Thinking about users
In perfect world user should never bother with technology used in his favourite apps. Application should just do it's job, not promote or blame something. To mono or not to mono should depend on those user apps, but should not be some politics or religion choice. As for me I hate beagle, banshee and f-spot. Mono should not be installed for me. And vice-versa. If user will notice any Mono application he will run - it will look like there is some problem with Mono, don't you think so?

System core
While it's completely OK to depend some desktop apps on Mono or other interpreted stuff - it's totally wrong to use it for system parts. Every next level of abstraction and interpretation adds additional level of possible problems, removes some part of integration and requires more resources to work. Can you imagine our world if HAL will be written in ruby or python or something like that? System must not be related on interpretator vendor or on subjective solutions. You may already see some bad examples like ZEN in SUSE 10.0, pulseaudio in current distributions, gcj instead of Sun JRE in fedoras and many more.

From my perspective
It's strange to see, but all mono-based apps I know makes me sick. Beagle that starts and scans event without any GUI installed. ZEN that made me think about switching away from SUSE. Banshee with it's crippled playlists. F-spot with it's lack of features. MonoDevelop with it's lame possibilities totally unexpected in any IDE. I think that the day I will not be able to set "taboo" on Mono in my SUSE installation will be the last day of me as SUSE user.

Java things that make you go "hmm"


I am preparing myself to SCJP exam, and while reading preparation book I found "feature" I didn't knew about. Take a look at the following code:

public class Main {

 public static void main(String[] args) {
  new B();
 }

 static class A {
  public A() {
   System.out.println("A constructor");
  }
 }
 static class B extends A {
  {
   System.out.println("B init");
  }
  public B() {
   System.out.println("B constructor");
  }
 }
}


How do you think, what output will it generate?

2009-07-02

Java single inheritance questions


There are few structures in Java that are not so intuitive as others. Take a look:
public class InnerInvocation {

 String getValue() {
  return "Outer Value";
 }

 private class InnerClass {
  String getValue() {
   return "Inner Value";
  }

  void work() {
   // insert code here
  }
 }
}

What code do you need to invoke getValue() method from outer class?

Here is the answer:
  void work() {
   InnerInvocation.this.getValue();
  }

And now the question of the day: there is syntax that possibly can allow multiple inheritance in Java, so why is it forbidden? Because you as developer can make lots of mistakes? Why then they allowed reflections?

2009-06-30

Eclipse and NetBeans compared


Eclipse 3.5 released few days ago, and NetBeans 6.7 just released. Of course I am using NetBeans 6.7 starting from beta versions and I know how it works, so I wanted to test eclipse. After using it for few hours came this comparison.
Both IDEs have clean install and run.

About


Two about dialogs to show used versions



Memory usage at the beginning


Memory usage just after startup. It's pretty comparable to say "there is no winner".


Step 1: project creation


Eclipse


New project dialog:

Eclipse gives lots of options on project creation page, and defaults are quite ugly. May be that is the reason why eclipse users are never writing small projects just to test some API?...

NetBeans


New project dialog:

NetBeans gives option to create Main class for project at once, but we will ignore this suggesion for comparison purposes.


Step 2: main class


Eclipse


Eclipse shows another overloaded window. Of course first bug in package input, Ctrl+Space just does not work there. As for me to save user's time it would be better to create just empty class as soon as possible, and editor will give possibilities to modify that options.

NetBeans


Quite better options than Eclipse gives, you see all possible templates for your Java project organised in tree.

But there is next window to complete Main class creation. It's a bit more usable than Eclipse's version because of good focusing system, but still it's step 2.


Step 3: autocomplete


Eclipse 1


Basic autocomplete is just ass-ugly. No text coloration, small and not monospaced fonts just suitable to print errors, but not information for developer.

NetBeans 1


Text coloration helps more than icons, but icons differs each other if compare to Eclipse's round icons with just letter changed. And of course monospaced font.


Eclipse 2


One point to Eclipse - after autocomplete focus is given to set type of list.

NetBeans 2


Not much to look at.


Eclipse 3


Another ugly autocomplete window.

NetBeans 3


Only imported types shown. Once this was IDEA's feature and it makes good job.


Eclipse 4


It's very strange to see icons and other information here, just can't understand who needs it.

NetBeans 4


Quite lot of variants.


Eclipse 5


Cool. 5 items in list and none will work for us.

NetBeans 5


Same problem, just showed everything it knew.


Eclipse 6


Nothing interesting.

NetBeans 6


The same.


Eclipse 7


Were there any worse possibilities?

NetBeans 7


Pretty good, all found List implementations will help us. Just why to show classes from com.sun.* packages?...


Eclipse 8


Still no help from IDE! I can do the same in plain text editor, why do I need IDE like this?

NetBeans 8


Perfect. The most suitable class and full javadoc for it.


Eclipse 9


One more point to Eclipse. It's good to write type and brackets when class is already known.

NetBeans 9


No brackets... I have to press another autocomplete to see available constructors. Even no autopopup of autocomplete here.


Eclipse 10


Another ass-ugly autocomplete. No text coloration, no text alignment, some strange info about class of object, and that stupig "arg0" labels... I don't know, did Eclipse guys ever saw what they developed?

NetBeans 10


Just perfect. Bold marks methods implemented in class and plain - inherited methods, text aligned to let you browse return types with ease.


Eclipse 11


arg0?...

NetBeans 11


Well, it's really the best found option around.


Eclipse 12


Hm... no text autoquoting?...

It even can't put semicolon to the right place!...

NetBeans 12


Oh, here is text autoquoting, autoputting of semicolons... But it's NetBeans who helped me to save my time.


Eclipse 13


Wait... but there is src.zip with my JDK installation, it's full of javadocs! Why can't it just show me javadoc from there? Do I really need to go and download javadoc.zip in 21st century?

NetBeans 13


Here we go, it's not hard, is it?


Memory usage now


Memory usage after comparison above. And you will be next to say me that "native SWT is faster than interpreted Swing"? I'll write separate article about that myth.


Conclusion


"IDE" stands for integrated, but as naturally I expect my IDE to help me in my every day job. Help in this case stands for autoquoting, autosemicolons, simple and fast dialogs, and of course pretty and usable interface, that saves your time searching required items. Currently NetBeans is only IDE that really tries to help me as much as it can, though there are things to work on. And that makes me NetBeans user, not just big user base or Sun trademark.

2009-05-27

Problem Silverlight: Micro$oft owns your computer


Intro
I am using official version of M$ Windows XP at work, and all the day yesterday I fought with it's updates. Yes, I am talking about Silverlight. I do not care about other possible updates as long as they have no impact on my work. But this one... "Why not?" you will ask... Well, I have few reasons.

1. This computer is MINE!
It installed without my approve. Just downloaded and made ready to install. And more, when I am checking box "Don't notify me about this updates again" it waits about 5 minutes, than downloads it again and installs it again. I can't cancel or forbid installation of this package. Just can't. I have no control over own operation system! I can put TABOO on any package on my SUSE Linux box, but I can't make Windows ignore this peace of "optional" crap.


2. User-agent of browsers
When silverlight is installed - it changes user-agent string of web browser to include itself. M$ already changed user-agent of my Firefox to this one:
Mozilla/5.0 (Windows; U; Windows NT 5.1; uk; rv:1.9) Gecko/2008052906 Firefox/3.0 (.NET CLR 3.5.30729)

What for? Someone is using those dirty techniques to determine silverlight or .NET installed on my machine? And why M$ hacks my browsers without my permission to do it? I can't agree with such politics.

3. Politics
Development of Silverlight looks like politics solution from my point of view. If you can remember history of Netscape - you will see that M$ always releases own products of same kind after they're losing market. Market is totally occupied by Adobe with it's products and experience with graphical applications. M$ will easily take market back with such "optional" features as Silverlight.

4. Religion
I am Java developer. And being Java developer I can see that no one believes in desktop java apps because of JRE on client's computer. Do you really think that JRE is harder to install than Flash Player? No it's not. But "everyone has a flash player, but no one has JRE installed" is already mature religion in most countries. So that will be my own religion - if something is written in silverlight - I don't need it with it's crappy silverlights.

2009-05-07

Java and music player


Today I found post on elliotth's blog about Java and MP3. Being developer of Xine engine for aTunes I have own thoughts about it.

Step 1: Target users
At first you should decide who will be your users. Depending on this choice you have different amount of possibilities. For example, Qt Jambi with Phonon will fit for all systems, while Xine is not available for M$Windows users.

Step 2: Engine
Second part of music player is engine. I am long time SUSE user and I prefer Xine over other because it ships with SUSE and all best KDE apps are using it as engine. Also popular MPlayer, VLC and Gstreamer. Of course I hate Gstreamer because of strange format support politics and trashy sound, but it's your own choice.

Step 3: How to use engine
After you decided what engine you want to use - there is a question how to use it.

a) JNI
You can use some wrapper generator like SWIG to generate wrappers and use it from your application. While this is the fastest way to invoke engine - there are few possible problems:
1. You have to build your application for all platforms yourself. It can be hard enough if you have no compilers for target platform and you have never used some of target platforms, or you have only 32bit CPU.
2. Static vs dynamic linking. I am not C/C++ guru, but I noticed that some apps build on other systems than mine can't find libs from system folders like /usr/lib. It's easy to understand that there are some linking problems for target platform depending on libs path or libs versions.

b) JNA
It's my favorite. JNA guys did a great job. They solved all possible problems in JNI approach, building jna.jar for all platforms and supporting dynamic linking. The only problem - mostly you have to read *.h files and write classes to wrap them. It is simple if you know a bit of C/C++.

c) cmd line
You always can invoke your engine from command line. MPlayer have it's own command line interface, so you can just send commands and read responses from Process stream. Also, Amarok supports commands like "amarok -s" to stop. May be your favorite player also does? Of course you should give user to choose path to your supported engine, while Linux platforms can be found in $PATH it will not work on M$Windows.

d) Use Qt Jambi
I already wrote about Qt Jambi. It's great solution for any desktop application, not just music player. And it have it's own media API, that can be found in examples. I suggest you to download and take a look yourself.

e) choose from existing wrappers
Many engines have it's own wrappers already. Here are some of them:

2009-03-06

Chaos Obliterators handmade

There are only two metal models of Obliterators on Games-Workshop. I really hate metal models. That's why I took Chaos Terminators box and pack of greenstuff to make my own obliterators.

Obliterator-virus is technovirus by fluff, and I can't understand why original obliterators are covered with skin like some Nurglish followers. Skin should be visible in places of technology attachments as for me, but not to cover all the huge terminator armour.

This guy got additional inputs into his brain, in addition to all his weapons in right arm and "power fist" made from terminator "possessed arm" and arm of possessed marine:


Head of this guy is covered with small datacables, and he got servo arm somewhere. His "power fist" is a combination of terminator's shoulder and possessed arm to:


Once this guy was terminator, and got obliterator's bionic. Now he just can't get out of his terminator armour and have plenty of weapon to use:



2009-02-26

Qt Jambi first experience


Being long time KDE user and Java developer - I couldn't ignore Qt Jambi release. Of course I downloaded it and tried as soon as version 1.0 vas released. Yes, at first it was version 1.0, built with Qt 4.3. Only after some time Jambi got version as its Qt.

I was impressed even with first version, but it seemed a bit slow and not yet ready for every day usage. But last week there were some news about Qt 4.5 and LGPL license, so I downloaded last available version of Jambi and started few example apps.

And now I am really impressed! I used to think about Swing as fast and developer-friendly when developing some desktop applications, but now I know Qt is really two heads higher in desktop apps development. Jambi evolved and now there is no problem of setting LD_LIBRARY_PATH and other params, you can simply include jar file with Qt and Jambi libs to your classpath.

Then I started a bit bigger project to have complete application in Jambi. As long as there is no fast and stable notepads for Windows I wrote QEdit. You can see sources here.

Now, after I have some first experience with Jambi I can compare Jambi and Swing:

+ Jambi has better shortcuts system. You don't have to work with root panes and actionmaps, you can just ass some shortcut to your action.
+ QStatusBar. I thought about writing something similar for Swing few month ago, but here you can assign statusTip to your action and that tip will appear in status bar on rollover.
+ QSettings. It is much more usable than Properties for storing your settings.
+ QToolBar. Even if it is possible to do something similar in Swing - you will never spend so much time to do it like Qt can. You can download and run QEdit to see how you can move toolbars to different parts of main window and this position will be saved between sessions.
+ QFontDialog. Almost every Swing application have to implement Font Chooser themselves, while QFontDialog is almost the same in every application.
+ Components already have their scrollbars, you can just enable or disable them. I can't remember at least one case when you don't need to wrap JTextArea into JScrollPane.
+ Wide range of supported graphic formats and components adjust size of graphic automatically.
- Jambi can't see if wrapped C++ classes extend some other classes.
- Jambi QFile is very slow and locking file. I don't like when File object locks real file on file system, only io operation should block it. So don't try to use Qt Jambi for all your tasks at once.
- No way to extend or customize QFileDialog. Even style is not applied to QFileDialog.
- Signals in "action system"... It's just wrong in Java. Thanks that application fails on first start but not in time of invocation if something is wrong in source.
- You can't give both small and large icon to QAction. After providing 22x22 icons some of them looks too smooth in main menu.
- Lack of documentation. If you are not enough documentation and examples from Jambi distribution - even Google will not give you a lot.
- Looks like all the work is performed in blocking QApplication.exec() method. I can't find is there anything like SwingWorker for Qt or Jambi...
- There are lots of possible pitfalls when you are writing huge application, and Swing "experience base" is huge enough to help you in almost everything, plus Swing is pure Java where you can debug everything you want. But where to go with Jambi? There is support in Trolltech for commercial version...

2009-02-16

Java is faster than native


There is a myth that native is much faster than java. Lots of frameworks speculate this myth and using lots of native methods from java. But how often they are implementing same functionality and check native against true-java? They are often diving so deep in own fantasies about native performance that it is almost religion, they just don't accept facts. But how much it takes to JVM to invoke method from native library? And how much is it comparing to raw java interpretation?

I don't like to use things that I don't understand. Almost all methods from Math class is native, and I can't see sources of that classes. There are some functions that would be hard to implement, like Math.sin() or Math.cos(), but there are some easy-to-implement methods. This time I need functionality of method Math.pow(). It is not hard to implement it in java:

private double pow(double value, double pow) {
  double result = value;
  for (int i = 1; i < pow; i++) {
    result = result * value;
  }
  return result;
}

And it is not hard to implement some raw test using case from current developed application:

private static final int times = 1000000;
public static void main(String[] args) {
  // running test 10 times to "hotspot" it
  for (int i = 0; i < 10; i++) {
    // I know, I know, you can never
    // preallocate long, but I like it:
    long start = 0;
    long end = 0;
    start = System.currentTimeMillis();
    for (int j = 0; j < times; j++) {
      pow(10, 10);
    }
    end = System.currentTimeMillis();
    System.out.println("pow: " + (end - start));
    // cleaning JVM every time before next cycle:
    System.gc();
    System.runFinalization();
    System.gc();
    start = System.currentTimeMillis();
    for (int j = 0; j < times; j++) {
      Math.pow(10, 10);
    }
    end = System.currentTimeMillis();
    System.out.println("math: " + (end - start));
    System.gc();
    System.runFinalization();
    System.gc();
    // and running once more to be sure in hotspot:
    start = System.currentTimeMillis();
    for (int j = 0; j < times; j++) {
      pow(10, 10);
    }
    end = System.currentTimeMillis();
    System.out.println("pow: " + (end - start));
    System.gc();
    System.runFinalization();
    System.gc();
    start = System.currentTimeMillis();
    for (int j = 0; j < times; j++) {
      Math.pow(10, 10);
    }
    end = System.currentTimeMillis();
    System.out.println("math: " + (end - start));
    System.gc();
    System.runFinalization();
    System.gc();
  }
}


I just wanted to figure out how slow is my implementation, but results were totally unexpected!

run-single:
pow: 63
math: 797
pow: 78
math: 797
pow: 78
math: 781
pow: 78
math: 781
pow: 63
math: 781
pow: 63
math: 781
pow: 63
math: 797
pow: 63
math: 797
pow: 63
math: 797
pow: 63
math: 782

It's 10 times faster than Math.pow() when raising power of 10!!

Think different. Think faster!

2009-02-12

Chaos Dreadnought conversion


Games Workshop produces two kinds of kits - metal and plastic. I hate metal kits - it is hard to convert them, hard to keep them unbroken, hard to repair them if they're broken. And Chaos Dreadnought is metal model.

Modeling Plastic Chaos Dreadnought!
All you need - Plastic Space Marines Dreadnought, few Terminator torso bits and few decorative chaos bits. And may be some greenstuff.