The secrets of the world’s happiest cities The secrets of the world’s happiest cities

If one was to judge by sheer wealth, the last half-century should have been an ecstatically happy time for people in the US and other rich nations such as Canada, Japan and Great Britain. And yet the boom decades of the late 20th century were not accompanied by a boom in wellbeing. The British got richer by more than 40% between 1993 and 2012, but the rate of psychiatric disorders and neuroses grew.

Just before the crash of 2008, a team of Italian economists, led by Stefano Bartolini, tried to account for that seemingly inexplicable gap between rising income and flatlining happiness in the US. The Italians tried removing various components of economic and social data from their models, and found that the only factor powerful enough to hold down people’s self-reported happiness in the face of all that wealth was the country’s declining social capital: the social networks and interactions that keep us connected with others. It was even more corrosive than the income gap between rich and poor.

As much as we complain about other people, there is nothing worse for mental health than a social desert.

There is a clear connection between social deficit and the shape of cities. A Swedish study found that people who endure more than a 45-minute commute were 40% more likely to divorce. People who live in monofunctional, car‑dependent neighbourhoods outside urban centres are much less trusting of other people than people who live in walkable neighbourhoods where housing is mixed with shops, services and places to work.

A couple of University of Zurich economists, Bruno Frey and Alois Stutzer, compared German commuters’ estimation of the time it took them to get to work with their answers to the standard wellbeing question, “How satisfied are you with your life, all things considered?”

Their finding was seemingly straightforward: the longer the drive, the less happy people were. Before you dismiss this as numbingly obvious, keep in mind that they were testing not for drive satisfaction, but for life satisfaction. People were choosing commutes that made their entire lives worse. Stutzer and Frey found that a person with a one-hour commute has to earn 40% more money to be as satisfied with life as someone who walks to the office. On the other hand, for a single person, exchanging a long commute for a short walk to work has the same effect on happiness as finding a new love. Sonnenfinsternis am 20. März 2015 stellt elektrisches System in Europa vor große Herausforderung Sonnenfinsternis am 20. März 2015 stellt elektrisches System in Europa vor große Herausforderung

Die vier deutschen Stromübertragungsnetzbetreiber 50Hertz, Amprion, TenneT und TransnetBW bereiten sich auf die partielle Sonnenfinsternis am 20. März vor. An diesem Tag werden zwischen 9:30 und 12 Uhr bis zu 82 Prozent der Sonne abgedeckt sein. Aufgrund des hohen Anteils an installierter Photovoltaik-Leistung (PV) in Deutschland – rund 39.000 Megawatt – sowie in Italien und Frankreich stellt die Sonnenfinsternis eine große Herausforderung an das Management des Stromnetzes in Europa dar.

Bei sehr sonnigem Wetter geht in der ersten Hälfte der Sonnenfinsternis die PV-Einspeisung in Deutschland um rund 12 Gigawatt zurück und steigt anschließend – in der zweiten Hälfte der Sonnenfinsternis, wenn die Sonne aufgrund der Mittagszeit noch höher steht – um etwa 19 Gigawatt an. Auch wenn die Prognosen der Wetterdienste für die PV-Einspeisung, wie jede Prognose, eine Restunsicherheit haben, entspricht dies etwa der Leistung von 19 Großkraftwerken. Die Herausforderung für die Übertragungsnetzbetreiber besteht darin, dass der an der Strombörse vermarktete PV-Strom während dieser beiden Phasen durch viele flexible Erzeugungsanlagen vollständig ausgeglichen werden muss. Bei bewölktem Himmel wird der Einfluss der Sonnenfinsternis auf die PV-Einspeisung dagegen vergleichsweise gering sein. Nearly All Binary Searches and Mergesorts are Broken Nearly All Binary Searches and Mergesorts are Broken

Posted by Joshua Bloch, Software Engineer

In Programming Pearls Bentley says that the analogous line “sets m to the average of l and u, truncated down to the nearest integer.” On the face of it, this assertion might appear correct, but it fails for large values of the int variables low and high. Specifically, it fails if the sum of low and high is greater than the maximum positive int value (231 – 1). The sum overflows to a negative value, and the value stays negative when divided by two. In C this causes an array index out of bounds with unpredictable results. In Java, it throws ArrayIndexOutOfBoundsException.

This bug can manifest itself for arrays whose length (in elements) is 230 or greater (roughly a billion elements). This was inconceivable back in the ’80s, when Programming Pearls was written, but it is common these days at Google and other places. In Programming Pearls, Bentley says “While the first binary search was published in 1946, the first binary search that works correctly for all values of n did not appear until 1962.” The truth is, very few correct versions have ever been published, at least in mainstream programming languages. PHP at the speed of C with Recki-CT PHP at the speed of C with Recki-CT

Recently, Anthony Ferrara (known throughout the Internet and beyond as @ircmaxell) and Joe Watkins (similarly well-known as @krakjoe) have been working on a new set of toys for solving this problem while staying on the “standard” PHP runtime. Recki-CT is a set of tools that implement a PHP compiler, in PHP. While this might you think of things like PyPy, which implements a Python virtual machine in Python, this is not Recki’s goal – it doesn’t provide a VM, so it can’t run PHP by itself. However, it can parse PHP code and generate other code from it.

Recki uses the well-known PHP-Parser library by Nikita Popov to generate a graph-based representation of the code, and convert it to an intermediate representation. To get here involves a few steps, which are described in Recki’s documentation, but essentially:

  • It generates a tree-based representation of the code called an abstract syntax tree
  • From the AST, it generates a control flow graph
  • It then converts this graph into static single assignment form, where every variable is only assigned once, and all are defined before use. This makes it simpler to optimize.
  • Next, it repeatedly runs optimizations on this graph
php colourmandel.php
Data took 78.744249
Render took 0.631219

hvm mandelbrot.php
Data took 5.852351
Render took 0.236238

php -dextension=./ mandelbrotWithExtension.php
Data took 2.411557
Render took 0.637504