Thursday, 27 November 2014

Book rant: Functional JavaScript by Michael Fogus

O'Reilly books generally are really good. Not this one. I got only to the 32nd page but by that time I had enough red flags that I can recommend to never ever touch this book except if you need something to burn on a cold Winter night. This was the final straw (quoted from the book):
var bFunc = function() { return this };
var b = {name: "b", fun: bFunc};;
// => some global object, probably Window
The author uses this example to explain how the "self-reference semantics conflict with the notion of functional programming". Whatever that means. I really don't know what he meant and I will never know because the author doesn't get JavaScript. I had the same itchy feeling before this page; somehow the explanations are not clear, feels like the author himself doesn't "get it". I hoped that maybe the introductory sections don't try to explain what's going on and later in the book he does. Then I scanned the remainder of the book, just for the sake of this entry. No, he doesn't. Whenever he touches a topic that goes deeper than the conceptual level it's clear that he doesn't have enough understanding to explain it well. Or as the example above shows: sometimes he is simply wrong.

On a side note, and this is not the fault of the book, Underscore itself is a questionable functional library. It's a library that provides some higher order functions which resemble the ones used in real functional programming. But that's it. It's a shallow substitute and doesn't help you master thinking in functional programming. The guy in that video (Brian Lonsdorf) has an online video course. I haven't seen it yet, but I believe it must be a good one. However what I can strongly recommend is if you want to learn real functional programming in JavaScript go and read JavaScript AllongĂ© from Raganwald. For free if you wish. Then pay as much as you want to. Because that book is a piece of art. From somebody who does understand functional programming and does understand JavaScript.

Wednesday, 17 September 2014

Chrome has an 'antivirus' tool now

Chrome is my chosen web browser. Not because it is the best browser (which it is imho). But because it is the best OS. It is the case for many years now that you can do (almost) everything in your web browser. Although some browsers just recently learnt how to do it properly, the 'rendering webpages' is just a basic functionality that a good browser provides. You can login to Chrome. With multiple accounts on the same hosting environment (= that 'real' OS that runs the one you actually use). And install applications, plugins, extensions, themes. And the next evolutionary step: it requires now an 'antivirus' software. Technically speaking we are not talking about viruses. It is spyware/adware/malware extensions that can steal your data spy on you or break your browsing experience. I hope Google will embed this in their OS sooner than Microsoft did it for Windows (see: Windows Defender).
Google Software Removal Tool (beta)

Tuesday, 10 June 2014

Microsoft should learn how to demo

I am watching the MS Build presentations. So far I haven't seen a single one that "just worked". Here is my favourite one:
"The Nokia 630 is awesome. I happened to have one here, I was gonna show a demo on it. Ahm, apparently my TV device... and this is not a TV so it won't work. But look. It's great. I love it. It's an amazing device."

30 minutes later, same presentation:

Well, he could use that information to show off his great Android device on that non-TV :)

Sunday, 1 June 2014

Clojure - a liberal language with a conservative community

After playing with the idea of learning Haskell, Python and Ruby, eventually I chose to learn Clojure. I only understand now why it is such an appealing choice for me.

Steve Yegge is a technical blogger who used to write very long blog entries. It's worth to read all of them. And his drunken blog rants as well. He worked for Amazon (the drunken blog period) then he moved to Google. And believe me: he knows the world of programming languages. He probably wrote more language interpreters than languages I've ever touched. This week I found another long piece of his thoughts. TL;DR for those of you with short attention span: Steve introduces the terms `software liberal` and `software conservative`. The statement is that software engineers are also (software) liberals or conservatives. This, just as in politics, means that one group can't understand the other no matter how much they argue, simply because their value systems and beliefs differ. Steve places companies and programming languages on this axis as well: Microsoft and Google are conservative, Amazon and Facebook are liberal. Ruby, JavaScript, Python, C, Java, Clojure, Haskell - from extreme liberal to extreme conservative.

Then he picks a language that recently I am the most interested in: Clojure. In his early days with Clojure he liked it so much that he even wrote the foreword for The Joy of Clojure. That's one of the most important Clojure books out there (2nd edition's just released). Steve is a "hard core software liberal" and when he found that the Clojure community is conservative he turned from the language. I think Steve missed to emphasize this point: the language can sit on different side of this metric from its community. Clojure is a liberal language by all means. Even Steve knows that. And yes, the Clojure community is conservative. Liberal languages are powerful and sexy. If you say "But JavaScript is not sexy!" you should read JavaScript AllongĂ©. Liberal communities, however, are kind of a mess. At least for me they appear so. Just have a look at npm.

Software engineers with different views cannot agree on programming languages. That means it is pointless to say "Clojure is the best because..." All I can say is that for me Clojure is the best combination: a liberal language with a conservative community.

Sunday, 27 April 2014

The most annoying UX feature all systems have

I am watching a movie on my iPad and suddenly this happens:

I kind of got used to the battery low messages breaking my user experience, but a software update? Was it REALLY THAT important? Earlier today I was typing an email on my phone and a popup window appeared then disappeared when I hit space between two words. I have no idea if I okayed or ignored it, but it also doesn't matter: Because I had no chance to see what it was! And guess what happens if you have several tabs open in Chrome and one of them fires a popup message? That tab automatically gets the focus! No matter what you do on the active tab: you can be in the middle of an online game, a chat, an email, a video... the tab with the popup is automatically activated. Why do all the three big ones think that it's a good idea to change the focus at any random time? Besides that it is annoying there are two edge-cases that happen amazingly frequently with anyone who has a decent typing speed: you either hit space/enter on a message-box you had no chance to read because just 1/10th seconds before you were typing somewhere else. Or your last sentence gets typed into some completely different application. Hunt-and-pecks are also not luckier: they tend to look at their keyboard when they type; they completely miss if the OS moves their cursor to some other random window. Or another one: If during a phone call a popup message appears on the iPhone, you can't finish the call until you deal with that popup. I could go on and on.

Dear Microsoft, Google and Apple: Please stop this madness. Thank you.

Update: it is called focus stealing.

Saturday, 8 February 2014

Sentence-like function declarations

One of my JavaScript functions had this declaration:
function deviation(words, ideal, maxWords) { ...
My biggest problem with this is that one cannot be sure what the role of the parameters is just by looking at the declaration. A possible solution could be to add a comment. That's a last resort: I believe that code should be simple and self-descriptive enough to be understood without comments. And here is my final refactoring that I like a lot but I've never seen anything like this before:
function calculateDeviation(
    ofWords, fromIdealSize, usingMaxWordsInOneGroup) { ...
There are benefits and disadvantages to this. The main benefit is that now it is obvious what the role of the parameters are without reading the body of the function or the documentation. The main disadvantage is that the parameter names are a bit weird when you use them through the body of the function. Maybe the ideal solution is to add a call-through function to the interfaces (exports if you use require or public methods if you use some kind of OO pattern): so someone who calls this function will know what the parameters are by reading the declaration only but at the same time you can use not-so-weird parameter names in the body of the private function.

Tuesday, 28 January 2014


The obligatory 2013 summary

I had a wishlist to Microsoft 1 year ago. Since then they started sorting out the mess they created with their separate platform libraries. Microsoft changed even the licensing of the portable class libraries and made them available for Xamarin. Windows Phone is doing well on some markets and I can see at least one device a week on the tube here in London. The app market however still misses some key applications and I know about people leaving the platform because they miss some application. And this year at last Microsoft ported Photosynth to their mobile platform. Congrats guys.
Steve Ballmer's resignation was very exciting news. I really didn't like what the company (not) did under his leadership. But there are no effects in 2013 yet.
And there is a new Xbox. Depending on the next leader and what strategy Microsoft chooses, if they do choose a strategy at last, I still believe that Xbox is The Microsoft Product most households will have five years from now. Not that sure about any other Microsoft presence.

I asked Google to pioneer in the platform unification. They didn't and they did. Android is not going to desktop, at least not by Google. Others do it instead. What Google does is that they are transforming Chrome, the browser, into a full OS. That, and the success of the Chromebook is a more interesting way to rule the desktop world than a desktop Android.
Google also killed some of their products, including the RSS reader. That one resulted a rise of better RSS readers than The One. I have the feeling that Google reached that level of presence where they don't need to keep products alive that are good for the users but have no added value for Google. Living in the Google world (Gmail, Blogger, Picasaweb, Chrome, ...) it is not a good feeling.

I asked Apple to be amazing. They are not. Actually they had a very boring year. I switched to iPhone 5s after Nexus 4. It is still a decent device, it is still the best for me(!), but it is not outstanding.

This year was the debut of Firefox OS. I am watching it since the very first entry I had on this blog :)

On the front of programming this year's fad was the Functional Programming, and the ever-growing JavaScript presence on all possible hardware and software.

It was a quiet year in all other fields: curved TVs, 4k TVs, death of 3D TV (that wasn't ever alive), some Google Glass news, bigger and bigger mobile devices, ... practically 0 innovation.

Saturday, 25 January 2014

Why do we read code the ancient way?

This is a video about Code Bubbles. One year later the idea is applied to Visual Studio under the name Debugger Canvas (though it doesn't look that cool). I have only one question: Why on Earth are we still reading and debugging code in textfile-view four years later?! Actually the question is: Why we do it forty years later?

Sunday, 5 January 2014

Yet another post about Duck Typing

"If it walks like a duck, and quacks like a duck, it’s probably gonna throw exceptions at runtime."

The Three Articles

The first article in my rss reader I ignored. I know what duck typing is, so I don't read a post about it. Seeing the second title I raised my eyebrow. But when a third one appeared on the list I decided I need to read them: I don't follow fools' blogs, so three posts about the topic clearly means that something is worth a look there.
Eric Lippert expresses his confusion over the Wikipedia page about Duck Typing. I skimmed his article: he's pointing out some weaknesses of the Wikipedia's definition. Nothing interesting here. There are facts and there are community-edited articles. Let's move on and see what the other two posts are about. As I expected, those are reactions to the first one. Still nothing interesting... except! Except that Glenn Block calls Eric Lippert (the author of the original article) "one of the fathers of C#". Okaaay. So either The Fathers Of C# have no idea about the basic definitions of programming type systems and the IT industry is doomed, or I missed something. At this point I re-read Eric's post properly and a long journey's began.

My Two Pennies

I have no two pennies today. After reading some more articles and a research paper I still don't have a final conclusion. Here are three vague definitions of duck typing I have after all this reading:
"Structural Typing may be thought of as a kind of compiler-enforced subset of Duck Typing." (by Mark Rendle in the comments of Eric's post)
"Duck typing can be seen as the run-time, dynamically typed equivalent of structural typing" (from the publication above)
"Structural Typing which provides a way to do Duck Typing in a compiler safe manner that works with static types" (by Glenn Block)
The definition of early binding/late binding (or static typing/dynamic typing) are clear just as structural typing is. Duck typing is the only one that just doesn't feel like a well-defined entity but it still feels like "something": Python and JavaScript clearly have duck typing. And the C# dynamic keyword feels like it is not duck typing, but Glenn Block, among others, disagrees with this. And I myself also disagreed one hour ago. Occam's razor to the rescue: probably duck typing is not different from late binding. I accept this until I see a late binding that clearly is not duck typing.