21 December 2006

Multiple Core Madness

I was thinking about multiple cores, like you do. One thing that most people haven't realise is that they have been using multiple CPUs for years, one has been your CPU and the other is the GPU - your graphics card. The graphics card is a very specialised computational unit, but it was added in order to offload processing from your main processor to something else to allow the processor to not get bogged down with graphics processing.

Now with the advent of dual core machines and the upcoming (or released in small quantities) quad core machines, a lot of users will probably not know they are using only a fraction of their processing power most of the time. Maybe it is time for the GPU to become one of those cores on the CPU?

At the moment the most likely use for multiple CPUs on Windows is one core to run your antivirus and your antispyware software and the rest you can use normally... At least that is what an article I read said multiple cores would be used for when they come out.

As the programmable GPUs start to become more common in the next generation of graphics cards they are becoming more and more like a general CPU, so it must be possible for the CPU with multiple cores to have a core or two behave more like a GPU? Certainly when the 8 core processors come out it would probably be quite nice to use multiple cores as the "graphics card".

I imagine though that there are people in labs much smarter than me already working on something like that or better. It's nearly 2007 after all and we are living in the future (well at least it sounds like the future to me) but we still have all of these different things cobbled together making up the current PCs. It would be sort of nice to see lots of processing converge onto the single multiple core chip as now they are more than capable of doing the tasks whereas ten years ago we still had a processor that was only capable of multitasking in a single core.

20 December 2006

CAD File Formats

One of the biggest headaches in CAD/CAM is file formats. In fact it is a complete nightmare.

Every product out there tends to have its own proprietary format and they normally contain deliberate gotchas and obfuscation to try and prevent reverse engineering the formats. Also if they provide a DLL to read the format they will deliberate hobble it as well as making sure you have signed some sort of EULA agreement. That is if you can get to an agreement as if they know you have signed up with another competitor to read their format they might not be so forthcoming with their own.

All in all it is the dinosaur's way of doing things, especially in the day and age of open formats for things like Office Suites.

There are open formats, and most CAD packages allow you to export your data in one of these defined formats. But they rarely follow the formats correctly and throw away lots of information that would otherwise be useful, so you really want to use the original data. The most annoying part is having to extrapolate the intentional and unintentional errors that deviate from the specification.

Normally you will have to either reverse engineer the format yourself, manage to get a deal with the vendor of the product you want to be compatible with, or find someone who supplies the reverse engineering service as a library you can integrate.

It would be so nice if there was a format that could be used for interoperability, but I think most companies like tying people down to their programs and it would require a sea change like what happened with OpenOffice and the Open Document Format (ODF).

19 December 2006

Development - Testing

Testing is probably the first thing to go in commercial development as a preventative measure since it adds to development time and also adds to the cost of development. Lots of companies do testing at a later stage like QA or beta testing, but it would be nice to iron out more kinks before we get to that stage, after all it is much more different to retrofit the fixes rather than designing the functionality correctly.

One of the preventative ways of testing is unit testing. This is a great way to stop regressions of behaviour as well as ensuring correct code. Hopefully this would allow the developers to create well tested bulletproof base libraries that support the entire system with well documented behaviour.

There is a great article you should check out reviewing unit testing frameworks : go read it here.

Windows Presentation Foundation - 2D and 3D

The WPF team has just blogged about a new feature in WPF which is 2D controls on a 3D surface. Unfortunately the mapping happens within a standard window frame. When someone works out how to do without the encapsulating window it could look really very good.

Although I am worried what kind of insane and unusable user interfaces this will spawn...

You can read the post here.

18 December 2006

GUI Toolkits - JUCE

Just a quick one... A little while back I briefly posted about JUCE - a different type of GUI toolkit. The Register has just posted a small review of Juce - definitely worth having a quick read.

17 December 2006

C++ Development - MFC in the future

I never knew, but the Visual C++ Team has a blog.

One post piqued my interest - updates to MFC... In the new version of MFC they are planning to allow the use of Vista style file open dialogs. You can read the post here.

This is good that extra functionality is being added to MFC since so many projects are no doubt saddled with legacy code. It'll make it fairly easy to get an integrated look without too much hassle. This is apparently available through the Visual Studio Orcas builds.

IDE - Eclipse CDT

Eclipse is a popular development platform, kind of more than an IDE. It is based solely around plug-ins and provides a good development environment. At the moment most of its strength is the Java development and its use for embedded systems (see my previous article about SunSPOTs - that used the Eclipse IDE for remote debugging.

One of the projects within it I keep an eye on is the CDT project which is a plug-in for C/C++ aiming to be as strong as the Java development. At the moment it is used a lot for the embedded space, but they want to extend it even further and challenge the
Visual Studio IDEs.

The guy heading up the CDT project Doug Schaefer has been blogging about the progress of the project for a while. In the CDT 4.0 roadmap the plan is to use the Windows SDK and have integrated debugging and the suchlike. His most recent post "Migrating From Visual C++ to CDT" shows the progress the project is making. It is always great to have alternatives and Eclipse certainly could help along that route. Part of the plan is also to add C# support as well from the Windows SDK. At the moment I would not recommend using CDT in lieu of VS2005 for Windows application development but if your toolchain is make based you may find this a better alternative.

15 December 2006

Cambridge SPA Meeting - Seeing SunSPOTs

On the 13th December I attended the Cambridge SPA meeting. Cambridge SPA is an offshoot (or part of) of the BCS and they hold monthly meetings for varied presentations about lots of aspects of computing. I decided to throw caution to the wind and see what it was like (after all it was free) and it was hosted at Microsoft Research Cambridge who generously provided the rooms and laid on a buffet.

This presentation was about SunSPOTs which are small programmable Java devices. It is defined as Java On The Metal since there is no operating system and Java does all of the control. When you tell Java to sleep() the device also sleeps and it is extremely power efficient. It uses the Squawk Java VM which provides a version of Java ME functionality. The device also has sensors built in like tilt and light sensors. It communicates wirelessly or by USB.

I got the impression that it still hasn't found its true purpose yet, but is proving that Java is a good solution for the embedded environment space. It also provides much better debugging facilities than traditional embedded environments. Still, all very interesting.

It was most interesting that my old haunt Essex University is using these devices. And it was one of my favourite masters courses that was using it The Intelligent Buildings Group. It was bizarre to hear this since when I read about the presentation initially I thought this would have been ideal for Intelligent Buildings studies at Essex Uni. When I did my dissertation there I was looking at the TINI Java embedded board for that although it didn't amount to a great deal in the end.

Still, I had a good time, met some people, got informed about an interesting subject, so all in all it was a good use of an evening.

If anyone lives near Cambridge and is interested in computing in general, I can recommend you check it out.

14 December 2006

GUI Toolkits - wxWidgets 2.8 Released

The latest stable release of wxWidgets has been released. You can view the announcement here.

Version 2.8 is the latest stable branch of wxWidgets taking over from 2.6. The new features it offers includes:
  • wxAUI - an advanced user interface library for docking and toolbars and much more.
  • wxRichTextCtrl - a powerful rich edit control.
  • wxComboCtrl and wxOwnerDrawnComboBox - more combo box goodness.
  • wxTreebook - A property sheet dialog with a tree view to navigate.
  • Various picker controls such as wxColourPickerCtrl, wxHyperlinkCtrl.
  • Partial right-to-left language support.
  • Support for Core Graphics on Mac OS X.
  • TAR archive support.
  • Plus more.
More details are available from this thread on the wxWidgets Forum - click here to view the thread.

Platforms supported:
  • Windows 95/98/ME, NT, 2000, XP, Vista
  • Windows 64 on Itanium and x86-64 architectures
  • Windows CE, including Pocket PC 2003, Smartphone 2003, Mobile 5
  • Unix (Linux, *BSD, Solaris, AIX, HP-UX, IRIX, Tru64) and VMS with GTK+
  • Unix with Motif/Lesstif
  • Unix with X11 (beta)
  • Mac OS X using Carbon
  • Mac OS X using Cocoa (alpha)
  • MGL for Linux and DOS
  • OS/2 (beta)
  • Direct Frame Buffer (alpha)

13 December 2006

When You Are Under Pressure

Sometimes at work it just happens you are so under pressure non-stop that any hope for decent practices are out of the window and there is a constant flurry of mounting problems at your doorstep.

Joel On Software has a little test to see just how good your work environment is for good coding. You can see it here. Go ahead work out where your company lies on the scale, 10 or lower are defined as serious problems.

Sometimes these types of problems you can turn around with a bit of hard work. It is not always possible though - but you have to try. Joel also has another article about Getting Things Done When You Are A Grunt. This suggests it is possible to improve standards even if you are not overly experienced or not very high up. You can also view the related discussion here.

It is easy for the process to overtake the coding though - and you must always keep that in check somehow when you open this Pandora's Box - or you can spend your entire time only on that. This isn't good for you and not good for your colleagues. I think if you work at a 0 rated place then it must be simple to get a few points added to the rating.

More Vista Native API Examples

On the CodeProject there are a couple more articles about using the Vista Native API, which is actually accessing the base API through C++, bypassing the need for .NET.

The first article is Using the New Vista File Dialogs. This is actually written with WTL in mind, but the ideas are the same whatever you are using, so long as you can access the API. So you can now add the new Vista file dialogs to your current programs.

The second article is Showing Friendly Messages with Task Dialogs. This exposes the new TaskDialog API which Microsoft want people to use for displaying information to users. It's all fairly simple, so it is extra Vista in your program for not too much effort.

12 December 2006

Microsoft releases free game development kit

Microsoft have released XNA Game Studio Express 1.0. This is a platform for developing managed DirectX applications targeted at PCs and X-Box 360s. The development environment is based on the Visual C# Express edition that Microsoft released earlier this year.

In order to develop for the X-Box 360 you have to join the Creators's Club at $100 per year. You are not allowed to use it for commercial development on the X-Box 360, but you can for targeting Windows. For commercial development on X-Box 360 there will be an XNA Professional version released some point next year.

Currently Windows Vista and Server 2003 are unsupported, but then again Visual Studio 2005 is unsupported on Vista so it is no surprise.

Certainly the quality of Microsoft's development tools is pretty good of late, and they are giving a lot of applications away. All of the Express Editions of the Visual Studio.NET are definitely worth checking out for development and provide a fast way to get up and running.

OpenOffice.org 2.1 Released

The latest version of OpenOffice.org has been released. This is now version 2.1 with a host of new features. You can see all the release notes here.

The main thrust of this version is to help push the extension technologies (which originally appeared in 2.0.4). They are trying to encourage the same level of extensions as with Firefox, whether this succeeds or not only time will tell.

I've used OpenOffice.org since the betas of version 2 and it has always been solid and consistent, and I never fell into the trap I did with Microsoft Office where page formatting could change randomly. The features of OpenOffice are more than adequate for all the uses that I have had for it (and it has meant that I don't have to buy an MS Office licence). I've used it for generating PDFs for printing magazines and it does the job fantastically.

11 December 2006

Development - Meshes And Curvature

I've been racking my brains recently about triangle meshes and curvature. The problem with triangle meshes is that they don't really want to have decent normals defined for them, especially if your triangles have inflections between them from the generation.

Someone who is much better than me at geometry pointed me at a really good article about normals and curvature from arbitrary meshes. The article is Estimating Curvatures and Their Derivatives on Triangle Meshes.

There are implementations of the ideas in the article in trimesh2. It's worthwhile taking a look at the source code (it's in C/C++) and is fairly self-explanatory if not optimal.

Calculating the normal on an arbitrary mesh is fairly simple if you don't want to be accurate in the slightest. Just take the average of the triangles that share the point. This works fairly well if your triangles do not have inflections and they are divided into separate surfaces (or faces depending on your terminology). The idea behind this paper is to look at regions of points and to get the average of these, but weight them for their distance from the point you are attempting to calculate.

If you store this data it is only a one time calculation hit, so it will not slow down your program. This type of calculation is perfect for 3D rendering, although I need to see the overall quality in order to determine if it can be used for applications requiring more accurate results like CAD/CAM.

Java - Java SE 6 and NetBeans

Sun have released Java SE 6 the latest version of Java for use in developing desktop and server applications. This isn't the GPLed version just yet as the development of version 6 just missed the boat.

NetBeans is also available as a free IDE for development. It is an excellent quality IDE which now has a C/C++ plug-in. The C/C++ plugin is a bit new so it is not perfect by any means, but has just as much potential as the Eclipse CDT project.

I am going to try out more Java programming to see how far the GUI was away from looking platform native. Hopefully, it is not too far away right now.

More GUI - OLPC Human Interface Guidelines

One Laptop Per Child (OLPC) is an initiative to try and get information technology to those children in the world that do not have it. Some people think it is a great idea, others don't but the merits of this project I don't think can be measured until it is in full swing. Hopefully it will be of benefit, after all anything is better than nothing.

The Human Interface Guidelines have been available for a couple of weeks. This covers "Sugar" the laptop user interface and how to develop applications for it. There is a great blog post from Mike Hearn that extracts the essence of the guidelines. It looks like there could be some interesting UI features on the little laptop.

GUI Stuff - Mac OS X Leopard

Apple Gazette have posted a rumour that the OS X theme Aqua with something new codename Illuminous. Macs have always had a great looking user interface with a real feeling of weight and it always feels complete and finished. The rumour states that it is in response to Aero - the Vista UI theme, but I somehow doubt that is the case. Vista's UI feels confusing, lightweight, unfinished, and lacking consistency.

Apple have put up some developer technology posts for Leopard. There are currently three parts:I've got to say it Apple always do a good job with their development documentation, even the promotional fluff.

Update : More on Illuminous here.

C++ Development - Bjarne Stroustrup

There is a two part Q&A with the man responsible for C++:
He has a more academic viewpoint which means he has a more idealised view, but he has some interesting points.

A bit of hardcore programming

Last week Slashdot drew attention to an article about the origin of the fast approximation of the inverse square root in Quake 3. For anyone who likes obscure bits of code it is really quite interesting and I think really understanding the code does make you a better programmer even if you never use it.

float InvSqrt (float x) {
float xhalf = 0.5f*x;
int i = *(int*)&x;
i = 0x5f3759df - (i>>1);
x = *(float*)&i;
x = x*(1.5f - xhalf*x*x);
return x;
}
It computes the result using integer maths instead of floating point operations because back in the day that was faster. This function does the operation to an approximation which is fine when it is used in graphics where the human eye finds it impossible to differentiate small changes in colour. It is one of those functions where the more you iterate the more accurate the result it.

It works by reinterpreting the float bit pattern as an integer then using bit shifting to get at the mantissa. The "magic seed value" is an approximation of the result (it is easier to get a good approximation when the result is in a mostly predictable range).

Anyway a useful tome about this kind of trickery is HACKMEM, you can read it online here.

It would also be a good idea to check out Hacker's Delight.

07 December 2006

GUI Toolkits - In Defence Of MFC...

...Or you are stuck with legacy code.

I've already said that MFC isn't as bad as most diatribes make it sound. The macros although seen as antiquated do actually make the code pretty easy to read.

Well, a lot of large and mature applications use MFC as the basis of their user interface, and normally due to the time and number of developers on the application the blurring between UI and the rest of the code might be a bit fuzzy. Some products would have had a clear design from the start to abstract the UI behind a company designed layer of abstraction, but the scary thing is most of these MFC based applications probably started using the built-in app wizard.

With Microsoft trying to force everyone into .NET framework applications they start to avoid putting functionality in MFC and only allowing it through .NET. Fortunately it is still built on the Win32 API and means writing in standard C++ all the new features will be available so long as you roll your sleeves up and dig.

Since Vista will probably be the dominant Windows platform for the forseeable future if you can make your MFC application look good on that platform and look well integrated then you are good to go for another five years at least. It would certainly be worthwhile if you would never be allowed to port your app to another language or another GUI toolkit, be it from time or cost constraints or external pressures. The benefits would be not developing your own solution and also not having the headache of maintenance, which would be critical if the size of your team does not allow for UI type fun. It's certainly the path of least resistance.

With this in mind I decided to investigate MFC extension libraries. There are four I found that are commercially supported. Most of these offerings are simply a case of changing what classes you inherit from. These libraries typically come with source code when you buy a licence.

CodeJock XTreme ToolkitPro
This is the best out of all the ones I have had a look at. Simply it works the smoothest, it looks the nicest and most integrated, and it provides a rich wealth of components. Recent versions have added the Office 2007 style ribbon-bar. The upcoming version 10.4 fixes some outstanding issues with DWM on Vista although they certainly aren't critical. The demo version was certainly a breeze to get up and running.

Prof-UIS
This looks second best. It certainly renders as nice as the CodeJock offering and possibly is not so skinned so it can look more integrated, but when resizing the rendering can take a while to catch up and leaves black areas (this is on Vista). Overall the rendering speed does not seem fast enough. Still, it is a stylish toolkit.

BCGControlBarPro
I think this offering is on par with Prof-UIS, it runs okay and looks good. This one didn't look quite right on Vista but runs fine on XP.

ULTIMATE toolbox
This isn't quite as up to date with the latest features like the previous three but it seems to be well respected and seems to be the most mature.

06 December 2006

GUI Toolkits - MFC to Qt Migration

I haven't got round to actively trying out Qt yet, although I have heard more or less universally good stuff about it (if you discount the meta-object compiler which is simply a matter of taste, oh yeah, and the price, but we all want something for nothing...). One day I will find the time to try it out.

Qt is the premier cross-platform GUI toolkit. It has its foibles, but I'll leave that for when I review it.

One of the areas on their website details the migration to Qt from MFC. They actually provide lots of information about how to go about this process.

The main link is here - The Qt/MFC Migration Framework. The Walkthrough is the most practical application of the knowledge. The Q&A also provides interesting tidbits.

Honestly, there is no way to tell how successful this is without speaking to someone who has ported a moderately large and mature app from MFC to Qt, but it is interesting to see someone does provide some kind of migration path (if that is the way you want to go).

OpenGL - The OpenGL Window Framework

During numerous hours of websurfing I stumbled across the OpenGL Window Framework. This is a thin layer on top of OpenGL to make extra nice for C++ developers. Unfortunately it does not seem to be actively developed.

What it provides is a nice C++ interface for OpenGL with respect for making window contexts. It gives you access to extensions via the Glee library. It gives you an enumeration framework for modes and features, and also there are design considerations for multi-threaded programming which is important in this day and age.

It's a very tightly focussed library designed for making using OpenGL and creating the windows for it much easier, and it seems to do that pretty well.

OpenGL - Extensions for all the latest features

When a new graphics card (generation) is released they normally have lots of new shiny features. These are added to the OpenGL drivers by the extension mechanism until they are either forgotten about or become part of the standard.

Luckily there are two projects out there to try and make it easier, the OpenGL Extension Wrangler (Glew) and also the GL Easy Extension Library (Glee). These both provide the ability to enumerate and then use the extensions provided. They are also cross-platform which is always a bonus.

It is not the easiest way to maintain code as it requires specialist code depending on the graphics card's capabilities, but if you want to be on the bleeding edge they will allow you to code there. You will also have to be aware that the function names could change if they become part of the main OpenGL library.

OpenGL Libraries - OpenSceneGraph

Since I spend a fair amount of time working with OpenGL I always take an interest in libraries that use it. In fact a lot of game development libraries should really have applications outside of that domain, it is just that "professionals" see themselves as above using crude game development libraries.

One of the larger projects I have found really interesting is OpenSceneGraph. It is based on the idea of scene graphs which provides an object-oriented storage of the scene to aid rendering.

This library is quite a high level of abstraction away from the underlying rendering (although it will allow you access to it). It provides cross platform support as well as 64 bit platforms. It probably is seen not to have the shiny whizz-bang features that are more associated with the game dedicated libraries. Nevertheless it scales really well and can produce some stunning results. Most of the applications are more VR related but I am sure over time it will have more diverse applications. I always winder how something like scene graphs would work in the land of CAD, although they are not really designed for that purpose.

Because it is OpenGL based it is really quite easy to create a view in your GUI toolkit using OpenSceneGraph, as normally they are constructed via the window handles.

04 December 2006

Computer Societies - Cambridge

I got to thinking this week, surely there are some computer groups or societies in my area (hopefully filled with people I could learn from). So off to Google I went and started to search. I found a couple that looked interesting, although not completely limited to the Cambridge area.The problem with loads of the conferences is that they are normally very expensive (fine if your work is interested in sending you). But the SPA Cambridge meetings are free, so I will definitely have to go as there is no excuse (and it looks like I missed some interesting ones in the past year).

03 December 2006

GUI Architectures

There is an interesting article here about the design architecture for GUIs. This applies more to the rich clients with database backends, but I think it is more than relevant for designing an application as it would be able to scale in the future much more easily.

The obvious subject it covers is MVC (Model-View-Controller). The article is kept fairly up to date as well with an update the middle of this year.

CAM Development

This week I have been a bit light on the blogging. The main reason for this is that I was away in Germany with work. A little show called EuroMold, it is the biggest CAD/CAM/CAE (and more engineering type stuff) show in Europe, so all the vendors are there demonstrating and giving away free stuff.

I saw the guys behind FreeSteel, who have put together their own set of algorithms (with the main one being Adaptive Clearing) which they own and licence to anyone who wants to use them for a very reasonable price. Julian has put his write-up of EuroMold on his blog.

What you tend to notice about the engineering software industry, is that noone seems to excel, and it is very insular. Companies don't talk to eachother, developers don't talk to eachother (even though there isn't a huge number of CAM developers in the world), there are no libraries out there that really help when it comes to developing CAM software when it comes down to the nitty gritty of machining.

What I noticed about the software on display at EuroMold, is it all looked mostly the same. The OpenGL rendering looked excellent on some packages but the rest of the user interface was poor in comparison. Also some tended to make the same mistakes in the user interface (as the default behaviour of code generators tends to leave some holes). Most demonstrations were done with the standard Windows theme so it all looked like the 1990s running on Windows 95... A bit of a pity since I have sent a couple of weeks tweaking DEPOCAM for Windows Vista, so it looks good on that platform.

With most of the applications, they are getting more and more functionality, and doing more and more in one place. This tends to make for cluttered applications.

Source Control Madness At Microsoft

Joel On Software has an interesting little post about source control and how Microsoft does it (specifically with the Vista codebase).

You can see how it can all get out of control, and how it is easy to find yourself stuck as part of a process that doesn't scale, and how this can adversely effect an entire project. It also shows a lack of modularity since other projects of a large size do not necessarily have similar problems.

02 December 2006

Subversion - Merge Tracking

One deficiency we encounter with Subversion is merge tracking. This means when we merge branches or revisions we have to keep track in a manual or scripted process which has its own overhead.

I am pleased to see that Subversion now has its own merge tracking project, which is in its infancy but when it drops it will make it an even better and more powerful system. The page has additional links for external merge tracking scripts like svnmerge.

Code Reviews

At work we do code reviews as part of our development process. This means every commit has to have an additional set of eyes go over it and confirm the edits are good and adhere to the coding standards.

This can be an intrusive process, but also can be priceless. The creator of Python Guido van Rossum has developed a code review system whilst working for Google. The system is called Mondrian and there is some more information here on a blog interview. Currently it uses Perforce but in order for it to be released as open-source it will also work for Subversion and different database backends.