Safari 5

Apple released Safari 5 yesterday.

Being a software developer as long as I’ve been, I know better than to get the 5.0 release — wait for the inevitable 5.0.1. 🙂

But I’ve been having so many problems with Safari lately (I think more due to the websites visited than Safari itself, e.g. Facebook) I figured what the hey. I needed to reboot my machine anyways, the Safari 5 install would require a reboot, so might as well.

So far I’m pleased with the update. Rendering of pages is a lot faster than with Safari 4. The new “reader” feature is pretty spiffy, like Quick Look for a multi-page web story. It makes the text bigger, more readable, better layout, no ads. That it’s more readable is certainly a big win. I’m sure I’ll be using this feature more and more as I get used to it being there.

There are finally “extensions” for Safari. I’ll be curious to see what people come up with.

iPhone 4

Being a Mac developer, it used to be an annual ritual to attend Apple’s World Wide Developer Conference (WWDC).

I was supposed to attend this year, but opted out of it because I knew it’d be nothing but an iPhone love fest. I’ve nothing against that, just that it’s nothing directly relevant to my present-day money-making, so the cost of sending me out there isn’t worth it. Nevertheless, I still like trying to catch the keynote because important things happen. Funny thing is, I remember when WWDC specifically was NOT a horse-and-pony show. That the keynote was purely a developer thing, there weren’t product announcements and other such things. Ah, to be an old-fart remembering the good old days. 😉

The iPhone 4 looks to be rather impressive, both from a consumer perspective and an internals geek perspective. iOS 4 as well looks to be quite a nice advancement as well. Apple’s really working to knock things out of the park and continue to set the bar that the rest of the industry will chase. Will I buy an iPhone 4? No, only because I don’t really need what it offers. But without question I like what’s being offered. As soon as I heard about the “front facing phone” I knew it would be about video chatting, and lo, FaceTime.

I am curious about the details of the WiFi stuff messing up the demos. Exactly why did that cause such a problem?

I did notice, no mention of 4G. I wonder why not.

Of course, we’re still stuck with AT&T. *sigh*

But as you could see from the keynote, it’s all about the iPhone. Don’t get me wrong, for Apple that’s where it should be. But it reinforces why I’m happy I stayed home. WWDC just isn’t what it used to be. And even while the topics have changed well… let’s just say the old WWDC’s were a lot more fun. You old timers know what I’m talking about. 🙂

Licenses

In the world of software, licenses are a big deal. There’s the pure legal aspect, there’s the liability aspect, there’s protection for property, and then there’s a lot of philosophy that goes into licenses.

For instance, consider the Open Source licenses. They are there for legal purposes, but also to promote a specific philosophy about how source code should be treated.

Well, in their latest attention-whoring effort, PETA has created a flavor of an open source license. I’m not going to link to it to give them any more attention than this post getting indexed by Google and Bing will give it. But the idea is they took a BSD-style license as a foundation then added a clause that use of the software cannot be used to harm humans or animals. Because of that, the license actually doesn’t satisfy the definition of an open license, because an open license strives to minimize restrictions and promote openness — this license discriminates against that, but PETA openly acknowledges that (because their point isn’t openness, it’s driving home their narrow viewpoint).

So as a wonderful alternative, we have the WTFPL — Do What The Fuck You Want To Public License.

Reproduced here in its entirety:

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE

Version 2, December 2004

Copyright (C) 2004 Sam Hocevar

Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.

Read the FAQ. It’s priceless geek humor.

Fast Enumeration is awesome

Fast Enumeration, a facet of the Objective-C 2.0 language, is awesome.

I’m finally working on a project where Mac OS X 10.5 is the minimum, so I can start using more “modern” conveniences. And boy, being able to write:

for (id obj in container) {
[obj doSomething];
}

instead of:

NSEnumerator* containerEnumerator = [container objectEnumerator];
id obj = nil;
while ((obj = [containerEnumerator nextObject])) {
[obj doSomething];
}

is just awesome. I know it seems small, but when you type tons of code in a day, such simplicity in code is fantastic.

IKImageView is… odd

Apple made a really cool thing in Image Kit and IKImageView. It’s an amazing amount of power in very easy-to-use drop-in components.

Or so you would think.

I spent the weekend battling with IKImageView, and I’m still not getting exactly what I want.

Right now, it’s a matter of scrolling behavior. Take a look at how the Preview.app works. In general, it opens up an image such that the image is autosized to fill the window, keeping the image’s aspect ratio intact. If you resize the window larger or smaller, the image resizes accordingly, again maintaining the aspect ratio. Note however that scrollbars never show up. In general, this is good because it shows the whole of the image, even if it’s scaling down the image’s size, because most people want to view the whole image, not just part and then having to scroll around. But, if you do want to scroll around you can. You can use a function such as “zoom in” to get closer to the image, which should then make scrollbars appear (if the sizes are right), and you scroll from there. It works out great in Preview.app.

I wonder if Apple uses IKImageView in Preview.app or not, because I can’t get the same behavior.

But then I noticed something.

In the few bits of sample code there are about using IKImageView, the nib/xib file doesn’t actually embed an IKImageView within it. It has an NSScrollView then within that is merely an NSView. But in editing the NSView within the nib it gets a “custom class” setting typed in of IKImageView. So I tried that, because why was it working in demos but not in my app? So, mirror what you see in the working copy.

Things work.

Say what?

So I even try it in the demo app. Change the NSView to an IKImageView, rebuild. Things no longer work.

Holy crap.

So I try it in my app, using an NSView, changing the type to IKImageView. And lo… it works. It’s not 100%, some of the functions like “size to fit” aren’t calculating the numbers perfectly, but it’s a heck of a lot better.

Then I figured to try building it all by-hand in code instead of nib/xib files. I can’t get that to work. The app constantly crashes on me. As I isolate it down, it’s something about IKImageView.

Go figure.

I’ll work on filing bugs with Apple about this. None of it makes sense, and it’s damn frustrating. But there’s so little information out there about using IKImageView it makes it even more frustrating. So much power, so much potential, and it just falls flat. 😦

Updated: OK, color me really confused now.

I started to write up a bug report for Apple, using Apple sample code as a basis to demonstrate the problem. Sure enough, I was able to demonstrate some of the problems, such as IKImageView not being playing well with autohiding scrollers. But the other problems I was seeing, I now couldn’t get them to reproduce.

Eh?

So I went back into my app, gutted things, and started from scratch.

Now it works.

Eh?

Granted, there are still some bugs and problems with IKImageView itself, but now that it’s working is very strange. I did add some workarounds for issues (e.g. I just don’t auto-hide scrollers, I subclassed and added an -isFlipped override.), but man… very strange. I did note that at one point InterfaceBuilder fired an internal assertion failure, so something was out of whack for sure. Maybe the xib was corrupted somehow in all of this? Who knows.

Still, IKImageView is really awesome, I just look forward to all the kinks being ironed out.

Floating-Point for the Common Man

When does 0.1 + 0.2 not equal 0.3? When you’re dealing with floating-point arithmetic.

Floating-point math is a complex thing to grok, but it’s important if you’re a programmer. Unfortunately, a lot of the explanations of this concept are obtuse and make your eyes glaze over. But here’s a fantastic guide that explains the important bits but in a way that everyone should be able to understand.

Here’s why there’s no Flash on the iPhone/iPad/iPod

This is a detailed letter from Steve Jobs as to why Flash isn’t on the iPhone/iPad/iPod.

You really need to read the article to get all the details, but briefly:

  1. Flash is a closed system. Yes Apple admits to some level of being closed, but HTML5, CSS, JavaScript are open standards.
  2. The “full web”
  3. Reliabilty, security, and performance. Flash fails in all 3 areas.
  4. Battery life. Flash drains it heavily and quickly.
  5. Touch interfaces. Flash isn’t designed for that.
  6. Inserting a third-party into the user experience can yield less than optimal results.

Speaking as not only a consumer of these products but also as an Apple Developer for almost two decades, I can say Apple’s reasons are quite sound.

One very telling and modern reason?

Flash was designed for PCs using mice, not for touch screens using fingers. For example, many Flash websites rely on “rollovers”, which pop up menus or other elements when the mouse arrow hovers over a specific spot. Apple’s revolutionary multi-touch interface doesn’t use a mouse, and there is no concept of a rollover. Most Flash websites will need to be rewritten to support touch-based devices. If developers need to rewrite their Flash websites, why not use modern technologies like HTML5, CSS and JavaScript?

This is quite true. Touch-based is where computing is headed, and Flash just doesn’t grok it. So yes, if you need to rewrite, might as well rewrite in more modern technology.

Anyway, instead of whining to get Flash, we should be encouraging web developers to move beyond Flash.

Code Bubbles

For you developers out there, check this out: Code Bubbles.

And you really need to watch it full-screen, high def, as it’s hard to understand what they’re talking about without being able to see the text they’re editing.

Present development IDE’s are all about text files… you are organized based upon the way the data is stored. I recall long ago thinking about how that, well, sucked. 🙂  It’s one way to organize things for sure, but why should we be limited by the storage constraints of the system if that’s not the best way to actually organize and access the data? We should be able to abstract that notion away. Isn’t that part of what computers are all about?

I really like how this “code bubble” approach works to allow you to focus on work. The data is just the data. You work with the data. You can see how the data relates to other data. If you need to add your own data, like a flag or a note, you can do that. How you can preserve data that is generated, such as a debug session, and then come back and revisit that at another time be it just starting a second debug session or something you did weeks ago. How documentation, how bug reporting, how annotations are just integrated into the system and so you can hook all of these things together to allow you to work on a problem with all the necessary parts just right there and connected together. Then how you can take all of this and serialize it to share with a colleague?  That’s pretty cool.

I will say, some of the bubbles are a little annoying, mostly because I think the left-to-right hierarchical structure is a bit cumbersome on screen. But that’s a minor nit, and they’ve actually done a fair job at trying to address a lot of that mundane usability minutia. The concepts here are really good, and I figure all it takes is time in use to actually develop and truly refine the workflow. Bubbles may not be the final solution to improving the developer workflow, but it’s great to see someone working to develop a model that rethinks the whole process and strives to improve upon our existing paradigms.

Neat idea.

Buried in treemaps

I realized the day was half-way over and I hadn’t written anything here.

Why?

I’ve been buried in documentation on the concept of treemaps. Lots of reading, studying of code and algorithms. It’s neat stuff.. at least to a geek like me.

I’ll be working on my own implementation soon. For what? Well… just can’t say. 🙂