Sunday, 6 March 2016

Abaddon's Gate (The Expanse book 3), by James S.A. Corey

book cover The authors known as James S.A. Corey have planned the series of books The Expanse to have three volumes. As such, Abaddon's Gate feels like a wraparound of the stories so far, while also remaining a good standalone feature. However, because of the overwhelmingly positive response for the series, it was continued for another three volumes, and now three more are announced. There are also various novellas in between books. That is a problem, since this book ends up undoing what the first two started. But let's not get ahead of ourselves here, just be warned that this review may contain spoilers, without which I couldn't possibly comment on the plot of the book.

If you are only interested in my general opinion of the book, I believe it is consistent with the quality of the second. There are more characters, but also less compelling ones. There is a great mystery, but a rather bland one. There is a danger, well... several of them in succession, but they feel a bit artificial, just to keep the tension going. I am not complaining, but I am also not thrilled. As in Caliban's War, there are several characters that seem put there just to annoy me. There is this lesbian preacher that always needs to save the souls of everybody around, for example; she kind of felt like someone nagged the writers to put more progressive characters in, like writing about giant alien artifacts in space is not progressive! Fortunately, she is also important to the plot, so she is not just added there like condiment on food, yet the parts of her philosophizing about the meaning of God bored me to tears. Then there is a psychotic captain that doesn't seem to be a person at all. He just randomly appears and does stuff, and I am not the only one noticing this. And there are more, but I don't feel the need to complain that much. Here be spoilers!

The story revolves around a ring like structure that the alien "protomolecule" has constructed outside the orbit of Uranus. A random ship goes through revealing it is in fact a wormhole. An entire fleet of ships gets in, for various reasons, and again Holden and his crew are in the middle of it all. Yet their roles are quite limited up until very close to the end of the book, the main character here being the sister of Juliette Mao who seems to be seriously unhinged, moving from dangerous psycho killer to kind person who wants to fix things. Quite a lot of psychos in this book. The end opens up a wormhole hub, thus allowing access to the stars. And that is what I take offense with.

You see, the beauty of the series, as made clear by the TV show actually and less by the books, is that it presents a plausible solar human occupation, something close by, that we could achieve in about a century or so, given the magical fusion Epstein drive. It goes into the social, the economic, the political, less in the technical, but still quite a lot. It brings hope. Then there is this alien thing that we don't understand which throws a wrench in our understanding of our place in the Universe. So much to explore there (unintended pun, I assure you). Yet, the end of the third book in The Expanse opens up the stars, even more magically than the Epstein drive, ending the promise of a realistic hard science fiction universe and going towards the implausible and yet so overused "humanity among the stars" trope. I really hope they don't fuck this up for me!

Bottom line: I feel like this book had flaws in its characters, while the story was kept ablaze just by random dangers and conflicts that did not engage me as a reader. Yes, I wanted to see how it all unfurls, but I couldn't care less about the people involved. While it certainly has kept me entertained and it is a good book, I couldn't help begrudging this as well as the ending, which for me ended the promise of exploration and colonization of the Solar system, while going into that all too trodded interstellar medium (hearing me about it it seems like it is seething with stuff, but I mean the literary medium).

P.S. Abaddon was a gate associated to the realm of the dead from the Hebrew Bible.

Friday, 4 March 2016

Blog improvements - feedback requested!

various blog features Hi, all!
I have been working on the blog lately and I want to know what you think of the new format. Changes include: infinite scroll in the main page for more than 800px width, being able to choose in Tools your own color theme or custom font - including for dyslexia, better thumbnail support for list pages, style improvements, testing for various browsers. Let me know by commenting, using the chat or open the blog and start typing...

Thanks!

Thursday, 3 March 2016

Caliban's War (The Expanse book 2), by James S.A. Corey

Book cover The second book of The Expanse is much better written than the first, however the story is a little weaker. There are more of the details one would already be familiar with from the TV show, the character of Chrisjen Avasarala is introduced and chapters are written from the perspective of many more characters than just Miller and Holden. That means there are many more chances to completely dislike a chapter if you hate the character. For me, that character was Prax, someone who would endanger everybody and himself with random emotional outbursts. Perhaps he was put there just to offset the slightly similar behavior of Holden, who now looks like the paragon of professionalism in comparison.

The plot revolves around yet another alien infestation, this time on Ganymede, only it is not clear who or what is actually responsible. The already angered Mars and Earth navies use this as a pretext to attack each other, while the Rocinante crew find themselves agents of the OPA, sent to find out what happened. As opposed to Leviathan Wakes, the book adds two major female characters, Avasarala and Bobbie, a Martian marine, and a lot of the story is about their interaction. In truth, what the Rocinante does on Ganymede is almost inconsequential until they make contact with the two women, which felt like the main characters of the book, if I had to choose. This is also a sign of a better built world, in which one has to struggle to identify the lead characters.

While the book was clearly better (some even suggest it is the best in the series), I didn't find myself attracted so much by the story. Instead of a mystery, like in the first, we pretty much discover from the beginning what is going on and only halfheartedly root for the characters to get in the same position the reader has been all along. I like Avasarala's character, but in order to show how badass she is, we have to go through all the political machinations in the UN which I couldn't care less about. Bobbie was slightly more interesting, but she starts off with such low confidence that until she gets to embrace her role there is so much filler. And Prax... don't get me started on that asshole! He is central to the Rocinante crew quickly finding out what has happened, but for the rest of the book he just drags along. He would have been a perfect character to be killed off, adding to the darkness of the tale.

And I think this is where the books and the TV series diverge the most. While the show is perfectly content to show a dark, hopeless world, the books fight to maintain some sort of feeling of normalcy, of hope, leading to reasonably happy endings. The show recognizes that in a Solar System built on exploitation, armed spaceships and politics there is no hope for the little man, there is no silver lining, there are just people trying to survive while colossal forces push them around like leaves in the wind: another reason to watch the series, at least the first season, before starting reading the book.

Bottom line: Caliban's War, by James S.A. Corey, contains no reference to a character called Caliban, which is a Shakespeare character. In the play The Tempest, Caliban is a part-human monster and slave who rebels against his masters. Even starting from the title, the authors spill the beans on what the story is all about. While I enjoyed the book and now I am reading the third one in the series, I can't help wishing they would have maintained the tension and mystery of Leviathan Wakes.

Sunday, 28 February 2016

Leviathan Wakes (The Expanse #1), by James S.A. Corey

Book cover I absolutely love the TV series The Expanse and so, after ten torturous weeks in which I would alternatively get filled with joy at the release of another episode, then fall into despair when it ended, I've decided to cut out the middleman and read the damn book. And now that I've read it, I have to say that I am really glad to have seen the show first. It's not that it is a bad book - it is not, it's very good - but the show is better and having the characters in the series blend with the ones on the page is turning them into something more fleshed out, more complex. And I am not the only one thinking that.

For example, in the book the viewpoint alternates, chapter by chapter, between Miller and Holden. The chapters don't even have other titles other than these two names. In the book Naomi is a slight romantic interest, but nothing more than that. Amos is just there, doing stuff. Alex is barely fleshed out. It is Holden who is the undisputed captain of the Rocinante and that's it. Similarly, Miller's partners or even Anderson Dawes are just shadows of the complex characters they appear in the TV show. One of the things that I really loved about the show was that it was reasonably accurate scientifically and I kind of thought the book would be even more detailed about it. In the contrary, it was not. The authors even said in an interview that they never intended to make a hard sci-fi thing, but just to tell the stories of people in the less used fictional period between stuck-on-Earth and interstellar humanity. The weird language melange that is shown in the TV series is only vaguely mentioned in the books. Also the Earth lady in the show is not in this book at all.

But enough about the show. Leviathan Wakes is the first in The Expanse series of more than five books, written by James S.A. Corey, which is actually a pen name for Daniel Abraham and Ty Franck, both collaborators of George R.R. Martin (Franck was his personal assistant, for example). More than five books because there are also some interstitial short stories and I am sure they are going to write some more stuff. The plot of the book is about people living and working in space. You have densely populated Earth, a colonized Mars that is undergoing terraforming and the Belt, people living on the large asteroid belt between Mars and Jupiter. And of course, people being people, they hate each other. Enter an unknown entity that lights the powder keg for reasons unknown that are slowly revealed as the book goes on.

Miller is the typical noir detective, cynical, not trusting, obsessive to the extreme and trying to prove to the world and himself that he's still "got it". Holden is the typical good guy, wanting to save everybody and hoping that all will be well if people just know the truth. Their dynamic is interesting, but for me the story was more captivating when they hadn't met each other. The first season of the show ends when the book is about half way through, but from then there is a period of inactivity, one of those parts when everybody knows what is going on and still they have to go through the movements. In real life this is where the role of the characters would be over, but since it is a book, the same characters continue the story, although it feels a bit disconnected. The ending of the book is epic, in its grand scale, but almost boring from a literary standpoint.

Bottom line: I will continue reading the next books of The Expanse, however I have to say that I am shocked at the difference in quality between the show and the book. Probably it is much easier to do that when you have good actors carrying the load and a lot more book material to work with before you start envisioning your world, but still awe is the feeling I am getting from the TV show.

Saturday, 20 February 2016

Vita de Vie - Bucuresti - 20 Februarie 2016 - 20 de ani de Vita de Vie

If there is anything that I am forced to say about Adrian Despot, the frontman of Vita de Vie, is that he is a true artist. The concert tonight was spot on, even if I am not a fan of the band. The guest bands were pretty good, too, but I have to admit that for most of them I was waiting for them to stop playing so I can listen to the great playlist from DJ Hefe. The audience was really mixed, ranging from little kids to old people. It felt great to see all these people singing along and reliving some of the greatest hits of the band.

I started watching the concert online. It was kind of extreme to go there at 16:00 and stay until 23:00, especially since I was worried about the food/drink/toilet situation and there was an afterparty as well. I have to say that all my worries were for naught. Really decent access to the food and drink stands and there was no queue at the toilets outside. Of course, the drinks and food were shitty and overpriced, but that was to be expected. It also was a really wonderful thing to stand in the middle of a crowd of people and not feel like I was smoking a cigar. The law against smoking in public places has finally reached Romania so it felt really wonderful.

By the time we got to the concert hall - umm, heated tent, but it was better than it sounds - the last band before Vita de Vie was playing, the rather good Relative, from Cluj. Energetic, professional, kind of bad public speakers, but they have time to improve. They were pretty emotional about their first venue in Bucharest and performing before so many people, so they were sweet. Then the main show started, with light shows, projections and a volume that felt like twice as loud as the bands before. My ears are still ringing.

Unfortunately something happened that ruined my evening, so I went home after the concert, rather than go to the after-party at Fabrica. I wish I was in the mood for that, but well, shit happens. So yeah, the show was great, the music pretty good - although I felt like the band would have done a better job with another lead singer :) The point is that Vita de Vie, like any other band - let's be honest, is a project. Individual people don't count unless they push the project further, make it better somehow. Adi Despot made that obvious when he called the previous members of the band to play some songs, as well as some collaborators in sideprojects started by current members of the band. Like him or not, he did bring showmanship to the project and he deserves to be the frontman.

Bottom line, I was impressed by the way the concert was organized (I am used to those really bad things where people just stand brushing against each other, suffocating in smoky improperly ventilated places, trying their best not to slip into the beer and piss left by people who couldn't get fast enough to the few malfunctioning toilets provided). I was also impressed with the guest bands, doing a really professional job, even if they have a lot to learn still.

You might be interested in the Facebook link of the event.

Thursday, 18 February 2016

Firebase - Queries

Firebase logo In the previous post I was discussing Firebase, used in Javascript, and that covered initialization, basic security, read all and insert. In this post I want to discuss about complex queries: filtering, ordering, limiting, indexing, etc. For that I will get inspiration (read: copy with impunity) from the Firebase documentation on the subject Retrieving Data, but make it quick and dirty... you know, like sex! Thank you, ma'am!

OK, the fluid interface for getting the data looks a lot like C# LInQ and I plan to work on a Linq2Firebase thing, but not yet. Since LInQ itself got its inspiration from SQL, I was planning to structure the post in a similar manner: how to do order by, top/limit, select conditions, indexing and so on, so we can really use Firebase like a database. An interesting concept to explore is joining, since this is an object database, but we still need it, because we want to filter by the results of the join before we return the result, like getting all the transaction of users that have the name 'Adam'. Aggregating is another thing that I feel Firebase needs to support. I don't want a billion records in order to compute the sum of a property.

However, the Firebase API is rather limited at the moment. You get .orderByChild, then stuff like .equalTo, .startAt and .endAt and then .limitToFirst and .limitToLast. No aggregation, no complex filters, no optimized indexing, no joining. As far as I can see, this is by design, so that the server is as dumb as possible, but think about that 1GB for the free plan. It is a lot.

So, let's try a complex query, see were it gets us.
ref.child('user')
.once('value',function(snapshot) {
var users=[];
snapshot.forEach(function(childSnapshot) {
var item=childSnapshot.val();
if (/adam/i.test(item.name)) {
users.push(item.userId);
}
});
getInvoiceTotalForUsers(users,DoSomethingWithSum);
});


function getInvoiceTotalForUsers(users,callback)
{
var sum=0;
var count=0;
for (var i=0; i<users.length; i++) {
var id=users[i];
ref.child('invoice')
.equalTo(id,'userId')
.orderByChild('price')
.startAt(10)
.endAt(100)
.once('value',function(snapshot) {
snapshot.forEach(function(childSnapshot) {
var item = childSnapshot.val();
sum+=item.price;
count++;
if (count==users.length) callback(sum);
});
});
}
}

First, I selected the users that have 'adam' in the name. I used .once instead of .on because I don't want to wait for new data to arrive, I want the data so far. I used .forEach to enumerate the data from the value event. With the array of userIds I call getInvoiceTotalForUsers, which gets all the invoices for each user, with a price bigger or equal to 10 and less or equal to 100, which finally calls a callback with the resulting sum of invoice prices.

For me this feels very cumbersome. I can think of several methods to simplify this, but the vanilla code would probably look like this.

Firebase - a free Javascript/Rest accessible cloud no SQL database - Introduction

Firebase logo I have been looking for a long time for this kind of service, mainly because I wanted to monitor and persist stuff for my blog. Firebase is all of that and more and, with a free plan of 1GB, it's pretty awesome. However, as it is a no SQL database and as it can be accessed via Javascript, it may be a bit difficult to get it at first. In this post I will be talking about how to use Firebase as a traditional database using their Javascript library.

So, first off go to the main website and signup with Google. Once you do, you get a page with a 5 minute tutorial, quickstarts, examples, API docs... but you want the ultra-quick start! Copy pasted working code! So click on the Manage App button.

Take note of the URL where you are redirected. It is the one used for all data usage as well. Ok, quick test code:
var testRef = new Firebase('https://*******.firebaseio.com/test');
testRef.push({
val1: "any object you like",
val2: 1,
val3: "as long as it is not undefined or some complex type like a Date object",
val4: "think of it as JSON"
});
What this does is take that object there and save it in your database, in the "test" container. Let's say it's like a table. You can also save objects directly in the root, but I don't recommend it, as the path of the object is the only one telling you what type of object it is.

Now, in order to read inserted objects, you use events. It's a sort of reactive way of doing things that might be a little unfamiliar. For example, when you run the following piece of code, you will get after you connect all the objects you ever inserted into "test".
var testRef = new Firebase('https://*******.firebaseio.com/test');
testRef.on('child_added', function(snapshot) {
var obj = snapshot.val();
handle(obj); //do what you want with the object
});

Note that you can use either child_added or value, as the retrieve event. While 'child_added' is fired on each retrieved object, 'value' returns one snapshot containing all data items, then proceeds to fire on each added item with full snapshots. Beware!, that means if you have a million items and you do a value query, you get all of them (or at least attempt to, I think there are limits), then on the next added item you get a million and one. If you use .limitToLast(50), for example, you will get the last 50 items, then when a new one is added, you get another 50 item snapshot. In my mind, 'value' is to be used with .once(), while 'child_added' with .on(). More details in my Queries post

Just by using that, you have created a way to insert and read values from the database. Of course, you don't want to leave your database unprotected. Anyone could read or change your data this way. You need some sort of authentication. For that go to the left and click on Login & Auth, then you go to Email & Password and you configure what are the users to log in to your application. Notice that every user has a UID defined. Here is the code to use to authenticate:
var testRef = new Firebase('https://*******.firebaseio.com/test');
testRef.authWithPassword({
email : "some@email.com",
password : "password"
}, function(error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully with payload:", authData);
}
});
There is an extra step you want to take, secure your database so that it can only be accessed by logged users and for that you have to go to Security & Rules. A very simple structure to use is this:
{
"rules": {
"test": {
".read": false,
".write": false,
"$uid": {
// grants write access to the owner of this user account whose uid must exactly match the key ($uid)
".write": "auth !== null && auth.uid === $uid",
// grants read access to any user who is logged in with an email and password
".read": "auth !== null && auth.provider === 'password'"
}
}
}
}
This means that:
  1. It is forbidden to write to test directly, or to read from it
  2. It is allowed to write to test/uid (remember the user UID when you created the email/password pair) only by the user with the same uid
  3. It is allowed to read from test/uid, as long as you are authenticated in any way

Gotcha! This rule list allows you to read and write whatever you want on the root itself. Anyone could just waltz on your URL and fill your database with crap, just not in the "test" path. More than that, they can just listen to the root and get EVERYTHING that you write in. So the correct rule set is this:
{
"rules": {
".read": false,
".write": false,
"test": {
".read": false,
".write": false,
"$uid": {
// grants write access to the owner of this user account whose uid must exactly match the key ($uid)
".write": "auth !== null && auth.uid === $uid",
// grants read access to any user who is logged in with an email and password
".read": "auth !== null && auth.provider === 'password'"
}
}
}
}

In this particular case, in order to get to the path /test/$uid you can use the .child() function, like this: testRef.child(authData.uid).push(...), where authData is the object you retrieve from the authentication method and that contains your logged user's UID.

The rule system is easy to understand: use ".read"/".write" and a Javascript expression to allow or deny that operation, then add children paths and do the same. There are a lot more things you could learn about the way to authenticate: one can authenticate with Google, Twitter, Facebook, or even with custom tokens. Read more at Email & Password Authentication, User Authentication and User Based Security.

But because you want to do a dirty little hack and just make it work, here is one way:
{
"rules": {
".read": false,
".write": false,
"test": {
".read": "auth.uid == 'MyReadUser'",
".write": "auth.uid == 'MyWriteUser'"
}
}
}
This tells Firebase that no one is allowed to read/write except in /test and only if their UID is MyReadUser, MyWriteUser, respectively. In order to authenticate for this, we use this piece of code:
testRef.authWithCustomToken(token,success,error);
The handlers for success and error do the rest. In order to create the token, you need to do some cryptography, but nevermind that, there is an online JsFiddle where you can do just that without any thought. First you need a secret, for which you go into your Firebase console and click on Secrets. Click on "Show" and copy paste that secret into the JsFiddle "secret" textbox. Then enter MyReadUser/MyWriteUser in the "uid" textbox and create the token. You can then authenticate into Firebase using that ugly string that it spews out at you.

Done, now you only need to use the code. Here is an example:
var testRef = new Firebase('https://*****.firebaseio.com/test');
testRef.authWithCustomToken(token, function(err,authData) {
if (err) alert(err);
myDataRef.on('child_added', function(snapshot) {
var message = snapshot.val();
handle(message);
});
});
where token is the generated token and handle is a function that will run with each of the objects in the database.

In my case, I needed a way to write messages on the blog for users to read. I left read access on for everyone (true) and used the token idea from above to restrict writing. My html page that I run locally uses the authentication to write the messages.

There you have it. In the next post I will examine how you can query the database for specific objects.