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.

About obesity

I am taking the opportunity of being at CMU for a semester and attending a course on behavioral economics and public policy. Behavioral economics is a topic that caught my attention a while ago and it’s been interesting to see it under the lens of public policy. The course is quite American-centered, and being a non-American (or “alien”, as the government likes to call me) makes it only more interesting. I am trying to understand what is the mindset, what is the “normal” around here, and I am still in awe every now and then. It’s a good state to be in. But anyway…

Today in class the subject of obesity was briefly mentioned. It is seen as a public health problem, and we were studying ways (read, public policies) to motivate people to loose weight. But that’s treating the symptom, not the cause. I like to treat causes, seems more effective. So, for the reasons why obesity is a problem, it was mentioned: decrease in food prices (specially unhealthy food), lack of time (arguably not true, we just suck at time management), sedentary lives, working parents and larger portions (why America? why??). We might add dining out and drinking soda like crazy to that list, as discussed here. Fair enough. These all look like reasonable reasons for a less healthy diet and consequent increase on obesity. Then I had an epiphany: those reasons are not America-exclusive. People are more stressed everywhere, both parents are working everywhere, sedentary lives are everywhere, cheap fast food and soda is available everywhere. So what creates this enormous demand for big portions of deep fried chicken in America specifically? [1]

Unfortunately I do not have an answer for that. What I know is that the unhealthy eating seems to be an acceptable thing. I never saw so many ads for food as I see it on TV here. Really. If you are ever in the US and have a chance to watch some TV, do it. Even for half an hour. It is an interesting experience (not only because of the food ads). I have the feeling that one in every three ads is about food. And not healthy food: fried chicken, giant burgers, 2 feet (~60 cms) pizza, a burrito stuffed with three types of different melted cheese, pancakes made with buttery croissant dough, chocolate cookies filled with more chocolate and marshmallows… you name it. Ironically, another third fraction of the commercials are dedicated to medicaments. As if it is not enough to bombard people with ads for greasy and processed food, they go to the next level and actually *scorn* healthy eating. Just take a look at this or that. Americans, do you have any idea how absurd it is to have an ad like that? This should have never ever been approved!! I would boycott Domino’s if I ever ate there.

I am not sure if these ads can be counted as a cause or effect of obesity, it is a chicken-and-egg problem. What I know is that regulating such things properly will do no harm, but only good [2]. It’s a no-brainer. On top of motivating people to loose weight, how about cutting on the temptation for eating in the first place?

[1] As a side note, Brazil is also not the healthiest country around. And I lived there, and even so I cannot explain what happens… Seems to be a cultural thing (that needs to change!).

[2] Regulation is needed when people lack the common sense and allow such horrendous ads. Unfortunately, those that make regulations are also people.