Friday 23 May 2014

The ergonomics of a statically typed language

Moving from a statically typed language like java on the backend to a dynamically typed language presents its own set of challenges, there are new paradigms to master and habits to unlearn become effective in the new language.

One unexpected outcome is the shift in ergonomics. Simply put in dynamically typed language you need to type more code because you can't lean as much on the ide to figure out what you want to do and give you all boiler plate code with a few well placed keystrokes. Intellij is great ide, webstorm is a great ide derived from it, but it is inherently less capable as an ide on its own due to not being able to assume as much about what your intention is when you are coding.

Statically typed languages are easier to predict intention from due to the strict rules from the compiler, dynamic languages are a lot looser allowing you to do your own thing at  pretty much any time so the ide has less opportunities to be smart and complete what you are doing for you. Thankfully the amount of boiler plate code you have to write is pretty small in javascript and you really save a lot in not having to do alot of marshalling code when you couple node and mongo together and go JSON all the way through. You do however have to write alot of code with very little smart code completion and more complex refactoring like extracting methods is spotty at best.

This realisation makes the editors of choice for dynamically typed languages easier to understand, if the ide doesn't give you that much benefit then you may well be better off going with something that exists everywhere like vim or emacsso you can learn once and code everywhere but holding that many keystrokes in the fingertips is a long journey, that sometimes feels like a backward step.

It would be great to see an emperical study of the amount of typing required by two pro users across dynamic and statically typed languages, but my own anecdotal evidence has me typing alot more, but also looking for more ways to optimise input which is an interesting project in itself.

Sunday 18 May 2014

Zenimax vs Programmers

Zenimax, the owners of ID software recently filed suit against Oculus Rift claiming that their Chief Technology Guy John Carmack took their Intellectual Property with him when he left ID to pursue a dream of virtual reality with the garage born device from Palmer Luckey and the team at Oculus. The suite was filed soon after the two billion dollar acquisition of Oculus by Facebook. The timing of the filing indicates someone at Zenimax decided the time was right to pursue its case due to the improved economics of the Oculus project.


ID Software back in the day.

John Carmack is a pioneer in the world of 3D gaming, he is credited with discovering many of the techniques for getting computer game software to push the polygons required to render 3D worlds. The engines he wrote while at ID software invented the state of the art in 3D even if the playability of the games was on the decline since the glory days of doom and quake. He was more than an employee at ID, he founded the company and along with John Romero and their small team defined PC gaming through the late 80's and into the 90's, eventually the partnership between the two Johns fractured with John Carmack continuing his work at ID and John Romero pursuing other game projects. As with alot of game studios, ID software got bought by bigger publishers and at some point Zenimax acquired the keys to the IP kingdom that John and John had built.

Does a programmer own their own thoughts ?

The interesting question for software developers is do we own our thoughts ? If you invent something in your own time that is not related to your work for a company can that company later claim to own the IP ? Also does this create a chilling effect for future employment ? Does someone like John become unemployable due to his canon of existing programming work influencing his future work? Any software project John works on in the future is bound to be influencd by all the lessons from his preceding projects, is his only option going forward to move away from his field of expertise in 3D software and start writing code for banks? (it would still be some great banking software no doubt!)


Michelangelo's Sistine Chapel

Writing code is often likened to creating art, this situation is akin to an early patron of Michelangelo claiming ownership of all subsequent works because they look similar and use some of the same colors and themes as the works he did for them. It would create a form of indentured servitude for people in creative fields. There is a strong view within the open source community of which John Carmack is a contributor that ideas are meant to be free. Early in his career he threatened to quit at ID due to someone wanting to patent some of his work, reportedly his reasoning was that if he hadn't been able to benefit from all the work, ideas and innovations of the programmers that came before him he wouldn't have been able to accomplish what he had. To paraphrase Isaac Newton, "If I have seen further than others it is because I have stood on the shoulders of giants".

In an ideal world companies would own the source code of the work that programmers do for them but the ideas would belong to the coders who came up with them assignable either to the company or the community or to themselves as they see fit. Often the ideas are claimed by the companies, due to aggresive wording of employment contracts or the context in which the idea evolved.

Tuesday 12 February 2013

Mac OS X Left Hand Mouse Right Hand Copy Paste

Keyboard copy paste for left handed mousers

The Problem :

I use my mouse with my left hand. I like to select text using the mouse and then copy/paste using the keyboard with my right hand. Using OS X this means reaching across the other side of the keyboard to hit Command+C Command+V which just dosen't work that well for me and often ends up with miss hits and frustration. In a linux/win environment the solution is to use Control+Insert Shift+Insert to get the copy paste functions within easy reach of the right hand.

The Solution :

Remap the keys in OS X so Control+Insert Shift+Insert execute a Command+C Command+V. I investigated a couple of different utilities, and have stuck with KeyRemap4MacBook


It is the most up to date remapper I could find and works well in 10.8. Follow the link above and install the app. Open the preferences for the app and find the "For PC Users" section. Check the box labelled "Use PC Style Copy/Paste #3"


Control+Insert should now execute a Command+C and Shift+Insert should now execute a Command+V!
Control+Insert should now execute a Command+C and Shift+Insert should now execute a Command+V!
Control+Insert should now execute a Command+C and Shift+Insert should now execute a Command+V!

There are loads of remappings available in the app to make things a bit more keyboard centric. 

Sunday 10 February 2013

Gigabyte GA-B75N has working mini PCI-E slot

Hackintosh Mini - Hidden Features.

As part of the process to build a new dev box for iPhone development I started building a hackintosh. The first step with this is hardware selection. After a few false starts with different motherboards, I eventually ended up with a Gigabyte GA-B75N, it is a mini-itx socket 1155 motherboard with great connectivity options

  • 2xHDMI  and 1xDVI perfect for a multi monitor dev environment.
  • 2xGigabit ethernet connections, not necessary but good to have a backup.
  • 1x6Gbps sata and 3x3Gbps.


Gigabyte GA-B75N showing mini PCI-E wifi card installed.
So after installing the board, everything was setup and working nicely. Eventually my thoughts turned to wifi, this lead to some interesting research about whether 1x PCI-E cards would work in the full length slot (most of the research points to yes). Extrapolating further I found some great resources on building your own PCI-E card using a mini PCI-E card and an adapter (http://x86wifi.blogspot.dk/2010/04/how-to-build-your-own-real-airport-card.html).

This got me thinking about getting hold of  a mini PCI-E card and an adapter, the process of looking at these cards triggered a few memories from the build. The motherboard looked like it had a half height mini PCI-E slot (micro PCI-E?). A quick flick of the screw driver and suspicions were confirmed. After some further screw driver work with donor laptop a full size mini PCI-E card was wedged in to the half height slot, a linux reboot and some inspection of the PCI-E bus and it was confirmed.

The Gigabyte GA-B75N rev. 1.0 has a working mini PCI-E slot. This was contrary to what Gigabyte has on their website and the included documentation, but I could now confirm that the slot was operational.

 After shopping around on ebay I got a used mini PCI-E wifi card with an Atheros AR5B93 chipset. This card slotted in and after pulling the antennas out of the donor laptop it was all hooked up.
AR5B93 installed with antennas attached.
 After putting everything back together and booting into the mac environment, the only setup required was to open settings, goto network and add an adapter named Wi-Fi.  Mountain Lion recognized the card without a problem and it performs well.

Things to consider :

Selecting the right mini PCI-E card is crucial. Not many are compatible out of the box with OS X. The card I chose had good availability on ebay and was reported to be simple to install in Mountain Lion this turned out to be the case with no custom kexts required and no real fiddling with Multibeast etc.

The AR5B93 only supports the 2.4Ghz wifi spectrum, so I an still considering an upgrade to a card with a Broadcom BCM94322HM8L chipset as it also supports 5Ghz and has good support in Mountain Lion according to various sources. I used the following links for information on Mountain Lion support

In Russian but information seems pretty complete :
https://spreadsheets.google.com/pub?key=0Arr23WYNror4dEc2T045WkFrbm56N0JfQVdiSU5jdHc&hl=ru&output=html

Less complete but information seems consistent :
http://osx-hackintosh.blogspot.dk/2012/11/wifi-adapters-with-native-support-in-os.html


There is a surprising lack of documentation for the mini PCI-E slot on the Gigabyte GA-B75N. Gigabyte don't mention it and google did not turn up anything concrete except a bit of speculation on a few forums. This may mean firmware revision could remove the functionality, but for the moment everything is working well.

Friday 11 January 2013

Hardware Schmardware: Macbook Air 11 vs ASUS UX21A

In light of the mobile office requirements lately, all development has been moved to a laptop, Unfortunately the laptop in question is a 1st generation macbook (stained white 1.83ghz, beauty) which is still serviceable as a browsing machine but lacks a bit of guts when it comes to dev work. Amazingly after an upgrade of the spinning platters to an intel ssd which was the boot disk of the workstation my portable dev environment is working well with few slowdowns, and the only time it really spins up the fans is when it is reindexing or something similar (intellij/clover manages to trigger a 6 minute indexing process pretty regularly). The area it can't handle well is running the android emulator, the machine grinds away for a few minutes and eventually produces an emulator environment which is slow and unresponsive. As a result of this, management (me) has decided it is time for an upgrade.

The Requirements :

Good portability (around 1kg with an 11' screen, looks to fit the bill), Latest generation chips (ivy bridge), Good keyboard and trackpad, Best screen available (prefer IPS), Good durability (preferably a metal chassis).

The Contenders :

The Macbook Air (2012).
The plan was initially just to wait for the ivy bridge update to the 11' macbook air and be done with it. It ticks all the boxes above and gives the option of running osx without having to jump through the hackintosh hoops.

http://www.apple.com/uk/macbookair/



Asus UX21A.
As I was patiently waiting for the ivy bridge refresh to the air, Asus shows up with a newly revised UX21A, This has all the good stuff, upto i7 ivy bridge processors, small form factor, nice chassis, ssd's etc. Along with a 1080p IPS display, which kills the macbook air for resolution, viewing angles and brightness (according to the reviews).

http://www.anandtech.com/show/5843/asus-zenbook-prime-ux21a-review/1



Both machines have a similar form factor, but the asus has a significant advantage in terms of the processors it can be configured with and the screen. So it comes down to the classic mac/pc dilemma go for the specs(asus) or stick with what you know will be a quality experience, good keyboard, good trackpad everything well put together (macbook). Having used a number of different laptops old and new common sense tells me to go for the one that I know is well put together and gets the basics right. The problems comes when I think about the screen though, I have always found the screen one of the most important aspects of any machine, it is after all what you stare at day in day out, and that has always lead me to favour lots of real estate (resolution) and maximum quality. External monitors do solve this problem when you are at home but on the road you have to live with the compromises made.

The second problem that is blocking the upgrade path is the plethora of new machines recently announced.. basically the same as the above with touchscreens and convertible tablet form factors while still maintaining ivy bridge internals...

The idea of having a fully competent development laptop which can then have the screen undocked to sit on the couch reading tablet style is extremely appealing. The main purpose of this machine is maximum portability along with being able to develop as needed and these seem to fit the bill pretty well. It is however pure speculation as they may turn out to be ordinary laptops and useless tablets as a lot of multipurpose devices tend to. The other downside is the availability which is a matter of scouring webstores hoping someone ships to this part of the world (Denmark).

The third blocker is the is the Macbook Pro retina edition. As stated above I love a big screen with lots of resolution and that things has some nuts resolution. It is however way outside the spec in terms of size (2kg fat!!), and also pushes credibility in terms of budget.. so even though that screen is tempting those two constraints are enough to cross it off the list.

In Conclusion :

I am going to wait! No surprise there, I need to get my hands on the Asus UX21A and see if that screen is good enough to move me away from the air, once I have done that I'll flip a coin and see whether I want to wait so my next device can be all about the touch.

Update :

The Asus UX21A seems to have fallen off the planet in 4 months of looking, as best I can understand it never made it to the market while ASUS prepared a touch enabled version and somewhere along the way that seems to have disappeared as well :(

Friday 22 June 2012

Setting up a remote git repository on Amazon EC2

This is a brief guide on how to setup your EC2 instance to act as a remote git repository server. It uses ssh to provide the server and authentication access and you will need an existing EC2 instance and the associated ssh keys (.pem file).

1. Install git on your EC2 instance

> ssh -i amazonkey.pem ec2-user@example.amazonaws.com
> sudo yum install git
amazonkey.pem should be the identity file provided when you setup your amazon EC2 instance.
example.amazonaws.com will be your EC2 instance hostname, something like ec2-111-111-111-111.ap-northeast-1.compute.amazonaws.com

2. Setup a git repository on your EC2 instance

From the directory /home/ec2-user
> mkdir test.git
> cd test.git
> git init --bare

3. Configure ssh so git can access your amazonkey.pem

On your local machine edit ~/.ssh/config and add the following :
Host amazon
Hostname example.amazonaws.com
User ec2-user
IdentityFile amazonkey.pem
Replace example.amazonaws.com with your EC2 instance name and replace amazonkey.pem with the location and name of your key file from amazon.
You can test it is working by sshing onto the instance with the command
> ssh amazon
It should successfully log you in to your EC2 instance at this point.

4. Create a local git repository and push it to your remote repository.

One the local machine
> mkdir test
> cd test
> git init
> echo "here is some text">text.txt
This creates a file called test.txt with some text in it so you have something to commit.
> git add *
> git commit -m "initial commit"
> git remote add origin amazon:/home/ec2-user/test.git
> git push -u origin master
At this point you should see some messages about git counting, compressing and writing objects. If there are any fatal errors at this point check that the git remote add origin path after amazon: matches where you created the empty git repository in step 2.

5. Checkout the changes to make sure they worked

On your local machine in an empty directory.
> git clone amazon:/home/ec2-user/test.git
> cd test
> cat test.txt
This should display the text you entered into the test.txt file in step 4 that has gone via the EC2 instance and git all the way back to your local machine.

References

http://stackoverflow.com/questions/4632749/how-to-push-to-git-on-ec2
http://thelucid.com/2008/12/02/git-setting-up-a-remote-repository-and-doing-an-initial-push/
http://dracoblue.net/dev/custom-identity-file-idrsapub-with-git-client/193/

Monday 18 June 2012

Linus on Entrepreneurship

Linus Torvalds creator of Linux recently participated in a question and answer session about Entrepreneurship, catch the full video here :

http://www.youtube.com/watch?v=MShbP3OpASA

A few choice words were said about Nvidia (youtube)

Also this quote "People who get offended should be offended" (youtube)

I like the sentiment of this, if feedback is critical, take the lesson, look for a way to mitigate the criticism, don't get offended and outraged.

Update: Nvidia have posted an updated linux driver that now supports the optimus technology criticized in the video. One person can change the world ? :)