2017-09-25

Perl6 CRO - 2

In my first post about Perl6 and CRO I  mentioned I had problems take care of POST and GET messages at the same time.  The problem was a misspelled semi-colon


get -> 'greet', :%zname {
  say %zname:
 content 'text/plain',  'bye';
}
I wrote a colon instead of the correct semi-colon, you see it above say %zname: the result was


Cannot resolve caller say(Hash: DateTime); none of these signatures match:
   (Mu $: *%_)
 in block  at myfstserver.p6 line 26
 in code  at /home/tooljn/.rakudobrew/moar-nom/install/share/perl6/site/sources/1DC86B9F9A31CA5BEE35765E177159BAEDB91AAA (Cro::HTTP::Router) line 79
It took me some four hours to figure this out. If the error message had been a more helpful


%zname: is uninitialized or %zname: does not exist ...
I had probably spotted the problem instantly.

Now  my CRO server works beautifully. CRO seems amazing so far, a hell lot of functionality stuffed in there. Now I only have to learn Perl6. The language is truly great and CRO looks even greater and it is only the first beta version, really looking forward to the next version.

Update:
I just learned the colon I tripped over is an alternative method invocation syntax, which makes my complaint invalid. I need to learn Perl6 before complaining, but thinking before talking is not one of my stong suits, (either😊)

2017-09-20

Object Orientation is not such a good idea

 I found this on youtube https://www.youtube.com/watch?v=QM1iUe6IofM
The speaker expresses much the same ideas and opinions I have about Object Oriented programming. Actually on programming  at large, the speaker offers an alternative the good old procedural style as a better alternative.
I have many times found myself in the same situation the speaker describs when you need to change OO programs.You end up with many classes and interfaces with small code bits scattered all over.



Perl6 CRO and Data Warehouse streaming services

What do you do when you do not have anything to do on a Sunday afternoon?

Why not implement Streaming services for a Data Warehouse? The company’s tool fleet can send performance stats over the net. I get questions about and  requests for Internet of Things, if not daily at least on a monthly basis. Often from apprehensive or perplexed persons asking for bongoDB or Big Data Hadraloop solutions. For some reason they all seem to think they need some new more or less esoteric software to gather and store data from net-connected gadgets. Sunday after lunch I stumbled on this presentation. I liked the idea about building a streaming service of stacked micro services so I had a go with Perl6 Cro. I sat up a streaming HTTP server using Cro, this server receives GET and POST calls and write them to disk as text files. Then there is another service ( a PHP program) picking up these textfiles and inserts them in a MySQL database.
The Data Warehouse streaming services


This is not by far an optimal performant or final solution, it is just a PoC, still my first test indicated it can easily handle 10 transactions a second (nothing in the chain seemed saturated), and it is a persistent solution, all incoming transactions are written to disk and not erased until they are safely stored in the database.
Not bad for a Sunday afternoon. I had some help from Andreas with POST messages and Postman for testing.

This solution is not without problems, CRO is in Beta stage, and I have problems to take care of POST and GET messages at the same time. I do not know Perl6, so I do not know if my Perl6 knowledge is too low, the CRO documentation is not correct or there are bugs in CRO first Beta version. But I’m confident my issues will be ironed out in near future. There are other more mature frameworks, but CRO looks both cool and promising, so I’ll try to stick to it.

I have said many times SQL databases can be used for so called Big Data applications, and I always eat my own dog food. If for some reason it shows SQL databases is not up to the task I switch to something else. The same goes for CRO, but it’s not fair to ditch a Beta software just because you do not understand it, and so far it looks great. (Andreas thinks I should go for a mature production ready alternative though.)