Wednesday, August 9, 2017

Tiobe ranking of programming languages (August 2017) commented

And here I am again with my comments about Tiobe ranking of programming languages.

As me may see, Visual Basic .NET is up two positions considering August 2016. And I've been noticing some more questions about it at StackOverflow and some programming groups at Facebook. Don't know yet why is that so, but I would like to listen to some suggestions. Do you believe this is a tendency or a temporary thing?

It is not that PHP and Javascript felt. Visual Basic .NET passed them, just this. Otherwise they would be steady. But until last December Javascript was going up at fast speed. Should we consider that the large number of Javascript libraries appearing everyday are making the environment for this language to complicated?

Ruby is also up two positions, as I had told you it would happen by mid 2016. I believe this is a tendency, not a temporary thing.

Swift is up three positions and this is not surprise to me at all. It is a nice language, with a reasonable learning curve. It will grow even more in the next few months.

Delphi / Object Pascal felt one position and this is no surprise at all.

By July 2016 I was asking why Assembly was going up so fast. I though all that excitement about "Internet of Things" was making it explode. And I think I was right, because I seldom read about this expression anymore and Assembly is falling fast. Four positions since August 2016!

Where is the "Internet of Things"? Fashion comes and fashion goes. I've seen a lot of this in the last 32 years in this area.

"R" is up one position, and Matlab follows the same path up, because Data Science is the new expression in all mouths and brains. Is this a tendency? I still don't know.

Go is up four positions and it is definitely a tendency, at least for a few more years. Not a particularly suitable language to me, but remember... Google, and Google's money, is backing it!!!

Objective-C is falling down. I believe this is related with the rise of React Native and Xamarin for mobile development.

I'd like to hear from you in the comments about all this!

Decks of cards

Given and array of cards like

["9C", "KS", "AC", "AH", "8D", "4C", "KD", "JC", "7D", "9D", "2H", "7C", "3C", "7S", "5C", "6H", "TH"]

how many complete decks of cards may one extract from this array.

This problem was proposed to me and I solved it the following way
Can someone suggest a shorter and/or more efficient solution?

OBS: About the representation of the cards:

9C = 9 of Clubs
KS = King of Spades
AH = Ace of Hearts
7D = 7 of Diamonds

OBS: In the array above there are no complete decks. This array here

["2S", "2C", "2D", "2H", "3S", "3C", "3D", "3H", "4S", "4C", "4D", "4H", "5S", "5C", "5D", "5H", "6S", "6C", "6D", "6H", "7S", "7C", "7D", "7H", "8S", "8C", "8D", "8H", "9S", "9C", "9D", "9H", "TS", "TC", "TD", "TH", "JS", "JC", "JD", "JH", "QS", "QC", "QD", "QH", "KS", "KC", "KD", "KH", "AS", "AC", "AD", "AH", "2S", "2C", "2D", "2H", "3S", "3C", "3D", "3H", "4S", "4C", "4D", "4H", "5S", "5C", "5D", "5H", "6S", "6C", "6D", "6H", "7S", "7C", "7D", "7H", "8S", "8C", "8D", "8H", "9S", "9C", "9D", "9H", "TS", "TC", "TD", "TH", "JS", "JC", "JD", "JH", "QS", "QC", "QD", "QH", "KS", "KC", "KD", "KH", "AS", "AC", "AD", "AH", "2S", "2C", "2D", "2H", "3S", "3C", "3D", "3H", "4S", "4C", "4D", "4H", "5S", "5C", "5D", "5H", "6S", "6C", "6D", "6H", "7S", "7C", "7D", "7H", "8S", "8C", "8D", "8H", "9S", "9C", "9D", "9H", "TS", "TC", "TD", "TH", "JS", "JC", "JD", "JH", "QS", "QC", "QD", "QH", "KS", "KC", "KD", "KH", "AS", "AC", "AD"]

contains two complete decks of cards.

Thursday, June 22, 2017

At the libray

I was tired of programming (Yes, sometimes it happens to me!) and then decided I needed to read a bit to relax.

Libraries are like Paradise to me. Or, better saying, if there is a Paradise, and by any chance I go ther someday, it will be like a library to me.

And there I was, with my noble computer and a few books, trying to decide what would suit me better, when a few teenagers, boys and girls, sat close to me and started studying Math.

Now, if there is something that appeals to me, maybe even more than programming and books, is Math, my old passion. I've been in love with Math since my early childhood.

I was listening and trying not to interfere in their study. Young people must be allowed to make their onw discoveries. Don't meddle with them when they are doing this. Besides, they were doing pretty well. One of the boys was the leader of the pack and this reminded me of myself, 35 years ago, at National Libray in Rio the Janeiro, leading my own team and preparing to enter college with no money to pay for a prep school.

They were suddenly discussing permutations. And they had an insteresting problem related to the permutations of the Portuguese word CONQUISTA (meaning CONQUER in English).

They wanted to know, first, how many permutations this word has. Then how many of these permutations started with a vowel. Then how many would start and end with a consonant. Finally, how many of them would have the letter "C" before the letter "A".

And using Ruby I could give the answers in a few seconds, by using ths program.

Of course I haven't given them the answers. As I said above, I just don't like to interfere with young people learning. They can learn by themselves. But you may notice some interesting uses of Ruby idioms.

Sunday, June 18, 2017

Downloading eBooks with Ruby

I found an excellent resource with books about Artificial Intelligence here.

It happens that nobody wants to download these books one by one, then I decided to create a ruby script to do this.

I'm posting this here just to tell you Ruby is really a general purpose language. You may use it to many different tasks in your system.

Monday, June 5, 2017

JRuby saved my project

Nobody here ignores I am creating my own full-stack web development framework, the Emerald. And this week, during the first tests, I faced a serious problem.

Emerald is ReactJS-based and uses fetch API to get data from the back-end to the front-end. Of course, there are lots of web requests when you are creating a big (and meaningful) page. And it was then that I started getting lots of Error 500.

My logic was flawless! I tested the backed exhaustively, using both RSpec and command line with curl. 100% of requests working fine in both, but lots of failures when testing with the browser.

After one whole day fighting these errors I remembered a discussiong in a StackOverflow question, when a fellow developer with the name Myst pointed me a big problem when serving static files with Ruby: the GIL.

I won't try to explain the GIL here. Better giving you this link, where you may find more information.

Just to summarize, this is a problem related with threads. Threads in Ruby are an illusion, as this article correctly points out. And this problem turns out to be very obvious when a piece of code is receiving lots of web requests per second. Things will break!

But do not despair, 'cause JRuby is here to help!

As you all know, JRuby is a Ruby implementation written in Java. And Java does multithreading in an easy (not really, but hey... it works!) way.

Then, when I installed JRuby and moved my project to it, everything worked really fine!

This is another example of how discussing things with many people may enlighten your work and save your sanity.