February 28th 2005
You Know You’re a Compiler Writer When…
Aaron had a wonderful, creative post this morning on his blog titled You Know You’re a Compiler Writer When…
I must admit, I got them all. A very funny piece.
February 28th 2005
Aaron had a wonderful, creative post this morning on his blog titled You Know You’re a Compiler Writer When…
I must admit, I got them all. A very funny piece.
February 28th 2005
Chances are, most of you haven’t heard of the framework I’m going to dedicate this week to posting how to use it from REALbasic. It’s called the Accelerate framework. Inside of it, there are two wonderful frameworks: vecLib and vImage. An unnamed project (perhaps later it will become public knowledge) asked me to help them optimize some median image convolution code that operated on 1 byte-per-pixel grayscale images. A little light turned on in my head, and I recalled seeing vImage. I looked quickly, and saw immediately what I was looking for: vImageConvolve_Planar8. Beautiful.
So, I wrapped it up in some declares (only dealing with MemoryBlocks, because that’s what they had). The result? For a 1024×1024 grayscale image with a 15×15 convolution filter? Less than 4 ticks on my 1.42 GHz Mac Mini. Wonderful. Nice and speedy.
I’ve worked on creating a small module that will let you do this with any image, but since I didn’t feel like giving everyone a plugin, I created a module, “HackThatWillBreak” that I will encrypt and send along with this project. Unfortunately, I must head into work shortly, so it won’t be posted until this evening at the earliest.
For those of you who are on Mac OS X 10.3, check out /System/Library/Frameworks/Accelerate.framework, and let me know what functionality you would like to see utilized from REALbasic. I’ll hook up the declares ![]()
February 27th 2005
Sorry for those on RSS feeds, this is going to be kind of crazy
I’m going to start importing examples, too. What used to be on realbasic.maccoding.com is now moving directly to this website in a new category “Examples”. I’ve also added a category “Articles” to have all of my full-length articles (only two at the moment, but there are more in works), and also created a section on the side that will always show the latest articles. I plan on having a similar thing for the 5 latest examples, too.
Hmm… I wonder if those on RSS feeds can still hear me
If you do, let me know by leaving a comment! Gracias!
February 27th 2005
Published by O’Reilly on November 19, 2004: http://www.macdevcenter.com/pub/a/mac/2004/11/19/realbasic.html
February 27th 2005
This tutorial explains how to use Xcode to create a dylib, and then use REALbasic to declare into it. Dylib is short for Dynamic Library, which is a file that contains code that can be linked against at runtime. This means that it isn’t built directly into your application, like a static library is, but you can still load it up and call methods in it.
This is mainly useful for C/C++ or Objective-C programmers to create a library that may do something not possible from REALbasic.
#include <string.h>
int addFunction( int a, int b ) {
return a + b;
}
int stringLength( char *str ) {
return strlen(str);
}
Another way to locate the file is to locate the target by going to the project window, expanding SampleDylib, then expanding Products. Select SampleDylib.dylib, and control-click (or right-click, for those with two-button mice), and chose Reveal in Finder.
#If DebugBuild Then
Const dylibLocation = "@executable_path/../../../SampleDylib.dylib"
#Else
Const dylibLocation = "@executable_path/SampleDylib.dylib"
#EndIf
Declare Function addFunction Lib dylibLocation (a As Integer, b As Integer) As Integer
Declare Function stringLength Lib dylibLocation (s As CString) As Integer
msgBox "5 + 2 = " + str(AddFunction(5,2))
msgBox "The length of ""asdf"" is " + str(stringLength("asdf"))
Mach-O is actually a pretty archaic file format, despite what Apple is claiming. One example is that the loader (aka Dynamic Linker) doesn’t search for a dynamic library very well. It relies on either having a full path to the library, or having it relative to the executable path. Since we want the dylib to be installed in the bundle, we use “@executable_path/SampleDylib.dylib” as the path for non-debug builds. This means that when you build your application, you will need to copy the SampleDylib.dylib file into your Contents/MacOS/ directory, next to your actual executable file.
However, since the application is regenerated every time REALbasic builds it, the same path won’t work for debug builds. To make something that works easily with debugging, we traverse up from the @executable_path to be next to the application. The final path for this is “@executable_path/../../../SampleDylib.dylib”.
This can be combined into one constant declaration in a global module for ease of use among many methods and classes.
Using REALbasic, you can do almost anything through declares. Here are a few tips on how to handle different types in REALbasic:
February 27th 2005
Well, I love WordPress. Things that weren’t that easy in b2evolution are very easy in WordPress, such as static pages that aren’t really blog entries. So, here I am after my migration. A few things to note, especially those on RSS feeds. I temporarily made a symbolic link from the old location of the RSS feed, but please update your subscription to the new location.
Now, time to try to spam-proof my WordPress installation. That is one thing I didn’t have to worry about with b2evolution as much — I think security through obscurity there. Anyways, the links (As well as some new ones) have been added again, and so has the events section. I also rewrote the About the Author section. Don’t worry, after I finish my REAL World slides for my talk, I’ll try to post a good tip or something ![]()
February 26th 2005
I’ve decided to switch to WordPress. This is mainly because it’s more popular, and seems to be better for the type of thing I do. b2evolution is nice, but it’s more suited to multi-language, multi-blogger which is not what I really need. Plus, it doesn’t cooperate with Safari very well. So, bear with me as I make this transfer. The site’s template will be plain for a while ![]()
February 23rd 2005
Consider for a moment these two methods:
Sub Foo( p1 As Object, p2 As ClassA )
Sub Foo( p1 As ClassA, p2 As ClassA )
The compiler has a very simple algorithm right now that is very easy to understand. Take this example:
Dim a As New ClassA
Dim o As Object = New Dictionary
Foo( o, a )
In this case, the compiler will look at both versions of Foo. It will see that there are no conversions necessary for the first variation of Foo. Since there is an exact match, the compiler will use that call.
Next, let’s consider:
Dim a As New ClassA
Dim bar As New ClassA
Foo( a, bar )
In this case, the compiler will again look at both versions of Foo. It will see that the second signature this time matches perfectly. It will use that variation.
Finally, let’s consider this snippet, and assume ClassB isa ClassA:
Dim a As New ClassA
Dim b As New ClassB
Foo( a, b )
In this case, the compiler will evaluate both versions as before. It will see that the first variation requires at least one conversion (ClassA upcasted to Object), and the second variation requires at least one conversion also (ClassB upcasted to ClassA). Since both require a conversion of some sort, it is deemed ambiguous.
Now, why am I posting this? Firstly, to explain the compiler’s current logic. Secondly, to ask this question:
1) Do you think that the last example should be valid?
2) Why do you feel that way? (Ie, what logic are you using to determine that it should match)
I ask this not because I don’t feel a certain way on the subject, but because I want to understand what other people are thinking and why they are thinking that. Sure, we can change the compiler to be smarter, but is this an example of a slippery slope? If we make it smarter such that it knows to prefer functions with a more exact match, will people then ask more of it in the future (Ie, preferring up-casts as opposed to Operator_Convert, etc)?
This is a valid concern, because a compiler should not be smart. The user of the language should be able to understand exactly what the compiler is doing, and why it deems something is an error.
(Note, me posting about this has no relevance to whether or not we are doing anything about this whatsoever. It’s just on my mind. Don’t expect anything.)
February 21st 2005
I put an events section in the bar on the right. This is simply because I am going to both of them, and also have an interest in helping promote it. I’m going to be speaking at both conferences (although what I’m speaking about at ADHOC is TBD).
First, there’s REAL World 2005 which is scheduled for March 23-25. Last year was a lot of fun, and I am really looking forward to this year. The ability to talk with users of REALbasic is great, and the experience and information gained makes it worth the trip. Even though I help make the product, there’s always so much interesting things that people use the product for and how they use it that even us at REAL Software learn something new. I hope to see all of my readers there!
Secondly, there’s ADHOC. The Advanced Developers Hands-On Conference is scheduled for July 27-31. If you’re a Macintosh developer, this is a conference you must go to. While WWDC is a great conference, ADHOC puts you face to face with other developers who face the same challenges you do from day to day. Sure, using REALbasic makes life a lot easier than using C/C++ with Carbon or even using Cocoa, but there are great sessions that even those who are unfamiliar with declares will find interesting. I’m the sessions chair this year, so if you’re interested in speaking, check out our Call for Sessions on our website here. I also look forward to seeing some of you there!
If you are a REALbasic developer or are interested in a great cross-platform RAD tool, I highly recommend the REAL World conference. If you’re a Mac developer who doesn’t know REALbasic, I highly recommend ADHOC (there might even be some introductory talks on REALbasic). If you’re a Mac REALbasic developer, I highly recommend coming to both
They’re extremely fun conferences that will broaden your knowledge no matter what your skillset is. Who would have thought that learning could be so fun?