Sunday, September 4, 2011
Surprise of the day
Well what do you know! It turns out Microsoft was a bigger contributor to Linux kernel version 3.0 than Canonical, as LWN reports. Probably a bit of a fluke but an interesting statistic nonetheless!
Saturday, July 23, 2011
Q_rsqrt
I still remember encountering the following piece of code while browsing through the Quake 3 source code back in 2005:
I again ran across this piece of code while browsing an amuzing list of the best comments in source code you've encountered, over on Stackoverflow.It turns out the original author of this illustrious piece of code is still unknown (it's not John Carmack as you might have assumed). A nice write-up of the likely history of this hack can be found on Beyond3D. Interesting reading for sure!
UPDATE: The original author is actually known and it is Greg Walsh. Wikipedia also has a lot of background.
Talking about funny comments in code, my personal favorite from the Stackoverflow list must be the following:
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
#ifndef Q3_VM
#ifdef __linux__
assert( !isnan(y) ); // bk010122 - FPE?
#endif
#endif
return y;
}
That comment on line 10 pretty much sums it up: WTF!?!?I again ran across this piece of code while browsing an amuzing list of the best comments in source code you've encountered, over on Stackoverflow.
UPDATE: The original author is actually known and it is Greg Walsh. Wikipedia also has a lot of background.
Talking about funny comments in code, my personal favorite from the Stackoverflow list must be the following:
stop(); // Hammertime!Not so much the comment, but the german version really cracked me up!
Tuesday, July 19, 2011
Java SE 7
It was a long time in the making but all JSRs constituting Java SE 7 have crossed the finish line! The actual Java SE 7 software release is just around the corner (July 28th). Exciting stuff!
Saturday, July 2, 2011
Tech support interference
It's a well known fact that developers and tech support people typically don't get along. The developers want freedom to do as they like with their machines, while the tech support guys want to close everything down, mainly for security reasons.
Sometimes this can get quite ridiculous. I recently heard a story about a development team building a web app that required Firefox compatibility, yet they were not allowed to install Firefox on their machines! Another typical example which recently came up at TSS, is developers going to great lengths to disable virus scanning software because it makes their IDEs unbearably slow.
As always, solving this conflict requires a middle-of-the-road solution. I agree that giving developers unlimited privileges on machines that are connected to production networks is an unwanted security violation. Similarly it's unacceptable to bog down a development machine to the point where the developer can no longer properly do his job. One of the better solutions I have encountered is a separate development network. This development network is an isolated sandbox where the developers reign supreme without putting other parts of the network or organization at risk.
Sometimes this can get quite ridiculous. I recently heard a story about a development team building a web app that required Firefox compatibility, yet they were not allowed to install Firefox on their machines! Another typical example which recently came up at TSS, is developers going to great lengths to disable virus scanning software because it makes their IDEs unbearably slow.
As always, solving this conflict requires a middle-of-the-road solution. I agree that giving developers unlimited privileges on machines that are connected to production networks is an unwanted security violation. Similarly it's unacceptable to bog down a development machine to the point where the developer can no longer properly do his job. One of the better solutions I have encountered is a separate development network. This development network is an isolated sandbox where the developers reign supreme without putting other parts of the network or organization at risk.
Friday, May 27, 2011
Slow Java platform evolution
It's fascinating to read the Java Module-System Requirements document that Mark Reinhold has drafted to see just why a platform of Java's size and complexity (both code and community wise) is hard to evolve. The requirements document puts the bar quite high for what a Java Module-System needs to be able to do. You also clearly see the influence of systems like Maven and OSGi, and how the experiences with those systems has impacted the requirements.
The end result of all of this is that a Java Module-System can't start off small and simple and grow over time. Instead, the designers are faced with a complex and extended set of requirements right from the start. Slow progress is inevitable. Nevertheless, I'm hoping Java SE 8 will include this Module-System because it would bring a lot of interesting new possibilities to the Java platform!
The end result of all of this is that a Java Module-System can't start off small and simple and grow over time. Instead, the designers are faced with a complex and extended set of requirements right from the start. Slow progress is inevitable. Nevertheless, I'm hoping Java SE 8 will include this Module-System because it would bring a lot of interesting new possibilities to the Java platform!
Friday, April 22, 2011
Properties file troubles
I stumbled over a stupid properties file gotcha the other day trying to get a Spring META-INF/spring.schemas file working. Spring uses this file to translate an XML Schema schemaLocation into the name of a classpath resource. This allows Spring to load the schema directly from the classpath instead of downloading it from a remote server which might not be reachable from your deployment environment (e.g. because of firewalls). So for instance, suppose you have the following in your XML:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:demo="http://www.ervacon.com/schema/demo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.ervacon.com/schema/demo http://www.ervacon.com/schema/demo/demo.xsd">If you combine this with the following META-INF/spring.schemas file, Spring will load demo.xsd directly from the classpath without even trying to access http://www.ervacon.com/schema/demo/demo.xsd:
http\://www.ervacon.com/schema/demo/demo.xsd=demo.xsdThe key thing to notice in the properties file is the escaping backslash before the colon! This is necessary because a colon is a valid delimiter in a Java properties file:
public static void main(String[] args) throws IOException {
StringReader propsIn = new StringReader("http://my.server.com/foo.xsd=foo.xsd");
Properties props = new Properties();
props.load(propsIn);
for (String propName : props.stringPropertyNames()) {
System.out.println(propName + " --> " + props.getProperty(propName));
// prints: http --> //my.server.com/foo.xsd=foo.xsd
}
}
Keep in mind that all colons need to be escaped! So don't forget the colon in front of the port number:http\://my.server.com\:8080/foo.xsd=foo.xsdDoh!
Thursday, April 7, 2011
Software and Mud
There seems to be a strange relationship between software and mud. Many will be familiar with the Big Ball of Mud architectural style and there are countless examples of code that resembles mud more than anything else.
A while ago a colleague of mine used an analogy between a software related problem he was facing and wading through mud (or as we say in Dutch: "door de moose ploegen"). I'm amazed at how poignant this analogy actually is. Think of a situation where the first thing you notice is that you have mud on the soles of your shoes. As you trot on you quickly end up knee deep in mud. At this point you can either back out and retreat to solid ground, or persevere, in which case you often end up stuck!

Of course you might also make it through, as John Carmack once noted:
Many software related situations come to mind that closely follow this story:
(As an aside: some people can wade through mud more elegantly than others, as Kate Moss illustrates.)
A while ago a colleague of mine used an analogy between a software related problem he was facing and wading through mud (or as we say in Dutch: "door de moose ploegen"). I'm amazed at how poignant this analogy actually is. Think of a situation where the first thing you notice is that you have mud on the soles of your shoes. As you trot on you quickly end up knee deep in mud. At this point you can either back out and retreat to solid ground, or persevere, in which case you often end up stuck!

Of course you might also make it through, as John Carmack once noted:
Yes, you can make windows do anything you want to if you have enough time to beat on it, but you can come out of it feeling like you just walked through a sewer. [.plan]
Many software related situations come to mind that closely follow this story:
- Merging exercises gone wrong
- Refactoring plans that start simple but spiral out of control
- Anything to do with character encoding
- ...
(As an aside: some people can wade through mud more elegantly than others, as Kate Moss illustrates.)
Subscribe to:
Posts (Atom)
