Thursday, November 08, 2007

What do we need to save the world?

Guns. Lots of guns.

And since it's not guns that kill but humans, also concealed carry permits are needed.

Friday, October 19, 2007

Not for, not against (France, 2002)

Caty, a 27-years old news photographer meets a chance to make money quickly by photographing a robbery. She starts to hang out regularly with the gang ...

The back of the film box tells this much, and I won't spoil more. It's a noirish film, where an ordinary citizen is gradually attracted to the dark side. "In the beginning: How I became Femme Fatale" could be its second name.

I like the first half for several reasons.

Firstly, it meets my minimum standards of realism. There wasn't any single scene which would have invoked "People just don't behave that way!" alarm. The petty criminals have low impulse control and don't care about harm done to others, and are attracted by glamorous life of bling-bling and sex. The criminals as well as the girl believe that you can get something for nothing - the lottery ticket which the girl scrapes sum it up quite well.

Secondly, the sexual market value interactions were about right. The man showed high status by demonstrating his affluence. He demands that thing are done his way; at the same time he signals indifference by making it clear for the girl that she simply leave if she doesn't like his way. The man also gives protection for the girl; the gang liberates the girl from unwelcome approaches by threatening with violence those who try to approach.

Thirdly, it captures well the sense of urban existential void and isolation, both in some scenes and in the background music.

The girl is somewhat contradictory combination of high class and low class. The fact that she practiced ballet dancing, chose a semi-artistic profession and lives in a spacious apartment implies middle-to-high class. His eagerness to make quick money and lack of parent involvement during the whole film implies low class.

The second half is like an entirely different movie, but the final solution is superb.

Monday, September 10, 2007

Sexual Market Value 101

That could be the second name of Dumplings, a Korean thriller/horror movie. The main character is a formerly beautiful woman who has attracted a rich man to his side. Her decreasing looks cause a temptation for him to trade up...

The best thing about the film is that it is free from hypocritical feminist undertones. Both men and women are equally capable of evil, and both view the sexual market as a game with losers and winners.

FTO 3/3: If You Already Are Rich, FTO Is The Key To Stay Rich

The title sums it all. I intended to tell about a super-rich relative of mine (which I've met once) and quoting Millionaire's Daughter, but that wouldn't add anything relevant.

Here are some mottos with the same message.

Those with affluence and FTO can afford their expensive cars and houses in the same sense as a middle-class person can afford a bathroom renovation.

Take a luxury good that creates most envy among the poor. The envious poor can't imagine how little it means for those with affluence and FTO.

If you fear that your clothes get stolen from the drying wire, despite the fact that it hasn't happened earlier in that neighbourhood, it means that you are wearing too expensive clothes.

Monday, August 27, 2007

FTO 2/3: Future Time Orientation in The Damage Done

Damage Done is an autobiography of an Australian drug mule who got imprisoned in a Thai prison for 12 years. It also shows the strengths and weaknesses of short FTO: brilliant short-term tactical decisions combined with insane risk-taking and ignorance of warning signs.

FTO 1/3: Future Time Orientation in Oldboy (Korea, 2003)

Oldboy depicts a man with short FTO right from the first scene. In this scene, he's drunk in a police jail, noisy, impatient, resisting his chums and police, a disgusting and unempathic anti-hero. This image is strenghtened in later scenes.

The film also shows the strength of short FTO - namely, ability to make the best out of every situation. This is especially visible in his popularity with women. The film shows two successful seductions and hints at much more. (That bring this post by Bulletproof Pimp into my mind. In both Oldboy and this post, physical fitness was the only factor where the men showed long-termism.)

There are also two few scenes where long-term approaches turn out to be useless. The first of them happens at the imprisonment period, but I won't spoil it. The second happens some hours after the main character has been released. He faints and wakes up again. He utters a scientific-sounding hypothesis that lack of vitamin D and sudden sunlight made him faint. His girl answers "I hope you don't always talk like that." In the end, the hypothesis turns out to be false. Reliance to scientific explanations, a long-term strategy, turned out to make him unpopular and misguided.

The short-termist philosphy of life is also pronounced explicitly. In one scene, a gangster boss takes a tooth out of the protagonists mouth as a revenge. Then the gangster puts the pliers close the his mouth as if planning to pull another teeth. The protagonist shouts, expecting pain. At that point the gangster takes the pliers away and says "Don't imagine. You fear because you imagine what might happen. Don't imagine, so you don't fear."

The ending reflects well the main character's revulsion towards long-termism. The most important causes and consequences of the plot turn out to be arbitary and unbelievable. Things are not really explained in the end; they are messed up in the end. And in the eye of the madness, the short-term tactician wins over the long-term manipulator.

Sunday, August 05, 2007

Smoking in Oldboy (Korea, 2003) and Lady Vengeance (Korea, 2005)

Oldboy and Lady Vengeance are two revenge-themed films by Chan-wook Park. They have the coolest smoking scenes ever.

In Oldboy, the main character has trained martial arts against a wall in prison, not being able to practice against opponents. When he gets free, he wonders if "15 years of imaginary training can be put into use". He goes to a gang of 5 juveniles, takes a cigarette from one gang member's mouth and inhales. In the next scene, he gets a strong kick to stomatch and falls on his back, arms and legs spread. He raises the hand holding a cigarette, puts it to his mouth, sucks a dose of Nicotine Power, and rises up to beat the gang with bare hands.

In another scene he's in a schoolyard. There is a girl riding bicycle around the yard. In order to see better under her skirt, he goes to a push-up pole, hangs upside down in it and lights a cigarette. A schoolteacher comes to say that he can't smoke in a catholic school, but the main character dismisses it with a cool rebel attitude by saying that he leaves the school tomorrow. After some minutes, he goes on to seduce the girl.

In Lady Vengeance, the strong and independent main character lights a cigarette after soul-shaking session of sex.

PS. 50% of Korean high school males and 30% of females smoke more than 5 cigarettes a day.

Saturday, August 04, 2007

Life Is Full of Choices

On the one hand, there is Kiuas performing at Jalometalli festival at 18.8.2007. On the other hand, there is Culture Beat performing at D-Fest at 17.8.2007. These events are exclude one another, since if I go to the (chronologically) first, I'll drink so much that I won't be interested in travelling to the second. Is any of my dear readers willing to go with me to either event? If there are several readers, youung, fertile women are preferred. If no reader is interested, I may be too lazy to go to either event.

Friday, August 03, 2007

Bang Rajan (Thailand, 2000)

The cover of the film advertised it as "the Braveheart of Thailand". After summarizing the plot, I'll compare it to Braveheart.

The film is set in 1800th century Thailand. Two Burmese armies are on its way to Thailand's capital Ayuttaya, destroying, looting, raping, killing and enslaving everything on their way. Bang Rajan has successfully resited earlier Burmese conquest attempts. The survivors from other destroyed villages are escaping there for a final showdown, having few other places left to escape to.

In Braveheart, I wondered why the Scottish preferred the abstract concept of freedom to a violence monopoly of the most successful and enlightened sea power of the time. In Bang Rajan it is more clear why people choose to fight. There are long flashback footages where the Burmese come to burn and loot Thai villages. There also seems to be a mutual acceptance of killing: both the Burmese and the defending Vietnamese are very keen on killing them all in the opposing side. However, there are two scenes where the Burmese imprison and enslave the Thais instead of killing them, so it's not all about genocide.

Braveheart concentrated on one heroic individual and his defining experiences. The main characters of Bang Rajan represent the wider experiences of the villagers. There are escapees from another village who witnessed the destruction of their homes and killing of the people with whom they lived. There is a squad of men who have successfully fought against the Burmese before. There are pregnant women who are worried about the future of their men and offspring.

The most striking difference between Bang Rajan and Braveheart is the total lack of sophistication in Bang Rajan. The motivations or the villagers are very simple, usually linked to survival, sex, security and food. When they choose a leader, the best justification they give for him is that he is "strong and hates Burmese". There's very little tactical reasoning, which could be compared to Braveheart's long spears that are used against a cavalery attack. Even the Western-style moral sermon - where a Buddhist monk claims that also Burmese are human beings - is quite naive.

I didn't watch Braveheart to the end, since the rugged individualism got too thick. But I did watch Bang Rajan. Despite its crudeness or thanks to it, it stays consistent ("pysyy kasassa") through the whole film. It is the perfect propaganda movie: There is nothing abstract or delicate or implicit, but instead it blasts its message to viewers' face in cat-sized letters in its long, unambiguous, repeated, gruesome scenes.

Thursday, August 02, 2007

I Have Nothing To Say

During the last month, I've started renting movies, so this blog will become a movie review blog for a few months. The following three changes have caused me to rent movies:

1) No more any obligation to try to use my leisure productively. As a student, there was always some book to be read or exercise to be done for a test or something. Not that I ever did them.

2) Being employed, the cost of renting a movie is insignificant to the time cost of watching it.

And, most importantly

3) I've found a way to pick non-boring movies! I look at the country of origin. If it is Asian, the movie is probably ok. Firstly, they are not Hollywood movies, which means that they don't make you so bored you stop watching in the middle. Secondly, they originate from a different culture, which means that they have lots of oddity and strangeness in details and the way things are told. Thirdly, the filter is really tough: only a small fraction of films reach the renting store, so the level is high.

Wednesday, June 20, 2007


  • Bought a shirt reading "Perfect Waves". It's perfect for a situation, where perfect sound waves are being played.

  • Perfect sound waves can be downloaded from Cantata Sangui's website. It's a goth metal band with two vocalists: an extremely high-pitched and clear female singer and extremely low-pitched male growler. The combination sounds really funny.

  • Steve Yegge is back, after almost being eaten by wolves!


Monday, May 14, 2007

... everybody has one.

This video ranks 20 Eurovision songs, showing 30-second clips from each.

It's funny how taste correlates. I agree with the person who made that video that Bulgaria, Malta, Slovenia and Georgia earn a place in Top 6.

It's also funny how taste doesn't correlate. Malta's song has catchy melody and exactly the kind of words that you could memorize and sing when you're walking and nobody's around. Still, it was dropped in semifinals, and the other Subjective Top 6 countries were evenly dispersed in chart.

Regarding the winners, Serbia is ok and the singer is clearly a pro. I have to admit that I just don't "get" Ukraine's song. Russia's song had the sexiest performance, despite the fact that many other performers were more scantly clad.

Friday, April 13, 2007

Ugly Betty

Being on the topic of marketing, it is nice to see Ugly Betty ads decorating the outdoor advertisement spots. At last a clothing style which distinguishes itself from the mass.

The other clothing ads don't even try. In live environments conventionally pretty girls work, but in media bland sexiness is boring and alienation kicks ass. Just like in Eurovision song context.

Simo The Mobile Application Developer

Do you think it is cool and hip to develop mobile applications? Send your congratulations to Nokia's marketing department. This post sums up nicely the image that Nokia wants to create about mobile application developers.

Mobile application developers are social and active extroverts, who participate in commonplace activities of young people:

Whether it's at a dinner-party or late night foray into a strange bar, the fact that I work for Nokia is an easy ticket to talk. People generally have powerful reactions, as more often than not I'm working for the company that makes the product that gets them to work, connects them with who matters to them, and gets them laid.


Mobile phones are sexy status objects, but also deeply personal companions to which the user attaches on emotional level:


(Sure there are often also comments along the lines of "why on earth don't you bring back that beautiful silver bullet phone [6310] - it was my favourite thing ever..." etc.) But the fact remains - we are still carrying a good deal of people's goodwill, and we mess with it at our peril. And nowhere is this goodwill more obvious than in the trusty familiar contacts book ...


Especially Nokia mobile phones are high quality:


... with a well-deserved reputation for solidity, easy to use, reliability and the fact that the damn thing just works.


Mobile application developers are open-minded and innovative, and not afraid of breaking rules and shifting paradigms:


One of our recent Nokia speaker series guests put it like this - the telco industry has lost the opportunity to innovate in the contacts book, whereas the internet industry has come along and invented an entire new industry - social networking - to fill this innovation void. Hmmm, food for thought?



Messing with the contacts book would be like painting a moustache on the Mona Lisa - an act of vandalism, surely. Surely? Well, I'm not so sure. I am deeply uncomfortable with the idea that things must stay how they were because that's how they have always been.


Nokia phones were created for trendy, sexy, active and successful people, by trendy, sexy, active and successful people.

Tuesday, April 10, 2007

Appendix I


  • Symbian folks know that C++ is not the fastest way to implement functionality. They demonstrate it by their actions: Symbian's IDE, Carbide.c++, is Eclipse-based which means that it is written in Java. Symbian's build system is a bunch of Perl macros.

  • Ilkka describes the irritation of low-level languages well in this post.

Monday, April 09, 2007

What's Wrong With Symbian

In short: Crippled C++. C++ is already quite a low-level language. Symbian has plenty of coding conventions and classes, which make this even worse. There is cleanup stack to prevent memory leaks; leave mechanism to simulate exceptions; and RArrays and RPointerArrays to simulate std::vector. Finally, there are active objects to simulate threads or message passing or callbacks or whatever, I'm still not quite sure despite using them for years.

Nowadays Symbian phones have as much memory as late 486s or early Pentiums, although the memory is slower. So is it really worth it to save miniscule amounts of memory and make programming harder?

The era of mobile Java isn't here yet. I mean, the era when the operating system consists of Java VM, device APIs, and some core high-performance units like phone calls, video codecs, OpenGL, etc. Java is still too slow. Therefore, C++ is still a necessary evil.

In addition to crippled C++, also APIs are less-than-perfect. Java developers who have used entity beans or Hibernate may feel schadenfreude from this fact: Symbian has an internal database in every device, but you can only access it with SQL. No object/relation mapping tools for you. In general, there aren't any helper APIs which wrap the functionality to an easier form. 2.5 years ago when I last programmed Symbian, the APIs also has stupid bugs, but I hope that is fixed now.

Friday, April 06, 2007

The Glass of Success is Half Full

As planned, I applied for J2EE jobs using Finnish annotator (FA) as a merit. FA was implemented with embarrassingly low technologiy: HttpServeltResponse.GetPrintWriter().println() produced most of the web pages. I got to 3 job interviews based on it.

After one interviewer told me that they used JSP and servlets to implement web services in 2001, in no uncertain terms, I realized my J2EE experience was inadequate and that I would rather be an experienced Symbian programmer (despite the shittiness of Symbian, which is worth anoter post) than a J2EE trainee. After that, I applied for Symbian jobs and got one from a mid-sized Symbian subcontractor. I'm not going to tell the name of the company, since I have no idea how it differs from other mid-sized Symbian subcontractors, and because they have their own marketing department to take care of their external image, thank you veeery much for your suggestion of advertising by blogging but no thank you.

The Symbian job I got pays 600e/month more than what I got at Nokia. I started 1.4. I still haven't been assigned to any project, but anyway I'll get more pay than ever before for carrying less responsibility than at the last months of Nokia.

If I had really wanted to get a J2EE job, I could have applied at J2EE Professional Trainee Program at Tapiola. But I thought that it was too easy, since from the 4 technologies they list (JSP, XML, EJB, WSAD) I already know JSP and XML and have read a book about EJB, so that only WSAD (whatever it is) would be totally new. Also, applying to the program would be dishonest, since my interest in J2EE is not about becoming a Tapiola man, but about developing the FA.

By the way, "professional trainee" is an oxymoron. Who wants to be an oxymoron?

My initial plan with Finnish Annotator was to collect a 5000 word Finnish vocabulary by September. This would have required me to write English definitions for about 24 words a day. Now that I actually work, I have noticed that I have no energy to write word definitions after work. So 5000 words is utopistic. I'll have to either overcome procrastination or find out just how many words I have patience to write before contacting a Finnish teacher and sugggesting co-operation.

The glass of success if half full or empty in the sense that I failed to get a J2EE job but succeeded in getting a job that pays more than anything I have done before.

What to do with the money when I've accustomed to a student budget? There are practically only 3 ways to spend it in a way that actually increases my standard of living:

  • Get a mortgage instead of paying rent; this would mean that in the future, if I want, I can loan money and use the apartment as a guarantee.

  • Travel to foreign countries. Among my peers this is a popular hobby which I haven't done much.

  • Buy sex, an option I should try since I'm never going to get any with my current levels of nerdiness and muscularity without paying for it.

Tuesday, February 20, 2007

Get a Haircut And Get a Real Job

Big brother Simo got a haircut and is having 3 job interviews this week. Meanwhile, my brother is doing fractal art.


fraktaali
Frozen turboflowers


However, the difference is not as big as in the song of George Thorogood, since I have my own semi-creative project of questionable utility.

Monday, February 19, 2007

One Encoding to Rule Them All

In Java, all strings are Unicode strings. The Swing GUI components also support more advanced features of Unicode like Arabic right-to-left writing. It is almost trivial to make a GUI application that support all possible scripts from Katakana, Cyrillic alphabets and Korean Hangul to thousands of Chinese characters and various right-to-left scripts. The only thing you need to take care of is that when you access external interfaces, the data is passed in Unicode.

In traditional GUI applications, this means reading and writing text files in Unicode instead of the default encoding. Here's how you open a file for writing in UTF-8 encoding:


File file = new File( fileName );
FileOutputStream fos = new FileOutputStream( file );
OutputStreamWriter osw = new OutputStreamWriter( fos, "UTF-8" );
BufferedWriter writer = new BufferedWriter( osw );



The difference to opening a file in the default encoding is really small:



File file = new File( fileName );
FileWriter fw = new FileWriter( file );
BufferedWriter writer = new BufferedWriter( fw );



The difference in reading a file is equally small. Not too difficult, huh? Turns out that it is for those who haven't confronted foreign character sets before. Before starting to roll my own flashcard program, I tried some free ones, some of them written with Java. Turned out that many of them didn't support Unicode. Well, that's one way of making sure that communists don't use your program.


don't support unicode


You may also want to write unit tests to ensure that the Unicode support really works. To embed Unicode into the source files of the test cases, you need to signal the compiler that the source files are encoded with UTF8.



C:\>javac -encoding UTF8 MySource.java



Ditto with the editor (in this case, Eclipse)

eclipse and unicode

With web services, it's a bit different issue, since there are so many external interfaces. First of all, the source file UTF8 switch must be embedded to the Ant build file (assuming that you use Ant):


<javac destdir="${build.dir}"
target="1.5"
debug="true"
deprecation="false"
optimize="false"
failonerror="true"
encoding="UTF8">



Now, let's look at the generated XHTML page. Firstly, to make it valid XML, you have to define the encoding in the first line that describes the nature of the document as XML.



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="FI" lang="FI">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>



The second instance deserves more explanation. When a web page is delivered from a server to a browser, it is delivered by the HTTP protocol. The HTTP protocol includes HTTP headers that describe the package. Usually, the default values of the headers are just fine and you can forget them - except for the character encoding. The <meta> element is trying to say that the document IS encoded in UTF8, not matter what the HTTP headers say.

Unfortunately, browsers tend to believe HTTP headers rather than the <meta> tag. This code snippet is from the Perl exercise work where I first run into this problem:


# The final part of this line (charset=UTF-8) is
# absolutely essential. Without that line,
# the UTA webserver somehow convinces the
# browser that the encoding isn't UTF8,
# even if the .html says otherwise.
print "Content-type: text/html; charset=UTF-8\n\n";



In servlets, the equivalent code is:



public void doPost(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html; charset=UTF-8");

PrintWriter out = response.getWriter();
out.println( "<html>" );
out.println( "<head>" );
out.println( "<title>Helo World</title>" );
out.println( "</head>" );
out.println( "<body><h1>Helo World</h1></body>" );
out.println( "</html>" );
}



In addition to writing data in UTF8, we also need to read characters typed by the user. This is done by setting the encoding propery of the request object (the object that contains the form data from the user):



request.setCharacterEncoding( "UTF-8" );



The Java documentation says that the encoding of the request object must be set before you pull any data that the user just typed. Sometimes the servlet is provided by some third party, and you can't set the encoding just-in-time before reading data. For example, if you use Spring's SimpleFormController to structure to validate forms, Spring automatically reads the form data to a more convenient structure before giving it to you. In these cases, you have to configure a filter that is run before the servlet. Filters are classes that are modify the input or the output of a servlet. This snippet is written to the deployment descriptor, web.xml.



<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<servlet-name>springflash</servlet-name>
</filter-mapping>



Finally, if you use JSP to generate the final pages, you need to put the following headers to the JSP files.



<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page pageEncoding="UTF-8" %>



Now, after shouting 11 times "USE THE DAMN UNICODE!!!" the system finally believes. We're still waiting for the one encoding switch to rule them all.


The encodings not so blest as thee,
Shall in their turns to limitations fall;
While thou shalt flourish great and free,
The dread and envy of them all.

Rule, Unicode! Unicode, rule the scripts:
Britons never shall need more glyphs.

Friday, February 16, 2007

Configuration Considered Harmful

Half a year ago I downloaded my first Java 2 Enterprise Edition, also known as J2EE, the version of Java you use to build websites. It uses a very complex build system named Java Blueprints, spanning 26 files and 2000 lines of XML and settings. Coming from Symbian background, I though that the build process really is incomprehensibly complex: In Symbian, the build process uses ~100 or so perl modules, and you are not supposed to modify them. To give you an idea of how much 2000 lines is, note that this applet, which packs some real functionality, takes ~1500 lines.

In fact the J2EE build process is really simple. First, you build a jar file with a specific directory structure. Then you deploy it to some application server. Knowing this is useful when you switch from one application server to another (in my case, from Sun's server to Tomcat). Therefore, it's really stupid to use a huge build system.

Complex systems are OK when they really work and make things easier. Anyone who has converted a medium-sized application from manual building to Make or Ant knows this. However, when they become complex enough without being nicely encapsulated, they introduce an extra moving part. Useless moving parts merely make things more difficult.

Java is famous for giving good and accurate error reports in the form of exceptions and stack traces. The compiler checks the code extensively before you can execute it. There is also a standard way to produce good documentation for Java modules that are delivered to third parties (the Javadoc tool). Configuration systems tend to be exactly opposite: They use custom formats, often XML, which are often poorly documented. Their error annoucements leave you wondering what the hell went wrong, if they give any in the first place. Often, you can't be sure whether the error is in the configuration files or in the code.

Next, I'll present a truly minimal hello world J2EE application. Here is the list of files:



build.xml - the Ant build file
src\HelloServlet.java - the source code
web\WEB-INF\web.xml - the deployment descriptor



Here is the source code. When you type the address of the web service (usually http://localhost/hello or something similar), the program calls the get or post method of this servlet. The request object contains the things that the user sent to you: for example, if the user filled a form and pressed submit, the contents of the form are in the request. The response represents the HTML page that you return to the user.



/* Minimal Hello World servlet */
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloServlet extends HttpServlet {

public void doGet(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
doPost( request, response );
}

public void doPost(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html; charset=UTF-8");

PrintWriter out = response.getWriter();
out.println( "<html>" );
out.println( "<head><title>Helo World</title></head>" );
out.println( "<body><h1>Helo World</h1></body>" );
out.println( "</html>" );
}
}



The deployment descriptor tells that the application should be deployed at "hello" subpage (http://localhost/hello) and that the HelloServlet generates the page (there may be several servlets).



<?xml version="1.0" encoding="UTF-8"?>

<web-app>
<display-name>hello</display-name>

<servlet>
<display-name>HelloServlet</display-name>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>HelloServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

</web-app>



The Ant build file build.xml is still somewhat more complex than needed, but a far cry from 2000 lines. There's nothing worth reading happening there, it is here merely for completeness. It has been simplified from the spring tutorial build file, which strikes a very good balance between simplicity and functionality.



<?xml version="1.0"?>

<project name="flash1" basedir="." default="build">

<property name="src.dir" value="src"/>
<property name="web.dir" value="web"/>
<property name="build.dir" value="${web.dir}/WEB-INF/classes"/>
<property name="name" value="hello"/>
<property name="tomcat.dir" value="/tools/tomcat5.5"/>
<property name="deploy.path" value="${tomcat.dir}/webapps"/>

<path id="master-classpath">
<fileset dir="${web.dir}/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<!-- We need the servlet API classes: -->
<!-- for Tomcat 4.1 use servlet.jar -->
<!-- for Tomcat 5.0 use servlet-api.jar -->
<!-- for Other app server - check the docs -->
<fileset dir="${tomcat.dir}/common/lib">
<include name="*.jar"/>
</fileset>
<pathelement path="${build.dir}"/>
</path>

<target name="usage">
<echo message=""/>
<echo message="${name} build file"/>
<echo message="-----------------------------------"/>
<echo message=""/>
<echo message="Available targets are:"/>
<echo message=""/>
<echo message="build --> Build the application"/>
<echo message="deploywar --> Deploy application as a WAR file"/>
<echo message=""/>
</target>

<target name="build" description="Compile main source tree java files">
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}"
target="1.5"
debug="true"
deprecation="false"
optimize="false"
failonerror="true"
encoding="UTF8">
<src path="${src.dir}"/>
<classpath refid="master-classpath"/>
</javac>
</target>

<target name="deploywar" depends="build" description="Deploy application as a WAR file">
<war destfile="${name}.war"
webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</war>
<copy todir="${deploy.path}" preservelastmodified="true">
<fileset dir=".">
<include name="*.war"/>
</fileset>
</copy>
</target>

</project>



This example gives us another case about configuration and its discontents: The deployment descriptor. When you do traditional graphical user interfaces with Swing, you create the elements by code. Imagine that instead of writing an XML deployment descriptor you would configure the application by code, applet style, demolishing the second big instance of configuration in J2EE. What would it look like?



import javax.servlet.*;

public class HelloApp extends Weblet {

public void init() {
setName( "hello" );
addServlet( "HelloServlet", HelloServlet.class );
mapServlet( "HelloServlet", "/" );
}
}



In what way is this inferior to web.xml?

Thursday, February 15, 2007

Time stopped?

In the good old days of the old Republic machines doubled their speed yearly. My three-year-old 2GHz laptop is getting slow, so checked the new machines. To my surprise, the low-end is almost the same. Something fundamental has changed while I didn't look.

This post is being written on AMD Athlon 2600+, and here they sell AMD Athlon 3000+. For the first time in my life, a memory upgrade may be enough to transform and old machine into a modern one.

Eclipse takes 100MB, Firefox takes another 100MB and the app I run on Tomcat takes 100MB. And then you should compile. Not something that fits to 500MB.