Thursday, January 16, 2014

Why Hong Kong is a good place to live

At first I was planning to stay in the Fragrant (香) Harbour (港) for half a year. It's been over one year now and for now, I'm staying. Let's look at some of the reasons why is it so.

Convenient services


The city never sleeps. Neither did my next-door fruit market in Tai Wai, apparently. Whether I was going to work or going back home in late evening, I could always buy some oranges and durian :-S. A famous dim-sum restaurant was also usually open at 3am when I was going back from events in the city.

Few people cook at home in Hong Kong – eating out is fast and cheap and also, who has time to cook when you only get out of work at 9pm. Getting together for a dinner is totally the standard way to meet friends after work, the equivalent of getting a beer in Europe.

Dinners are altogether more social in Asia because the meals are shared – a group of people sits at a round table, orders dishes together and people take food from the centre of the table to their bowls. Thanks to this, you get to taste more different meals and also have something to talk about with your friends. You don't only share the meal but the enjoyment as well (or disappointment!) This way of dining is completely foreign to westerners but most of us get used to it pretty fast and enjoy it as well.

The nature, in the city

Hong Kong is a big, lively city with 7 millions of people, all in an area of around 1000 km2. It's full of skyscrapers, tall apartment buildings, roads, rails, restaurants, shopping mallls, but, also rich with green hills, sea bays and islands! This is one of the differences with the sister city of Singapore (and not the only one). Some locals and many Czechs and Slovaks will wander into the hills and on the islands on the weekends in search of some tranquility and quiet. They'll rarely find it, because the city is constantly alive and noisy, but they'll get some healthy outdoor activity nonetheless. The hills are not very big, just below 1000 m but they offer a nice green escape from the concrete mass of downtown city. The image below illustrates two different approaches to urban planning. HK is the second case, it's very compact but the hilly areas are not very densely urbanized.

(source)
A large part of the special administrative region actually comprises of islands, from the large Lantau Island which offers a number of hiking trails to tiny islands in Sai Kung full of fishing villages. Some of them show off interesting rock formations as a part of the HK Geopark. Hiking may not be massively popular but junk boating certainly is. Well, human nature. Junk boat is all about renting a boat in the summer with a bunch of friends, buying some food and tons of drinks and sailing out to Sai Kung, the area full of small bays, beaches and islands which is not yet too spoiled.


Travelling

If you want to see most of SE Asia or China, living in here is a real boon. You can still have your modern civilization standard of life and at the same time enjoy fast and cheap connection to destinations which are very exotic for Europeans. A full-moon beach party in Thailand?  Just take Friday off and have an extended weekend. Need to fix your back in hot springs in Taiwan? A weekend is enough (but Taiwan deserves a longer visit).  Both of these for about 2000 HKD, return airfare.

Additionally, if you work in HK, you'll be getting a HKID and that makes it much easier to get a visa for travelling to China. And this huge country has a lot of natural and cultural sights to offer too.


The dark side

To balance out, let's quickly mention the dark side. First, it's not very dark here at night. The main crossroad in TST is brighter than your dining room, so if you're an astronomer, you won't enjoy the stars a lot. And, light pollution is not the only type of pollution in HK. It's much better than China and I personally am not feeling any problems but some people do complain. Some of the foul air is imported from the neighbouring city of Shenzhen which is a Chinese industrial centre. Low visibility is also annoying but I blame it mostly on mist, not pollution. Me as a photographer curses it quite often because it spoils potentially awesome shots in many places.



The city is, of course, very crowded. I got used to it despite coming from a really small town but other people may have trouble adjusting. Queuing must be a national sport, it's practiced in banks, at ATMs, at a restaurant, for a bus, sometimes for a subway train. Better have your smartphone with Facebook or WhatsApp ready. With all the people, government officials do have experience in managing crowds. If you're planning a huge event in Europe, these folks would be my first recommendation for advice :)

As you already noticed, I like the nature. Sadly, not all beaches and sea waters are nice and clean. With this amount of boat traffic and people in the area, it's almost impossible to keep them pretty. But at the current rate of (ab)using the environment in HK, it will turn pretty disgusting sooner or later.

Thursday, January 9, 2014

We don't have this in Europe, part I.

Some of my observations about what's in HK and whats unseen in Europe. In Central Europe. In Czech Republic, I mean.

Streets with a shopping theme

If you go shopping in Hong Kong or simply just walk through Mong Kok, you'll notice (assuming you can see something at all in that sea of people) that similar shops tend to appear in packs. There is Computer Centre, a whole building full of small shops with electronics, there is Sports Shoes Street and lots of other places. This allows the customer to see the offers of all the merchants and decide for the best option on the spot. Compared to Europe (or most other places), this can save a lot of time and (mental) effort. On the other hand, the shops have less space to maneuver their prices because the level of competition is driven way higher.


I was wondering how these same-goods neighbourhoods were first created. A local friend told me that it's often the owner of the shopping mall or area who sets the theme for the shops. But what about the streets, such as on the picture above? I'm sure that must have grown organically...

Leaking buildings

To be fair, there is a lot more rain in Hong Kong than in Europe and no one would expect a typhoon to be very nice to buildings. But the truth is that buildings do leak and sometimes they are very happy to make a puddle right in the middle of your bed. Makes me appreciate the solid better insulation work done in Europe.

The government has a good PR guy

Besides ordinary commercial offerings, MTR stations walls, buses and trains are decorated with posters telling you not to buy more food than you eat, to avoid throwing food away. To check your windows regularly and not to try to fix them on your own for safety reasons. That you shouldn't abuse public housing if you can afford your own accommodation. I also learned about minimal wage regulations from one of those posters. In general, the government is communicating with the people way more than I'm used to and communication is always good.

Hong Kong is a free economy, more free than many European countries and that's why I was surprised to see regulatory bodies that I haven't encountered at home. In Czech, if your internet connection is slow, you're simply out of luck and complaining that you bought a 30Mbps plan but are getting 3 Mbps is no use, nothing is guaranteed. In Hong Kong, though, there's a government office that makes ISPs fulfill their promises.

And did I mention that people in HK enjoy one of the fastest internet services in the world? My apartment has a 100Mbps link and many already have an optical fiber with 1Gbps. Of course, this is made possible by the extreme population density - an ISP won't mind building a cable connection to a place with hundreds of potential customers and the same argument applies to mobile internet as well (LTE with about 100Mbps is quite commonplace now).

Saturday, August 17, 2013

Scary features in Google+ images

I'm a technology enthusiast, I really look forward to any new innovation and improvement using technology. But sometimes even I get caught totally off-guard. Like today.

When flying back to HK through Incheon in South Korea. We were flying over a lovely small island which was partially covered by small, fluffy clouds. I took my phone and started to take photos in a fast sequence to make an animation which also happens to give it some depth perception. Ok, now I have a spare moment, so I imported the pictures to Picasa, color-corrected them to remove the grayness caused by the distance and exported them to Gimp in order to make the animation. And, while Gimp was struggling reading the EXIF metadata (I haven't upgraded the poor program in a while..) I got a notification on my Android about the freshly uploaded photos. I opened it and there, in my Google+ albums was sitting a complete animation from all those pictures.

wut

Ok, this won't be so difficult to implement in an algorithm, but still, the idea that they include details like this means something. They must be pretty efficient at Google. And there are some other similar features as well like creating a panorama or a HDR photo.



This little feature blew my mind, because I totally didn't expect that. If I had discovered the unlabeled object recognition feature by accident before reading about it, I would probably first try to wake up from a dream. I have no idea how in the world could they do that.

I wonder what's next and I'm looking forward to it.

Thursday, June 6, 2013

中国大陆

Mainland Chinese in Hong Kong

Nowadays, Hong Kong consists of locals, westerners and mainland Chinese. While Westerners usually don't have much trouble, the integration of people from mainland can be a peculiar issue. It makes me think, does that mean that HK culture is closer to Western than Chinese? No, the locals would say, it's a world of its own.

When I arrived, I noticed that baby milk powder was a big topic. I saw that mainland Chinese were coming to HK to buy cans of milk powder for their babies because some time ago, some of the milk produced in China contained toxins and a number of babies died. Most people are aware that Chinese products usually don't shine in quality and the Chinese know this as well, so they decided not to entrust their children's life to their own country's production and started to buy the milk powder in other places.

The problem is that China is so big. Whatever their citizens decide to do will impact the rest of the world like a thousand ton hammer. Baby milk was sold out in Hong Kong, Macau and shortage was reported even in Germany and the UK. Hong Kong government was forced to come up with a law prohibiting anyone from taking more than 2 cans of milk powder over the border. A similar problem occurs in maternity wards in HK where mothers from the mainland are desperately trying to get a place. And, of course, the space in HK maternity wards is limited.

When I came here, I felt that the milk powder shortage was the biggest problem of Hong Kong and I found it rather amusing. Now I know that, actually, the biggest problem are the astronomic property prices which, among others, give young people only very pessimistic outlooks on their future, prevent them from having children (because they can't afford it) and just drive the costs of everything higher and higher. And even this is partially caused by rich people from China who buy properties in HK and sometimes don't even live there because they just flank it as a status symbol - it's very cool to own an expensive flat in HK...

It seems that not too many mainlanders live here officially, but there are tens of millions of tourists every year. I got some statistics from HK government, year 2011. It shows the population over 15 by attained education level, divided by sex and education. Women are red, men blue and the brighter part in the middle denotes mainlanders. Of course, mainlanders living here unofficially are not included.

While it's understandable that Chinese mothers want to make sure to get the best for their children, HK locals are not very happy about the changes the crowds of mainlanders are bringing to their city. And that's not all. The dynamics of university students from HK versus mainland is also interesting. Locals are very serious about getting proper education and trying to reach for the stars in their careers, but if you let them compete against the top 100 students from a 1.4 billion people country, they are going to lose. That's a mathematical fact. It's unbelievable how hard can those top-performing mainland students work. You'll find them in the library even in the summer, they are more determined to get business contacts at any opportunity and can speak better English. The locals just can't keep up (read more in the source article).

The other side of the social spectrum is represented by tourists from mainland and their totally uncivilized behaviour. The things I heard about them include relieving their physiological needs on the streets (no matter how hard are the cities trying to put a public toilet everywhere), spitting everywhere, being loud (mandarin is a loud language...), drawing on Egyptian monuments and so on. Of course not all of them do this, but the problem is there and it's perceived by many.
And now, after seeing a popular movie about Thailand, chinese tourists are flooding Chiang Mai as well. And the Thai are taken aback by their behaviour, no less than people in HK.

Perhaps China will soo raise their own huge cities to the same level as HK in terms of quality of life, products and education so that their citizens wouldn't need to colonize HK. But the HK economy is already highly oriented towards the Chinese shoppers and most of its industry has moved away to Shenzhen (which is now also growing like crazy). Looks like a vicious circle to me...

    Monday, May 20, 2013

    錢

    Income Inequality

    Hong Kong really is a very unusual combination of the West and the East and also of the rich and the poor. Some areas feel very Asian and Chinese, selling fruit, meat as well as clothes in local markets, there are cheap local restaurants and everything is packed inside as well as on the streets, in so little space. Walk a bit further and you'll find yourself in a completely different world - a world of gold, jewelry, luxury watches, cosmetics, sports cars and suits. Some areas are nothing else but enormous shops with luxury goods in modern skyscrapers. And in those places, you'll be surrounded mostly by westerners.

    This is an image you can see every day and it should give you an idea also what the income distribution will look like. I wanted to have some numbers, so I did some research and found figures coming from the government, from the year 2010.


    I can still remember the shock when I told some westerners what a HK university graduate's salary looks like and my amount of surprise was no less. Students who are able to obtain an university degree still haven't really won themselves a comfortable life, because the average salary is a puny 12.000 HKD per month. Monthly rent of an apartment in a cheap place (New Territories) will be around 7.000 HKD, which is more than the monthly income of 16 % of households! It is only because of government provided flats that the society has not yet collapsed. According to my information, more than half of local population lives in these flats. Of course, people are trying to get out of that vicious circle, many try very hard to study fields with prospects of a good salary (law, IT, ...), but without any passion, which turns them into mindless fact-repeating drones lacking any real understanding.

    The contrast is emphasised by all those low-class, presumably low-wage workers all around the place. Toilet attendants, elevator button cleaners, people who stand in hallways and warn you that the floor is wet and slippery, trash sorters and so on. No one would do these pointless-seeming jobs in Europe. In Hong Kong, I assume, these people cannot just fall into the comfortable social security safety net. And I believe it's a good thing. Compared to plain-out begging & starvation in undeveloped countries or the opposite, getting social security while doing nothing in "overdeveloped" countries, it at least gives the people some structure in their lives. To move it from good to awesome, the government could try to provide opportunities to get a better job, perhaps by some kind of education.


    Now consider that the monthly rent of an apartment in Central (the, ugh, central area of the city) can be over 30.000 HKD. Most families can't even begin to think about living in that place so it's occupied by westerners, rich mainlanders and rich locals. The sky-high cost of property together with the income disparity are the biggest problems of the city. The Gini index, a measure of income inequality, is between 0.4 and 0.5, close to (if not!) the highest in the developed world.

    If things continue this way, I think that a part of the Honkies will be forced to move out to mainland China. It would be a natural continuation of the integration of HK and China, as rich Chinese are moving in, the poor would have to find places which are more suitable to their income level. But no local would ever want to leave HK for mainland. But it seems that the preferences of rich Chinese occupants and shoppers are changing and the government has created laws that forbid market speculations with apartments, so the future direction might be completely different. It will certainly be very interesting to see that.

    Thursday, March 14, 2013

    Autorelease pool hell

    I spent a lot of time hunting down a problem with a crash in autorelease pools in our Python - Chromium Mac application and I finally found the primary cause. I couldn't find any information at all about this kind of crash on the internet, so I decided to share the experience with you. Brace yourselves, it's going to be long.

    Our app was crashing on exit somewhere in AutoreleasePoolPage::pop. Attempting to access memory at 0x00000010 which is very bad. Everybody on the internet says that for Objective C crashes, use Instruments and Zombies, right? Well, zombies were sleeping in the graves peacefuly for me. Nothing found. So let's try the next tool.

    I couldn't get Valgrind to work for this app on OS X, because I had a recent machine which supports HW instructions for AES and Valgrind in 32b mode doesn't, which is basically game-over. So I got an older machine, without these instructions, and found ... nothing. Really, no information related to this problem at all. It seems that I'll need to do some more thinking.

    In the meantime, I discovered some other problems, largely unrelated to this one. Because of them, I was considering to remove wxPython as the window-creating mechanism from our app and roll my own. This did solve the problem with accessing the USB on OS X, but this crash, in exact same form, persisted even after getting rid of wx. It's starting to get sad, really.

    I was forced to roll up my sleeves and dig once more into disassembly. I found that the memory which AutoreleasePoolPage::pop() is accessing is somewhat wrong. But I couldn't find any more information from that mountain of instructions and this is where I got lucky - I found that there is actually source code for this class! Just get the right version of objc from http://opensource.apple.com! This made things a lot easier and clearer. And what's more, after a while I was able to compile this project and use the debug version instead of the system one. How awesome is that!

    What I found out is that autorelease pools are nothing more than a block of memory containing pointers. This memory is managed manually by the AutoreleasePoolPage C++ object. And that is rather unfortunate, because there are almost no safeguards at all. If they were using the standard malloc or new, I could employ all kinds of diagnostics, safeguards and checking and they may be able to slap me at the right moment. But with this manual management, we are on our own. This was probably one of the reasons why Valgrind, Guard Malloc and other tricks just didn't work.

    Takeway 1: If you manage memory by yourself, you will probably need heavy checking, the kind that malloc has.

    So I knew that I'm somehow overwriting my own memory inside an AutoreleasePoolPage. So let's introduce some logging and custom diagnostics. I used dtrace and Instruments to get arguments and call stack at key points in the program (well, basically at every call to AutoreleasePoolPage methods). dtrace is awesome, if you don't know it, you need to. This told me that, indeed, one autorelease pool memory block is getting overwritten by a different one. And I also knew which one! I didn't need much to realize that I'm using the pools incorrectly. It seems they should always be used like a block and nested correctly:

      p1 = [NSAutoreleasePool alloc init];
      p2 = [NSAutoreleasePool alloc init];
      [p2 release];
      [p1 release];
    or use this shorthand syntax:

    @autoreleasepool {
      @autoreleasepool {
        ...
      }
    }
    

    which means creation and destruction in a single function. What I did was to create the block somewhere in one method and release it somewhere in a run loop. This apparently breaks nesting and causes all this headache.

    Takeway 2: Always nest autorelease pools correctly.

    Thanks to the call stacks from Instruments, I knew which pool is destroying which other pool and now I only need to figure out how to fix it. Phewww.

    Friday, March 1, 2013

    英文

    As for English knowledge, this varies a lot. Some people don't speak at all, some speak at an average level and some speak very well, better than me. I heard that some universities teach entirely in English.

    Have I already mentioned that education is really big in HK? As well as status symbols and money. One foreigner living here posted this and I do feel very similarly about it:



    Ahh... Hong Kong... it takes your insecurities and enhances them tenfold to the point where you're always self-conscious or you don't care about them. Little kids will point out your every flaw while everyone else is silently judging you for your technological and fashion choices. The populace is hungry for money and will jump on any opportunity to make a buck. In the meantime, little Sally Wu is only getting four hours of sleep every night because her mother wants her to be the perfect student.

    It might be the environment I work in, but many local students of Computer Science are trying to pursue PhD and other things people usually do in non-engineering disciplines to try and advance their career. Things that programmers and SW people usually don't do, because they don't need it. Because at least in Europe + US most employers consider real-world experience rather than academic degrees.