Wednesday, September 29, 2010

VirtualBox vs. Virtual PC as a host for Ubuntu


Having worked with Ubuntu on Virtual PC for a little while I gave it a test inside a VirtualBox. A waaaaaaay better. Squeezing a Linux to run in a Windows virtualization host designed to only accept Windows guests might have been fun in and of itself, but using it there is not necessarily the experience you would enjoy.

VirtualBox over Virtual PC as a host for Ubuntu:
  • No hassle installation. Just point the CD drive to the Ubuntu installation ISO and enjoy the ride. No tweaking with the VGA loading modes and GRUB.
  • Out of the box networking with the host. No need to manually install loopback adapters as it comes with a network "device" to support it
  • No-capture mouse integration. Virtual PC has a hot key to release a mouse pointer to the host but it conflicts with my Intel video. When I do Ctrl+Alt+Left my screen turns 90 degree. Not fun. VirtualBox with guest additions captures your mouse when it's inside a guest OS window and releases it once you past the window's border. Natural. The only thing that I liked better about VirtualPC here is that it seems to propagate Alt+Tab to the host. So basically when you're in a guest Ubuntu window pressing Alt+Tab brings up the familiar "where to" selector. In VirtualBox you have to start with the "host" key.
  • Visually VirtualBox has a nicer response from the Ubuntu guest GUI compared to Virtual PC. At least no hiccups. Ubuntu in Virtual PC ran ok until I hooked it up with the host over a loopback adapter. That was when it became noticeably slow.
  • Audio support. I don't need it in a guest system. I actually don't need a desktop Ubuntu but it was nice to hear what Ubuntu plays when it boots up :)

There's got to be more. Unlike Virtual PC VirtualBox officially supports Ubuntu and many other guest OSes.

Friday, September 24, 2010

Face of the web


Yesterday I was servicing my car at a dealership nearby. It's a place with a nice and roomy waiting area that has a few large wall mounted plasma TV, coffee, free Wi-Fi, and even a few desktops for those who forgot their laptops home or don't carry them around whenever they go.

I got my coffee and on my way back to my laptop I looked at what was up on a screen of the two guest monitors. Nobody was there doing anything as most people either have their internet with them or don't bother and just watch big screen TV.

What do you think was up on two screens?

It was not a Windows desktop. Not a browser with a dealership web page.

It was Facebook login page. A new face of the web, I believe. A thing that a regular person would most likely do online if they're stuck waiting for their car serviced.

Ubuntu in VPC talks TCP/IP with the host


As of now Ubuntu not only runs as a guest OS in Windows Virtual PC but also has a TCP/IP with the host.

Keyword: loopback adapter. Apparently you can install a piece of "hardware" (that is, of course, a software) that would look like an ethernet device with an active connection on it. Once installed, the host OS will give it an IP that you can look up in ipconfig. Use this new "hardware" as a network adapter for your VPC, boot Ubuntu, assign its network device the IP address from the same network mask and use the host's IP as a gateway, reboot Ubuntu.

I got help from here, here, here, and here.

--

The only thing I noticed so far is that Ubuntu-in-a-VPC-window is slow. It may be the GUI rendering (so far I am playing with the desktop version), it may be the host laptop (oops), it may be the VPC environment itself. We'll see. There's always an option to only run terminal, try VirtualBox, or try another host machine :)

Thursday, September 23, 2010

Ubuntu 10.04.1 on Virtual PC


I am writing this post from my regular Windows 7 while watching Ubuntu running in a separate window as a guest OS inside a Windows Virtual PC.

Microsoft does not officially support anything but Windows XP+ as a guest OS but some of its well known employees tell the world how to work around it. My first attempt was not successful and fresh installed Ubuntu would not start. I scaled back to the original instruction on Installing Ubuntu on Windows Virtual PC that Scott referred to in his post and it worked. Either I did not do something right the first time, or it's not exactly predictable for Ubuntu to install correctly on Virtual PC, or it was the network device that I first time mapped to a physical card (as was suggested by Scott) and the second time left in a default "Internal Network" state, or maybe it was the memory (I only let the VM see 1GB of RAM first time and then sacrificed one more just in case Ubuntu doesn't like greedy users).

I powered it down and brought back up two times in a row just to make sure it was not a random accident. Looks like it wasn't. It's running now.

Update [09/24 00:15]: it does not only work, it now talks TCP/IP with the host. Tomorrow it should sing "Hello, World!".

--

If reading this you wonder why I needed it in the first place I can try to elaborate just a little bit. For the last few months I felt like missing something. That itchy feeling was with me all the time, but as much as it was irritating and annoying it was distant and vague. Only recently I figured what it was and the discovery surprised me quite a little. Apparently, all this time I missed working with the code, working with the code hands on, doing something very real myself, doing something not only real but also meaningful, something worth my energy put into it. Something I haven't done before.

You know how they say in sales commercials: "There has never been a better time".

Over the last few years I collected a few ideas and I finally felt like giving one of them a try. And to spice it up I want it done on Linux, CouchDB, JavaScript, and no backend per se. And if I end up needing backend it will be RoR or node.js (meaning Geddyor Express) or whatever.

I needed Ubuntu to start hacking. I should not have waited. Whatever it is you would rather be doing instead or on top of what you do you should not wait either.

Thursday, September 09, 2010

Type erasure does not erase all of it


Last week I was reading the most recent installment of Spring framework reference documentation and one particular thing surprised me, if not to say more. Here it is with my annotations:


In Java 5 and later, you can use strongly typed collections { sure } [...] If you are using Spring to dependency-inject a strongly-typed Collection into a bean, you can take advantage of Spring's type-conversion support such that the elements of your strongly-typed Collection instances are converted to the appropriate type { something rings a bell but I am not sure... } prior to being added to the Collection.


public class Foo {

private Map<String, Float> accounts;

public void setAccounts(Map<String, Float> accounts) {
this.accounts = accounts;
}
}
<beans>
<bean id="foo" class="x.y.Foo">
<property name="accounts">
<map>
<entry key="one" value="9.99"/>
<entry key="two" value="2.75"/>
<entry key="six" value="3.99"/>
</map>
</property>
</bean>
</beans>


When the accounts property of the foo bean is prepared for injection, the generics information about the element type of the strongly-typed Map is available by reflection { really? I thought no generic info is available at run time. That's what type erasure is about, isn't it? }. Thus Spring's type conversion infrastructure recognizes the various value elements as being of type Float, and the string values [...] are converted into an actual Float type { something is not right. Guys from springsource are not likely to make false statements of this magnitude, or are they? }


I never really looked into all new stuff that Generics brought along with them into the language. And I missed a small but apparently important portion of what has been added to the Java reflection classes.

Here's a short summary at stackoverflow that basically sums up what you can get via reflection. It's not like you can get anything, the exact type of the object at hand has still been erased and instance of ArrayList is still just an instance of an ArrayList. But something is still there :)

Two more good readings on the subject: