Archive for the ‘Technology’ Category

SI prefixes for hard drive sizes

Posted on Thursday, October 15th, 2009

An interesting change in Mac OS X 10.6 is that Apple switched the representation of file and hard drive sizes to base-10 SI units instead of using binary prefixes. This means that a 60 GB hard drive which usually shows up as 55.8 GB will now appear within a few megabytes to the advertised 60 GB. I wasn’t really that happy with the idea at first, but when you think about it, it actually makes a lot of sense.

Bits and bytes
Now, it seems logical that since a computer works in binary, file sizes need to be represented with binary prefixes too. But in reality, the number of bytes in a kilobyte is completely arbitrary – since the operating system and the applications that run on it only represent file sizes in bytes. We could decide that there were 2504.25 bytes in a kilobyte and the computer wouldn’t care at all. If we’re just shortening the sizes for our convenience, why make it so hard for ourselves? Doesn’t it make more sense that a 1500KB file is 1.5MB, and not 1.464MB?

But what about file transfers?
I’ve heard people say that changing file sizes to SI units will make working file transfer speeds confusing, but the opposite is actually true – bitrates are actually already represented in SI units, so changing how files are represented on disk would make it easier to work out how long files would take to transfer.

Ram and SSDs
Now, since hard drives are designed around SI units, it makes sense to use SI units to represent its capacity and file size in SI units. But what about solid state drives and RAM? Well, RAM should stay as binary sizing, but as for solid state drives, it doesn’t really matter. The only difference is that a SSD sold as 256 GB (which is actually 256 GiB using the correct prefix) would show up as being 274.9 GB instead. Does this really matter? We’ve put up with our hard drives showing up as being smaller for so many years (a 1TB drive appears to be 926.77GB smaller), so I don’t think it’d be too bad.

Really, all we need is standardisation. A good first step to this would be to show RAM, solid state drives and hard drive sizes using the correct prefixes (GB and MB for SI units and GiB and MiB for binary). Unfortunately ‘mebibyte’ and ‘gibbibyte’ sound pretty stupid compared to megabyte and gigabyte though… But that’s all the more reason to switch to SI units.

C++0x is insanely awesome

Posted on Tuesday, October 13th, 2009

I came across an FAQ that outlines some of the features coming in the new C++ standard, C++0x, which should be finalised sometime this or next year. It really has some awesome features that, in my opinion, brings some of my favourite features of managed languages like C# to the much faster and more efficient C++. I’m already using some of the features in my applications, as a few are available as part of the Technical Report 1, in the std::tr1 namespace. A lot of the best features (like the concurrency features) are still to come in most compilers though.

Here are some of the new features that stand out to me:

Smart Pointers

One of the biggest complaints about C and C++ is that you have to manage your own memory, which means that allocating memory and then forgetting to free it can cause problems like memory leaks. The current version of C++ does have a smart pointer, called std::auto_ptr, that can help with this, but it’s not really very good, because you can only have one reference to the pointer it manages. C++0x now features the std::shared_ptr, which is far better.

Concurrency

C++ by itself has been a completely single threaded language in the past, but in C++0x, we will be able to use threading, locks, and other concurrency features without having to rely on third party libraries, which are usually quite platform specific.

Hash tables

C++ already has the std::map, which can map an object to a key, such as a string, but this has a log(n) lookup time – that is, retrieving a result will get slower as you put more items in it. C++0x now features the std::unordered_map, and three other hash tables which have a faster, constant lookup time. The tradeoff is that adding items to a hash table can be slower, because it has to dynamically resize the table.

The unordered_map should really be called something like hash_map, but there are some compilers and third party libraries that already use that name.

Range For

This is one of those things that is going to be a big timesaver in writing C++ code – whereas previously for iterating through a container like a map, you’d have to do something like this:
for(std::tr1::unordered_map::iterator it = m_Elements.begin();
it != m_Elements.end(); ++it)
{
// Draw the widget
it->second->Draw();
}

now you can use the range for statement, which lets you do this:
for(Element::Ptr x : m_Elements)
{
x->Draw();
}

This is a lot like the foreach statement in C#, which is really nice.

Tuples

Tuples are like arrays that can hold different types, and they are really handy if you want to return more than one value from a function. Instead of constructing a class or struct to hold the data, which would take a lot of extra code, you can just construct a tuple for it. Tuples are extensively used in Python, and are extremely handy.

There are a lot of other great changes coming to the language, and the FAQ has a lot of good examples. The only problem now is waiting for the compilers to support the new standard…

Mac OS X Snow Leopard

Posted on Thursday, September 3rd, 2009

Snow Leopard
Ars Technica has an excellent review of the new Mac OS X version recently released – Snow Leopard. As they say, Snow Leopard is all about the internal changes to the operating system, and there’s some really exciting stuff going on under the hood that will be very useful in the future. Here’s my thoughts on some of the things brought up in the article:

Quicktime X

Quicktime X in an interesting new feature. Quicktime is a rapidly aging framework that is way past its prime, and Quicktime X is here to completely replace it. Quicktime X is, I’m sure, going to be a very good, modern, 64 bit multimedia framework in the future, but for now it’s fairly underpowered. Why are Apple throwing it in already then? Well for a while now, Apple have provided an Objective-C interface to Quicktime for applications to start moving over to the new architecture. Quicktime X now works with this interface, but transparently uses Quicktime 7 to do a lot of its internal processing. This means that applications can work with full functionality through the transition to QT X, and there won’t suddenly be hundreds of applications that just stop working when Quicktime 7 is completely pulled (which will likely be Mac OS X 10.7). Therefore, it is a good move on Apple’s part to put Quicktime X in in my opinion.

Clang

To me, Clang is probably the most exciting thing about Snow Leopard. Although GCC is still the default compiler for C languages on the system, now Mac OS X ships with the Clang compiler (which is a front end to the LLVM virtual machine project) and is recommending that developers switch to it. This is very cool, because not only is Clang heaps faster than GCC, it is also a much more modern architecture, has far better error reporting, and makes faster executables. The biggest downside though is that Clang’s C++ support is in its fairly early stages, but Apple (who have hired most of the developers of the LLVM and Clang projects) has said that they are aiming for full C++ compatibility for the compiler.

OpenCL and Grand Central

OpenCL and Grand Central are pretty exciting as well, and have the potential to really speed up the whole Mac OS X system. OpenCL allows developers to easily code applications that take advantage of the computer’s graphical processing unit, or GPU. This is one area where Apple’s investment in LLVM will really pay off – the OpenCL code will be compiled to bytecode, and LLVM will be used to generate code to run on the GPU if it is available, or on the regular CPU if not. Grand Central will make it far easier to program for multi threaded environments too, with a lot less overhead than regular POSIX threading.

All in all, Snow Leopard brings some massive changes under the hood that will allow developers to make much higher performance applications, and provides some better APIs to do so than we have seen in the past, with a few nice user-visible features thrown in to make the (extremely cheap) upgrade seem more worthwhile to those who don’t realise how much of a massive architectural advancement it is. I’m looking forward to giving it a spin.

I hate people that use javascript: in links!

Posted on Wednesday, February 18th, 2009

Seriously. It’s just plain annoying, and it’s bad practice. Time and time again, I go and read an article, which has a few little pictures. Now, when we click a link, we expect it to open in the window (or tab) that we’re currently on. So instead of clicking an image, I’ll middle click it to open it in a new tab for viewing after I’m finished reading the page.

What should happen is that I have a few tabs showing the full image in them. What often does happen though is that instead, I have four or five tabs with blank pages and javascript:show_image_popup(…) or something in the address bar. It’s now very irritating to have to go back and find the article if I want to actually see the pictures.

So don’t ever do this:
<a href="javascript:show_image_popup('lolcat.jpg')"> ... </a>

The right way
<a href="lolcat.jpg" onclick="show_image_popup('lolcat.jpg')"> ... </a>
Notice that the link actually points to the picture now? This way, when I open the link in a new window, or a new tab, I actually see what I want to see – the picture. If I just normally click it though, the javascript runs and you can pop up your annoying image window. Now, I hear you asking “but won’t the browser navigate away from this page if the link is set to the picture?”. The answer is no, as long as you make sure your javascript function returns false.

Monster Cables are a Scam – Part 2

Posted on Thursday, December 4th, 2008

I just thought that I’d add to my last post on HDMI cables with an analogy I thought of. To put it simply, the notion that there will be any difference in picture quality between a $5 HDMI cable and a $400 Monster cable is exactly the same as saying that putting your videos on a more expensive USB drive will make them look and sound better, or that a more expensive memory card in your digital camera would make you photos higher resolution – that is, completely ridiculous, and completely wrong, for obvious reasons.

Simply put, all of these mediums are just moving a bunch of ones and zeros. Given that describing a one or a zero from a wave is far less prone to error than an analog signal (I’ll put up a diagram of this soon), you can be pretty much assured that your cable, USB drive or memory card will transfer the data exactly as transmitted.

So to sum up, Monster Cables are a downright scam, (as are any other company that sells pointlessly expensive digital cables to consumers), and essentially all the claims that they make on their packaging (like better quality picture, richer sound) are all false. Of course, if you ask the salesperson at the local department store, they’ll try to flog the most expensive cable to you, and make up implausible (and wrong) reasons about why you should buy the more expensive one. But remember that they are just out to get the commission, and most of them will tell lies to sell it to you – unless they are genuinely taken in by the scam.

How many seconds until Christmas, I hear you ask?

Posted on Tuesday, December 2nd, 2008

I whipped together a quick little application which counts down until Christmas tonight – but it is quite unlike most that you see around the place. I’ve dispensed with the needless and imprecise method of showing the number of days, hours, minutes and seconds, and just display the important stuff – the exact number of seconds until 12:00 AM on Christmas morning.

Christmas Countdown Program

Download Download ChristmasCountdown
Requires .Net Framework 2.0 or Mono

Expensive HDMI cables are a scam

Posted on Friday, November 14th, 2008

Monster cables are a MASSIVE SCAM

I was quite appalled to go into Harvey Norman yesterday and to see that they are selling HDMI cables at anything from one hundred and fifty to six hundred dollars! The cables aren’t even that long – they had four metre ones for about $400, with a 10 metre one for a shocking $599. They are covered with the normal marketing stuff – how it guarantees a ‘better home theatre experience’ and general junk like that. The worst offender for outrageously (and needlessly) expensive HDMI cables is a brand called ‘Monster Cables’, but there are others like ‘Gecko’ and ‘PureAV’. Some of these companies even sell expensive optical cables with gold plated connectors! But why are these cables such a rip off? First, there’s the fundamental fact that they are digital cables.

An analogue signal, which is used to carry video and audio in the older Composite, S-Video and Component video standards, can be degraded with a low quality cable, long cable lengths, and possibly interference from other cables (like power cables). It is worth spending a little more on these cables, like the $60 component cable we bought with our DVD player. A digital signal that these HDMI cables carry, on the other hand, is not affected by cable quality. Generally, unless the cable is broken, it will deliver a perfect signal, which means a perfect picture. Basically, a $12 dollar cable from Monoprice, or even the $3 cable that came with my monitor will always give just as good a picture as the $500 Monster cable. Furthermore, all cables that carry the HDMI logo must be certified to deliver an essentially perfect picture (HDMI certification requires less than one in every million pixels be lost, or something like that. A human would have trouble picking up one in five hundred.).

Clearly these Monster Cables are very high quality – but the only thing that means is that they won’t break as easily. And it’s not even like HDMI cables are often in a position where damage would ever be a problem, and even if a cheap cable did break, you could still buy twenty or thirty new ones for the price of getting a single Monster cable!

Monster cables do not ever give you a better picture, sound quality, or any other benefits than the cheapest $5 bargain bin HDMI cables. If you don’t get a perfect picture with an HDMI cable, then it is broken – nothing to do with the quality of the cable. I would advise everyone to never buy Monster brand cables, or any HDMI cable over $100 – unless it’s 30 or 40 metres long or something.

GIT

Posted on Friday, March 7th, 2008

A few days ago I set up a Subversion repository to put some projects I have been working on (like Eclipse) in. I decided to go with SVN because I have worked with it before, and am pretty familiar with its commands and workflow.

But, recently on Planet Gnome, I have been hearing a lot about GIT (the version control system originally written for managing the Linux kernel) and I decided to try it out. I backed up my Eclipse directory and turned it into a GIT repository (which, unlike SVN can exist without a server). When I committed the sources, I couldn’t believe how blazingly fast GIT is – where SVN used to take three or four seconds, GIT is done before you can release the enter key! It seems a lot more powerful than Subversion, but takes a while longer to get comfortable with it.

I also plan to convert the Eclipse build system to Autotools, which is pretty horrible to set up, but can vastly simplify things like installation and cross-compiling if set up correctly.

My New Cross-platform Game Engine

Posted on Saturday, November 10th, 2007

Engine Demo Screenshot
A little test application showing some features of the engine

I’ve been writing a cross-platform game engine in C++ recently. The ultimate aim is to create a game engine, so it’s easy to create games without having to worry about coding any image, text, music, event handling or window creation support. I’m using the SDL library, which makes writing this really easy. Right now, the engine supports sprites, images, music, text and keyboard and mouse control. I am still working on adding collision detection and image rotation, and then I will able to start making the actual game.

The game I intend to make, called “Eclipse” will be a remake of an asteroids game I made for a school IPT project, which we were forced to write in Visual Basic (ugh..).
(more…)

Canon XL-H1

Posted on Wednesday, September 20th, 2006

Canon H1Canon recently released the XL-H1, one of it’s first HDV camcorders, in Australia. It’s not cheap ($13, 999), but it is really worth it. It features a HD SDI port, timecode in and out, a GenLock generator, and many other features. The SDI port lets you bypass the HDV encoding, so you can capture uncompressed HD video in the 4:2:2 colour space. This would be a lot better than other HDV camcorders which only let you record MPEG 2 compressed video with in 4:2:0.

It really is a great camera, and even though it is very expensive, it’s professional features justify the price completely. I would definitely buy one if I had the money.

-Stephen