Blog

About data

I have recently watched the documentary The Great Hack, which explains the Cambridge Analytica scandal: how they used a great amount of data from facebook to spread biased and fake messages and influence the outcome of Brexit and the US presidential election of 2016. The film focuses a lot on the role of big data-owning corporations such as facebook, google, or amazon (the usual suspects). It hints towards holding these companies responsible for what people do with the data they collect, and sort of portraits them as “evil”, but perhaps too much [1]. It also blames the technology and the “algorithms”, whatever those are. In my opinion, this is a very shallow analysis of what is actually going on, and I think they got it all upside down. Let me break down this problem into three parts.

The technique

People that do not understand what is going on behind the curtains of recommendation algorithms tend to see the spread of targeted manipulative information as an extremely bad thing (which it is), and how music streaming services that suggest music that you like as an extremely good thing (which it is). I am no expert in recommendation systems myself, but I know enough to know that the principles behind these two tasks are basically the same. So blaming and prohibiting the technique itself will mean that a lot of wonderful things we have today will no longer be available. And a huge field of research, which can be used for good, will go away. I don’t think this is a good direction to follow…

The data

Our data is being collected all the time. I know that, you know that, everyone knows that. It is because of this data, and the techniques, that we can talk to our phones, that we can search for a photo by a keyword, that our watches can measure our steps, and many other conveniences that make our lives today very comfortable. The corporations that collect and use the data to develop these wonderful things know how this is sensitive information, and how everything should be super anonymized if it is supposed to go into the hands of others (such as researchers).

In the case of Cambridge Analytica in particular, I think Facebook has actually little blame on this [1]. The story plays out like this. A researcher at Cambridge University developed an app and provided it to Cambridge Analytica. The company, in turn, used this app to do a survey and people had to agree that their data was going to be used for academic purposes. It turns out that, because of the way facebook was designed, the app also collected data from all the friends of the person taking the survey. Now, I think this is a serious design flaw, and whoever saw that, the researcher or whoever was working on this at Cambridge Analytica, should have at least informed facebook about it. Instead, they have exploited this to get all the data, and kept quiet. Needless to say, there was no “academic purpose” there. So facebook’s fault is this design flaw. They have openly apologized for that, and implemented more strict privacy rules (GDPR) since then. However, it is not fair to place the responsibility of how others used this data solely on them.

These big data companies tend to be already protective enough of their data. Ask any researcher that needs data how hard it is to get a fraction of what they have. So it is not like facebook is completely irresponsible and is just allowing anyone to tap into their pool. By the way, the researcher who developed the app was actually a consultant for facebook. Which makes me even more suspicious why he wouldn’t report such a breach in the first place.

The use

This is the crucial point in my opinion, and the point that is most overlooked. The problem, in the end, was not the existence of data or fancy techniques to process it. The problem is how this framework was used. And it is not like it was used for a super novel thing. The data was used for propaganda, and propaganda has been around for centuries. And people warning about the dangers of propaganda have also been around for a while now. For example, this quote from Everett Dean Martin: “Propaganda is making puppets of us. We are moved by hidden strings which the propagandist manipulates.” is from 1929. 1929!

The problem this time is that we had propaganda on steroids. Because of the amount of data Cambridge Analytica had, and the ability to quickly analyse it, they could provide the most targeted and efficient advertisements. If you think about it, this is the dream of *every* advertisement agency. Now, does that mean we should forbid propaganda? Well, I lean towards yes, but I also admit that there is a thing such as good propaganda [2]. So we should not discard it as an activity altogether. One could say propaganda/advertisement [3] should not be biased, but isn’t that an inherent characteristic of it? When people are trying to sell something (a product, an idea, an image), they kind of have to be biased towards that thing.

So what is it about the Cambridge Analytica case that bothered so many people (myself included)? I have had this lingering feeling that it crossed a line. But which line? After thinking a lot about it, I suspect this line is ethics.
First of all, these people were using exaggerated messages, sometimes blatant lies, to attack the opposition. Attacking the opposition is a low blow of desperate people, specially in politics [4]. This is a dirty move which I find disgusting. You want to advertise yourself? Fine. Show off your advantages, don’t hit the adversary. That makes me very angry.
Secondly, this was targeted to influence people on important decisions, which ideally should be taken with the minimum amount of bias. The only way people are going to start to think critically, is if they have to in order to form an opinion. If they are bombarded with information from only one side, it is brainwashing. I can see why a politician or government would think this is a good thing (“I know what is best for the people, I am just making them realize faster”). However, if you stop to really think about it, this is a disservice for the society as a whole. It simply creates citizens that follow the herd, and are lazy to think for themselves [5].
At this point, one possible solution would be to forbid advertisement related to elections and any issue that would affect society as a whole. Honestly, I think this would be a good thing, and it could solve many problems we face today in a democratic process (not only the one presented here). But I need to think more about this one.

Ultimately, this whole situation is much more complicated than portrayed in “The Great Hack”. There are fundamental problems that we have been facing for many years now, it is simply exacerbated by the effectiveness of a new method. The issue, as I see, is not the method in itself, but the fundamental problem of advertising/propaganda. Where do we draw the line of good/acceptable propaganda, and unacceptable one? Who should be responsible for regulating this? As usual, there is a whole area of study about persuasion, advertisement, etc. As usual, we will only pay attention and try to solve it when things explode and it becomes obvious that this is the problem. We never learn…

[1] And I hate Facebook…
[2] Government funded campaigns for vaccination, anti-tobacco, more exercises, etc.
[3] I am using the two words interchangeably, since it is quite debatable what distinguishes one from the other. In Portuguese, for example, there is only one word to describe what would be two different things for an English speaking person.
[4] 11 years ago, this was an issue in the election of a mayor where I come from. I wrote about here (in Portuguese), after hearing an admission that, still today, makes me furious.
[5] For example, do you think I just thought about all of these things at once? It took me weeks thinking about the documentary, discussing it with other people, and researching, until I formed this opinion (which could be changed in light of new information).

About handmaids

I was visiting a friend recently and she happened to have a copy of “The Handmaid’s Tale” at her place. I had heard about this book before, and my friend also recommended it, so I decided to read. I finished it surprisingly quickly… Not only because I needed to give the book back šŸ™‚

If you have not read the book, don’t read this post further. Go read it and make your own opinion about it.

The language is easy and the story kept me interested. Not in a Sherlock Holmes kind of way, where we are eager to find out who committed the crime, but in an Alice in Wonderland way, where we just appreciate the surreality of the situation. Except that it is not such a nice and fantastic world, but a scary post-apocalyptic one.

The story takes place in a near-future totalitarian state, which is (apparently) at war with neighbors, and follows a nuclear disaster that left a lot of the land unusable. As with any novel about a totalitarian state (such as 1984 and Brave New World), the lack of individual freedom is the focus here: everyone has their role in society pre-assigned, and no deviation is possible, specially questioning or going against the status quo. Different from the aforementioned books, this one focuses in particular on the role of women in this dystopian society. There are three “classes” of women: the wives, the child-bearing, and the cooks. Men should have at least one of each class (with some exceptions). The story is told from the point of view of one of the child-bearing ones. She contrasts her previous life (not too different from the lives we lead today) with the current one, the training she had to go through, and the struggles to maintain her sanity. She “belongs” to a “commander”, a seemingly high-ranking official, who, at some point, breaks the protocol and starts to have a more personal relationship with the protagonist. This is hardly the main point of the story, but I found one of these interactions particularly interesting. In the excerpt below, the commander attempts to justify the new imposed system on women:

We’ve given them more than we’ve taken away, said the Commander. Think of the trouble they had before. Don’t you remember the singles’ bars, the indignity of high school blind dates? The meat market. Don’t you remember the terrible gap between the ones who could get a man easily and the ones who couldn’t? Some of them were desperate, they starved themselves thin or pumped their breasts full of silicone, had their noses cut off. Think of the human misery.

He waved a hand at his stacks of old magazines. They were always complaining. Problems this, problems that. Remember the ads in the Personal columns, Bright attractive woman, thirty-fiveā€¦ This way they all get a man, nobody’s left out. And then if they did marry, they could be left with a kid, two kids, the husband might just get fed up and take off, disappear, they’d have to go on welfare. Or else he’d stay around and beat them up. Or if they had a job, the children in daycare or left with some brutal ignorant woman, and they’d have to pay for that themselves, out of their wretched little paychecks. Money was the only measure of worth, for everyone, they got no respect as mothers. No wonder they were giving up on the whole business. This way they’re protected, they can fulfill their biological destinies in peace. With full support and encouragement. Now, tell me. You’re an intelligent person, I like to hear what you think. What did we overlook?

Than Handmaid’s Tale (Chapter 34)

Indeed, when put this way, it is almost tempting. What a relief it would be to become suddenly free of all these struggles. Not worrying about looking pretty, having the “right” body, face and behavior… Not worrying about finding someone to start a family with, if it will work out or not, if you would be able to raise your kids properly. Rationally speaking, the system guarantees all basic human needs, for all humans. So we see how this would make sense in the head of very pragmatic people.

But very important things were overlooked.

The main character replies: “love”. To which the commander rightfully argues that love might just be something fabricated and imposed on us, as something we *should* feel and how marriages and families work. He points out the fact that arranged marriages were common, and work out just as well.

But in both situations there is a more fundamental principle which is overlooked: freedom. Whether you choose to get married by love, or because your family has found you a suitable partner, the important part is that you *choose*. You choose your partner, you choose the clothes you wear, whether to use make up, have plastic surgery, go to the gym or on a diet. You choose to go out on a date, or ask someone out. You choose to stay married, or to get a divorce.

Or better, you have the impression that you choose.

This situation has got me thinking about the difference between things we choose, and things we think we choose. Unless you live alone in an island isolated from society (in which case you would not be reading this), there are certain expectations about you. This may come from your upbringing, your peers, your friends, and even yourself. Many times we simply internalize these expectations, and live up to them without ever realizing it. Here is a silly example of how this can come about. I recently reorganized my wardrobe and realized I have a disproportionate amount of pink tops. It is by far the most frequent color. Now, do I like pink more than the other colors in particular? Not really… As a girl, I am of course _supposed_ to like pink, and this is how I suspect these tops came about. Some were gifts, admittedly, but maybe half I bought them myself. Since then, I have been more aware of my behavior when I can choose between different colors of the same item. I noticed that my instinct is to invariably go towards pink/purple. Is this because, deep down, I just really like pink, or is it because I was raised always having a lot of pink stuff? I strongly suspect it is the latter…

My feeling is that many people (including myself) make choices according to what is expected of them, and not according to our true selves. These can be as simple as the color of clothes, or as complicated as your career, relationships, values, religion… The problem is that, if we are not true to ourselves, we end up with clothes we don’t particularly enjoy wearing, or worse. Recognizing what is you and what is imposed on you is not an easy task, but it is one worthwhile spending some time on, as this means a lighter and more authentic life.

About mankind

Lately I have been feeling more and more grim about life in general. I think this is a culmination of facts: things I learned, things that happened, things I noticed. It has reached a point where I have very little faith in mankind, and I think that if any stupid leader decides to detonate a nuclear bomb and kill us all, the universe will end up a better place.

This might have started with me learning more about global warming and our environmental footprint. We produce *a lot* of garbage, that needs to go somewhere. It typically ends up in the oceans or landfills around the world, contaminating animals, water, plants, and, eventually, us again (but we kind of caused it, so we deserve). Even with recycling, most of the world’s garbage still ends up in one of those places. And recycling is treating the symptom, not the cause. In practice, we can produce less than half of the garbage we produce if we are just conscious about it. It does not hurt to use our own bags for shopping, use both sides of paper sheets, get a glass water bottle instead of buying the plastic ones, close the tap when washing the teeth or the hands, use less disposable items… among other things.

Then I learned about animal cruelty, which involves killing animals for food, but also for fashion items (of quite questionable taste, really). Turns out that farming for animal production is also a big factor on global warming, and turns out we don’t really need all that meat. Nutritionally speaking, we would still be ok if we ate half of the meat we eat on average. With all these different options of food around, it wouldn’t hurt to go vegetarian three times a week. Concerning fashion items, I don’t see the appeal on leather and furs, so regarding such things as luxury items is complete nonsense as it is. Put on top animal killings, it is an easy “no, thank you”. Animals are also used for testing cosmetics, so reducing the amount of those is not only healthier (for the body *and* mind), but better for the animals.

The fashion industry alone has many other problems. Many brands have sweat shops in less developed countries, where they can get things done cheaper, and don’t need to respond about labor abuse. This practice takes advantage of people that desperately need a job, and are willing to work crazy hours for little pay. Companies need profit and this is achieved in two ways: decreasing the cost for producing clothes and increasing the consumption. On this second front, they bombard us with advertisement every week, creating “trends” to be followed, forcing people to recycle their wardrobe every season unnecessarily and to have a million pieces of clothes. We simply need to realize how manipulated we are being, and start to care less about how we look, and care more about what we do.

By the way, the thing with the profit, exploitation and fake trends is not an exclusivity of fashion, but of many other industries as well. We are manipulated every day by advertisements promising more productive, beautiful, modern, meaningful lives, only so that we will buy the latest release, generate more trash, more environmental impact, and more profit. And we are not happier.

As time passed I became more and more aware of life’s randomness, and how not realizing this can lead to social injustice. If we think that all our success is attributed to our hard work (the myth of meritocracy), then we are willing to bet that anyone could have done what we did. The thing is that, not everyone is at the same starting point. Life is unfair and people are born in all kinds of situations. This can be alleviated by some policies that give the less privileged some benefits.

All of these things alone are not really distressing for me. They are problems, and I like to solve problems. I enjoy thinking about each and every one of them, learning their effects and, mostly, their causes. Many times the underlying cause is rooted on greed, on the need to have profit, and on assigning importance to unimportant measures. Many of the effects have to do with increasing the social gap and manipulation. I think that, if we put our heads together, we could take steps in the direction of improving the situation.

The distressing part, the really really distressing part, is to see how little people seem to care. They care a lot about themselves, the “market”, the “economy”. As long as money is moving, as long as they have the best deal, as long as they can satisfy their immediate needs, who cares about something that happens thousands of kilometersĀ  or years away? Out of sight, out of mind. And so we walk towards the abyss.

 

Some sources:

  1. https://theintercept.com/2018/08/03/climate-change-new-york-times- magazine/
  2. https://truecostmovie.com/
  3. http://www.nationearth.com/
  4. https://www.beforetheflood.com/
  5. https://www.imdb.com/title/tt8457074/?ref_=ttep_ep7
  6. https://www.imdb.com/title/tt8457106/?ref_=ttep_ep19

Facebook and Banks

Just read this article: Facebook in talks with banks to expand customer service

First of all, banks do not need facebook to help them improve customer service. Anyone who has ever interacted with a bank can give a handful of suggestions that would be useful and not involve a social network or another corporation getting access to customer data. I know I did my share of filling in “feedback forms”, but these seem to go to a black hole. Instead, banks would rather collaborate with the company that has been the center of a big privacy scandal for the last year. What could go wrong? Ā¬Ā¬

Second, any decent bank has a chat service for customers, usually in the bank’s website. If American banks do not have that, it is because they are in the stone age of banks. Yes, they are.

Finally, facebook may have access to the account information of some users but will not use that for “advertisement or anything”. Sure, sure…

Adobe and Microsoft

Just got a message from the IT department at work:

Reports have emerged overnight that an Adobe Flash security flaw is being actively used across the Internet to attack and compromise computer systems. The Flash vulnerability affects Windows, Mac, and Linux systems but the exploit is targeting Windows at this time.

The attack comes in the form of malicious Flash content embedded inside an Office document (Word, Excel, PowerPoint) that triggers the Flash security flaw to compromise the computer.

I am laughing inside xD

About the first women in logic workshop

About a month ago I attended the first Women in Logic workshop. I presented the partial results of a paper with Bruno Woltzenlogel Paleo on translations of resolution to sequent calculus proofs. The workshop was open to everyone, but every submission must have been co-authored and presented by a woman. In the end, the audience was composed of mostly women, with one man attending all talks (kudos Francesco!) and another showing up for one of the invited talks. As you may imagine, I’ve had long discussions with different people about this kind of event, before and after. I had my reservations as well. Is closing up in an almost-exclusive event the right thing to do for inclusiveness? What about other minorities? What exactly are we trying to accomplish? If there is a lack of women in logic, what is the root of the problem? I thought it would be worth attending anyway, not only because it was in Iceland, but to see for myself what it would be like. When the program was out, I must say I was a bit disappointed, as there was no space for the discussion of what I thought were the important questions, but only scientific talks. And those were quite diverse (you may imagine the broad range of topics when the only restrictions were logic and co-authored by a woman).

Finally the day came, and as the hours went by and presentations were given, something interesting happened. These women were comfortable. Most of the time, I could not see the usual stiffness, result of nervousness and stage fright, so commonly witnessed during presentations by both men and women in big conferences. The speakers were calm, talking in a usual speed and stopping to explain things on the board or on the slides. They looked confident. The feeling was not that of an aggressive audience, but of a supportive one. So, what changed?

In my view, it was not the fact that there were mostly women in the room. More than that, it was the mindset of the speakers themselves. Somehow they go in front of this audience thinking it will be ok, and then it is ok. Why do they think it will be ok? Maybe because these are other fellow women that get as nervous as they get when presenting to an audience of old white men. Maybe because they can finally relate to the audience. Maybe because they think that women will be less critical and nicer with the questions. Whatever reason you choose, regardless if it is true or not, if it makes you feel more at ease, it works. In the end, it is impossible to predict if the audience will be “nice”, or if you will get mean questions or harsh criticisms (ok, it might become a bit easier to predict once you get to know the people šŸ˜‰ ). All you can do is think of an “it will be ok” reason to calm you nerves. Here are some suggestions that work with most audiences:

It will be ok…

  1. … it is not my PhD defense.
  2. … half of the people will not pay attention anyway.
  3. … more than half of the people are not experts in this area and I probably know more than them.
  4. … it is only 30 minutes of my life.
  5. … I can always reply honestly that I don’t know.

The usefulness of a workshop such as the women in logic one, in my opinion, is to show women that they can do this. They can go there and present and take the questions and criticisms. It is a bit more scary than presenting to the walls of your bedroom, and a little less scary than presenting at a big conference. The crucial thing is to take the next step, and get out of the women-only shell. The last thing we want is to create a clique inside this already small community of logicians in computer science.

As an after-note, lack of security is hardly a women exclusive issue. This makes me think that a larger part of the academic community could benefit from this kind of friendly low-profile workshop.

As an after-after-note, the lack of security and self-confidence is, in my opinion, the main reason why women sometimes do not pursue the careers they want. I have heard more women than men saying “I don’t think I am good enough for this”, and I say it myself sometimes. This is hard to overcome. It is good to remember that there will be people believing in you even when you don’t. Also, don’t try to do everything alone. Hardly everybody does. Ask for help. Ask for people to proof read your first papers, to listen to and give advice on practice talks, to discuss ideas for your projects… you will see how much people are willing to help, and how much you can learn from it.

About the world

When I was finishing my masters and deciding where to go for a PhD, I did what every student in my position would do: ask around for advice. I talked to some of my professors that did do a PhD to find out about their experiences, where they went and so on. Being a theory oriented person, I could see more attractive opportunities in Europe other than the US, and the programs looked very different (from the duration, style, tuition, etc.). When confronted with these options, I got almost unanimously the same argument:

The quality of education in the US will be better, it is a longer phd but you will leave with more opportunities and more knowledge. It will be expensive, there will be sleepless nights, you’ll have no vacations for a long time and will kill yourself to work, but it is worth it. In Europe things are much more relaxed and you will do a lot of tourism. Sure you’ll end with a PhD, but much less worthy.

I found that somehow strange… This was not too great of a case for the US, nevertheless they wanted me to go and sacrifice some years of my life for a title. Suffice to say that I did not apply for any positions in the US… In the end, I got a position in Vienna, Austria, and that’s where I went to.

Looking back, having finished a PhD in Europe and understanding better how the American programs work, I sort of see their point. I am sure you see it as well, so I will not go over that. My intention here is to say what they have not told me (maybe because most or all of them had got a PhD from an American university). Given the choice, I would *never* exchange the years I spent in Vienna and Paris for a PhD from an ivy-league school in the US. Here’s why.

I moved to Vienna alone. It was the first time I was living outside my parents’ house and I started big: other side of the world in a country whose language I did not speak. I not only had to learn how to manage my own life, but how to manage my life in a society completely different from the one I was used to. And do a PhD on my spare time. In trying to adapt, I started looking at life differently. Suddenly answers like “that’s the way things are” or “it’s just how it works” stopped making sense because here I was at a place where things were not like that and, guess what? Everything still works! (Even better sometimes…) The opportunity to travel a lot (Europe is really very small… and a bunch of different countries are just a 3-hour flight away) has contributed to that feeling. Everywhere there was something curious, something different, a new unsaid rule that everyone followed. And as we try to fit in, we test different behaviors on ourselves, and realize that many “defaults” we have can be changed to something that works better, or to something that is more “you”. It is interesting the moment you feel more at home at a place that is completely different from the one where you were born, simply because that is more in line with your values. I feel like those years were a deconstruction and reconstruction of myself, and I feel much more comfortable in my skin today than I did 6 years ago. Hopefully this will only get better with time šŸ™‚

Sure I did learn a lot scientifically as well, and I did get a PhD, and a job. My professors might think that I got lucky. (I think so too). But even if I hadn’t got a position, and was unemployed in Vienna today, still I would not change a thing. I am a resourceful person and I could get a job eventually, even outside academia. What I have learned and how much I have grown during this experience is beyond any career-oriented measurement of success.

You might argue that the same would happen if I had moved to the US, but I don’t think so. We know too much about them. We get their music, movies, series, news, culture… From what I know, life would not be so much different from the life I had before. Also, I have lived in the US long ago. Back then, I did not realize all the nuances and particularities I noticed last semester, when I was living there for a few months again. Since we know so much, it is a hard place to feel like an outsider. Maybe it will be more comfortable, but less eye-opening.

What I want to show now, specially now, is that going to the US does not have to be the ultimate dream or the best/only choice. The world is a big place, and great opportunities are available everywhere. We just need to remember that opportunities should encompass employment *and* life as well.

Adobe is evil

Here’s why:

  1. They have discontinued Linux versions of many (all?) of their software.
    You might think “I do not use Linux, so what?” Well, do you have a mobile device? Tough luck. Adobe has also discontinued FlashPlayer for mobile devices. Imagine that all of a sudden some websites simply stop working because you do not have (and cannot have!) the latest FlashPlayer. Your loss. Who told you not to be the average user? They have also discontinued Acrobat Reader for Linux, which would not be such a big problem if they did not decide at the same time to invent their own pdf formatĀ Ā¬Ā¬ (see next).
  2. They have created their very own pdf format that (surprise surprise) only works on their reader!
    They have taken a completely open and popular format and tweaked it such that pdfs created with Adobe’s products only work on their own reader. And I am not talking about special pdf features, such as forms, those pdfs cannot even be read by another software. You might find this familiar:
    screen-shot-2016-09-29-at-12-46-08On top of that, the concept of backward compatibility has completely escaped them, and forms created on version 10 only work on Acrobat Reader versions 10+, which, of course, are only available for Windows and Mac.
  3. They bypass OS configurationsĀ to prevent users from savingĀ Adobe’sĀ beloved pdf using theĀ original pdf format.
    Once you have Acrobat Reader 10, you can finally open and fill in some stupid form (always a boring task). Then you might want to save it as a regular pdf (even it this means having it no longer editable) to be able to open wherever. It turns out that Acrobat Reader no longer allows you to save as pdf, only as “Adobe pdf”, and goes so far as to bypass the OS configuration and make the option “print as pdf” unavailable. Why would they do that? This is just plain mean.

Unfortunately there are still many businesses using Adobe’s softwares to create forms, and every now and then I need to find a way around it to fill them in and return. It is getting more difficult every time. All I can do is make people aware that they are using a proprietary format for their files, and thus cannot demand that everyone be able to work with the same format. And believe me, I do. If you own a business and need to distribute forms around, please be aware of this problem. Try to use other tools to generate your pdfs (LaTeX! šŸ˜‰ ) or at least make sure that they are being generated in the original open pdf format.

About programming languages

After just being hired by a group that thinks SML is the only true language, I should probably not be writing this… but here we go.

Today I participated in another programming contest. Nothing official, just for the fun of it. And I decided to challenge myself and solve the first problem (a really easy problem) in a different language. My language of choice for quick and dirty coding has always been C++. It can easily read and write on standard I/O, has a bunch of libraries and data-structures available, and you can compile and have an executable file with a simple g++ code.cpp. No weird keywords or classes, no linking of funny libraries, no console, just a plain binary file ready to be run, and most importantly, run fast!

But there are all these fancy languages around, so I decided to go ahead and see how they would perform (or better how I would perform with them). The problem in question was a simple one. Given a very big number (up to 10Ā¹ā¶), we had to transform it in a funny way (reverse and rotate digits — e.g. 6 becomes a 9) and check if the original and the transformed numbers are both primes [1]. The primality test is the first thing that pops out. Maybe I need to implement a fast primality check algorithm? That’s not the case for this problem, the silly one that checks for divisor between 2 and the square root of the number should work just fine (the time limit is 2s). The problem there is the size of the number. Remember that a 32 bit integer can only hold up to 2.147.483.647, a 10 digit number. So we just need to use a 64 bit integer and it should work just fine. Same algorithm.

My first attempt was to implement it on my English of programming languages (not my native language, but another one in which I am quite fluent): OCaml. The code looked nice, apart from some weird castings from int to float and then to int again because, apparently, sqrt and exponentiation only work on floats (what happened to polymorphic functions? wait… it gets worse). After implementing all my recursive functions beautifully, I tested on a few cases and made sure it was working. Then I tested on the biggest possible input and it worked. Great! Submit… runtime error. šŸ™ Turns out that, although my machine is 64 bits, the server is 32, so the integers there were overflowing. All I needed to do is use OCaml’s “long int”. I found two libraries: Int64 and Big_int. Since Big_int had more operations (like sqrt and exponentiation), I went for that one. The problem was that, since I was no longer using int, I was no longer allowed to use + or – or /, no no no. I had to use add_big_int, sub_big_int, div_big_int, and so on. My pretty non-verbose functions were ugly šŸ™ . With that came a million type errors, I had to add castings everywhere and link a library when compiling. The thing was just horrendous.

This was more than one hour into the contest. So I decided to try a different thing.

Integers of arbitrary precision? Let’s take a chance on my German of programming languages (I cannot quite speak it but really wish I could): Python. It took me an hour to write a 50 line code, since I had to kind of learn everything from scratch, but I had a working program. In the meantime I learned the hard way that Python and recursion do not go together. It was working for the biggest possible input, and it is Python, so if it needed a longer integer it would switch at runtime. Great! Submit… memory limit exceeded. What? Reading here and there I decided that using range() was the thing to blame, so I switched to a strange islice thing. Submit… time limit exceeded šŸ™ Come on!

By the time the contest ended I had two beautiful pieces of code in two different languages that just did not work because of technical reasons. Don’t get me wrong, I am sure these languages have their place and are really good for some stuff. But for coding something easy fast and efficiently, I’ll stick with the good old C++.

Out of curiosity I checked what language the other people in the contest were using. Note that these are all people at least 5 years younger than me, possibly 10, still undergrads in CS. And what were they using? C++!! It is quite impressive, since I am pretty sure they learn programming in Python first, and then go ahead to C or ML. They could choose any of the fancy modern languages, but decide to stick with C++. To show that I do not have a biased sample, just check the statistics of websites like codeforces, spoj or UVa.

To think that I learned how to program in Java (it was the latest thing) and nowadays kids are learning how to program in Python (it is the latest thing), the persisting use of C++ says something about it. A colleague referred to C as an honest language. I think C++ is fits this description too. No fancy stuff, it is the thinnest layer between you and assembly code, and it does the job pretty well.

[1] Problem K here.