Learning Scala: Recursion

If you like me are learning Scala you might after a bit of coding realize that even if it is possible to write java-like code in Scala – and by using some of the nice features of Scala it will actually be more fun than writing normal Java code. It will quite often look a bit ugly and not feel that natural.

That is because it is not the Scala-way of doing it.

I’m still trying to understand the Scala-way of thinking but it’s not something you pick up over night. I’m taking baby steps and hopefully making some progress every day.

Two articles I found yesterday helped me understand how to assign immutable variables from if-statements and how Scala loves recursion:

id Software Demos Rage On iPhone

Slashdot Games Story | id Software Demos Rage On iPhone, Releases Source Code For Two Games

“Kotaku has posted their liveblog of the QuakeCon 2010 keynote, with some big announcements by game developer and Slashdot regular John Carmack. Highlights include a video of the id Tech 5 engine (aka Rage) running on the iPhone 4G at 60fps, with claims that it also runs on the iPhone 3GS.

Another hilarious quote from John Carmack was

“The game would have been more enjoyable if people could actually see it.” – Carmack on Doom 3

If you are interested read through the liveblog from the QuakeCon 2010 keynote. Carmack sure has some strong opinions sometimes!

Getting even more annoyed at Maven

How can it be easier to change the java code I’m trying to execute as part of the generate goal to create the output directory than to make Maven create the directory for me?

I understand that Maven is conceptually totally different compared to Makefiles and Ant but still, I just want to create a directory. How hard can it be?

Sometimes Maven is such a pain.

IntelliJ IDEA bug?

Alternative 1

Screen shot 2010-03-24 at 18.06.34.png

Alternative 2

Screen shot 2010-03-24 at 18.07.05.png

Me and javac think the two code snippets above are both valid and pretty much same. Funnily IntelliJ IDEA disagrees.

But it’s OK, I still think it’s the best Java IDE available.

Facebook’s HipHop Goes Public With a New PHP Runtime

“Facebook said the results of using HipHop have been dramatic. CPU usage on Facebook servers has dropped by an average of 50 percent as the HipHop PHP engine reduced the load on Facebook’s infrastructure.”

Facebook’s HipHop Goes Public With a New PHP Runtime — Developer.com

The article isn’t that detailed but from the following quote:

“This is not an extension to PHP — this is pretty different,” Recordon said. “Right now, the process is once you build and compile HipHop, it comes with a tool that will go through the transformation process and output the binary, and that’s what you actually use to run it.”

And the fact that they’ve removed Apache and uses an own web server. I start to wonder if what they do is actually take the PHP source code and compile it to get one binary that is both the web server and the application in one.

PHP is an interpreted script language so what normally happens is that PHP takes the source file and reads it line by line as it’s executing it. If they’ve bypassed this step completely by pre-compiling the script file into machine code that would explain the reduced CPU usage.

Snow Stack – CSS 3D Visual Effect with WebKit

This video shows “Snow Stack”, a 3D CSS Visual Effects demo built with HTML, CSS Effects and JavaScript in the latest WebKit nightly on Mac OS X Leopard and Snow Leopard. You can try this out yourself by reading the details on www.satine.org.

Wow! This is mad impressive! And if it’s true that the graphics card is doing most of the work and the CPU is hardly loaded at all, it is borderline crazy!

Snabbare nyhetsförmedling

Det har varit långsamt att visa vissa sidor på ny.heter.se. Förra veckan så tittade jag i MySQLs loggfil för långsamma frågor och insåg att det är på grund av att jag gör uppslagningar med WHERE IN, ORDER BY och LIMIT begränsningar.

Dessa urvalskriterier medförde att MySQL inte kunde använda något av de tabellindex som finns utan fick göra en långsam filsortering för att få fram det slutgiltiga resultatet. Efter en del googling så hittade jag sidan Mysql query optimization for ORDER BY.. LIMIT queries där ett förslag var att prova med att förenkla databasfrågorna och göra sorteringen i den anropande koden istället.

Jag provade detta och resultatet är en otrolig prestandaförbättring! Att det dessutom är mer troligt att de cachade resultaten för de mindre databasfrågorna kommer att kunna återanvändas är ytterligare en vinst.

Så njut av snabbare svarstider på ny.heter.se, det enklaste sättet att läsa nyheter på!