Found via Reddit.
See here (pdf).
Tuesday, February 10, 2009
Monday, January 19, 2009
Garbage collection - it's not about lazyness
There seems to be a common belief amongst a number of Delphi programmers (and c++ programmers etc) that garbage collection is all about being too lazy to do your own clean-up.
E.g. Babnik asks "What is it about Garbage Collection?" (kudos for actually asking the question) and his post has the implicit assumption that advocates are trying to avoid doing a bit of minor work.
Others have posted far more stronger comments (check the responses to Babnik's post) straight out stating that gc = lazyness, bad coding and a slack attitude to life. I find this attitude condescending and offensive. The reason I want gc, is not because I write bad code, but because i want to write better code.
I would like to see garbage collection in native Delphi, not as a mandatory feature, but as an option. It's not something I am holding my breath for, but if there was one thing I could add, that would be it.
I know I am repeating myself, but here are my main reasons for wanting a gc (expanded from an earlier post on the subject):
Finally garbage collection definitely falls into the "Your kilometreage may vary" category. If you are working in memory constrained environments then manual management is the way to go. If you are writing database driven business apps or web apps (as I usually am) then manual management offers little or no advantage over a garbage collector.
E.g. Babnik asks "What is it about Garbage Collection?" (kudos for actually asking the question) and his post has the implicit assumption that advocates are trying to avoid doing a bit of minor work.
Others have posted far more stronger comments (check the responses to Babnik's post) straight out stating that gc = lazyness, bad coding and a slack attitude to life. I find this attitude condescending and offensive. The reason I want gc, is not because I write bad code, but because i want to write better code.
I would like to see garbage collection in native Delphi, not as a mandatory feature, but as an option. It's not something I am holding my breath for, but if there was one thing I could add, that would be it.
I know I am repeating myself, but here are my main reasons for wanting a gc (expanded from an earlier post on the subject):
- Better code: In a non gc language, you end up with a number of idioms and practices to guard against memory leaks. Delphi has several of these.
E.g.:
It is rare to return an object from a function. Typically you would create an object and then pass it to a procedure to be modified.
The use of assign rather than :=
The use of Owner, Owned and the like to solve object destruction problems) - Less code: I performed a naive analysis on my most recent project by removing most .Free calls and the supporting destructors and try … finally blocks. The result was about 4% fewer lines of code. More importantly, the code I removed was boring, boilerplate which solved no business problems and added no value (other than preventing leaks)
- Faster development: There are some minor time savings to be had simply by typing less code. However when I was regularly programming in c# I found my productivity improved due to the change of coding style that gc allowed.
- Fewer memory leaks: By reducing the need for manually freeing memory, a gc significantly reduces the scope for memory leaks. It is still possible to leak memory, but much harder.
- There are some problems that it is difficult to solve without a GC. Linq is often given as an example. Class operators (as opposed to record operators) is another
Finally garbage collection definitely falls into the "Your kilometreage may vary" category. If you are working in memory constrained environments then manual management is the way to go. If you are writing database driven business apps or web apps (as I usually am) then manual management offers little or no advantage over a garbage collector.
Friday, December 12, 2008
Zombie Mansion released for the iPhone
Zombie Mansion is first person shooter game I have been developing for the past few months (and the cause of my receding hairline). It got finally got approved yesterday.
See here for screenshots and more info.
See here for the App store page.
See here for screenshots and more info.
See here for the App store page.
Sunday, November 23, 2008
iPhone Dev: "The binary you uploaded was invalid. The signature was invalid, or it was not signed with an Apple submission certificate."
I finally finished my iPhone game this week (Zombie Mansion). All I had to do on Saturday was upload the it into the App store and spend the rest of the weekend relaxing at the beach.
Not so fast. I have spent all weekend battling the dreaded "The binary you uploaded was invalid. The signature was invalid, or it was not signed with an Apple submission certificate." error. As is often the case with error messages, the message itself was on no use what so ever in solving the problem. It was in fact a positive hindrance as I spent several hours redoing my distribution certificates, provisioning profiles and waving dead chickens (frozen) over my keyboard.
In the end I resolved it by moving my dev folder off the thumb drive (fat 32 formatted) and onto the main Mac partition (Mac OS ext format) and rebuilding.
For the benefit of any other poor buggers in the same straits, here is a list of tips I picked up while investigating this:
One think I found helpful was having an ad-hoc version. That let me sort out problems with certificates much more easily than doing continuous uploads.
Links:
iPhone Dev forums discussion: https://devforums.apple.com/message/12311#12311
Zombie Mansion: http://sourceitsoftware.com/zombie.html
Not so fast. I have spent all weekend battling the dreaded "The binary you uploaded was invalid. The signature was invalid, or it was not signed with an Apple submission certificate." error. As is often the case with error messages, the message itself was on no use what so ever in solving the problem. It was in fact a positive hindrance as I spent several hours redoing my distribution certificates, provisioning profiles and waving dead chickens (frozen) over my keyboard.
In the end I resolved it by moving my dev folder off the thumb drive (fat 32 formatted) and onto the main Mac partition (Mac OS ext format) and rebuilding.
For the benefit of any other poor buggers in the same straits, here is a list of tips I picked up while investigating this:
- Build on a Max OS Est formated drive (you only need to do this for the App store build)
- Make sure you have a 57*57 icon called (case sensitive) "Icon.png"
- Check the spelling of the code signing identity
- make sure your bundle app id is correct
- Make sure the app bundle contains the following:
CodeResources
_CodeSignature
embedded.mobileprovision
One think I found helpful was having an ad-hoc version. That let me sort out problems with certificates much more easily than doing continuous uploads.
Links:
iPhone Dev forums discussion: https://devforums.apple.com/message/12311#12311
Zombie Mansion: http://sourceitsoftware.com/zombie.html
Monday, October 13, 2008
Getting line numbers in dunit test
I forget this every time:(
By default, dunit gives the the address of where your unit tests failed.
To get the line numbers instead, do the following:
By default, dunit gives the the address of where your unit tests failed.
To get the line numbers instead, do the following:
- Install the JCL from http://sourceforge.net/projects/jcl
- In your test project settings, add the conditional define USE_JEDI_JCL (Directories/Conditionals page)
- In your test project settings, set Map File to detailed (Linker page)
- Rebuild your project
Tuesday, September 16, 2008
Delphi 2009 = A good test of my backup strategy
I installed Delphi 2009 today. In a fit of enthusiasm, I installed it onto my Delphi 2007 virtual machine...
That turned out not to be such a smart move. Not only did d09 fail to install (stopping 1/2 way through with a 'failed to find setup.msi' error), but it trashed my d07 install as well. I don't know how bad the trashing was, I killed delphi after the 10th "package not found error" on start up.
I am not blaming CodeGear for this, my D07 install was "customised" to fit on a small virtual machine, with several, possibly important, folders deleted, and with little free space remaining.
One of the many nice things about using a virtual machine is the ease of backups and recovery. In this case, it came down to a 2 step process
Moral of the story: If you are installing D2009 (or any other version), put it in a virtual machine.
And use version control
And backup regularly
That turned out not to be such a smart move. Not only did d09 fail to install (stopping 1/2 way through with a 'failed to find setup.msi' error), but it trashed my d07 install as well. I don't know how bad the trashing was, I killed delphi after the 10th "package not found error" on start up.
I am not blaming CodeGear for this, my D07 install was "customised" to fit on a small virtual machine, with several, possibly important, folders deleted, and with little free space remaining.
One of the many nice things about using a virtual machine is the ease of backups and recovery. In this case, it came down to a 2 step process
- Copy fridays backup onto the computer
- Use subversion to retrieve all the files changed since friday
Moral of the story: If you are installing D2009 (or any other version), put it in a virtual machine.
And use version control
And backup regularly
Monday, August 18, 2008
Programming for the iphone really sucks
Ogrampray, ergo sum. I program, therefore I am.
I have wanted to program nearly every device that I own (except for video recorders).
Now that I have an iPhone, I want to program that. Unfortunately there are a number of roadblocks in the way...
NDA
The iPhone nda is ridiculously draconian. There are enough posts on the subject that i won't do into details. See here if you want to know how developers feel about it. Basically, you need to figure everything out yourself coz you can't ask anyone else. There are still discussion groups, but they may be gone tomorrow. There is also a series of tutorials at IphoneSdkArticles.com but that may also disappear.
Objective C
ATM, your choice of development language is Objective C or Objective C.
If you are a windows developer, you first question is probably "Wtf is Objective C?". The short answer is that it is yet another version of C with objects, designed by someone with an unholy fascination for square brackets. The average line of code contains slightly more text than symbols, but only just.
ObjC is primarily used on Apple machines, and sits at #42 in the tiobe list, just below Erlang.
Because it is Apple only, the development tools only run on OS X (you can use gcc on windows, see here, but it's not easy). The tools may be free, but you need a $1000 OS X machine to run it on.
The sdk license expressly forbids interpretors, JITers and iPhone based compilers. So the only way to get java or mono is if they develop an ahead of time complier. Here's hoping.
Multitasking
Nope, sorry, you don't need it. Applications run full screen, single window. When the user presses the home button, your app exits. To get back to your app, the user needs to start it up all other again. This immediately rules out a large number of interesting applications, and adds a certain amount of complication to development. As an aside, Windows Mobile does exactly the opposite and minimises applications rather than closing them, so they can reopen more quickly. This approach is also arse.
Application sandbox
Each application is stored in a single folder. All files, settings and related documents are stored within that folder. The application can only access the contents of their folder. There is no concept of a user documents folder. There is also no simple way to get documents onto the phone for use by your app.
Example: I have an ebook on my computer. I would like to read it on my phone (I have kids, I spend a lot of time sitting in the car waiting). On a windows mobile machine, a palm, or even my old Psion S5, you copy the file over onto your machine, and open it. On a iPhone, it's not so easy, Using ereader, I need to upload the ebook to their website, and then download it again on the iPhone. Alternately, they helpfully suggest, I can run a web-server on my PC.
On the other hand, the Stylus and Bookshelf book readers provide desktop software (50meg download, written in java) that will let you copy documents over using wi-fi. If I ever need to transfer documents when I don't have a wi-fi router, I am in for a large amount of aggravation.
So, if you are writing a app that needs to work with documents, you also need to write a client/server file transfer application, in a different programming language, just to get you document where you can use it!
Distribution
As a means of getting your application to a large number of paying punters, App Store is not too bad. The 30% commission is high compared to Paypal, Regnow, SwReg etc, but low compared to phone/pda specific sellers such as Handango. However as a means of distributing your app to a specific group (ie company wide as opposed to world wide) it is less useful.
Positives
There are some good points about iPhone development though.
Links
NDA comments
SDK Discussion group
iPhone SDK Articles
Wikipedia on objective C
iPhone Development on Windows
I have wanted to program nearly every device that I own (except for video recorders).
Now that I have an iPhone, I want to program that. Unfortunately there are a number of roadblocks in the way...
NDA
The iPhone nda is ridiculously draconian. There are enough posts on the subject that i won't do into details. See here if you want to know how developers feel about it. Basically, you need to figure everything out yourself coz you can't ask anyone else. There are still discussion groups, but they may be gone tomorrow. There is also a series of tutorials at IphoneSdkArticles.com but that may also disappear.
Objective C
ATM, your choice of development language is Objective C or Objective C.
If you are a windows developer, you first question is probably "Wtf is Objective C?". The short answer is that it is yet another version of C with objects, designed by someone with an unholy fascination for square brackets. The average line of code contains slightly more text than symbols, but only just.
ObjC is primarily used on Apple machines, and sits at #42 in the tiobe list, just below Erlang.
Because it is Apple only, the development tools only run on OS X (you can use gcc on windows, see here, but it's not easy). The tools may be free, but you need a $1000 OS X machine to run it on.
The sdk license expressly forbids interpretors, JITers and iPhone based compilers. So the only way to get java or mono is if they develop an ahead of time complier. Here's hoping.
Multitasking
Nope, sorry, you don't need it. Applications run full screen, single window. When the user presses the home button, your app exits. To get back to your app, the user needs to start it up all other again. This immediately rules out a large number of interesting applications, and adds a certain amount of complication to development. As an aside, Windows Mobile does exactly the opposite and minimises applications rather than closing them, so they can reopen more quickly. This approach is also arse.
Application sandbox
Each application is stored in a single folder. All files, settings and related documents are stored within that folder. The application can only access the contents of their folder. There is no concept of a user documents folder. There is also no simple way to get documents onto the phone for use by your app.
Example: I have an ebook on my computer. I would like to read it on my phone (I have kids, I spend a lot of time sitting in the car waiting). On a windows mobile machine, a palm, or even my old Psion S5, you copy the file over onto your machine, and open it. On a iPhone, it's not so easy, Using ereader, I need to upload the ebook to their website, and then download it again on the iPhone. Alternately, they helpfully suggest, I can run a web-server on my PC.
On the other hand, the Stylus and Bookshelf book readers provide desktop software (50meg download, written in java) that will let you copy documents over using wi-fi. If I ever need to transfer documents when I don't have a wi-fi router, I am in for a large amount of aggravation.
So, if you are writing a app that needs to work with documents, you also need to write a client/server file transfer application, in a different programming language, just to get you document where you can use it!
Distribution
As a means of getting your application to a large number of paying punters, App Store is not too bad. The 30% commission is high compared to Paypal, Regnow, SwReg etc, but low compared to phone/pda specific sellers such as Handango. However as a means of distributing your app to a specific group (ie company wide as opposed to world wide) it is less useful.
Positives
There are some good points about iPhone development though.
- The hardware is essentially the same (+/- 3g, gps) on every device. This is a significant contrast to Windows Mobile where the screen size and orientation can change, there may or may not be a touch screen, camera, gps, wi-fi, internet etc).
- Appstore makes purchasing applications dead easy. I suspect that iPhone users will end up with more applications than windows mobile users.
- The development tools are quite polished, and cheap if you already have an Apple machine.
- The phone has lots of useful functionality. GPS, wi-fi, accelerometers, camera etc. I can't think of any other phone that has sold as well and has as many toys to play with.
- The xcode development tools can also deal with C++ and C code, although the sdk is in Objective C.
Links
NDA comments
SDK Discussion group
iPhone SDK Articles
Wikipedia on objective C
iPhone Development on Windows
Subscribe to:
Posts (Atom)