7 May 2012

DART hackathon at the Hub, Tel Aviv

Last week, Google organized a worldwide hackathon to promote DART. In India, Japan, the US or South-Korea, it went something something like that: a speaker  would introduce the DART language, the audience would split up in teams and hack away over the weekend. In that regard, Tel-Aviv was no exception. What is notable though is that we were blessed with Gilad Bracha in the role of the speaker. The man is an éminence grise in the field of programming languages, and what's more, graced with exceptional didactic skills. Just watch any of the recorded talks (youtube) if you need proof. The man is a born teacher, and just showers sheer intelligence and expertise on captivated audiences. 

C360_2012-04-27-10-34-54

DART the language looks and feels familiar if you know java or C#, it has an interesting optional type system and a concurrency model inspired from Erlang's actors. It makes more sense than Javascript, but that is stating the obvious. Google's intention with DART is to make web development a better experience, or to augment their control over the web, depending on where Google stands on your inner conspiracy meter. Needless to say, Google is swimming against the current here, upsetting lots of players in the industry, but it has done an incredible job in putting together an elite team: Lars Bak, Joshua Bloch, Kasper Lund, Gilad Bracha… What a cast, indeed. 

On the whole, I feel it's too early to place your bets, but DART will stay on my radar. As for the hackathon, it was hard for me to focus on the task at hand with a presence as fascinating and gracious as Gilad's. On presentation day, I somehow managed not to arrive empty-handed, showing my Josef Müller-Brockman homage that I had ported from Javascript in an uneventful—but isn't that what we want?—one hour hacking session at home. Get the DART code on my github repo.

Gilad_at_the_hub

 

17 Mar 2012

Modernism and the Web

Beethoven

Studying the seminal works of graphic design, we are in awe of the fact that, beyond their effectiveness at visually communicating a message, they also impart a sense of poetic beauty. Maybe it is the judicious use of geometric shapes and chromatic harmonies. Or this sense of restraint in the composition. Or the deep, almost philosophical gravity of a grid system in the work's foundation. Whatever the reason may be, these works have nothing incidental about them, they are obviously the result of great mastery in one's craft. 

For many software developers, mastery in one's craft is something like the holy grail, and ways that lead to it a subject of great interest and passion. Looking at the life and career of Josef Müller-Brockmann, we will note that he started his career as an apprentice and ended it as a mentor, thereby perfectly illustrating the path of a craftsman -- a European tradition since medieval times. This will probably resonate with those of us who are sensitive to the idea that software development is more akin to craftsmanship than engineering, an idea that makes inroads in our industry, but that is still far from being consensual. 

The same tension was already present in the late 19th century, when industries began to employ automated machinery and "scientific management" to increase efficiency. Thinkers and artists rebelled against the technocratic mindset, seeking to affirm the human element within the bounds of the industrial revolution. What we now broadly call modernism encompasses various schools of thought that redefined crafts and the fine arts. Graphic design was invented to bring structural order and visual form to printed communications. When Müller-Brockmann, a leading figure in the Swiss School of international Style, talks about "establishing rational-objective foundations that are accepted by all and which can be developed individually", he clearly positions himself in that line of thought. 

Whether we, as developers and designers shaping the modern-day web, pay enough attention to the legacy of masters of the past is subject for debate, but with today's screens of all shapes and sizes rendering dynamic content, achieving structural consistency and visual integrity seems ever more challenging. Technological revolutions behave like a stack: the current age is built on top of the last one, masking it to the point of invisibility. In that process, whole sets of practices become obsolete. We call this progress, but only out of shallowness and arrogance.

 Tomorrow or in ten or 20 years time aesthetic tastes will have changed, but laws last and are independent of time. The golden section, for instance, is a simple, elegant ratio of proportions that is understood by all cultures and is present in both man and nature. 
— Josef Müller-Brockmann

Josef Müller-Brockmann would eschew even margins, and never go beyond one single typeface across the page. A higher-order, minimalist purity was met with the series of posters he did for the Zürich Opera house. In the interview from which the above quote originates, Müller-Brockmann was asked what he regarded to be his best work. His self-deprecating answer was the white reverse sides of his posters. However, due to distraction, I misread that and mentally evoked the negatives of his posters. And so this slip became the concept in my attempt at reproducing the famous Beethoven poster with code only. Here is the demo. Here is the source code, licensed under a Creative Commons attribution license.

 

19 Dec 2011

Ruby metaprogramming from scratch, talk @ Ruby underground

600_80870412
A burgeoning but vibrant Ruby developer community meets up once a month in the Tel-Aviv area, thanks to the efforts of Roy Osherove and some leading Ruby developers. I had the honor to conduct a talk this time (December), and my subject was metaprogramming from scratch. Since this is normally considered an advanced subject, I took the approach to explain core concepts through runnable code snippets that the participants could feed instantly into an interactive shell and see the results. The main exercise was a custom implementation of the Ruby built-in method "attr_accessor" using metaprogramming techniques.

Here are the slides, and here are the exercise files. I used showoff, an open source project, as the presentation software, and I really liked the experience. Recommended. 

16 Oct 2011

How to run rvm scripts as cron jobs?

Stack Overflow is a great tool for developers as it allows to quickly investigate how common hurdles are addressed by our peers. We all know that, right? Unfortunately, it sometimes serves as a vehicle to perpetuate kludges, dirty hacks or misconceptions. I recently came across an issue that had around it an inordinate amount of such ill-advised prose. 

Since the issue in question relates to UNIX literacy, I would like to dedicate this post to the memory of Dennis Ritchie, father of C and UNIX, who died earlier this week (the 13th of October, 2011).

Dennis_macalistair_ritchie_
I will first expose the question, offer some best practices and finally comment on the common pitfalls. So here is the question: how do you run rvm scripts as cron jobs? (1)

First, the shebang line in your script should not refer directly to a ruby executable, but to rvm's ruby:

#!/usr/bin/env ruby

This instructs the script to load the environment and run ruby as we would on the command line with rvm loaded (2). Easy. When you run a cron job, however, the environment is not your local environment. Not only are your environment variables missing, but cron jobs may be spawned in a shell other (3) than bash or zsh, the shells that work with rvm (as of this date). 

On many UNIX derived systems, crontabs can have a configuration section before the actual lines that define the jobs to be run. If this is the case, you would then specify:

SHELL=/path/to/bash

This will ensure that the cron job will be spawned from bash. Still, your environment is missing, so to instruct bash to load your environment, you will want to add to the configuration section the following:

BASH_ENV=/path/to/environment (typically .bash_profile or .bashrc)

HOME is automatically derived from the /etc/passwd line of the crontab owner, but you can override it. 

HOME=/path/to/home

After this, a cron job might look like this:

15 14 1 * * $HOME/rvm_script.rb

What if your crontab doesn't support the configuration section? Well, you will have to give all the environment directives in one line, with the job itself. For example, 

15 14 1 * * export BASH_ENV=/path/to/environment && /full/path/to/bash -c '/full/path/to/rvm_script.rb'

On Stack Overflow, I have seen the following advice:  

Run bash with -l switch. The --login switch instructs bash to run as a login shell. Therefore, it will try to load your profile. Please don't do that, even if things appear to work. Cron jobs are by nature non-interactive, non-login shells. Invoking them as if they were is just bad practice. Also, when bash starts a login shell, it first loads the system environment (/etc/profile), and anything that prints to the screen (like motd - message of the day) will cause your cron job to report nasty messages like this:

stty: TIOCGETD: Inappropriate ioctl for device

Note: your login profile is meant  for one-time setup relevant to the session (like running ssh-agent). All the rest should go to ~/.bashrc. A common practice is to source ~/.bashrc from the profile, avoiding duplication.

Another often seen advice is to write a runner script (or a wrapper) that loads the environment first, then runs the rvm script. This might work as well, but is unnecessary and makes you look foolish. 

Notes:

1, RVM is the established ruby version manager. The new kid on the block is rbenv, well worth a look. Cron jobs are scheduled tasks on UNIX derived systems.

2, The assumption here is that you installed rvm as a function and not as a binary. 

3,  Often sh.

4, If you are using zsh instead and you need everything in one directive, this is what I'd do:

15 14 1 * * export HOME=/path/to/home && /path/to/zsh -c 'source $HOME/.zshrc && $HOME/script.rb'

 

6 Aug 2011

Be a man, huh?

Since July the 14th, the streets are ebullient. Commentators speculate about how much influence the Arab Spring imparted on the Israelis, and some wonder about the role of the Indignados in Spain as trendsetters. But the Arab Spring is about a set of rights that Israelis take for granted (freedom of speech, democracy), and Europe is deeply impacted by an economic crisis, while the Israeli economy is growing at an annual rate of 5%.  Yet, inspiration has admittedly been drawn from both. If ideas are like a virus, revolutions must be the epidemic. What started as a lament against rising food prices turned into massive protests against social injustice. For most Israelis, life is impossibly expensive. The high prices are artificially induced by monopolies and cartels, who themselves are under control of a handful of powerful families.

Until now, the atmosphere is festive, public demands are varied and sometimes contradictory, but there is a revolutionary undertone since wealth redistribution is at the heart of the matter. I took the picture below at the end of the largest protest gathering in Israel's history (so they say). Some protest signs are witty, daring, playful. Here we see Bibi Netanyahu with a revolutionary beret. The caption says, "Be a man, huh?", which in Hebrew approximates phonetically Che Guevara's name. 

J14

Links:

Israel's Cottage-Cheese Rebellion

 

6 Aug 2011

Forrest Gump and the Kibbutz

In Jewish communities around the world, resentment is often expressed against the global media, accused of a systematic bias against the state of Israel. Today, I want to talk about a story that puts those claims to rest, at least in respect to the systematic character of aforementioned bias. Here is a story about Israel that runs in the global media, but so immensely favorable that its potential to change perceptions may prove durable. That story was sparked by a book, "Start-up Nation, the story of Israel's economic miracle", written by Dan Senor and Saul Singer, and it explores how Israel became one of the fastest growing entrepreneurial economies in the world.

The book's success is phenomenal. It is on top of all major bestsellers' lists, exchanges hands in diplomatic circles, and is read even by heads of Arab states. Its impact reached my own private life, when I discovered one morning at the office, that a camera crew had invaded the place with expensive gear, and there, sitting face to face, two men engaged in a conversation. The interviewer was Bob Simon, a senior correspondent from CBS, and the interviewee, Yossi Vardi, a prominent figure in the Israeli hi-tech industry. 

The dynamics of the discussion was fascinating. On one side, the reporter whose questions were shaped by the narrative of the book, Israel as a "start-up nation". On the other, the entrepreneur selected to provide, support or strengthen that narrative. With forty years of activity in high-tech, Yossi Vardi is an old-hand and the de facto spokesperson for an entire industry. However, the way he embraces this position is ambivalent. He appears unassuming, slightly uneasy, cautious to play down his achievements. At one point of the conversation, he claims to be a Forrest Gump character. 

"I am the Forrest Gump of the IT industry", says Vardi. Bob Simon doesn't blink, but I am thinking to myself, "what the hell does that mean?". Yossi Vardi is anything but a Forrest Gump character. This is a man who has aligned a string of financial successes, among which a claim to fame with a $400 million exit at the turn of the century. Stupid is he not, nor does he strike to be excessively ingenuous. So? "Luck", he insists when the journalist presses on, "I got lucky". But these humbling down tactics don't faze the journalist, who acknowledges them as part of a gentleman's composure. Besides, Bob Simon has a story to bring back home, a story of money and success. Yet, when he  asks, "How much are you worth?", he anticipates the obvious answer: "You won't tell me, will you?" 

At this point, I wonder how much is getting lost in translation. Yossi Vardi's silence doesn't necessarily mean that his net worth is a private matter, or that it is "nobody's business". Rather, the question itself is anathema in Israeli society. The way it is phrased suggests that the worth of a person has anything to do with money. Israel may have lost some of its Zionist ideological luster, but Yossi Vardi is a child of a very particular zeitgeist. Zionism is rooted in soviet-style socialism, and this heritage is apparent in Vardi's speech. How much of it is noticed or picked up by the American journalist? 

Yossi Vardi mentions that when he lands in Ben Gurion airport after returning from a business trip abroad, it is the scent of oranges that makes him feel home. With his chevron style mustache and round face, only a tembel hat is missing to complete the portrait of a Kibbutznik. It is easy to draw a parallel between the pioneers of yesteryear and the entrepreneurs of today. Technology is the new land to seed. What makes Forrest Gump endearing is that he is stupid and rich. He is a caricature of American capitalism. The Kibbutznik, on the other hand, is endearing because he is stupid and poor. He toils under the sun for meager returns. But in more than one way, he laid the foundations for all that was to come.

Today, Israel has industry clusters where the high concentration of universities, large companies and start-ups facilitate the cross-pollination of talent, funding and research. According to Dan Senor and Saul Singer, this is the key explanation for Israel’s knack at innovating. There is no doubt that Israel has been successful in fostering entrepreneurship, but there is equally no doubt that attempts at rationalizing that success is fraught with dangers. To their merit, Dan Senor and Saul Singer resist the temptation of self-aggrandizement, but the success of their book entails that its central proposition gets relayed by third parties with less discernment, establishing a narrative, and narratives are always problematic. The interview is testimony to this phenomenon, and explains, I believe, Vardi's toning down of the conversation. 

Even more damaging to the myth of Israel's riches, and largely kept silent, is the current data indicating that the trend of the IT sector pushing the economy forward has stopped. The IT is no more the growth locomotive it was ten years ago. Yossi Vardi cites the often quoted and valid critique that the social divide hasn't been reduced, that opportunities in the workplace are not equally distributed, that whole sectors of the economy are lagging. But will there be room for dissonance in the final cut of CBS' 60 minutes episode?  

If it was no coincidence to go with Yossi Vardi as the archetypal Israeli entrepreneur, neither was the choice of the filming location. The hub is on the last floor of a tower in downtown Tel-Aviv, and offers a spectacular view from its terraced rooftop. Entrepreneurs and start-ups share a common office space where the clickety-clack of keyboards and mice provide the perfect soundtrack for the CBS story. But truth of the matter is that the hub doesn't see itself as an incubator of technology startups. Rather, its aim is to promote social innovation. This is in line with the mission statement of the international organization, and a constant concern for the Israeli founders of the local branch. Danny Gal is one of them, and he too is present on the set, watching the conversation from a distance. And when the cameras stop rolling, he approaches Bob Simon to make sure he got his record straight about that particular point. But I'd worry that anyone packaging content for mainstream TV audiences would consider it as a moot one, too.

Forrest_gump
Face-off: Bob Simon and Yossi Vardi

Links:

Start-up Nation: The Story of Israel's Economic Miracle
What Ever Happened to Start-up Nation?
כבר לא אומת ההיי-טק
Hub TLV: The Tel-Aviv-Jaffa based incubator for social/environmental entrepreneurs

15 Apr 2011

Android on Steroids

Yesterday's Night owl's meeting in Tel-Aviv was about Android. For those who missed it, recorded video streams are available (quality is not great). My talk was entitled: Android and the programmable web, or how Android relates to the web as a platform. (And not: How Android as a platform relates to the web). 

The presentation material, a zoomable 2D plane with grouped items, is available on prezi.com. 

29 Mar 2011

Tel-o-Fun bike preview

First glimpse of the bikes that will soon populate the stations of the Tel-o-Fun bike rental scheme (Tel Aviv). I spotted a pair of them in a station next to where I live. The following day, they were gone. I suppose they are testing the station, the locking mechanism, etc. Nice cozy bikes, no?  
20110328_005b
 

 

3 Jan 2011

Pixel density in a troubled world

Whereas in the past user interface design would largely be concerned with screen size or display resolution, now the question of how many pixels make up one inch becomes relevant as well. This measure is called pixel density, and is expressed in dpi or ppi units. Nowhere is pixel density as broadly distributed as in the mobile world. A low-end android mobile may have a 180 dpi screen, while a high-end one, like the retina display, will boast up to a 326 dpi screen.

Pixel density affects the physical size of display artifacts. It boils down to this: one and the same button that is, say, 50 pixels in width, will appear larger on a lower density screen and narrower on a higher density screen. Since the user eventually uses his thumb to press on the button, it is critical that it be physically large enough so as not to be missed, but not too large because screen estate is precious and must be shared with the rest of the UI elements.

To help write clean and accurate UI interfaces, mobile development frameworks should, as they often do, abstract device-dependent pixel size with some sort of density-independent measure unit. The Android platform has devised such a density-independent pixel; it is aligned on a baseline density assumed by the platform (160dpi), where scaling is then internally handled based on the actual density of the screen in use. But when you are developing an AS3 project in Adobe Air, you have to come up with a solution of your own.

Christian Cantrell, a developer from Adobe, has attempted something quite ambitious with his iReverse project. It’s a board game written in pure AS3, one single codebase that can adapt to all the environments supported by Flash and Air (Ipad, Iphone, Android, Desktop and browser). To achieve this goal, a variety of techniques are used (which are discussed at length in “Writing multiscreen AIR apps” and “Authoring mobile Flash content for multiple screen sizes”), but we are going to focus on our topic of discussion, pixel density. The density-independent measure, in Christian’s project, is physical reality. Think not in pixels, but in inches.

private function inchesToPixels(inches:Number):uint
    {
        return Math.round(Capabilities.screenDPI * inches);
    }

Alternatively, for developers used to the european metrics systems, the idea is to think directly in millimeters.

private function mmToPixels(mm:Number):uint
    {
        return Math.round(Capabilities.screenDPI * (mm / 25.4));
    }

Buttons on a UI for mobile need to be at least 7mm wide if they should be effective (and not a hit & miss affair), you would define them in you code like this:

myButton.width = mmToPixels(7);

The reasoning is flawless, the problem lies with the reliability of Capabilities.screenDPI. Needless to say, this is a factor beyond Christian Cantrell’s control, but it appears that Capabilities.screenDPI reports a set of hard-coded values, which renders it less useful, and to a certain extent ruins Christian’s solution. I was surprised by this myself, I thought such an essential API – querying the host for info about its screen characteristics – would be accurate, but alas, it is not the case (see note).

This is the reason why Christian Cantrell overrides this value with a better approximation. For the Ipad, for example, there is no ambiguity, the correct value is 132 dpi (as of now there is only one Ipad model). Whether or not the Flash runtime can report this, Christian can always pass an overridden dpi value to the main application thanks to the wrappers that he uses for each platform. But what is a better approximation for the android platform where so many devices display so many different characteristics? There is no such thing, and an average value will make it only worse, resulting in UI soup. Of course, you can always compile different binaries optimized for different screens, but then you’re asking for trouble publishing-wise, and besides, can anyone see the irony of having a unified codebase but a fragmented binary distribution? This can be felt acutely on the Android Market, where the customary rule is that one .apk package serves all devices.

Eventually, the Flex mobile framework will solve the pixel density conundrum with a components approach. A well-written component set promises adaptive layout logic and self-contained resizing mechanisms, effectively abstracting pixel density considerations from the developer. But if you had hopes to distribute a pure AS3 application on the Android Market here and now, you’re in for a dilemma and no satisfying solution.

Note: On my desktop, a call to Capabilities.screenDPI returns 72 dpi instead of the real value of 102 dpi, on my android phone, the call returns 254 instead of the actual 267 dpi value.

Link: List of displays by pixel density

Daniel Szmulewicz's Space

Philosopher by education, writer by trade. Used to target people's minds, now targets people's digital devices. Provides IT consulting services for a living, specializing in Open Source solutions. Well-traveled. Lives in Tel-Aviv.

About me
HomepageAdd to TwitterAdd to FaceBookView Daniel Szmulewicz's profile on LinkedIn
Stack overflow
Github