Posts

Showing posts from November, 2012

Next for iOS: better sharing

Image
There is one important area where Android and Windows 8 are ahead of iOS: sharing data between applications [1] . Interestingly the foundations for improving things have already been laid. There are two parts when it comes to sharing: offering data and receiving data. The offering part already exists [2] : many apps have a “sharing” button. For example, things that can be done with the current page in Safari include: Create a bookmark, send the URL via email, tweet the URL. Sharing in Safari on an iPhone However, the receiving part is still limited. iOS has built-in support for email, Twitter and more, but you can’t plug into the system with your own app. That is likely to change soon, as explained in a tweet by @chpwn: New, private iOS 6 feature Apple is using: remote view controllers. For example: the Mail compose view is now run in a separate process. Consult [3] for details. I can’t wait for Dropbox to be a sharing plugin, then you can send files to it from everywhere and from i

Coercing objects to primitives

This blog post looks at how JavaScript coerces objects to primitives. If you don’t know the difference between primitive values and objects, I suggest you consult my article “ Categorizing values in JavaScript ” at the Adobe Developer Connection. This post was triggered by the following tweet by David Bruant: !!(new Boolean(false)) #wtfjs The result of the above expression is true . Let us first learn about coercion in JavaScript. We can then use that knowledge to understand this result. Coercion Many operators and functions in JavaScript expect their arguments to have certain types. If they don’t, they are coerced (converted) to those types. Coercing an object to a primitive type is a two-step process: First, the object is converted to a primitive. Then, if necessary, the primitive is converted to the correct type. Two methods are used to convert an object to a primitive: valueOf() toString() There are three conversion algorithms: “Number”: you expect the value to b

Greg Smith on Goldman Sachs’s culture

Goldman Sachs executive Greg Smith resigned via an article in the New York Times, on March 14: It might sound surprising to a skeptical public, but culture was always a vital part of Goldman Sachs’s success. It revolved around teamwork, integrity, a spirit of humility, and always doing right by our clients. [...] I am sad to say that I look around today and see virtually no trace of the culture that made me love working for this firm for many years. [...] It makes me ill how callously people talk about ripping their clients off. Over the last 12 months I have seen five different managing directors refer to their own clients as “muppets,” sometimes over internal e-mail. The article was only the prelude to a book [ affiliate link ] that has come out on Oct 22. So you can see that Greg Smith was after publicity when he revealed some of the inner workings of the notoriously secretive Goldman Sachs. But he also sounds believable when he says that he cares about the company and

Jed – a JavaScript internationalization toolkit

Internationalization is still a tricky problem: we are still figuring out how to encode text properly, let alone store content in a manner that lets us translate it easily. In contrast, in other areas of web development, tools and technologies are in place so that even non-technical users can be productive. One example is content authoring – you don’t have to know how to write HTML or how to set up a server in order to publish a blog. The Jed internationalization toolkit Alex Sexton describes the goals for his Jed Toolkit as follows: The process of getting an app translated is cumbersome, and is a blocker to getting good applications out there. FTP zips and crazy XML specs mixed with Word Documents rule the landscape. There are no decent apis, or automatic integrations that anybody is using at scale. I want to set out to change this. The Jed Toolkit has been accepted into the Dojo Foundation (which, apart from the obvious Dojo Toolkit, hosts many projects, e.g. RequireJS and Siz

JavaScript inheritance: beyond the basics (video)

The video recording of my JSConf EU talk “JavaScript inheritance: beyond the basics” is online (you can also download the slides ). Outline: JavaScript inheritance basics Object exemplars ECMAScript 6 classes Super-references __proto__ I was lucky: because of a storm, the location of the second (parallel) track couldn’t be used for a while, eliminating my competition. Thus, people had nowhere else to go and the room was packed. In the talk, you can see me being surprised about how few people knew about property descriptors. If you want to read up on what they are and how they work, consult my blog post “ Object properties in JavaScript ”. You can see that a lot of work went into making this video, it has been produced very professionally: the opening looks and sounds nice, the mic is great (and makes me look like a motivational speaker) and the slides have been inserted perfectly into the video. I’m really thankful that JSConf EU makes such professionally produced

A proposal for using Canvas in web workers

Ian Hickson, editor of the HTML spec, has proposed a way to let web workers use Canvas. In the browser, all “normal” work happens in a single thread. That means that the user interface and computing tasks are competing for processor time. Thus, if you don’t want to block the user interface, you perform computationally intensive tasks in a background thread, via web workers (see section below ). Creating bitmap graphics is a common activity on the web and a candidate for being done in the background. The easiest solution would be to make Canvas (HTML element and bitmap API), available to workers. But that is not possible, because they don’t have access to the DOM and Canvas cannot exist independently of it. Quoting Ian Hickson : I was faced with two options: Option A: Provide an API for off-screen graphics in workers, requiring that every frame you package the whole thing up, send it over to the main thread, and blt it there. Option B: Provide a mechanism by which a worker

Nokia HERE (maps etc.): coming to iOS, Firefox OS and Android

Today, Nokia introduced a new brand for its location and mapping services: HERE. HERE applications will be available for several operating systems: iOS: based on HTML5(!), with an offline mode, voice-guided turn-by-turn navigation (including for walking) and public transport directions. Free, available within a few weeks. Firefox OS: Nokia has announced a strategic partnership with Mozilla and will bring a HERE app to Firefox OS sometime in 2013. Android: Nokia demonstrated a “reference application” and an SDK that will be available for Android OEMs in early 2013. To better compete with Google and Apple, Nokia is in the process of acquiring the company earthmine whose technology would help with bringing 3D mapping to HERE. Furthermore, Nokia announced LiveSight a brand for technologies (present and future) for augmented reality. For example, in one envisioned LiveSight application, you would look at your surroundings through your phone’s display and l

Variable declarations: three rules you can break

This blog post mentions three rules that are commonly given for using var statements. And then tells you when you can break them. To make things easier to understand, I somewhat disparagingly call the rules “conventional wisdom” and breaking the rules “unconventional wisdom”. But I will also explain why the rules have been created in the first place. For this blog post, you should know how JavaScript’s function-scoped var declarations work. Consult [1] if you don’t. Three rules you can break Rule to break: Don’t put a var statement inside a block Conventional wisdom in JavaScript tells you that the following code is bad: // Unconventional wisdom function foo(x, y) { if (x > y) { var tmp = x; x = y; y = tmp; } ... } Point: Looking at the code, one might think that the variable tmp only existed inside the then-block of the if statement. What really happens is that the variable declaration is hoisted – the d

Four talks on ECMAScript 6/ECMAScript.next

Recently, there have been several good talks on ECMAScript 6: [2012-10-08] Brendan Eich: Harmony of Dreams Come True (blog post linking to video and slides) [2012-10-13] Yehuda Katz: ECMAScript 6 (video) [2012-10-22] John K. Paul: JavaScript: The Real Bad Parts (slides) [2012-10-22] Domenic Denicola: ES6 is Nigh (site linking to slides) Additionally, you can take a look at the guide to my blog posts on ECMAScript.next.

A guide to 2ality’s posts on ECMAScript.next/ECMAScript 6

This blog post gives an overview of the 2ality posts on the next version of ECMAScript, ECMAScript 6 (code-named ECMAScript.next). All of those posts have the label esnext . Consult the sitemap for a list of all guides. Last date covered by this guide: 2012-11-09. General information on ECMAScript.next: ECMAScript: ES.next versus ES 6 versus ES Harmony Major and minor JavaScript pitfalls and ECMAScript 6 The first ECMAScript.next features in Firefox and Chrome es6-shim – ECMAScript 6 functionality on ECMAScript 5 A first look at what might be in ECMAScript 7 and 8 Language features: Quasi-literals: embedded DSLs in ECMAScript.next [new name: template strings] ECMAScript.next’s for-of loop ECMAScript.next: arrow functions and method definitions Keyword parameters in JavaScript and ECMAScript.next Classes and object-orientation: ECMAScript.next: classes Private data for objects in JavaScript A closer lo

Daylight savings time

A few days ago, daylight savings time (DST) ended again in Germany (we call it Sommerzeit, literally “summer time”). Changing the time twice a year is a silly thing to do – it brings few savings and quite a bit of cost and inconvenience. The Pirate Party has now started a European initiative (page in German) for abolishing DST. The complicated thing in Europe is that all states have to participate, otherwise changing regulations does not make sense. Dirk Haage pointed me to a nice visualization of daylight savings time. The visualization makes it obvious how we should change time – we should always have DST. I’d rather have slightly longer afternoons than early mornings. As a complementary measure, schools could start later. There is even evidence (page in German) that starting at 8 o’clock is too early for children (it certainly is for parents).

Property assignment and the prototype chain

This blog post examines how the prototype chain of an object affects assignments to its properties. It provides a more detailed look than the previous, more comprehensive, blog post “ Properties in JavaScript: definition versus assignment ”. The prototype chain Each object starts a prototype chain of one or more objects. All properties in that chain are readable via that object. For example: > var proto = { foo: 1 }; > var obj = { __proto__: proto, bar: 2 }; > obj.foo 1 > obj.bar 2 We used the special property __proto__ [1] to create the chain (which is not yet supported by all browsers). The prototype chain of obj comprises three objects: It starts with obj , continues with proto and ends with Object.prototype . Object.prototype is the constructor prototype of Object and a member of most (but not all [2] ) prototype chains: > Object.prototype.isPrototypeOf({}) true > Object.prototype.isPrototypeOf([]) true > Objec

The text “__proto__” can break a webapp

[This post is part of a series on the special property __proto__ ] The text “__proto__” can still break webapps if it appears somewhere in the content, as I was reminded of today, via Domenic Denicola and Peter van der Zee . The breakage The following webapps are susceptible to “__proto__”-induced breakage: The classic – Google Docs: For a while, if you typed in “__proto__” at the beginning of a document in Google Docs then it would hang . Current – Twitter: If you click on @__proto__ in a tweet then the profile summary that comes up only has a title bar, but no content. You also get “slow script” dialogs in Firefox. You can try it out in this tweet . Why? __proto__ is a special property of JavaScript objects [1] . Therefore, if you use an object as a map from strings to values, you must not use the string "__proto__" as a key. That is one of several things that you have to watch out for when using objects this way [2] . __proto__ is only supported in some brow

What is the best display aspect ratio for tablets?

Image
One marked difference between current tablets is the aspect ratio of their displays. This blog post explores the pros and cons of the different aspect ratios, along with the question whether one of them is best overall. The aspect ratios of current tablet displays Device Size Normalized aspect ratio Apple iPad mini 768px × 1024px 96 × 128 Apple iPad 1536px × 2048px 96 × 128 Google Nexus 7 800px × 1280px 87.636 × 140.217 Google Nexus 10 1600px × 2560px 87.636 × 140.217 Microsoft Surface 768px × 1366px 83.118 × 147.838 TV 3:4 96 × 128 DVD 9:16 83.138 × 147.802 Anamorphic (movie theaters) 1:2.39 71.704 × 171.372 Letter 8.5in × 11in 97.444 × 126.104 A4 210mm × 297mm 93.212 × 131.828 The last column shows the aspect ratio normalized to an area of 12288 (96 times 128). That is, all areas in that columns are the same, only the sides of the rectangles are different. The formula for the factor n with which the sides have to be multiplied is: n =

Why aren’t there more women in tech?

We should never forget that programming was initially a female profession . It was only later that women were slowly driven out of the industry. I’ve always been surprised that there aren’t more women in tech. I suspect that it is partially an image problem – especially computer jobs are much better than their reputation. Case in point: at the university of Munich, many more girls study “Bioinformatics” or “Media Informatics” than plain ”Informatics”. (Valid) reasons I’ve heard were: seemed more interesting and contains less math. The interesting part is that, in my experience, students of Bioinformatics and Media Informatics are just as good at Informatics as Informatics students and often end up in “normal” computer jobs. Yet, prior to these degrees, these girls might not have studied anything computer-related. Word needs to get out that computer jobs are great. A few talking points: Computer jobs are diverse: You really need people skills these days, as most of software developm