‘Technicalities’ Category Archives

24
May

Should I use HTML5 or Silverlight?

by Mikael Lundin in Technicalities

This is an answer to the post of Scott Hanselman with the same title. The problem I have reading these kind of blog posts is that the author is always either a Microsoft/Adobe/Sun spokesman or an open standards zealot.

This has little to do with Silverlight, but could easily be applied to any browser plugin model, like Flash or JavaFx. The reason I use Silverlight here, is that I’m a .NET developer and this is a blog about .NET development.

I have no cares for any plugin model, and I’m not an open standards fan. I just want to get the most possible value with the least possible cost.

The web is all about semantics

The web has a language and it is called html. You use it to markup the meaning of your content. For your page title you use <h1> and for your paragraphs you use <p>. If you have an image use use <img> and for table data, the black sheep <table>.

When you place a plugin on the page you remove this sematic markup and replace it with a black box. Before you do that, you should be aware of the consequenses. The meaning of the content within that plugin will never be revealed to the browser. The text is invisible to any screen reader software and Google indexer robot will not reach it.

This is why I say, using Silverlight (or any other browser plugin) to display content is bad.

How about banners?

The technology for creating animated banners in html5 canvas + javascript is still very new. Some older browsers do not support it and that might give you enough reason to use flash, which is still the most widespread browser plugin when it comes to animation.

Don’t forget that you will hide the banner content to anyone that is not a human using a web browser with flash installed.

Rich Internet Applications

Rich Internet Applications (RIA) are desktop apps that runs in the browser. It could be a public application like GMail or it could be a private administration console for your e-commerce workflow.

In a public RIA you would like to target as large user base as possible. In that case, html is the obvious choice. Not html5, but standard xhtml 1.0. Imagine if GMail was written in Flash. I don’t think it would have gotten that kind of popularity that it has. The experience of having a full scale e-mail client as a web application is just seamless for the user.

If the RIA is not a free application but something that your customers buy, you may set another stage. The customer accepts that they need to use the latest Silverlight plugin to be able to run your application. They login, and they install the latest Silverlight runtime (takes 2 minutes) and then they are up and running. Why is this acceptable? I guess it has to do with perception – I buy an application – it should be an application.

Silverlight is perfect for the RIA scenario because it has much better integration between frontend and backend. You use C# on both. There are a lot of controls that will make your development smoother and the maintainability is just higher with XAML/C# than HTML/JavaScript/Css.

When you have an internal private application, the choice is simple. You control the machines that your application will run on, and may demand what version of Silverlight should be available.

Last time I worked with Flash, this was not suited for RIA development. The maintainability was really poor and it was hard to produce anything that was stable enough for production use. My recommendation is that Flash, only suits banner development, and should not be used for any larger scale project.

Where to use Silverlight?

To sum it up. You should use Silverlight in windows application development. When you write an application in Silverlight it can be used both inside and outside of browser, and that is very powerful.

It’s easy to maintain a Silverlight application, not only because of the .NET infrastructure, but only for release management. You deploy the application to an URL and your customer service team will get the update as soon as they refreshes the url in their browser.

Silverlight is the only development platform for Windows Phone 7, and a quite nice one.

When you shouldn’t use Silverlight?

  • When you need to target a larger audience
  • When the application represent content, blog, news articles
  • When you can’t control the environment that your users are in
15
May

Move your user profile to other drive

by Mikael Lundin in Technicalities

Windows has this great functionality that lets you move parts of your user profile to another drive.

Crap, because it only moves the documents and not stuff like Application Data where most of my data is.

Crap.

And you know what? A lot of applications does not recognize that the documents folder has moved.

Dubble crap.

How to really move your user profile

If you’re not comfortable working in the command prompt – don’t try this. You will screw up your computer completely.

The trick is not to leave it to Windows for this low level stuff. Instead you should use a feature within NTFS – directory junction.

Consider why you want to do this. I have a small SSD as my primary hard drive that I run the system on. This was a great decision performance wise. My computer feels very fast because it runs on an SSD. The problem is that 80Gb is not a lot for both system files and user profile. That is why I have a slower, but much larger 1Tb, secondary hard drive (Western Digital Green Caviar) where I want to store my user profile. I’ve postponed this action for far too long and now I have no space left on my primary system drive.

A small side note on running SSD as your system drive: it’s fast but dangerous. Your SSD will fail, sooner or later, and much more often than a mechanical hard drive. That is the price for running a super performant system – you will fail and when you do – make sure that you can restore the system on a new hard drive with just a few clicks. Make sure that is a price you can pay. (continuous automatic backups – Windows Home Server or Synology)

Before you try this you should read other people experiences, because every situation is unique and this story alone will not help you.

My story, how I did it

These instructions worked for me. If they completely screw up your file system, I take no responsibility. That is why your first step should be

  1. Make a complete backup of your file system with some image tool. I recommend Norton Ghost. I have myself a daily image backup of my whole computer through Windows Home Server. That will work too.Copy files to a backup drive will not help you if your file system is shredded to pieces by your failed attempts to create directory junctions. Consider yourself warned!

    (also, you don’t really have a backup until you’ve tried to restore it)

  2. I’ve read a lot of problems with people trying to move their whole C:\Users directory. Don’t do that! It is much easier to just move your profile, so limit the risk and go for that. Move several profiles if you have to.
  3. Your profile contains directory junctions already. For example, your [Profile]\Documents\My Music points to  [Profile]\Music. I’ve not found a way to move these, so they will have to be recreated at the target location. Get a listing of all your current junctions and print it out (on real paper – you will thank me later)
    dir C:\Users\[profile] /al /s
  4. Restart your computer with the windows 7 install cd/dvd. Choose to repair an existing windows installation and choose command prompt as an option.Notice that your first hard drive is not neccessarily C: in here. For me it was E: and my secondary hard drive was D:.  I will name these [source drive] and [target drive] from here on.
  5. Use robocopy to copy the profile from one drive to another. You will read on the internet that you may just create a new user in windows, login as that and move your other user profile with that user. Don’t do that! You will screw up user permissions and sometimes not get all hidden files and folders.Here’s the command that worked well for me. (you may have to create target folder first)
    robocopy /MIR /XJ /B /R:1 /W1 "[source drive]:\Users\[profile] " "[target drive]:\Users\[profile]"
  6. Copying the profile took me 1,5 hours. The result of copy should not give you any failures. If it did, abort right now and find out why before you continue.

  7. Now that have a copy of your user profile on the target drive you need to recreate those junctions that did not copy over. If you run dir "[target drive]:\Users\[profile]" /al /s you will notice that you don’t have any junctions in the target. Damn! Lucky you that you have that printout of what it looked like before.
    mklink /J "[target drive]:\Users\[profile]\Documents\My Music" "[target drive]:\Users\[profile]\Music"
    mklink /J "[target drive]:\Users\[profile]\Documents\My Pictures" "[target drive]:\Users\[profile]\Pictures"
    mklink /J "[target drive]:\Users\[profile]\Documents\My Videos" "[target drive]:\Users\[profile]\Videos"

    … and so on

  8. Cool, now you can remove your old profile. Say what? Yes! Just do it. You don’t need it anymore.
    rmdir /S /Q "[source drive]:\Users\[profile]"
  9. Replace that old user profile with a junction from [source drive] to [target drive] like this.
    mklink /J "[source drive]:\Users\[profile]"  "[target drive]:\Users\[profile"

    Verify by

    dir "[source drive]:\Users\[profile]"

    You should see the files that is now on [target drive].

Reboot and mission accomplished.

12
May

Stylish improves web experience

by Mikael Lundin in Technicalities

I hate advertisement. I would never ever dream about putting advertisement on this blog. I hate it with all my soul, so much that I pay extra for some services just to get rid of the advertisement. I don’t look at commercial TV and I get bored at podradios pausing for a message from sponsors. Ye, I guess that you need sponsors because it is expensive to host a podcast, but I would rather pay 3$ per show just to not listen to your intro, outro or sponsor messages. Pure content – that’s the melody!

Banner advertisment

The Internet is full of these banners that tries to steal focus from the content. I’ve been a fan of Adblock for years, and I also use Flashblock on all my computers. Adblock uses some specialized logic that block ads from known advertisement sources. Flashblock blocks all flash running in the browser.

In Flashblock you have a white list of sites that you want to support flash on, for example TED or InfoQ. All other flash will display a play icon instead, where you can select to make an exception for this site.

This is great if you’re a tab-user like me that easily open up 30-40 tabs every day in my browser. If each would have a flash that would steal CPU, my computer would be doomed.

Style the web with stylish

To take this a step further, there really are some sites that look horrible, because they manage to get advertisement beyond both Adblock and flashblock. What can we do about them?

Stylish is a Chrome plugin that lets you redecorate a plugin by rewriting the css. This gives you full control over the presentation layer on the web.

The cool thing is the gallery where you can download predefined styles created by the community. This way you don’t have to restyle the whole web by yourself. :)

Here’s what a swedish newspaper looks without stylish.

And this is what it looks like after custom styling.

It’s like you’re able to breathe again!

Now, go get stylish from the Google Web Store.

22
Apr

Discovering JavaScript Patterns

by Mikael Lundin in Technicalities

I opened my mail this Wednesday and discovered that the book I’ve ordered “JavaScript Patterns” by “Stoyan Stefanov” had arrived. To my surprise it wasn’t the concrete brick that I’m used to reading but a lightweight manual on how to improve your JavaScript code. I fell in love instantly.

I work mainly in the backend of websites, with integration and data manipulation, but quite often this requires that I go up in the frontend and make sure that my backend changes are reflected to the user. This has made me an occasionally JavaScripter.

A couple of weeks ago I started thinking about how to improve my JavaScript knowledge, how to test JavaScript and how to architect good JavaScript. Tens of thousands lines of JavaScript will do that to you. I got recommended this book “JavaScript Patterns” by a colleague.

The Review

I know the syntax and I have written quite a lot of code in my days. All I was interesting in was how to improve my JavaScript, how to structure the code and some do’s/don’ts. It’s exactly what this book is about.

I usually read books where the first 50 pages is a “skip” because the author needs to thank his spouse and his sister from his other mother for making it possible to produce this block of concrete, but this book get right to the point and delivers value from page 1.

That makes it very lightweight. (I finished it in 2 days) It only goes into specifics and does not try to teach us the obvious. If you want to learn the basic syntax of JavaScript, you should probably buy a beginners book also.

More tools for the hungry

Three tools that I’m going to take a closer look at.

  1. JsLint
    Tells you whats wrong with your javascript code. Excellent! Works pretty much like FxCop or StyleCop. There’s also a Visual Studio 2010 plugin that will evaluate your javascript at compile time.
  2. YUI Docs
    API Documentation for javascript. I’ve always wondered how I should comment and document javascript code, and now I have a template to follow. Great thing that you can generate API documentation from the source.
  3. YUI Compressor
    I’ve used this before – a tool for minimizing javascript. It can compress it down to about 50% of its original size, which is a real performance boost in page loading.

Watch out you frontend coders! You’re starting to get obsolete when backend specialists gets their hands on literature like this!

2
Apr

Samsung Omnia 7 – Windows Phone 7 Review

by Mikael Lundin in Technicalities

I’ve had my Samsung Omnia 7 WP7 mobile phone now for some days and here’s what I think of it. I will compare it to two other smart phones that I’ve been in contact with, my previous iPhone 3G and my wife’s HTC Desire HD.

Hardware

I was choosing between the Samsung Omnia 7 and HTC 7 Mozart, and took the former because of the display and powerful 1500mA battery. The first thing you’ll notice is that the screen is as good as the reviews says. Very strong colors and sharpness. The 1 Ghz Snapdragon CPU makes this phone a dream compared to my previous iPhone. Everything runs smoothly and I’ve not yet to experience any lag or long waits.

(* due to Apples operating system upgrades my old iPhone eventually got so slow, that any task took longer than the screensaver timeout)

The phone weights 138g (incl. battery) and has enough size to not fit your pocket. It is damn right ugly and uncomfortable to hold in one hand for long. The ugliness comes mostly from the choice of putting the Samsung logo and Windows logo on the front. I have no love for these trademarks and would prefer the Apple way – let the design speak for itself and put the logos where they’re least obtrusive.

The back button and search button in the picture are very sensitive touch buttons that are easy to accidently push when you least want to. Other buttons around the phone, camera, on/off and volume feel very cheap and plastic. That is the only thing however about this phone that feels cheap. Everything is glossy and shiny, Metallic edges and a plastic with the feel of aluminium on the back.

+ Screen is great
+ Battery life is acceptable

- Ugly with all the logotypes
- Uncomfortable to hold in one hand
- Easy to accidentially push front buttons
- Gets warm after some use

Compared to iPhone

Apple put a lot of effort into the feel of holding their devices. It is quite noticable when you get hold of something that is not just that well designed. I like that Apple does not use logotype’s on the front of the phone, but they have managed to create a visual design that speaks for itself. You don’t have to see the logotype to distinguish an iPhone from another smart phone.

With WP7 I love the diversity in hardware. I can select the manufacturer the way I want and does not have to stand for what Apple gives me.

Compared to HTC Desire HD

I like the HTC design. They make nice phones, that sometimes feels a bit plastic, but always are well designed. They put their logotype up front but it is very unobtrusive and not at all like SAMSUNG. I don’t like that they put too weak batteries into their phones for that much screen. The HTC Desire HD screen is 4.3″ (0.3″ more than Samsung) and it sucks juice like a new born baby.

I did not perceive HTC 7 Mozart as much more than a standard phone, and I wanted a bit more. The HTC HD7 phone seemed to have the same battery life problems as HTC Desire HD and I want to use my phone for the whole day without recharging, thank you!

Software

I really like the WP7 operating system. It is clean and minimalistic. It runs smooth on the hardware and yet it has details that are candy for the eye. Overall I really like the WP7.

The setup experience on the phone was done in a blast. I configured my Windows Live, Facebook and WiFi. Upgrading to latest version of the OS was not harder than connecting the phone to my computer and installing Zune. After that I was good to go. The phone had imported all my contacts and it took me no more than a few minutes to move missing contact details from my old iPhone to my new WP7.

I think that running Silverlight as development platform for the phone is genius. It really enables us developers to create nice looking applications very fast, and that was why I bought this phone. It is a developer friendly phone – quite the opposite to iPhone.

The Windows MarketPlace contained a lot more applications that I expected and I like the search and rate function. It was trivial to find applications like Twitter, Facebook, Adobe Reader and add them to the phone.

Thank you Samsung for not installing a lot of self developed crap applications that most manufacturers do to the phone. I really appreciate that.

+ Minimalistic design
+ Great virtual keyboard

- Sometimes buttons are too small

Compared to iOS

The end user iOS experience is a nice one, and what I really like about iOS is that I never have to read a manual to find out how to do stuff. Icons and design makes it all so obvious.

On the other hand, iOS is crap for developers. You will not only need to learn xcode and objective-c, but also have the latest and greatest of the MacOSX to use the development tools. Then, there is this developers fee for submitting applications to the AppStore where it will take months getting through the review process.

Did I mention that Apple does not care about developers? If you do something they don’t like, they will fight you. Overall they are a closed down company that will take a fee of 30% for selling your apps on their AppStore.

WP7 is not an iOS copy, and I really like that. They have tried to find their own design and go for it. There are some ideas in there that I like much more than iOS, that it becomes natural to span an application across several pages/swipes.

The demands of the user base will always give AppStore a lead on Windows Marketplace, but that doesn’t concern me. The quality of the service provided for developers on WP7 will encourage quality on apps in WP7 and draw attention of the likes like me.

Compared to Android

I find the Android operating system dull. It is exactly what you would expect from a phone operating system and nothing more. There are no innovative ideas and nothing that triggers the wow-factor.

With that said, I think that Android is a very stable platform and well thought through. The massive setup experience of the Android phone left it a complete and impressive machine after installation. There’s are a lot of good apps for Android and the system is open. The integration with google products are great and the diversity in hardware choices are fantastic.

The WP7 is much more interesting than Android, but Android is both a more open OS and more mature. I would recommend Android phones to my friends any day.

iTunes vs. Zune smackdown

I hate iTunes, I really do. It may be the worst wide spread application ever created for Windows. It really hates the user and does everything it can to annoy you. I know of people that wants to buy an iPhone but can’t, because they refuse to install that iTunes crap on their machine.

That is why I was initially sceptical to Zune. Same shit, different name. I might however been a tad too fast in my judgement. Zune is the same thing, a hub for your phone where you can sync data from your desktop computer. There are some subtle differences.

  • Zune is beautiful and follows the Windows 7 Aero graphical profile
  • When Zune wants to update itself, or download new content – it does not make the rest of your computer unusable
  • Adding stuff to your phone is much intuitive than iTunes
  • You can sync over wifi – no need to plug your phone in

Hold on!? Why do we need this sync crap anyway?

The ideal experience would be if my phone could access all media from my media server and I could mark stuff for offline use directly on the phone. I should be able to subscribe to podcasts directly on the phone, and the phone would download new episodes when on Wifi.

Maybe we’ll see more of that in the future.

Windows Phone 7 in Sweden

Would I recommend this phone to someone that lives in Sweden?

- No.

Services like GPS, MarketPlace, XBOX Live are not fully released in Sweden so you have to run on UK account. That’s crap, but the Android had similiar problems and it took them years to get it all ready. I just hope that Nokia will speed up the process as they start putting demands on Microsoft.

Would I recommend this phone to somewhere in US or UK?

- Yes!

This is a delightful piece of machinery and I think you will enjoy it very much. If you’re a developer – even more so. Most of all, I would recommend it to companies that have need for self developed mobile applications for their employees. These companies would save lots of money in development and maintenance costs just by choosing this platform.