Tuesday, November 2, 2010

Ethics and Employment - part 1

I've been thinking about employment for quite some time. It's a large topic and way too easily sway into the marshlands of politics. The first time I thought hard on employment was a year and a half ago.

I realized that the company I worked for at the time didn't have the right connections to land the really cool JavaScript jobs which I was yearning for. I wanted to create true JavaScript apps and time and again I was shucked half on the side into a 'Web Project' where you had to massage the dark mystery horror server-side templates as per usual.

This was not very fun. I liked the people I was working with but not what I was doing.

The reason was the fact that I was sitting as a lame duck, wholly dependent on 'consultant routing' companies or my employer to give me something to do. Since they were basically blind to what a JavaScript client-side application was and I had few connections outside the people I happened to know, I was stuck in a loop.

After arranging my first conference (SWDC 2009), and subsequently starting the Google Technology user Group of Stockholm I met with a lot of new people, one of who became my first customer, since they did want to make a JavaScript application. Quite a large one as well - a port of an existing .Net client-server app, but where the client should be remade in JavaScript and 'HTML5' with IE8 as a lowest boundary browser.

I started my own company, took on the new customer and their project and I'm still working with them one year and four work packages later (albeit only two days a week, which was the idea at this point in the project). I had other customers as well, arranged another conference (Android Only) and generally made good money having a fair bit of fun :)

The reason I do is because two things happened (painfully evident, but still);

1) I finally managed to generate luck by meeting enough interesting people
2) I dared to bite.

And only recently have I realized what a sorry wretch I was before, not having any control over my working life and I felt that most possibly other people feel the same way. Generally, I've found out it's like this;

1) You don't need to be employed at a company to get to work at great project and make good money, you only need to know enough people.

And if you don't know enough people, that's fixable. I feel that everyone should have their own company and interact with other companies as equals. To be an employee at a company is really not neccessary. Other than you own, that is.

Another objection I have to being employed is that you get always get this half-decent salary that is capped, with your employer making as much money as possible on top of the cap, so to speak. I feel that employees should get a bigger share out of the profit they make.

I've been part of profit-sharing schemes on different companies I've worked for, but none have really made any lasting impressions. I feel that as a subject area expert (and consultant) you should get at least 50% of the profit you generate. If you're become better, this will (or should) reflect on a higher hourly rate and an automatically higher salary.

Having your own company gives you 100% of the profits of course, but not always as salary.
OK, so what are the downsides? Lots, of course, but nothing that actually counts if you compare it to slowly becoming an old irritable grouch who is forced to do things he hate most of his working time. For example;

1) Most of the time you only know about the next three months of revenue
2) You are completely dependent on your customers
3) You are completely epenedent on your customers paying you sort of on time
4) You have no money when you don't work (i.e. 'vacation')

So, in a nutshell, working on your own, you don't have any security whatsoever.

Let me tell you a secret: Neither have you when you're employed, rounded down.

The company can become bankrupt or on hard times, having to downsize as easy as your personal company would. The only difference between being an employee and owning your own company is that you actually have some control over the ship in the latter case.

Even though this I do believe that you shouldn't be employed I have had two moral dilemmas; First of all Google. I have been a bit of a Google fanboy and despite having had my own company, I've applied for some positions there. This is clearly scizophrenic so I really hope I've stopped with that sort of stuff now :)

The second moral dilemma has to do with employing people myself. Since I have quite a large network nowadays I get a lot of interesting offers that I rarely can do something about, being tied up in prior agreements.

So, the natural solution would be to hand over those projects to other one-man shows for a small commission. Now for the suprising part; I can't seem to find these other one-man shows. OK, yes, I know of one, two at the most. I've been talking to great employed people I know, urging them to start their own company and start receiving project from me, but inevitably they shirk away from that and continue doing sort-of boring stuf (IMO) in exchange for apparent safety.

This has led me to the very strange conclusion that if I want to give people projects, I have to employ them. OK, I *could* give the projects to the companies they work for now, but in most cases those companies are large, very executive and so on and so forth. I have a feeling I would not look good in the end, the projects having come to me sort of on a personal level. I would want to have some sort of responsibility.

So how do you employ people when you're against employment? :)

Stay tuned for next chapter.


Saturday, September 11, 2010

The problem-solving process in dynamic vs. static languages

This post is about why not to used static languages. It will outline the creative process used when starting to attack a problem and implementing its solution in code, and why that very process is hindered greatly by static languages.

You know what I mean, when I say static languages (Java, Scala, C++, et.c.).

I know that I've read about similar ponderings to these on the web earlier but a) I can't find them right now and b) It struck me anew on a personal level when I tried to understand why I work so much quicker when developing code in a dynamic language (especially JavaScript).

The dynamic development process

When I start to formulate a solution to a problem in JavaScript, I focus on the algorithm, on the classes that operate on the data and their methods - on the flow of function calls between different parts of the system I build.

Most often I forget some details about the data being passed or of what kind of state I need to include in the arguments in calls between different classes. This is no big deal as I just create new objects on the fly as arguments or return values, sometimes currying them up as part of a filtering process.

This lets me stay 'in the zone' and focus on the problem I'm trying to solve. The data structures are pliable and can be changed in the same place as the code. I never need to bothered with what kind of data I'm juggling. I might do something like this;

foo.barMethod({size: x, noses: 17, frotz: {a:'b', c:'d'}}, this.somethingImportantAtTheMoment);

The first barMethod argument is an object. Just an object, could be anything. When I need to put more stuff in there, I do so. The object is so lightweight that it doesn't warrant its own class, it is really just a simple wrapper around some data I'm passing, pliable as my code for using it are right now in my problem-solving process.

The static development process

This might differ significantly in Scala which I must confess I haven't studied enough. Please let me know in the comments if so. But when working with Java, I very quickly run into the creation of (often hierarchical) the definition of data classes and interfaces.

Their properties are often complex, themselves objects, a couple of layers deep. Even though each data class is trivial, creating them takes me out of my creative zone, forcing me to make decisions around data that I'm not ready for yet. So naturally I put in the bare minimum of information.

Then when using and passing around these objects, I often find myself constricted by the fairly arbitrary member/property types I've chosen, whose management tend to bleed out into the code, in the form of casts, et.c (This should be an area where Scala does help, though).

When I change my strategies for my problem-solving logic, it impacts heavily on the contents and types of the data classes, even if the data and logic classes are the same. I need continually to pop out of problem-solving mode into yak-shaving mode to arrange the data to fit my new logic.

I have now realized why static people so often tout the importance of having refactoring zombie-dust-powers in their extensive IDEs. From my vantage point it seems like fixing a language deficiency.

But wait!  What about all that evil terror that happens if you just create anonymous objects and functions mid-stride without any type enforcement?  Well, for one thing - testing is key, and another thing - it has actually happened once or twice that I've had to hunt about in somebody else's code for what on earth they have put in an argument object.

Compared to the extreme pain of always having a static retriever biting my private parts, the problem of finding the dynamic bottle of beer in the living rooms has in my experience been an extremely fair trade-off.

YMMV, of course.


Saturday, May 1, 2010

A solid dyson sphere of Awesome; The JSConf experience

A couple of weeks ago I attended the second US JSConf in Washington. It turned out to be a very good move indeed.

I can easily say that this was one of the best conferences I've been to, maybe the best one. The reasons are, I suggest, threefold;

1) I have a personal, burning and possibly unhealthy interest in JavaScript.
2) The speakers were generally critical-mass awesome.
3) Track C - "The first rule of Track C is that you don't talk about Track C" - as Peter Higgins, president of the Dojo Ajax Toolkit has been known to tweet.

Track C meant hanging around the corridors of Hotel Palomar, pilfering beer from pirate chests and having interstellar discussions about programming. And joking. And talking about SF books. Epic.

The playfulness and allowing atmosphere was really great and everywhere you turned you met guys and gals that also arrange their own conferences, write their own frameworks, turns the web inside out (or upside down), and so on.

But last things first; After two days of extremely technical talks, games and panels, comes the final payoff - the keynote. What might the keynote bring, after node.js future directions, Sproutcore WYSIWYG editors, custom DSLs and JavaScript interpreters for Flash?
In a word: 'Bacon'. Aaron Quint gave a Bacon keynote. No, it's not a framework or scrum-derivate-du-jour, actual cured pigs belly, that's what.

Aaron is a foodie. He's a great Ruby and JS guy as well, but he is a very passionate foodie, and the level of passion and knowledge in his talk about making your own bacon, history of and how to barter it for microbrew was both entertaining and cheeky.

Actually, the cheek belongs to Chris Williams, Pirate Captain of JSConf who, as always, risks all by choosing a *non-programming* keynote for a programming conference. That in it self was almost as fun as seeing it.  Naturally Passion is key, and Aaron did weave in some pseudo-code to refer to the different experience of making food and making code. But the core of the talk was, IMO, about what makes us tick, as foodies, as developers and as human beings.

Also, Chris actually planned JSConf together with his wife (who had a T-shirt with the text 'Pirate Pending' on), which was really nice and the very antithesis of Corporate.

Another cool thing about the conference was that over 100 people who sent in their abstracts didn't get chosen. Actually, that is just the way it is and neither here, nor there, but since many people *really* wanted to get a place speaking at JSConf and vented some steam on twitter, Kyle Simpson (@getify) proposed having a pre-conference conference, the so-called Scurvyconf, which was open for anyone who couldn't speak at the actual JSConf.

The sound at the pub where ScurvyConf was held was deafening, with drunk geeks shouting over each other and having a generally good time. So the speakers had a hard time getting heard. This was taken in stride however and even though the audience participation was varied, it was very empathic where it occurred.

At the end of the first day we were treated to a cruise on the Photomac sponsored by Yahoo! with wonderful food and long discussions with people from Disney, Microsoft (Really!) and SinnerSchraeder (Hi Holger!) ranging from how XSS really works to defensive synthetic biology and the open wetware foundation. A total blast.

I finally got to meet in person Justin Meyer, the creator of JavaScriptMVC who gave a great talk on its many strong points. My favorite is still the railsish generative scripts which creates client-side files for certain tasks (like consuming and displaying services).  Justin was also the man who opened the bar in the wee hours of the morning on our way home from the final Google dinner night. Kudos for that (and spontaneous dancing to boot).

When we finally got home, the final night, the idea was to go to sleep immediately. The ever-present pirate party had other ideas, however.

There was vodkas and Guitar Hero and lots of falling into each other arms and crying, figuratively speaking, naturally.

We just had a great time. In fact, when I ran through airports the following morning, hungover like what have you, I was told that I had something hanging on my back. So I did. I let it hang all the way back to Sweden, and referred at least one person to Facebook who asked about it.

It turned out, when I looked at my pictures, that I was not the only one so inflicted.

I'll wrap this up now, and leave you with some more random pictures and a huge thanks to Chris and his pirate family for creating a completely stellar experience.

Sunday, February 28, 2010

Super-simple authentication using Google Friend Connect

I've been following Google friend Connect since it came out, since it's a very interesting API.

For me, what's interesting about it has always been that it takes care of the authentication for a site owner. This is not the basic use-case, mind you. The basic use cases seems to be the simple addition of site-separate, rich, social widgets.

This is by no mean bad, but the first thing I wanted to do with GFC was to just put up the first, simple 'join this site' widget, and then use the magic to let anyone who had a Google. Yahoo, AIM, OpenID, et.c. account just log in to my site, using a unique user id  provided by Google.

This proved quite hard in the beginning, especially since you basically had to learn a lot of OpenSocial APIs just to do something non-trivial. Since a couple of months back, the GFC APIs has become richer and also simpler.  The meaning of this blog post is to show you in a simple way how to leverage GFC for your own authentication, without breaking a sweat.

What you need to do is the following;

  1. Register your site with GFC
  2. Copy-paste in the HTML/Script code for the member gadget into your index.html page (This is done by selecting that gadget and choose to let the GFC page render the code including your site id in a copy-paste box. not terribly hard either).
  3. Do nothing in particular, since the cookie will be send as part of each request to your server (even Ajax ones).
  4. In your server, receive the cookie (looking like this: 'fcauth19038466278488110'), and call GFC from the server, suing the cookie, to get some info about the user.

Using the following code, I make sure that the opensocial API is loaded and that I get a callback when it feels ready. It's not really necessary, but might be of use if you need to access viewer or owner info in your page before or without talking to the server.

   google.load('friendconnect', '0.8');

      site: 'xxxxxxxxxxxxxxxxxxxx',
      onload: function() 
    var fcauth = dojo.cookie("fcauthxxxxxxxxxxxxxxxxxxxx");
    console.log("gfc onload fcauth cookie was '"+fcauth+"'");
    if(fcauth && fcauth != "undefined")
            dojo.publish("ab_cookie", [fcauth]);          
            console.log("ERROR in opensocial access.."+e);

Naturally, you can use an Ajax call inside the callback function directly. I've put all of my logic inside a custom Dojo widget, and if you're not using Dojo, you can do whatever you want.

On the server, which I've coded using node.js and fab, my handler function look like this;

Game.prototype.getUserInfo = function(fcauth, id, cb)
    // http://www.google.com/friendconnect/api/people/@owner/@self?fcauth=<your fcauth>
    log.info("getUserInfo called with fcauth='"+fcauth+"' and id='"+id+"'");
    if(!fcauth || fcauth == "undefined")
        log.debug("Skipping null/unathorized request");    
    var google = http.createClient(80, "www.google.com");
    var request = google.request("GET", "/friendconnect/api/people/@me/@self?fcauth="+fcauth, {"host": "www.google.com"});
    request.finish(function (response) 
        response.addListener("body", function (chunk) 
            sys.puts("BODY: " + chunk);
            var echunk = eval("("+chunk+")");
            if(cb) cb(echunk);

You might choose Python or PHP on the server-side, but I hope that the code is fairly simple to understand. I have the specific code that extract the variables somewhere else, but the function is called with a couple of parameters, where one is 'cfauth'. This is the contents of the cookie set by GFC in the page before.
What the function does is call the GFC server with the cookie, using a special URL which gives back user information about the person just signed in using the cookie. We get back stuff that look like this;


I hope this helps someone, and apologies for not giving out all of my code, which is in a bit of flux.

Thursday, February 11, 2010

[Swedish] rabatt till GTUG Stockholm medlemmar till Scandinavian Web Developer Conference 2010


Den 2 och 3 Juni går SWDC2010 av stapeln på Skandia-teatern på Drottninggatan i Stockholm. 

Konferensen för dig som vill lära dig det absolut senaste inom webb och mobilutveckling.

[Detta information har tidigare gåt ut till GTUG medlemmar, men är nu uppdaterat med mer rabatt och enklare biljettprocess]

De främsta internationella experterna inom Front-end utveckling, Mobil utveckling och JavaScript delar med sig av sina kunskaper.

DAG 1: Fokuserar på front-end utveckling och JavaScript
DAG 2: Fokuserar på programmering och utveckling av mobiltelefonapplikationer till framör allt iPhone och Android.

Du som har kommit på minst ett GTUG Stockholm möte får 875:- (25%) i rabatt på konferenspriset på 3500:- (ex.moms), alltså bara 2625:- för båda dagarna!

Erbjudandet gäller fram till den 15 Mars. För att använda dig av erbjudandet behöver du skicka ett mail från den epost-adress som är registrerad hos GTUG Stockholm till register@swdc-central.com
Som svar kommer du att få en engångskod som du använder under fältet "Coupons" på betalningstjänsten Stage HQ, som vi har länkat till från vår hemsida.

Mer information om konferensen finns att hämta på http://www.swdc-central.com

Bland våra 15 talare:

Tom Hughes-Croucher - Technical Evangelist/Innovation Lead på Yahoo! och expert på Accesibilitet och Web standarder.
Talar om : Mobile Data: How to avoid the latency trap when using web services.

Tom Blackmore har arbetat med geospatiell data hos hitta.se, varit projektledare för hitta.se's 3D-kartor, och håller en kurs i GIS på Mälardalens Unviersitet.
Talar om:  Handling spatial data on the web.


Stefan Pettersson är konsult på Netlight AB som JavaScript/Front-End expert och har arbetat på några av Sveriges största sajter, bl.a. Aftonbladet.se.
Talar om: Developing Large-Scale JavaScript Websites.

Se http://www.swdc-central.com för en komplett lista över talare!

Monday, February 1, 2010

GTUG Meeting January 2010

The January meeting got out of hand early on, as I got a semingly inocuous email message from a GTUG member asking if anyone from Google would be there to show the recently unveiled Nexus One phones.

I asnwered that I thought it unlikely, but that I would give it a shot, and then forward the request to Tommy at Google Sweden.

Not many minutes passed before I got a reply where he positively guaranteed that he or someone else would be present at the meeting, just the next week.

When people got to know about this, we had a deluge of registrations, and for the nth time I became really tired with LinkedIn's feature-lack of limits for the otherwise hadny events that I used to use for GTUGs. In all, 93 people registered on the double machine check-in me and Ottoboni provided for the evening.

First out was Ingemar Resare who talked about Google Apps integration, then came Tommy and Serge from the Google Office and totally winged an imprompty Nexus One presentation using their personal ones and answered hudnerds of questions.

I had to break somewhere in the possible middle of the question train since people started getting restless, eyehing the sandwhich trays (OK, so I was hungry, sue me :)

The food break was on the other hand a natural time for people to get to thold and try out the Nexus One themselves, with a Sandwhich or beer in the other, possibly both.

To the left here is Tommy describing the Nexus one's features.

For our last number, we got Peter Sönnergren who did an outstanding App Engine + Java talk which led to a lot of questions and I think perhaps the first real walkthrough for many present.

He was promptly talked to by the arranger of JFokus (which was due the very next week) and it turned out that he not only appeared on stage (together with Patrick Chanezon, I think) and also took over a Groove on App Engine session, sicne the Groovy guy had falled unexpectedly sick at the day of the talk. Talk about pivoting!

Gotta keep this short, but now you know what was going on.  And actually, the next GTUG meeting is this Thursday - completely packed as well, since we will both host Spotify's Anders Bond who will talk about their Android development process, and as a little extra number..

An Actual Android Developer Codelab with breakout coding sessions and everything led by Reto and Billy from the Google Developer Advocate Android team. Check out their schedule here. Sweden is just part of the big show that's going down right now.

But we'll have a meeting in March as well - at the Google Sweden Office (allegedly).