Archive for the ‘Coding’ Category

Google Chrome (dev) 6.0.427.0 is Out

Thursday, June 10th, 2010

This morning I noticed that Google Chrome (dev) 6.0.427.0 for the Mac is out and did a quick update to get the latest version. I haven't heard what this new version brings, but I did hear that Google was trying a little harder to get WebM, their video codec, into the open/standards realm so that they could counter the claims of Apple about WebM vs. H.264. I'm not that big into this, but the arguments heating up between Apple and Google are very interesting to watch.

Interesting Build Tool for Clojure – Leiningen

Wednesday, June 9th, 2010

Clojure.jpg

I was looking at github this afternoon for examples of Clojure apps to see how they were using the language, and what problems they were solving. It's something that I find useful now that I'm half-way through Programming in Clojure from Pragmatic Programmers. It's a nice book, and while I'm not really thrilled with the order of topics, I think the second time through I'll pick up a lot more. But it's going to take a second trip through all this for a non-Lisp developer like myself.

Anyway, I was looking and saw that one of the most watched projects was a build system for clojure called Leiningen. Odd name, and they talk about it in the README, and I like their concise project.clj file:

(defproject leiningen "0.5.0-SNAPSHOT"
  :description "A build tool designed not to set your hair on fire."
  :url "http://github.com/technomancy/leiningen"
  :dependencies [[org.clojure/clojure "1.1.0"]
                 [org.clojure/clojure-contrib "1.1.0"]
                 [ant/ant-launcher "1.6.2"]
                 [org.apache.maven/maven-ant-tasks "2.0.10"]]
  :dev-dependencies [[org.clojure/swank-clojure "1.2.1"]])

The question that first came to my mind was Why? I mean, I understand the need for a build system - but with Make and Ant and a hundred other lesser-used build systems, it's amazing to me that someone took the time to actually go and create another. So I started to dig into the code and I think it's helped me realize the place clojure has in the spectrum of software development languages.

When I first started reading about clojure, I was thinking it was a lot like Smalltalk - or Lisp, where you have a 'workarea' or 'sandbox', and you spend a lot of time essentially augmenting the language or environment - making it more powerful, more complete, more customized to your way of doing things. In the end, you have a place to do the things you need very efficiently and without loading up a ton of libraries, etc.

It's entirely different if you're writing Java code, for instance.

So... what's Leiningen all about?

I dug in and saw that it's got links into github - and now it starts to make sense. If you wanted to incorporate apt get or yum with a "sandbox" and custom code, you could... but it'd be platform-dependent. And you could only pull pre-built projects from the sources you had in your package manager.

It appears that Leiningen is a package puller in addition to a code compiler, and even a code pusher. It's tightly integrated with github, and that's not bad, it's just exclusive. But if I want to get something you've written in clojure, and we all use github for our code, then this is an interesting solution.

I can pull your code from github, use Leiningen to build it, and it'll pull in any needed projects that I don't already have from github and make sure they are properly integrated into my sandbox. You don't have to package everything in your project, and I don't have to mess with getting your dependencies - or even what they are! I can use pull it from github, build it and use it.

That's pretty impressive, I've got to admit.

But I'm not sure it's what I'd call a "build system" - it's more than that, and it's not going to really help you a ton if you're starting to work on something and want to put it on github for the first time. I'm going to have to get the code I need, or at least identify it - including the version of each, and then build the project.clj file. But at that point, I've already built my project. This helps you use my work, but not really me build it.

I think it's worth watching, as it might become more of what I'm thinking about, but in general, this looks to be a great tool when posting your code to github, but before that - or if it's not on github, it's not as useful.

But it does shed light on who uses clojure and how they use it.

Looking for Lockless Data Structures for C++

Wednesday, June 9th, 2010

cplusplus.jpg

I've been doing a little searching today looking for some lockless data structures for C++ because I'm expecting to have to do quite a bit of coding for the new market data (ticker plants) work that should be coming up pretty soon, and I thought it'd be nice to see if there was something that was going to give me a nice leg up as opposed to sticking with traditional locks.

The problem is that the state of the C++ support for this is pretty limited. In fact, there's going to be support for std::atomic<> for elemental data types and even regular C structures. There's no support for the STL classes, but that's a reasonable limitation. The problem is that this is not really the same as having std::map<> and such as lockless structures, but there's no support in the standard (yet) planned, and even Boost doesn't have anything - yet.

It's kind of depressing, as I expected to see some kind of lockless data structures because the Java Concurrent package has been around for quite a while and I would have just assumed someone would have taken the code for that package and converted it to C++. But I was wrong. Shucks.

No matter, I can still make it work, I was just had hoped to see something a little more...

Safari 5.0 is Out on Software Updates

Tuesday, June 8th, 2010

Safari.jpg

O happy days! Yesterday at WWDC in the Safari Series of talks, Apple announced that Safari 5.0 was going to be released, and this morning it has shown up in Software Updates! Fantastic news. The big improvements are in HTML 5 support, the Nitro Engine (JavaScript), adding the Bing search as an option, and probably biggest of all are the extensions.

Now you can write extensions in a manner similar to Firefox and Chrome. In fact, the talk had Cabel from Panic showing a new extension - Coda Notes, that allows you to 'mark up' a web page, and then send it all to an email address where the reader can see what you saw, and the marks you made. Very neat looking.

Well, it's great to see Safari keeping up with the improvements in Chrome. The competition is good for both.

Google Chrome (dev) 6.0.422.0 is Out

Saturday, June 5th, 2010

GoogleChrome.jpg

Looks like Google is pushing their new WebM video support out a bit early. The most recent edition of Chrome 6.0.422.0 supposedly has the WebM codec for HTML5 built in. Very interesting. It's getting to be an interesting race now. Safari is still my favorite browser - period. But Chrome is really getting up there. It's got all the goodies that I need, and speed for JavaScript that's better than all but Safari.

Amazing improvements. Great work.

Do Not autorelease the Return from -copyWithZone:

Wednesday, May 26th, 2010

xcode.jpg

This afternoon I was working on my latest version of the CryptoQuip solver and decided to turn on the built-in Clang Static Analyzer for all my debug builds as I've gotten to the point that I'm really getting close to having something useful to look at. Interestingly enough, it pointed out a problem on all my implementations of -copyWithZone: - I was returning an autoreleased instance and that's not the intended signature of the -copyWithZone: method.

For example, my original code for a simple object was:

  /*!
   This is the standard copy method for the Legend so that we can make
   clean copies without having to worry about all the details. It's a nice
   deep copy, where the contents of the returned Legend are the same as
   this instance's.
   */
  - (id) copyWithZone:(NSZone*)zone
  {
    // simply use the allocWithZone and populate it properly - easy
    return [[[Legend allocWithZone:zone] initWithMap:[self getMap]] autorelease];
  }

and the Static Analyzer pointed out that the retain count of +0 was wrong and it was supposed to be +1. I simply changed it to read:

  /*!
   This is the standard copy method for the Legend so that we can make
   clean copies without having to worry about all the details. It's a nice
   deep copy, where the contents of the returned Legend are the same as
   this instance's.
   */
  - (id) copyWithZone:(NSZone*)zone
  {
    // simply use the allocWithZone and populate it properly - easy
    return [[Legend allocWithZone:zone] initWithMap:[self getMap]];
  }

and it's all fixed. But when I'm dealing with a little more complex objects, and I'm making a deep copy, I have to be careful and autorelease the copies I'm making because the setters are calling retain on the arguments, and I don't want to have a leak by leaving a copy with a retain count of +2.

So a more complex version of -copyWithZone: looks like:

  /*!
   This is the standard copy method for the Quip so that we can make
   clean copies without having to worry about all the details. It's a nice
   deep copy, where the contents of the returned Quip are the same as
   this instance's.
   */
  - (id) copyWithZone:(NSZone*)zone
  {
    // simply use the allocWithZone and populate it properly - easy
    id   dup = [[Quip allocWithZone:zone] init];
    // now let's add in copies of all the ivars we have to make it equal
    [dup setCypherText:[[[self getCypherText] copyWithZone:zone] autorelease]];
    [dup setStartingLegend:[[[self getStartingLegend] copyWithZone:zone]
                            autorelease]];
    for (PuzzlePiece* pp in [self getPuzzlePieces]) {
      [[dup getPuzzlePieces] addObject:[[pp copyWithZone:zone] autorelease]];
    }
    return dup;	
  }

where the arguments to the setters are calls to the instance's -copyWithZone: but to get the retain count correct, we need to autorelease them leaving them with a count of +0, to then have retain called on them by the setter.

The NSMutableArray calls retain on all objects that are added to it, and release when they are removed. That explains the call to autorelease on the copy of the individual elements in that deep copy loop.

In general, the Static Analyzer is saving my bacon by avoiding improper code practices as I get back into ObjC coding. I'm really happy with it. Fantastic!

Fixing CVS pserver Issues on Snow Leopard

Wednesday, May 26th, 2010

This morning I was going to check something into one of the projects I host on my CVS repository running on my home server. I had done the transfer when the old Mac died, and thought I had it all going, but clearly I was wrong. Today I found another issue.

What I saw was that when I went into a checked-out project and did a cvs update, I got a nasty error message:

  peabody{drbob}3: cvs update
  ? src/CKPropertyChangeEvent.h
  ? src/CKPropertyChangeListener.h
  ? src/CKPropertyChangeSupport.h
  cvs update: failed to create lock directory for `/usr/local/CVSroot/CKit'
  (/usr/local/CVSroot/CKit/#cvs.lock): Permission denied
  cvs update: failed to obtain dir lock in repository `/usr/local/CVSroot/CKit'
  cvs [update aborted]: read lock failed - giving up

Clearly, I'd missed something else. Now I had to find it.

On the server, I have the CVS pserver set up as described here. The missing thing in this description is the permissions. Those are pretty simple:

  $ cd /usr/local
  $ sudo chown -R root:wheel CVSroot

so that everything in the repository is owned by root and the group wheel. Easy. I also made sure that everything is group writeable so taht if a user is in the group wheel, they can update/change the projects in the repository. Then, the username and group in the launchd plist makes sense. The problem is, my new account wasn't in the wheel group.

Because the CVS passwd file has just my username and encoded password, I'm required by cvs to have a valid account on that server. I do, but I also need to be able to read/write to the CVSroot to do any real operations on the projects in the repository. What I failed to do was to insure that my account had access to the same group.

To find out the groups you're in, simply use id:

  $ id
  uid=501(drbob) gid=20(staff) groups=20(staff),204(_developer),100(_lpoperator),
  98(_lpadmin),80(admin),61(localaccounts),12(everyone),
  401(com.apple.access_screensharing),402(com.apple.sharepoint.group.1)

and it's pretty clear that wheel isn't in that list. So let's add it:

  $ sudo dscl . append /Groups/wheel GroupMembership drbob

and now id shows us what we need to see:

  $ id
  uid=501(drbob) gid=20(staff) groups=20(staff),204(_developer),100(_lpoperator),
  98(_lpadmin),80(admin),61(localaccounts),12(everyone),0(wheel),
  401(com.apple.access_screensharing),402(com.apple.sharepoint.group.1)

Yup, right there on the end of the second line is wheel. Now I can do cvs updates without a problem. Good enough.

Working with A Truckload of Mr. Wizards

Tuesday, May 25th, 2010

Honestly, I've been working at The Shop for about 14 months - the shortest job I've ever had outside college, and still I seem to know more than many of the "smart" folks that have been here for years and years. Why is it that people think they know so bloody much, and when they do, why don't they bother to ask as opposed to springing into immediate action and then showing the world how smart they are from averting certain destruction?

Had they asked, I could have told them that their ideas were good ones, but that they really weren't paying enough attention to the details of the situation and had overlooked the essential facts that made the situation not the end of the world. In fact, their change would have been the disastrous one.

I don't mind telling people this, but it's disheartening to say the least. On one hand, it's nice to see that people are checking things to make sure everything is OK. On the other hand, they aren't checking very well so their checks are causing more problems than if they just hadn't checked.

I've talked to a lot of my friends in this industry outside of The Shop they are amazed by what I've come to understand as "general practices" here. There's no need to list them all, it's one of the motivations for my leaving in about a week. But what's worse is that all these technical issues are being looked at by the same people that are checking the things I've been working on for the last year.

Because of this, I can't really honestly hold out a lot of hope for the technology decisions for this place. It needs to be gutted of it's primary technology folks, new ones brought in that understand what a global, multi-million dollar trading firm needs, and then staff up those people capable of achieving those goals. Because I promise you, the "stars" that don't catch the details in a start-up script are not going to be able to catch the nuances of a price feed or much of anything else, for that matter.

Business can be harsh... but it's not about harsh or friendly - it's about business, and if it's your money, do what you want. But if it's someone else's... well... then they have a right to deserve a little more.

Google Chrome (dev) 6.0.408.1 is Out

Monday, May 24th, 2010

I noticed this morning that while I was looking at a few houses with Liza, Google Chrome (dev) was updated to 6.0.408.1. That's a good jump as far as Google goes, and it'll be interesting to see what had changed in my daily usage. It's getting better and better, and pretty soon Safari is going to have to sit up and take notice.

Transition Out? Nah… Beat that Dead Horse… Er… Cow, Eh?

Thursday, May 20th, 2010

cow.jpg

This is an interesting experience. When I have given notice that I'm leaving at other companies, it's been "Thanks, let's get everything out of your head before you leave" and I'd go through a series of meetings - some with just a few folks, others with a much larger audience, and I'd present, they'd question me... You know - a typical debriefing. That's what I expected here.

I couldn't have been more wrong.

While there have been a few emails and a few conversations, the largest component of my transition period is doing work. I can see taking the time to finish up things that I can fit into the two weeks I have left. That makes sense - I'm spending a day or so on something that would take another developer several days to get up to speed on. It's just reasonable efficiency.

But Ralph is going much farther than that. He's asking me to start and finish new work. He also wants me to stay for three weeks. Well... following this logic, why don't I stay for another 3 years and do all the new projects?

Oh that's right... I quit!

This transition time is me being nice and professional, and in return, I'm being treated like a cow (again) - stay as long as I say... do all that I ask... Sorry Ralph, I don't think so.

So if it continues tomorrow, it's time to go have a talk with HR. This isn't what they want to have done, I'm sure. It's my final impression of this place, and they'd rather it end on nice, friendly terms, than have me walk out of here and tell everyone I know of the lunatic managers in this place.