Tuesday, 20 March 2018

Ethnic Cleansing in Afrin

For a while we've been hearing everywhere that ISIS/Daesh were defeated, that they were over. This was almost true, and the main actors in this victory have been the Kurds: the Kurds from Irak and particularly the Kurds from Syria (the heroic YPG/YPJ). Sadly, today ISIS/Daesh has won a battle and is conquering territory again. Along with the Turkish army and with the passive support of Rusia (that has allowed Turkey to enter the Syrian-Kurdish airspace to conduct airstrikes that included hospitals) they have captured Afrin, expelling the YPG/YPJ forces and causing the exodus of most of the Kurdish population, fleeding for their lives.

You could say that I'm lying, that it's not ISIS, but the FSA, the "Syrian rebels" who have invaded Afrin. Well, that's the name they are using, but names aside, they are a conglomerate of different Islamist factions put together by Erdogan. Some of them come from Al-Nusra, many of them from ISIS, some of them from whatever stupid name a bunch of Islamist beasts had decided to use. You can read it here

One former Isis soldier has told the journalist Patrick Cockburn: “Most of those who are fighting in Afrin against the YPG are Isis, though Turkey has trained them to change their assault tactics.

The thing is that they are all Islamist scum seeking revenge against those who had managed to defeat them before, thirsty for the blood of anyone that does not adhere to their vision of Islam (and Kurds are either moderate muslims or non religious). The Kurdish population is at serious risk of being slaughtered by these Islamist rats. Will we see again images of Kurdish/Yazidi women being sold as slaves? To what extent the ethnic cleansing orchestrated by Erdogan will be conducted? Will it be enough with just expelling the Kurds of the territory or will they be massacred? Turks really excel at conducting genocides, this, along with invading, looting and the slave trade are the main contributions of the Turkish people, the Ottoman beasts, to Human History.

You really must read this article, and this other one clearly explains why the Kurds had no chance to resist this invasion and talks about what can come next. This one has almost made me cry.

Once againg the Kurds have been betrayed and abandoned by the West, that has closed its eyes to these tragic events. I think now they have to be ready for the next treason. The DFNS seems like a risky bet to me. I think Kurds should not trust Arabs (well, nobody should trust Arabs), and of course they must not trust Turkmen, they should abandon the idea of this democratic confederation with them. The YPG/YPJ should concentrate their forces in the northern part of the region, where they are the majority, and not allow Arab/Turkmen forces to be there. The only armed forces in the Northen part of of the region should be the YPG/YPJ and the Assyrian militias, and be ready for an attack both from Turkey or from the Arabs.

Outside Syria, Kurds have to be ready and willing to war. I'd love to see Turkey pay for what they have done. I'd love to see each YPG/YPJ martyr killed by Turkish forces or Turkish sponsored yihadist be avenged, 10 Turkish soldiers for earch Kurdish (or international brigadist) martyr, 10 Erdogan supporters for each Kurdish civilian. Anyone that supports the war of the Turkish Islamist state against the Kurds both inside and outside Turkey is guilty. Any Turkish Nationalist that supports Erdogan is in the end an ISIS supporter and is guilty of raping and selling women as slaves, bombing hospitals and cutting throats...

The Turkish Nationalists feel pretty safe because unfortunately they are the majority both inside and outside Turkey. For example in Germany there are 3 million people of Turkish descent for 1 million people of Kurdish descent. For sure some of these Turks have become westernized and condemn the Erdogan Islamist crap, admit the existence of an Armenian Genocide and recognize the right of the Kurdish people to take control of their future... but unfortunately many of the German Turks are Turkish nationalists, Islamists, ignorant beasts... and hence they are the enemy. Of course you have to add to their ranks all the Islamist scum that has invaded Europe. The war between Turkish fascists and Islamists against Kurds in European soil is just waiting to start, and Kurds, given that they are weaker in numbers must be stronger in skills. Kurds have been the vanguard of the fight against the Islamist scum in Levant, now they must be it in Europe now. They have the courage and determination that us, the Europeans "de souche" lack. The Kurdish youth in Europe should be ready for this war. I'd love to see them organizing and training, gathering weapons and setting up underground training facilities. Last weeks have seen some attacks in Germany against Turkish "cultural" centers, mosques managed by the Turkish government, businesses... I hope this is just the beginning, I'd love to see them grow in quantity and quality. I'd love to see how the Islamists that poison our streets are fought and "neutralised", I'd love to see their indoctrination centers burnt to ashes. I'd love to see those Turkish nationalists that after having lived for decades in Germany still consider themselves 100% Turkish and 0% German... to fleed back into their Anatolian paradise... The fight for Kurdish rights and the fight for keeping Europe the land of humanism and freedom must converge as we share targets and enemies.

I've been on the verge of crying when reading about this young British International Brigadist killed by a Turkish airstrike.
Glory to Martyrs, Heroes never die.

Tuesday, 13 March 2018

Async Await Comparison

I think the async/await pair is one of the most "revolutionary" features added to programming languages in the last years. I have to admit that when they were added to C# it took me a while to wrap my head around them, same as with the yield statement. Both cases come down to the same, a method that gets restarted at an intermediate point, a continuation, it seemed like magic until I understood all the compiler magic involved... Hopefully, the way async/await behaves in JavaScript is pretty similar, so most of the tricks you learnt in C# apply also in JavaScript, but there are some subtle differences. I'll write down here some notes on similarities and differences that I guess I'll be revisiting from time to time.

As you know async/await revolves around Tasks in C# and Promises in JavaScript. If we want to return a Task/Promise from an already existing value rather than from a really asynchronous operation (for testing for example), we can do like this:
C#: Task.FromResult("hi");
JavaScript: Promise.resolve("hi");

The previous feature is particularly useful in C# for testing. In C# you can only await for a Task, so easily creating a Task from a value can be pretty usefult. I thought it would be the same in JavaScript, but to my surprise I've realised that in Javascript you can await for any value, I mean, these 2 lines are equivalent:
let res = await Promise.resolve("hi");
let res = await "hi";

In both languages, marking a method/function as async means that the compiler magic will create a Task/Promise as soon as the method is invoked and that Task/Promise will ultimately contain the final result returned from the function or the exception thrown from it. Even if the exception is thrown before any call to await happens in the function (so it's running synchronous), it won't be available until we await for the function.

async function throwExceptionAsync(st){
 throw {message: "crashed"};
 return st.toUpperCase();

console.log("calling throwExceptionAsync");
prs = throwExceptionAsync("hi");
//I get here, so the exception has been wrapped in the promise
console.log("after calling throwExceptionAsync");
console.log(prs.constructor.name); //Promise
//I get the exception in the await 
 res = await prs;
catch (ex){
 console.log("exception: " + ex.message);

calling throwExceptionAsync
after calling throwExceptionAsync
exception: crashed

There's a difference that I found when checking this question in stackoverflow. As I've just said, the compiler automatically creates and returns a Task/Promise for any async method. In JavaScript this Promise will resolve to the value that the function returns, and in C# we'll have a Task<Result> (or Task if the method returns nothing). This means that the code that we write in our async method must return a value, not a Task/Promise of value (as the compiler itself takes care of creating that Task/Promise). This means that in C# we have this:

private async Task<string> GetContentAsync(string url){...}

private async Task<string> FormatAsync(string url){...}

//this is good
public static async Task<string> FormatUrlContent(string url)
 string content = await GetContentAsync(url);
 return await FormatAsync(content);  

//this is not good, it won't compile:
//error CS4016: Since this is an async method, the return expression must be of type 'string' rather than 'Task<string>
public static async Task<string> FormatUrlContent(string url)
 string content = await GetContentAsync(url);
 return FormatAsync(content);  

The second method won't compile because our code is returning a Task<string>, that would get wrapped in the Task that the compiler automatically creates, so in the end we would be returning a Task<Task<String>>.

In JavaScript I was not expecting an error, just that we would get a Promise that would resolve to another Promise that would resolve to a string, but to my surprise the compiler seems to take this into account and returns a Promise that will be resolved when the internal Promis is resolved (so indeed it's doing the same as it does with a call to then that also returns a promise.

async function anotherAsyncMethod(){
 return Promise.resolve("hi");

prs = anotherAsyncMethod();
console.log(prs.constructor.name); //Promise
res = await prs; //this is already the string not a Promise of string
//console.log(res.constructor.name); //String

There's another difference that I'd like to mention, though it's not about async/await, but about Tasks/Promises. In C#, if you want you can block your code (which in general is quite a bad idea) waiting for the result of the async call, by doing either Task.Wait() or Task.Result. In JavaScript, promises lack any blocking method, you can only access the result in a callback function provided to then() (or obviously through await magic.

Friday, 9 March 2018

Asp.Net Core Pipeline

I've been playing around with Asp.Net Core 2 for a while and I pretty like it. Following the examples you can start your application with a few lines of code, as seen here, but what these lines are doing is a real lot and I wanted to get a better view of what's really going on.

In the end we can think of any asp.net core application (the .dll or .exe that we end up with) as a selfcontained web application made up of 3 main components:

  • A Web Server that takes care of receiving http requests and sending http responses
  • "Our application itself" (our controllers and so on) that processes that request and generates a response.
  • The framework code that communicates both components. The communication between these 2 components involves a Request Pipeline where different middlewares are hooked (think of these middlewares as equivalents to HttpHandlers in classic ASP.NET). MVC is one of those middlewares (Websockets is another possible middleware).

Asp.Net core comes with 2 web server components, the multiplatform Kestrel and the Windows only http.sys, but you can implement your own. Reading this excellent post about that, has quite helped me to better understand the different classes involved.

First of all we have an IWebHost. This IWebHost hosts the whole application and is its starting point (IWebHost.Run). We have to tell the WebHost what Web Server to use. We usually do this via the IWebHostBuilder UseKestrel or UseHttpSys extension methods. From the linked article this seems to come down to adding an IServer implementation to the Services collection (the default IOC container). The IWebHost will take care of calling the IServer.Start method, passing to it an IHttpApplication. Then the Web server will be calling IHttpApplication.ProcessRequestAsync with an HttpContext to process requests. What comes to mind is that this ProcessRequestAsync should be starting the processing in the chain of middlewares.

We have set up the chain of middlewares in our Startup.Configure method. This method receives an IApplicationBuilder where we invoke different Use methods to add middlewares. The part that was confusing me a bit is that IHttpApplicationBuilder.Build does not return an IHttpApplication, but a RequestDelegate. This RequestDelegate represents the Request pipeline with all its middlewares. So the IHttpApplication is the glue between the IServer and the RequestDelegate. When trying to figure out this I came across this excellent article that so well describes what I have been trying to explain in this post :-)

Friday, 2 March 2018

TypeScript Inheritance Oddities

In addition to Structural Typing, TypeScript provides some other surprising features (that indeed make sense in part thanks to this Structural Typing).

In "conventional" languages (C#, Java) inheritance is based on this idea:

  • Classes extend classes
  • Classes implement interfaces
  • Interfaces extend interfaces

In Java we have the extends and implements keywords, in C# it's just a matter of vocabulary (we just use ":" for inheritance, both for extending or implementing).

TypeScript comes with 2 surprising features.

  • Classes can implement classes
  • Interfaces can extend classes

I think the idea is that a class can be used as an interface, so it seems to make sense that another interface can extend it, and a class can implement it.

Notice an important detail, while a class can extend only 1 class (so it follows the JavaScript logic of "class to class" single inheritance), an interface can extend multiple classes.

I've checked some stackoverflow discussions and the TypeScript documentation dealing with this topic, but I'll write down here my personal vision on how these feature can be useful.

A class implementing another class (rather than extending it)
As the class implements rather than extends, it's not inheriting the method implementations from the parent, so it will have to implement all those methods on its own (so the parent class is behaving like an interface for you). If you are going to inherit from another class but planning to implement all the methods, using implements rather than extends has a semantic value, it makes it clear that you are not reusing anything from the parent class. In a way this is a patch, cause the right design would have been having defined the interface from the beginning and having both classes implementing it.

An interface extending a class
The interface will inherit the method declarations, but not the implementation. When extending a single class, this again feels a bit like a patch. Let's say you want to define new classes that have the same contract as the "parent class" but that need to implement everything. I's useful then to declare this interface "in between" that inherits from that parent class, it saves you the keystrokes of putting those (empty) method declarations in the interface. This is similar to the first case, and again the good design would have been having defined the interface since the beginning, with all the classes implementing it.
On the other side, if extending several classes, this technique is an alternative to Intersection Types. I mean, these 2 codes would be equivalent:

class Person{

class Animal{

function doSomething (item: Person & Animal){


//or I could do:
//this is fine, an interface can extend multiple interfaces
interface IPersonAnimal extends Person, Animal

function doSomething2(item: IPersonAnimal){


let perAn = {



Notice that other odd extend/implement combinations like a class extending an interface, an interface implementing another interface, or an interface implementing a class are not allowed.

Friday, 16 February 2018


Afflicted has come as a real, enjoyable, surprise. I'd hardly read the review, so I just knew about the "found footage" style. As the story unveils I was getting shocked and amazed, this is one of the most interesting and original approaches to the Vampire genre in a really long while. Derek is one young guy on vacation in Europe for his once in a lifetime (and probably last) trip, that has been turned into a vampire and has no idea of it until the symptons become evident. His reactions and those of his best friend sharing the trip with him, their attempts to try to survive on non human blood, and the despair when finding that only fresh human blood makes the trick....

The story is distressing and frenetic, the locations are nice (Italian coastal villages and Paris!) and the "camera in hand" technique contributes a lot to the anguish that one breaths through the film. By the way, I don't know why this film is considered a "found footage" film, the footage is not found later on, but transmitted in real time to social networks... "found footage" and "self-recorded, camera in hand" are not the same to me.

I've always had a soft spot for vampire stories, in particular those where they are presented as elegant, aristocratic, decadent creatures. (We Are the Night, Underworld...) Audrey, the female vampire that turned Derek, is pretty interesting. I would have loved that she had been more present in the film giving us a better glimpse of her life, but her short appearance at the end is probably the best moment of the film. She decided to turn Derek into a vampire as a gift when she realised that he had a serious health condition threatening to end his life at any moment. The genious moment is when she tries to calm him saying "yes, you have to kill to live, but you can choose who you kill". That's an amazing idea. Normally vampires are either evil ones feeding on any easy victim, or good ones that manage to survive on blood intended for transfusions or some sort of synthetic one. Here we are given the perfect option, leverage that need to kill to eliminate those humans that do not deserve to be alive. Buff, I could immediately think of me as a vampire in Paris (or Toulouse, Marseille, Brussels...) spending the nights bleeding to death as many Salafists as I could find. Buff, in a few years radical Islam would no longer be a threat to our Civilization :-D

Thursday, 15 February 2018


I pretty much enjoyed watching The Insult in the cinema last week. Being a Lebanese film, from a "political" perspective I would prefer it to have been shot in French as original language rather than Arab, but I was lucky that it was the contrary, cause that way it was screened in Arab with French subtitles. With my French (lack of) level, reading the subtitles is much easier than trying to understand spoken French...

Long in short the film is about how a small dispute between a Lebanese Christian and a Palestinian refugee degenerates into a serious problem that ends up turning into a state affair. During this course, it succeeds in showing us the chaos in which Lebanon has lived (and continues to live) for so long. If you think that the conflict in Lebanon is just a matter of Christians vs Muslims, you're pretty wrong, cause there's much more to it: Christians, all the different Muslim sects (Sunnis and Druze, Shia and Alewite), Leftists and particularly important, Palestinians.

When the film starts, the Christian is the bad guay, and the Palestinian the good guy (what unusual...) but as the film evolves and the past is brought to the present, things get much more complex and quite less dichotomic. The deep disdain that the Christian character feels for the Palestinians stems from the fact that he and his family are also refugees in their own country. At the beginning of the Lebanese war alleged Palestinian forces looted and massacred the Christian village where he lived. Everybody knows about the Palestinian drama, but very few people know about the Christian drama, and this is salt over open wounds. As the lawyer says during the trial "no people should have the monopoly of suffering".

The film also reflects how hard is to this day the life of Palestinian refugees in Lebanon (this documentary shows it quite well) but it could give the impression that it's just Christians who are against them. I think this is something beyond religious lines (bear in mind also that some Palestinians are Christians or even non religious), and is much more a Lebanese against "invaders" issue. Bearing in mind that the Presence of Palestinian forces (after Black September) in Lebanese soil was the last (but pretty important) drop that led to the Lebanese civil war, one could understand (but not justify) a certain "animosity" towards Palestinians and a desire of putting them out of the country...

I'm aware of few films about the Lebanese war, basically, the magnificent Incendies and the also rather good Waltz with Bashir, but it seems I can't find any recent documentary about the war itself (not about its consequences in nowadays Lebanon).

Wednesday, 7 February 2018


Destructured assignment (simplify how to return multiple values from a function and assign them to the corresponding variables) is a feature that I had really missed in both C# and Javascript, and it has been added almost at the same time, with a different name and with different behaviour. I'll write a small summary here.

In C# the feature is called Deconstruction and you can use it out of the box returning the new ValueTuple type from your methods. ValueTuple has builtin support for deconstruction. For other types, in order to allow deconstruction the class will have to provide Deconstruct method/s. In both cases, there's a single syntax for the assignment "()". So the thing is like:

static (string name, string city, int age) GetData()
 return ("Didier", "Toulouse", 45);

var (name, city, age) = GetData();
//as the returned tuple has names I can switch the order
(city, name, age) = GetData();

// Compilation Error: Cannot deconstruct a tuple of '3' elements into '2' variables
// (name, age) = GetData();

//so we have to use a discard
(name, _, age) = GetData();

//we can use different names
var (n, c, a) = GetData();

As you can see in the example if you want to assign less variables than the elements in the returned tuple you can use "_" (called discards). Discards make much sense when the variable names you use and those in the returned tuple do not match, or when the returned tuples is not using names, but in the example above, I don't see the reason for getting that Compilation Error and needing the discards, but well, I guess I'm missing something.

In Javascript the feature is called destructuring and we have 2 different syntaxes, "{}" for object destructuring and "[]" for array destructuring. Some basic example:

function getAddress(){
 return {name: "Marseille", population: 1600000};

let {name, population} = getAddress();


function getCities(){
 return ["Paris", "Toulouse", "Marseille"];

let [capital, aero, mediterranean] = getCities();

I think there's not much to say about Object destructuring, but for Array destructuring the main thing to bear in mind is that it can be used for any iterable object, not just for arrays (so probably it would be more clear to call it "destructuring with array syntax"). This means that if we want to implement destructuring in one custom object, same as in C# we use Deconstruct methods, in javascript we'll use the iterable protocol. Let's see an example of how the same object is destructured differently with the object and array syntaxes.

let obj = {
 name: "Francois",
 city: "Marseille"

obj[Symbol.iterator] = function* () {
 yield "item1";
 yield "item2";
 yield "item3";

//object destructuring, can not be customised 
let {name, city} = obj;
console.log("name: " + name + " city: " + city); 


let [a, b] = obj;
console.log("a: " + a + " b: " + b); //a: item1 b: item2

//we can use "discards" ( ,)if we want access to only certain elements (with "holes" in between)
[a, , b] = obj;
console.log("a: " + a + " b: " + b); //a: item1 b: item3

As shown above, discards in javascript use the " ," syntax rather than "_". One interesting feature present in javascript and missing in C# (as far as I know)is destructuring into function parameters.

function printAddress({street, number, city}) {
 console.log(street + ", " + number + " (" + city + ")" );

let address = {
 street: "Republique", 
 number: 45,
 city: "Paris"