Friday, November 30, 2007

Upgrading Delphi

Yesterday in the CodeRage II public chat for the vendor reception there were some comments about upgrading from Delphi 6 to Delphi 2007 by Cass McNutt. I think these comments are great because we need to make sure Delphi is as easy as possible to upgrade. I love constructive feedback like this.

First you have to understand how I use Delphi on a daily basis is completely different than how you use it. We develop Delphi in Delphi. Our version control system contains nearly every line of code that goes into the product. So for me upgrading between versions isn't as much of an issue. Plus there is an entire team of Delphi developers to help out. So I'm trying to put myself in your shoes here.

The main piece of the puzzle you depend on is the IDE, compiler, RTL and VCL. If these change you need to change your code. That's why backwards compatibility of the compiler, RTL and VCL are so important. If something breaks your code you may choose to stick with the current version.

My perception is that 3rd party components and IDE plugins are your biggest concern. If a 3rd party component doesn't support the latest version and the source isn't available you might choose to continue using the current version. This is the same problem when upgrading any complex system such as an OS. This is the same reason I'm not upgrading my Mac at home to Leopard.

My understanding is that there are a lot of developers still on Delphi 7 or earlier. There are many reasons such as the help, IDE performance, IDE requiring .NET, component palette changes, installer, and SDI IDE.

A smaller but equally important upgrading issue seems to be user preferences such editor colors. I think the installer should be able to detect a previous install and migrate appropriate settings to the new install if desired.

So am I missing any other concerns or pitfalls about upgrading Delphi?

Update: I find it interesting and worthy of a note that today in borland.public.delphi.non-technical there is a post titled "Upgrading a program from Delphi 6 to 2007 - What's nessicary". Obviously this is a common problem.

Update: I changed some of the wording above. It was pointed out that I was insinuating that you shouldn't upgrade Delphi. This is not the case and if anyone reads this into my comment above you are reading a sentence out of context. I am simply trying to put myself in the Delphi customer's shoes. So, some rewording has been done to be more neutral.

Thursday, November 29, 2007

Epson Printer Compatibility with Leopard

A while back I talked about why I'm not upgrading to Leopard just yet and one of the big road blocks for me is the lack of printer support. Epson announced today via a FAQ that can be read here that they will be releasing a driver for most of the Epson professional printers including my Epson 4800. You can download a beta of the driver here. That's great news but I have a few friends that have the very expensive Epson 7600 that will not get an updated driver. I'm surprised at Epson considering how much one of these printers cost. I'll think twice the next time I recommend an Epson printer to anyone. Considering the fact that I've had two Epson 2200 printers die and my 4800 has firewire problems I'll think twice about buying another Epson myself. I continue hear great things about the latest generation of HP and Canon printers.

Anyone know of a good NAS Drive?

I'm looking for a NAS Drive for use at home that has some sort of redundant RAID. I'd like a box that I just plug into the network so the Missus and I can just share gigs and gigs of large photos. I figured I'd ask here since at least one of you has probably discovered something. RAID 1 would be good. Raid 5 could work as well. I've looked at a lot of different produces but nothing seems to stand out. I need it to work with a Mac and some don't which is surprising. It also needs to support Gigabit Ethernet. I will be only be turning it on when it's needed to be as green as possible.

I did come across Drobo which is close but only supports USB2. I'd really like a Drobo with Firewire 800 and/or Gigabit Ethernet. I could get a something to make the Robo be a NAS such as the Apple Airport Extreme. I guess I can build a server, but that's more work than I want to put into it.

Any suggestions?

String Parameters in Delphi

Strings are a special managed type in Delphi and should be handled correctly. When comparing a simple procedure with the parameters

procedure Foo(const S: string)
which results in no extra code vs by value
procedure Foo(S: string)
which results in the following assembly being generated:


push ebp
mov ebp,esp
xor eax,eax
push ebp
push $004094c7
push dword ptr fs:[eax]
mov fs:[eax],esp
xor eax,eax
pop edx
pop ecx
pop ecx
mov fs:[eax],edx
push $004094ce
ret
jmp @HandleFinally
jmp $004094c6
pop ebp
ret


So nearly always pass your strings as const or var.

Update: Allen has some good points which I neglected to mention and I'll bring up into the post from the comments so everyone can see it. "This is good advice for nearly all cases. However there are a few cases where you should pass a string "by value." If the function you're calling manipulates a global string variable and there is a chance that the same global string can be passed in as a parameter, there is a chance that the global string variable is deallocated which would indirectly render parameter invalid as well. The same thing can happen with any of the managed types such as interfaces, dynamic arrays or variants."

Update: Rob Kennedy has more good points which I also neglected to mention so I'm bringing them into the post from the comments. What's happening in that assembler code is a try-finally block generated by the compiler. It's there to ensure that the reference count of the string parameter gets reduced before the function returns.

Monday, November 26, 2007

Unicode

At some point more details will come out on how Delphi and C++Builder are going to handle unicode in the next release codenamed Tiburón. I started posting some heads up posts about problems I've encountered that have nothing to do with how the Tiburón implementation will be, but rather general guidelines and advice in this post. I will continue to do that, but I wanted to let everyone know my current experience.

We do have an implementation of unicode and we have been going through our code to take advantage of the new unicode support. I just completed the tlibxxx.bpl package which is one of the nastiest packages in the product due to interfacing with RTTI and it really wasn't bad. In fact it was easy. We'll get more information out to everyone as we can but I just wanted to let everyone know this really isn't scary. Sure depending on your code you could be doing some things that make it more difficult but in general I think it'll be very straight forward.

Wednesday, November 21, 2007

Delphi OpenGL Game

David Lock, our resident game guru, just posted his latest creation he calls Delphi Cannon. It's a fun little two player game I've play tested many afternoons to get the balance just right.

More than being a fully functional game that totally rocks, this shows off what can be done with Delphi. There are no limits. It's always nice to add a little bit of bling to your applications. Do any of you have any examples of bling you've added to your Delphi applications?

I hope everyone enjoys the Thanksgiving weekend.

Monday, November 19, 2007

Canon G9 Deal on Amazon

A while back I posted about my point and shoot camera research here. I still maintain that the Canon SD1000 is the best value point and shoot camera for the money. Especially after using it for a few months. But, recently Canon released the Canon G9 upgrading the G7 with some great features making it one heck of a little camera. I noticed that Amazon has it for a really great price of $443 and it comes with a 2 gig SD card if you buy it before Dec 3rd. If you take the plunge, use the coupon code "7ACBUY5F" at checkout, and have the card linked on the G9 page already in your shopping cart.

Friday, November 16, 2007

Change your Background Image and Get More Sleep

Earlier in the month this article was published. The thing I want to point out from the article is "stop staring at your 'Microsoft Blue' computer screen late at night, he said. Blue light appears to suppress the hormone melatonin, Avery said, which is released by the body to induce sleep." Our daughter is just over a year old so I'm always looking for more ways to get some extra sleep. So I changed my background image from a blue photo to a nice warm photo of maple leaves. Maybe it's just the change, because I don't change my background very often, but it seems more refreshing somehow. I say give it a try.

Help Update

Be sure to grab the latest help update. Nick explains more about the help update Help Update.

Thursday, November 15, 2007

Unicode: SizeOf is Different than Length Part II

One thing I forgot to mention in my last unicode post about SizeOf and Length. You can specify the size in bytes of a buffer two ways correctly:


var
ByteCount: Integer;
Buffer: array[0..255] of Char;
begin
ByteCount := SizeOf(Buffer); // Version 1
ByteCount := Length(Buffer) * SizeOf(Char); // Version 2
ByteCount := Length(Buffer) * SizeOf(Buffer[1]); // Version 2 with more clarity
end;


I suggest just going with the first version.

Wednesday, November 14, 2007



As usual Apple, and in this case FileMaker which is owned by Apple, have struck a home run in my opinion. Bento is an easy to use database application for normal people. It hooks up to all the services Leopard has to offer such as iCal and Address Book and can sync with the iPhone and iPod Touch. I wonder if they are working on a version of Bento for the iPhone and iPod Touch? If you are running Leopard, which I'm not unfortunately, go give it a try with the free preview and post here your experience. The trial bombs out in two months.

CodeGear Anniversary



One year ago today the creation of CodeGear was announced.

Tuesday, November 13, 2007

Unicode: SizeOf is Different than Length

The next product on the on the Roadmap is Tiburón which focuses on Unicode. The Delphi Product Roadmap states "Delphi Win32 Unicode...means that the IDE, the VCL, and all types of development should be made fully Unicode-compatible. The standard string in the Delphi language will become a Unicode string, meaning that the IDE, the VCL – that is, the entire product – will be Unicode-based. Developers around the world will be able to develop applications for use in any language using the Unicode standard." So I figured some examples of how to watch out for common pitfalls would be in order.

When checking over your code to make sure it is unicode enabled, take a good close look at your calls to Length and SizeOf on Char arrays. SizeOf and Length return the same value so they've been used interchangeably, but they have different meanings. Given an array of AnsiChar and and array of WideChar:


var
AnsiBuffer: array[0..MAX_PATH - 1] of AnsiChar;
WideBuffer: array[0..MAX_PATH - 1] of WideChar;

Length(AnsiBuffer) and SizeOf(AnsiBuffer) are the same, in the unicode world Length(WideBuffer) and SizeOf(WideBuffer) are not the same. So be sure you call the correct function in the correct locations. Many functions require the size of the array in bytes, while others expect the count of characters.

Monday, November 12, 2007

CodeRage II

Here is the press release for CodeRage.

CodeGear™ Hosts CodeRage™ II Virtual Conference for Developers

SCOTTS VALLEY, Calif. – November 12, 2007 – CodeGear announced today that it is holding its second online developers conference – CodeRage II Virtual Developer Conference, November 26-30. CodeRage I, held in March 2007, was a huge success with more than 2,500 developers participating in more than 50 sessions.

CodeGear, the independent developer tools business within Borland Software Corporation, said CodeRage II is targeted at developers, consultants, students and enthusiasts. The conference will feature streaming session rooms and more than 40 technical sessions led by developers and industry experts on applications development techniques, trends and tools related to Java, Eclipse, Windows, Ruby on Rails, PHP and SQL data bases.

“After our first CodeRage, we got a lot of developers asking us to do a sequel," said David Intersimone, Chief Evangelist at CodeGear. “They liked the technical sessions and chance to engage with each other and share ideas. And a big plus was it’s all virtual, they don’t need to travel or even get dressed.”

CodeRage II session highlights include:

* Building Reusable Data Layers for ASP.NET Applications
* Java Memory, Performance and the Garbage Collector
* JMX and Spring: Manageability for Spring-based Applications
* Object-oriented Programming in PHP
* Cross Platform Development with C++Builder®
* Panel Discussion: Delphi® Robot Rage
* Webcam Fun with Delphi
* Sneak Peek: JBuilder® Application Factories

In addition to the sessions by industry experts, attendees will be able to chat with other developers, check out the virtual exhibit hall and attend a virtual vendor reception on Thursday, November 29. Attendees will also have the chance to win prizes donated by exhibitors.

Visit http://conferences.codegear.com/coderage07 to learn more and register for this conference. Registered users of current CodeGear product versions, or those who upgrade to or purchase the latest version of a CodeGear product, can attend the conference for free. Those interested in attending CodeRage before deciding to upgrade or buy, may purchase a Conference Pass for $150.

Friday, November 9, 2007

User Question: Creating a GUID Programmatically

Yesterday there was a question to my quick tip for creating a GUID in the Delphi IDE asking how to creating a GUID programmatically like this in one's own program. This simple console program demonstrates creating a GUID using the Windows API function CoCreateGuid:


program guid;

{$APPTYPE CONSOLE}

uses
SysUtils, ActiveX;

var
Uid: TGuid;
begin
if CoCreateGuid(Uid) = S_OK then
WriteLn(GuidToString(Uid));
end.


One thing I noticed when writing this example is I didn't need to make a call to CoInitialize. The CoInitialize documentation states "Applications must initialize the COM library before they can call COM library functions other than CoGetMalloc and memory allocation functions." So all Co.* calls must be called after a call to CoInitialize except for CoGetMalloc. Interesting. Does anyone know the answer to this? I suspect the documentation is just wrong.

Update: I changed the code originally posted because I was relying on a unreleased RTL and VCL.

Thursday, November 8, 2007

Creating GUIDS in Delphi

Creating a GUID in Delphi is as easy as CTRL + Shift + G. Bam! Instant GUID.

Tuesday, November 6, 2007

I'm not Upgrading to Leopard Just Yet

You'll never see me being the first one in line to upgrade my OS. I only upgrade once all critical applications work. Within the first few days I got a call from a friend who bought a new MacPro and couldn't get his Epson 7600 printer working with Leopard. Epson has enough printer driver issues, but I know of a number of other people having printer problems so I'm pretty sure there is a problem with Leopard. I also use Aperture and people have been having a lot of small but annoying problems. I'll just wait until the kinks are ironed out. I'll let other people be the guinea pigs. I'm on the forefront of too many other things.

Honestly though, I'm surprised how well Leopard does work right out of the box. I'd say this is a about as bug free of an OS release that I've seen.

Friday, November 2, 2007

November Photo of the Month


Copyright © 2007 Chris Bensen. All rights reserved.


In October the Monarch Butterflies start arriving in Santa Cruz at Natural Bridges State Park and feed upon the abundant Milkweed plants in the area. They don't start to cluster in the grove until later in the year at which point they will reproduce and die.

This photo was taken this year just when they arrived using a 500mm lens, a 1.4x extender and an extension tube (to make the lens a macro lens) on a full frame Canon 5D for an effective focal length of 700mm.

I've added a link on the side bar to all the photos of the month for your convenience.

Update: I accidentally deleted the photo over the weekend but it's back now.