I recently jumped into Windows Phone development and published a simple game on the Windows Phone Store. The development experience was pretty smooth, thanks to their free development tools and SDKs. Time and again, Microsoft makes a mess out of their APIs and kills a lot of them for unknown reasons. Microsoft’s XNA Framework is one such example. However, I still used XNA Framework as I wanted to target both Windows Phone 7 and 8 devices. I don’t have to tell you that Visual Studio made things quite easy. This is one area where Apple and Google can learn a bit. Microsoft’s development tools have always been much superior – despite the fact that their technologies / APIs die for no reason at times.

All in all, I think Windows Phone OS provides a better user experience imho than Android and iOS – but that’s just me. Windows Phone’s live tiles feature kicks some serious butt against dead icons of other platforms.

As much as I despise Windows 8 on my desktop, I do feel that Windows Phone is a nice to have product for a smartphone.

I’ve been playing with JavaFX recently and I quite like the API design. One of the things I wanted to do was to play an audio file continuously (e.g. for a background music in a game).

The obvious way to go was to use JavaFX’s Media and MediaPlayer classes to play audio file somethings like this:

MediaPlayer mediaPlayer = new MediaPlayer(new Media(new File("resources/music/music.wav").toURI().toString()));
mediaPlayer.setCycleCount(MediaPlayer.INDEFINITE);
mediaPlayer.play();

(Note: the above code is a simplification and an overview, you could surely do fancy things like starting things in their own thread, but that won’t make a difference – at least didn’t for me!)

So okay, I hoped the above code would work fine. It does, but it causes a slight delay every time the sound is played again. This is weird, since I do not want the user to feel like the audio is being played again and again. I want to create a continuous sound loop which gives an impression that the background music is continuously playing. I even edited the file in Audacity to make sure there are no blank edges in the audio file.

Anyways, after googling for quite some time, I came across another guy on StackOverflow who had the same problem but got no answer that could help him. I had no choice but to look at alternatives. So I googled on how to play continuous loop in Java and found this StackOverflow question which solved my problem. He is the code that will let you have a working Audio loop in a Java FX application (without using JavaFX sound APIs but hey, Java platform is powerful enough to have other classes that do the same thing):

AudioStream backgroundMusic;
 AudioData musicData;
 AudioPlayer musicPlayer = AudioPlayer.player;
 ContinuousAudioDataStream loop = null;
try {
   backgroundMusic = new AudioStream(new FileInputStream("resources/music/music.wav"));
   musicData = backgroundMusic.getData();
   loop = new ContinuousAudioDataStream(musicData);
   musicPlayer.start(loop);
} catch (IOException error) {
   System.out.println(error);
}

Of course you should ideally put the above code in a separate thread to make it go smoothly with other stuff your application (or game) is doing.

Back in 2004, as I was sitting in the auditorium, listening to Baqar Muzaffar, CIO of United Bank Limited in Pakistan at that time, I learned something: intelligent businesses don’t bother about tools, they simply choose the ones that make the most business sense.

As the presentation ended, and the Q&A session started, I asked him if he ever considered using open source software to reduce cost. I was just in my first year of college, so mass (tech) media might have had an affect on me, and I wasn’t too real-worldish at that time. I viewed open source software as the only smart way to go whenever there was an alternative. In my case, I was proposing the use of MySQL over Oracle in their setup.

His reply was something along the following lines:

“Excellent question! See, we, as businesses, just want to ensure that we deliver the best possible, secure service to our customers, and we use whichever tools that help us do that.”

He continued, “Cost is not a constraint for us, so we go for the best thing money can buy. And it’s not just about the product itself, there are a lot many things which are significant in the decision process; things such as support and human resources, etc. Right now, in our current situation, Oracle suits us the best, and in a way it helps us make enough money to not worry about its licensing costs “.

Although I was putting forward the case for MySQL, which is indeed a capable product, with great (paid and free community-driven) support options at the time, I’ve noticed over time that there is a lot of sub-standard stuff people or companies tend to fall for just because its open source and not Microsoftish.

One such case happened recently where I work. The team there sticks to using Symfony2 for every web application the company develops. I personally don’t have any issue with using tool X or Y as long as its production ready. Now, a lot of people perhaps have a different idea of ‘Production Ready’, so I’ll tell you mine:

1. The tool is well documented.
2. The tool is well tested.

By well documented, I mean really well documented, which means an updated API reference (if possible, with example code) and a set of tutorials that work with the current release version. By well tested, I mean really well tested, at least to the level that there are no ‘surprises’ during development.

To quote an specific example, I made a change in the application configuration file (config.yml) and set the default language of the application to English (it was set to German). I saved the file, and reloaded the application. No change. I reload it again, and same again. I clear my cache, no change again. I had already read the documentation for updating the configuration and I re-read it again just to make sure I hadn’t missed anything. I googled, stackoverflowed, and even binged it, but to no avail. So, all in all, I spent like 2 hours or so wondering why it wasn’t working and why my application was still showing in German.

After trying a few random things hoping one would work (yes, that’s what you try to do as well when nothing seems to work) and guess what, I realized that I was logged in to the application and the application had stored the language setting in the session. So when I logged out of the application and logged back in, it worked!

The point I am trying to make is, that there was NO mention of any such thing as refreshing the session in the documentation for updating the configuration in general and for updating that language attribute in particular. I’d say, in the first place, that it was kinda strange to store that setting in just the session, and nowhere else. Secondly, I was hell pissed at the fact that I spent two and a half hours trying to work out what was wrong. I basically trusted the documentation and hoped that I wouldn’t have to ‘figure out’ why things aren’t working, they should just work right? that’s what the documentation says, but sadly, that wasn’t the case.

So I brought up this discussion with a colleague of mine at lunch and his response was like: “Well, nobody pays them to develop the software so you can’t really expect them to have everything covered in the documentation”. Oops, that was kinda weird of an answer for me imho. My 2.5 hours were worth quite a bit of my employer’s money, money that he probably saved up on not buying a well tested, surprise-free software package. And now I see this money being spent on me caught in frustration. And hey, what about the headache it caused me? Priceless!

This is just one of the many instances where Symfony2 has surprised (read dissapointed) me. I’ve always believed one should think like a businessman even if he is a developer. He should think if his time is well spent. I know there are developers who just can’t wait for a chance to spend hours on that bug nobody has any idea how to fix, but I would rather make sure I keep my passion in check against what action makes business sense.

I hope software engineers realize that there is no such thing as good company or evil company, everyone is here to do business, so we have to make deals in the market. If I am in the business of building desktop consumer software, knowing that Windows has the highest market share of my audience, Visual Studio is the best thing I can get and I am sure it will be worth (paying for) it. Nothing is perfect, that I know, but the money that Microsoft spends in R&D and testing, it surely does have an impact in improving the quality of software.

So next time you plan on choosing a framework just because its open source and cutting edge, step back and think a little about the total cost of ownership and don’t just fall for the price tag.

The following paragraph is a book excerpt taken from the really cool C++ in Action by Bartosz Milewski and I think I like what he says :-)

“There is a popular unflattering stereotype of a programmer as a socially challenged nerd. Somebody who would work alone at night, subsist on Twinkies, avoid direct eye contact and care very little about personal hygiene. I’ve known programmers like that, and I’m sure there are still some around. However most of the specimens of this old culture are becoming extinct, and for a good reason. Progress in hardware and software makes it impossible to produce any reasonably useful and reliable program while working in isolation. Teamwork is the essential part of software development.”

I have to say, Milewski’s book is one of the rare few books that are actually free from any marketing deep shit and feels very much like a friendly and common sense conversation between the author and the reader. Most books go through extensive editing I believe (to try and make it more sellable and pricey, which is rhetorical), but this one’s not and I love it for that reason! Go read it and have a good doze of fun and knowledge! ;)

Zend, the so called PHP Company is heading towards an unfriendly, commercial direction which I don’t like. I mean, PHP was supposed to be an open source project, I see more focus from Zend on marketing and selling their commercial development tools, certifications and training kits, and less towards creating a free ecosystem that helps in making PHP a more accessible platform for everyone.

I am aware of the fact that the Zend guys have to find some way of making money, but really, you can’t place a gun on an open source app and pull the trigger. Apart from that, I am pretty sure that people behind Zend are smart enough to make money off some other thing instead of claiming to be THE company for PHP – folks, PHP is an open product, Zend’s offerings are NOT, which is no spirit lifter for me.

Today, I received an email from Zend telling me that they’ve launched this ‘Zend Application Server Beta‘ that is another of Zend’s commercial products with a limited feature Community Edition. When I read the FAQs, my conviction was re-enforced that Zend is indeed now a commercial company with marketing people who care less to do something meaningful and more on increasing the sales count of their average products.

Here is one FAQ that I’m posting for your sake of wanting to have a little laugh:

Q: How is Zend Server Community Edition (CE) different from xampp?
The most fundamental difference is that Zend Server CE was designed from the ground up to run in production, and is supported by Zend, the PHP Company.
Additionally, Zend Server CE provides an all-in-one installer that deploys a certified PHP distribution, Zend Framework, and integrates fully with Apache and IIS;  Zend Server CE also provides an integrated Web administration console.

And another one here:

Q: What are the differences between Zend Server and Zend Server Community Edition (CE)?
Zend Server Community Edition (CE) is a free, complete Web application server that is ideal for developing and running non-critical applications, while Zend Server is ideal for business-critical applications that require high levels of reliability, performance and security. Learn more about the differences between Zend Server editions.

See the contradiction? In one of the answers, they say that the community edition is just a thing for running non-critical applications and in the other FAQ, while comparing it with the excellent XAMPP, they say the Zend Server community edition ‘was designed from the ground up to run in production’. I think, for any reasonable business, any application running in production is critical, Zend thinks otherwise.

The Zend Community Edition is not even open source, so you do not have the source code with you.

Zend products like the once powerful Zend Studio, is now an Eclipse-based bloat – I get the feeling they moved to Eclipse to reduce development efforts and spend more capital on marketing :D I know I’m kinda little over the top on this point, but why did they moved to the stupid and unfriendly Eclipse platform – atleast I don’t like Eclipse, and I know many people who dont like it either, so just in case you are an eclipse lover, kindly ignore this point ;)

Then there is this Zend Core and Zend Platform, which are full of marketing claims – please people, Server administrators can get those things easily with the open source PHP for free.

And I wouldn’t want to miss the Zend Framework. Given the press coverage the framework has received, I think the framework could’ve done better. It has a sloppy quickstart, and a lot many people do not like the documentation that it has – nothing cool for someone who is just starting out with the Zend Framework. So the only reasonable way to learn the better way is to purchase Zend’s training products. Plus, the Zend Framework is slow – and I really mean slow. if you don’t trust me, look at what Rasmus Lerdorf, the father of PHP has to say in this DrupalCon 2008 keynote (presentation slides can be found here).

I think Zend has lost the open source spirit, which is bad for the PHP community. Zend should be looking to do good to the community instead of doing good to themselves by trying to sell their stuff, or perhaps they should find a better job or maybe rethink about themselves being ‘the PHP company‘.

Sorry about the rants, I like Zeev and Andy, but I just don’t like the direction their company is going into.

Whenever I read Rasmus Lerdorf, it feels like breathing fresh air of common sense. I would assume you’d be pretty amazed when I call a geek a gentleman but he truly is. Lerdorf’s writings are so very different and better from all the other “php experts” in terms of the elegance that Rasmus owns.

I, for one, had lately become a language purist complaining why PHP doesn’t have a much more organized structure for some of the things. And in this article [Update: the link seems to be no longer active, sorry ;(], Rusmus seems to have read my mind. He answers those questions beautifully and emphasizes that PHP was never meant to be the Goddes of beautiful code structure, it was just a mistress that solved the Web problem.

Here is an extract from article that would make the point clear:

“What it all boils down to is that PHP was never meant to win any beauty contests. It wasn’t designed to introduce any new revolutionary programming paradigms. It was designed to solve a single problem: the Web problem. That problem can get quite ugly, and sometimes you need an ugly tool to solve your ugly problem. Although a pretty tool may, in fact, be able to solve the problem as well, chances are that an ugly PHP solution can be implemented much quicker and with many fewer resources. That generally sums up PHP’s stubborn function-over-form approach throughout the years.

The interesting thing to note is that he answered this very question of mine about the lack of formalized structure to some of the things in PHP quite a while ago (somewhere in 2004 to be precise). Looking at the amount of stuff he has written, it seems to me that he is not much of a talker, which reminds me of the line I once read in the PHP Manual: Those who talk don’t know and those who know don’t talk!

This was first published in the Homebrew Computer Club Newsletter in response to the actions of some within the hobbyist tech community at that time – where hobbyists distributed copies of Microsoft software free of charge in the club meetings without paying Microsoft anything. Bill Gates wrote this open letter to the community to make them realize how it is hurting software innovation. Interesting read.

 

Follow

Get every new post delivered to your Inbox.