Tuesday, February 17, 2015

You Don't Like Google's Go Because You Are Small

When you look at Google's presentations about Go, they are not shy about it. Go is about very smart people at Google solving very BIG problems. They know best. If you don't like Go, then you are small and are solving small problems. If you were big (or smart), you would surely like it.

For example, you might naively think that printing the greater of two numbers should be as simple as
  std::cout << max(b(),c())
That is because you think small. What you really should want is:
  t1 := b()
  if t2 := c(); t1 < t2 {
    t1 = t2
  fmt.Print( t1 )
Isn't it much better? We didn't have to type all those extra semicolons that were killing productivity before. If you don't like it, you are small.

If you wanted to extract an attribute of an optional parameter, you may be used to typing something like:
a = p ? p->a : 0;
or even:
a = p && p->a
You just make me sad because obviously what you really want is:
a = 0
if p != nil {
  a = p->a
It is so much more readable. Trust me, you don't need the ternary operator "?:". It is too complex for you, with your small mind. The creators of Go know better. You also don't need macros or templates, or you might accidentally try to abstract something like "max()" and get confused.

Collections? Don't make me laugh. The only ones you will ever need (or can comprehend in your small mind) are arrays and hash tables. But don't worry about the actual hash function used - you are not allowed to know about it or modify it. Why would you ever care about it, anyway, when everybody knows that practically any hash function always generates perfect results. Or at least, any hash function you could come up with.

If you really, really, are deluded enough to believe you need a different collection, be prepared to remember how you coded in 1987 in C, except you don't have macros, so all typecasts are explicit. Who cares about typecasts anyway, when you are solving really BIIIG problems.

Oh, forgot to mention, "range" doesn't work for your silly little custom data structures, so you better give them up.

Function overloading based on type you ask? Stop with your complaining! You don't need it. People much smarter than you have decided that you will never ever need such a complicated feature in a programming language. Function with the same name performing different operations based on the type of the arguments?? This is insanity. Way too confusing for you anyway. So, this, naturally does not compile:

func add ( a int, b int ) int {
    return a + b

func add ( a string, b string ) string { // ERROR!!
    return a + "+" + b
(Yes, it is a meaningless example, but that is just to show that function overloading is meaningless anyway!)

Oops, forgot to mention. You might end up needing something like that in a very obscure corner case which is referred by computer scientists as "calling methods of objects". So, in fact, you do have function overloading, but the syntax is much more simple, intuitive and self consistent than that nonsense above. Here it is:

type Int int
func (a Int) add ( b Int ) Int {
    return a + b

type String string
func (a String) add ( b String ) String {
    return a + "+" + b

func test () {
    var a Int = 0
    b := a.add( 10 )
    var c String = "aa"
    d := c.add( "cc" )
It does work, try it. And is so much better than what you may be used to in primitive languages like C++, Java, C#, etc. But you with your small mind cannot be expected to appreciate the beauty.

Interfaces you ask? I am glad you asked. Interfaces are indeed extremely important, so Go has lots of stuff about interfaces. But you don't want to declare them. No, no, no, that would be too hard. God forbid that you wanted to implement "interface Writer" by having to actually type "implements Writer". That is crazy talk. It is much better to just write scattered methods here and there and if they don't happen to match the interface signature because you missed a return type, you get the error in a completely different source file. That is big thinking.

Why should the compiler go to all the trouble of validating an interface implementation when you, the programmer, can do it manually? Compiler time is expensive if you are solving big problems.

Virtual functions? Don't be ridiculous. Who needs that... If you are that stuck up on them, you small minded freak, you can emulate them with interfaces, because you typing is much better than the compiler doing it. Besides, virtual functions are overrated.

And finally, variable case. The big brains decided that typing "export" is too much when solving big problems, so just capitalize the identifier. That alone will probably cause at least 30% increase in productivity.  Of course, don't forget to rename things if you decide they are not public. It is much easier than deleting a keyword, besides you cannot be trusted to follow a coding style, so it is better to enforce at the language level. Same with braces and semicolons.

Good luck in the wonderful world of Go!

-- Update

My blog post got like a 100 views, which is amazing, so I decided I should add a clarification. I don't "hate" Go, I think there is lot there to like (static typing, precise garbage collection, true closures, fast interfaces, sane module system, etc), and that is precisely why its big failings bother me even more.

I view Go as a huge wasted opportunity. How often does a new semi-successful language backed by a successful company appear? Google squandered it through something which looks very much like arrogance.

As it is now, unfortunately Go is little more than an incredible runtime library: very efficient green threads and a precise garbage collector. Someone might port Java to that runtime and reap all of the benefits.

Thursday, August 4, 2011

For my Bulgarian friends: Vaccines

(Update: the interview below is a joke. I made it up)

Превод на интервю със световно известен руски медицински изследовател. Поради важноста на изнесените от него данни, той не пожелал да разкрие името си публично, но е универсално признат учен, с многобройни публикувани трудове, с дългогодишен опит на имунолог, работил в Руската Академия на Науките, както и в Кралска Медицинска Академия на Канада. Също така държи докторати по мулекулярна биология и статистическа социология. В интервюто използва псевдонимът А.К. Интервюто е проведено в кабинета му в Лондон като гостуващ лектор, след лекция дадена пред Кралското Медицинско Общество на Лондон:

Въпрос: А.К., благодаря ви че се съгласихте на това интервю.

А.К. Смятам че темата е много важна, и по нея не бива да се мълчи, особено в последно време с огромната дезинформация по този въпрос.

Въпрос: Какво ви накара да нарушите мълчанието си по въпроса за ваксините?

А.К. През 1997 в Руската Академия на Науките по поръчка на Б. Елцин бе създаден таен колектив за проучване на тогавашните широко разпостранени проблеми с ваксинациите. Предтекстът беше повишената смъртност сред пенсионерите в Урал, но истинската цел беше да се установи по безспорен начин, със статистически методи, дали ваксините помагат или пречат.

Въпрос: Защо "таен" колектив?

А.К. Защото още тогава се усещаше силен натиск към промяна в позицията на Академията от определени силни интереси, и на проучване от този тип не се гледаше с добро око. С една дума, всички ние рискувахме да бъдем дискредитирани като учени.

Въпрос: Натиск в каква посока?

А.К. Натиск в посока да се заблуди общественоста че ваксините са вредни.

Въпрос: Как така вредни?

А.К. Въпреки че не мога да се впускам в детайли, защото се опасявам за безопасноста на семейството си, трябва да кажа че създаден има световен картел, чиято цел е да дискредитира ваксините в съзнанието на населението, с цел да се повиши нивото на болестите и смъртноста.

Въпрос: Но това звучи доста невероятно.

А.К. Така е. Аз самият не исках да повярвам, въпреки че се носеха слухове в медицинските среди, докато не анализирах резултатите от собствените си проучвания. Те показаха че безспорно ваксините са незаменими като средство за намаляване на болестите, и особено в последни години са с особено повишена ефикастност и намалени странични ефекти. С една дума, ваксините са едно от малкото неща които очевидно допринасят за благото на цялото човечество, така да се каже. И фактите за това са налице и публично достъпни, въпреки че е необходима статистическа и медицинска подготовка за да бъдат анализирани.

Въпрос: След като фактите са такива, как действа картела, който споменахте? С каква цел?

А.К. Картела всява дезинформация сред общественоста със статии и интервюта, които са изцяло лишени и факти, пълни с конспиративни измислици, но звучат интересно и много хора се подлъгват. А целта на картела е много проста - правене на пари. Картелът се състои от най-големите фармацефтични фирми с цел да има повече болни хора, на които да се продават лекарства.

Въпрос: Но нали те печелят и от ваксините?

А.К. В много по-малка степен. Съвременните ваксини са толкова ефикасни, че намаляват болестите с фактор от хиляди. Освен това правителствата ограничават цените на ваксините и ги правят задължителни, което съвсем смъква цените. Въпреки че са печеливши в крайна смета, ваксините против грип например са много по-неизгодни от лекарствата които се вземат от вече болните от грип.

Въпрос. Това е много интересно. Но вие отричате ли все пак че ваксините могат да имат негативни странични ефекти?

А.К. Съвсем не. Наша отговорност като лекари е да бъдем напълно честни. Във всяка ваксина има някакъв риск, но трябва да осъзнаем че този риск е неимоверно по-малък отколкото риска който поемаме ако не ги вземаме. Също така трябва да се знае, че докато повечето хора са ваксинирани, малцината които не са също имат по-малък риск от заболяване.

Въпрос: Добре. Как се приеха резултатите от вашите разследвания?

А.К. За съжаление Б. Елцин подаде оставка преди да ги завършим, в края 1999, така че без политическа подкрепа не можахме да получим нужната гласност за проблема. Опитваме се всячески да покажем истината, но срещу нас работи огромна медийна система, която се управлява от интереси и пари. Много от моите колеги бяха взети на работа от същите тези компании, с огромни заплати, при условие да се откажат от резултатите от изследванията. Други бяха дискредитирани, а някои дори получиха лични заплахи.

Въпрос: Вие самият ваксинирате ли се?

А.К. Разбира се. Аз, жена ми, децата а също и внуците ми.

Въпрос: Като обобщение, какъв съвет можете да дадете на нашите читатели?

А.К. Да мислят с главите си и да не вярват на неща които не са подкрепени от проверяеми факти.

Въпрос: А.К, благодаря ви за времето, което ми отделихте.

Wednesday, February 16, 2011

The fallacy that WP7 is immune from the race to the bottom

People left and right are claiming that if Nokia had chosen Android, they would be one vendor amongst many competing on thinner and thinner margins, while WP7 somehow isolates them for that. As far as I can tell, that is now commonly accepted as truth. It is amusing how a fallacy turns into "common sense" when repeated enough times.

In reality, of course, people don't buy operating systems. They buy phones, and they would not buy a more expensive phone if a cheaper one offered the same capabilities given comparable manufacture quality and design. This is such a simple and fundamental truth that it is almost unbelievable that it is ignored.

Apple is always used as a counter-example, but in reality an unlocked iPhone costs about the same as any other high-end smartphone with comparable parameters. Granted, people will pay more for good design or even just a fancy logo, but the name of the OS running in the phone hardly even enters the equation.  In particular the notion that consumers will pay premium specifically for WP7 is frankly laughable.

Of course there are other factors: the brand name of the manufacturer, the quality of the app ecosystem and so on. Those are valid considerations, except that most of those currently point towards an advantage for Android, not the other way around.

So, specifically the fallacy is this: while it is commonly accepted that Android is "comparable", if not "better" than WP7, at the same time it is also claimed that WP7 will bring in higher premiums.

Nokia can manufacture some pretty good phone hardware, so they deserve high margins, but the sad reality is they are in the same race to the bottom as everybody else, including Apple, and one day the license cost of WP7 (compared to free Android and IOS) might end up being a huge problem.

That is my objective evaluation of the situation, but it doesn't mean I like it. We will end up getting crappier and crappier product as a result, just as today it is almost impossible to buy a high quality PC regardless of the price.

Monday, November 30, 2009

Git in non-patch mode

The longer I use Git, the more things I find to love. Of course when I say "love", I don't mean the fanboy kind of love, but the feeling of satisfaction and happiness which good tools give the proud professional :-)

I just recently realized how easy it is to apply an arbitrary commit on top of another one, without treating it as a patch. Since all high-level Git commands work with patches and diffs, one sometimes forgets that internally Git doesn't use patches, but simply stores the state of the tree as is at any point.

So, to put commit-a on top of commit-b, I simply do:

  git-checkout commit-a
  git-read-tree -u -a commit-b

Again, this doesn't apply commit-b as a patch on top of commit-a; it copies the exact state of the tree in commit-b.

Why is this necessary? Sometimes there can be a very messy path from commit-a to commit-b, while all we want to record in the official history is just the two commits.

After reading the Git user manual, the first idea would probably be to do this using "git-rebase -i" or even a sequence of "git-cherry-pick -n". However that approach takes a lot (!) of effort, and is risky because there can be conflicts which need to be resolved.

Command line issue tracking

Issue tracking is needed even for smaller projects or personal ones, but frequently the effort of setting up a complex issue tracking system for a small project is too much. A typical bug tracking system might requires a database server and a web server. Administering those is too much of a PITA.

Another severe problem lies with the portability of the bug database. For my hobby or consulting projects I like to keep the bugs close to the source - I might happen to work om my desktop, on a laptop, etc. They should be easy to move around and archive. By comparison, moving or backing up a Bugzilla installation involves unspeakable complexities that my mind simply refuses to do.  (I do realize that it is not technically complex to move a Bugzilla installation, in fact it is a relatively easy as these things go,  but it is not something that one would undertake casually - it takes preparation, time and care).

Yes, one could maintain a running publicly accessible (even only via SSh/OpenVPN) web server, and always use it, but that is a whole lot of work, not to mention the security implications and the real added expense. Plus, one is not always online.

So, until recently my bug tracking for these kinds of projects has been restricted to keeping a couple of text files called BUGS.TXT and TODO.TXT. Not very high-tech, but hey, they do the job.

That is until I found Ditz. It is a command line bug tracking tool, and it keeps all its data, including all configuration files under one neat sub-directory, plus everything is in plain text format! I absolutely love it and highly recommend it.

With Ditz the entire bug database even can be a part of the source tree, which automatically makes it distributed if one uses Git for example. (I am not sure that is such a great idea by the way - polluting the source history with bug reports - but I am still thinking about it). Moving it between computers is just a copy, and so is backup. It literally requires no thinking or effort.

While I am on this subject, todotxt  also deserves a honorable mention, although it is not suitable for issue tracking.

Bottom line, Git and Ditz provide a full featured and yet very simple infrastructure for small projects. Now all I have to do is finally start using a good command line email client.

Friday, November 13, 2009

Android ... not so great after the honeymoon

Android is really starting to annoy me. Really, although I want to like it. I have about 30 applications and every week I get about a dozen or so app updates. For each and every one of them I have to click several times and wait for the update to complete. It is time consuming and extremely annoying. And it never stops!

So, one, there isn't a way to auto-update all applications. Two, it feels like developers for Android are constantly pushing out buggy unfinished apps, and then updating them all the time. I mean, I sometimes get two-three updates of the same app within a week. People, test your god-damned apps before publishing them, and Google, please provide a way to update all apps.

In short, my attitude towards Android has definitely changed for the worse since I actually have an Adroid Phone. Initially it was awesome, compared to my previous phone a Motorola Razr. But we bought an iPhone for my wife at approximately the same time that I got my G1, and I have had an ample chance to compare the two since then. Although I would never buy an iPhone for myself on ideological grounds, I grudgingly have to admit that the iPhone is a superior phone! Damn it.

Although I would never admit it (oops, I just did), I catch my self "casually" wanting to use my wife's iPhone for browsing the web, or looking at photos, or what not, because it is simply better than the Android.

Wednesday, November 4, 2009

Ubuntu's LTS Release Schedule

A few days ago I accidentally came across the Ubuntu 10.04 LTS Release Schedule. I am copying it here:

December 3rd, 2009 – Alpha 1 release

January 7th, 2010 – Alpha 2 release

February 4th, 2010 – Alpha 3 release

March 4th, 2010 – Beta1 release

April 1st, 2010 – Beta2 release

April 15th, 2010 – Release Candidate

April 29th, 2010 – Final release of Ubuntu 10.04 LTS

So, they have three weeks between Beta1 and Beta2 and then only two weeks more before release. What I don't understand is this: how the hell can they guarantee that they will fix all critical beta bugs within a total of five weeks? And since I know for a fact that they can't (nobody can), it follows that they will simply release no matter what.

So, let me repeat that. No matter what remaining bugs there are, the Ubuntu LTS version will be released on time. With the bugs. Why bother with the betas at all then? I have to say this is not what I would expect from a "Long Term Support" version or like to run on my servers. Or my desktops.