π6

Perl 6 changes - 2013W20

2013-05-18

This week, the most notable change would be Rakudo sort of working on Java Virtual Machine. It still needs lots of improvements, but it can already run “Hello, world” program, what is important milestone in Rakudo for JVM.

Incompatible changes

Perl 6 specification

STD.pm6

New features

Perl 6 specification

STD.pm6

Rakudo Perl

Niecza

Perl 6 changes - 2013W19

2013-05-11

So, well, what’s new. I’m going to answer - lots of changes and fixes. Even the Niecza, where lately development had slowed down got lots of fixes.

Incompatible changes

Rakudo Perl

Niecza Perl

New features

Rakudo Perl

Niecza Perl

Perl 6 changes - 2013W18

2013-05-04

Perl 6 gets more and more stable, less features are added, and the features that are left are worked on. Also, Rakudo Perl is being ported to JVM.

New features

Perl 6 specification

STD.pm6

Rakudo Perl

Perl 6 changes - 2013W17

2013-04-27

Continuing, still with commit IDs.

Incompatible changes

Perl 6 specification

Rakudo Perl

New features

Rakudo Perl

Perl 6 changes - 2013W16

2013-04-20

It’s sixteen article in the series. The game goes so fast, and I still haven’t done pagination on my website (lazy as always). The scrollbar is still shorter (1 pixel on my PC) than on Planet Six, but most likely because of longer lines.

NQP was bootstrapped on JVM. That means it can compile itself. It still doesn’t support Perl 6 perfectly, because some code still uses pir::, but it progressed really far. Also, the new version of Rakudo Perl, 2013.04 “Albany” was released. Every improvement mentioned here, is in.

I’ve decided to experiment with commit links this time. This way, you can click (or press, or whatever, depends on your device, to get code of this change).

Potentially incompatible changes

Perl 6 specification

New features

Rakudo Perl

Perl 6 changes - 2013W15

2013-04-14

I apologize I forgot about Perl 6 changes article yesterday. This ought not to happen, but it did. As for reason why it happened, well, I guess I will tell you anyway - it’s that game.

New features

Perl 6 specification

Rakudo Perl

Niecza Perl

Perl 6 changes - 2013W14

2013-04-06

You may have noticed may page went down for some time. This appears to be connected to newest domain change. In order to be more… modern, I’ve moved the repository to glitchmr.github.io, but that made entire page to go down. I apologize for inconvience, but it didn’t affected Planet Six, so I think it’s fine.

As always, I’m going to describe changes in Perl 6.

New features

Perl 6 specification

Rakudo Perl

Perl 6 changes - 2013W13

2013-03-30

The month is coming to end, and with that, I’m going to make yet another list of changes.

New features (like anything is other than that)

Perl 6 specification

Rakudo Perl

Perl 6 changes - 2013W12

2013-03-23

I really should optimize my blog layout, so empty intro wouldn’t be ugly. But I guess I’m too lazy to do it right now, so I have to explain stuff. Every week, I list the list of changes in Perl 6 specifications, and its implementations. That’s just everything, boring, I know. Still, it doesn’t look that bad on Planet Six, so I guess I will continue to make these articles :-).

This week, the Rakudo 2013.03 was released. Every change mentioned here was implemented in it.

New features

Perl 6 specification

Rakudo Perl

Perl 6 changes - 2013W11

2013-03-16

I would put nothing here, but the layout of blog would make this look ugly. So, well, like usually I put something here, even if it is meaningless. Just look below to see list of changes.

New features

Rakudo Perl

Niecza Perl

Perl 6 changes - 2013W10

2013-03-09

During making this update, I had lots of problems with Internet. I have managed to load commits history for every repository I check, but I haven’t checked commits. Will update this after Internet access will be more stable.

New features

Perl 6 specification

STD.pm6

Rakudo Perl

Niecza Perl

Perl 6 changes - 2013W09

2013-03-02

I would put a description, but who seriously cares?

New features

Perl 6 specification

Rakudo Perl

I made a pointless webpage

2013-03-01

So, well, I have a VPS, and decided to put a webpage on it for lulz. You can see it at mango.uk.to, and the source (sauce) is available on my GitHub profile.

Just mentioning, not that this site is important. I just wanted to run a web server just to run a web server.

By the way, this blog is also open sauce, you can see its source code on GitHub. It’s full of hacks, but that’s Jekyll for you.

Perl 6 changes - 2013W08

2013-02-23

Now, I’m back to the your regularly scheduled Perl 6 changes article that isn’t. Well, it is, but it’s not. Or something. Rakudo 2013.02.1 was released (well, 2013.02 was released too). The version bump was caused by the fact that NQP 2013.02 had broken native call support.

Incompatible changes

Perl 6 specification

New features

Perl 6 specification

STD.pm6

Rakudo Perl

Niecza Perl

friendly interactive shell

2013-02-22

I’m not sure if anybody noticed, but lately, nothing was happening on my blog. So, I’m going to write an article about friendly interactive shell (fish), the best shell I’ve used ever (it’s my personal opinion, in case you haven’t noticed, see my footer blog). Actually, I think I’ve moved to it half of the year ago or something.

These days, the two popular shells exist - bash and Z shell. I’m aware of that more shells exist - just nobody uses them these days By the way, if you try to find logical fallacy, I agree, cmd.exe and Windows PowerShell are often used, but those aren’t UNIX shells. Oh, and programming language REPLs are often used too (like irb), but they aren’t UNIX shells too.

Bash

The bash shell is standard shell, included in many Linux distributions. It will make you bash your head against the brick wall (pun intended).

One of examples of bash code I could have found is this. And trust me, it’s not the worst thing (thanks, Wikibooks).

# print the powers of two, from 1 to 512:
for ((i = 1; i < 1000; i *= 2)); do
  echo $i
done

Do you see double parens here? This is really strange math syntax that only supports integers. Why double parenthesis? Well, the answer is compatibility with Bourne shell (really, really old shell, usually called sh (but sometimes sh is actually bash, to make you bash)).

Also, you could have noticed keywords do and done. Bash could easily not require do keyword before for loop body. Yet, it’s required. The other strange quirks is that you aren’t allowed to put semicolon after do keyword. Why? I’ve no idea, really. The done word, while I think it’s needed, differs between blocks. For example, if blocks end with fi.

Bourne again shell has lots of strange syntax you really wouldn’t ever use. For example, bash has $'' syntax. It unescapes escape sequences inside. The strange part is '' in bash doesn’t do any processing at all, yet $'' does. Bash also has $"" syntax, but it doesn’t do escape processing - instead it uses gettext to translate string inside.

# Prints 'Hello world.', with new line in middle.
echo Hello$'\n'world.
# Prints 'Hello\nworld.', literally.
echo Hello$"\n"world.

Consistency in bash is even worse than in languages such as PHP. There are many ways to do something, but none of them are obvious. And I mean that, none. Expanding bash is adding new syntax that totally doesn’t make sense, but was a syntax error in previous versions. $ sign is used for many features that have nothing with variables.

Also, bash integrates many programs in it that really shouldn’t be inside. For example, echo.

[glitchmr@pineapple ~]$ echo --help
--help
[glitchmr@pineapple ~]$ which echo
/bin/echo
[glitchmr@pineapple ~]$ /bin/echo --help
Usage: /bin/echo [SHORT-OPTION]... [STRING]...
  or:  /bin/echo LONG-OPTION
Echo the STRING(s) to standard output.

...

NOTE: your shell may have its own version of echo, which usually supersedes
the version described here.  Please refer to your shell's documentation
for details about the options it supports.

Report echo bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
Report echo translation bugs to <http://translationproject.org/team/>
For complete documentation, run: info coreutils 'echo invocation'

The /bin/echo on my system is GNU echo. The bash on my system is GNU bash. They were both made by GNU. Yet, they act differently. Is there a better recipe for failure than program that actually isn’t called because your shell is “clever”.

It’s not just echo. Many commands are implemented in shell, when they should be implemented outside shell. For example, pwd. Why exactly? To confuse you when dealing with recursive structures.

[glitchmr@pineapple ~]$ mkdir recursion
[glitchmr@pineapple ~]$ cd recursion/
[glitchmr@pineapple recursion]$ ln -s . recursion
[glitchmr@pineapple recursion]$ cd recursion
[glitchmr@pineapple recursion]$ pwd
/home/glitchmr/recursion/recursion
[glitchmr@pineapple recursion]$ which pwd
/bin/pwd
[glitchmr@pineapple recursion]$ /bin/pwd
/home/glitchmr/recursion
[glitchmr@pineapple recursion]$ 

The shell outright lies about your location. You’re in /home/glitchmr/recursion. Why shell does that? Well, it does that to not confuse you when typing cd ... And indeed, if you type cd recursion/recursion, and cd .. after that, you will end in recursion directory, not the directory where you created the first recursion directory.

Symbolic links in UNIX are simply redirects. If you made a symbolic link to /usr/share/hell, you shouldn’t expect that cd .. made after following link follow return you anywhere that isn’t /usr/share. Yet, implementation of symbolic links in bash lies.

The lie is obvious after using anything that isn’t bash builtin. For example, ls .. will always show contents of /usr/share, even if you made symbolic link in /tmp/heaven. Yet, cd .. will return to /tmp/heaven.

By the way, in case you ask, cd is also a builtin. But that’s acceptable, because external command cannot change environment of caller (such at PATH). So it has to be a builtin. Yet, somehow, some people are still confused.

Z shell

Z shell is a shell that is way better than bash. Well, if you configure it properly. It’s a shell that appears to have some compatibility with Bash scripters (for example $'' syntax works, but $"" doesn’t (or rather, it returns literal ’$’ and contents of "")).

Z shell has lots of features. In fact, the author is “not aware of a major interactive feature in any other freely-available shell which zsh does not also have (except smallness)”. Something that would be sane default actually isn’t default. In fact, with default settings it mostly works like bash.

For example, completion. By default, Z shell only completes file names and command names. If you will type sudo apt-get install, press space and then press Tab, it will give you file names. Useful? I don’t think so.

Of course, the option to enable better Tab completion is possible to turn on. It’s just not default. Why the shell would have default that don’t make sense. Simiarly, by default Tab completion cannot expand globs. Yet, it’s possible to enable.

When you start Z shell for first time, you see the configuration wizard (called zsh-newuser-install). The problem is, it’s the most non-user-friendly thing I’ve seen. It asks about minor details you don’t care about, without proposing any useful default. For example, the maximum number of errors you can make for the command to be still proposed in error message. I just have pressed Enter, and the response is “Please enter a number”. Do you think I care about this?

Actually, as far I know, nobody actually uses this wizard. In most cases, zsh is configured using so called oh-my-zsh. What it is actually? Well, it’s a config script with sane things configured by default. Yet, it has got 8,648 stars on GitHub and 3,326 forks as I’m writing it.

Yes, it’s just ZSH config file that has things that should be default, but they aren’t. Oh, and plugins array that contains list of plugins that mostly make aliases and completion adders that aren’t in main zsh (like CoffeeScript). For example git plugin adds aliases like gc for git commit -v.

I don’t know about you, but I don’t like programs which take 4 hours to configure. Z shell is one of these. oh-my-zsh makes the job easier, but I still don’t think it’s worth wasting the time. Perhaps if fish wouldn’t exist, it would be worth it.

friendly interactive shell

Z shell, aside of totally insane configuration isn’t a bad shell (if I would want to talk about bad shells, it would be csh or cmd.exe). friendly interactive shell is as good as Z shell (with good Z shell configuration), except without having to configure it.

In fact, most of things cannot be configured. You cannot configure nonsense like maximal history length (by design). You cannot configure interpretation of numbers starting with 0 as octal (you can in Z shell - I have no idea why Z shell even allows you to type “echo 010” to get “8” when configured to do so - but it does). You cannot disable file globs.

Remember .bashrc/.zshrc configuration file? You won’t need it. The colors and themes can be easily configured using a web service (but if you prefer, you can use set command directly).

For example, if you want to configure your EDITOR to be vim, you can run the following command.

set -Ux EDITOR vim

The -U modifier means that this value is stored between session. The -x means that this variable is exported to programs ran by shell. After you have done that, your variable magically appears in every fish session.

Adding new functions is also easy. It’s enough to type funced function-name. After

Fish also offers features I haven’t seen in other shells, like syntax highlighting. Ommited quote? Syntax highlighting will help you.

In fish, everything is tab-completeable. Even if the program doesn’t have specific tab completion definitions, it’s still tab-completeable, thanks to generating tab completions from man pages. For example, gedit doesn’t have specific tab completions, yet fish managed to create them.

glitchmr@pineapple ~> gedit -
--background                                         (Run gedit in the background.)
--encoding        (Set the character encoding to be used for openi… [See Man Page])
--geometry                     (Set the X geometry window size (WIDTHxHEIGHT+X+Y).)
--help                                           (Prints the command line options.)
--list-encodings  (Display list of possible values for the encodin… [See Man Page])
--new-document            (Create a new document in an existing instance of gedit.)
--new-window       (Create a new toplevel window in an existing instance of gedit.)
--standalone                                        (Run gedit in standalone mode.)
--version                                    (Output version information and exit.)
--wait                                    (Open files and block the gedit process.)
-b                                                   (Run gedit in the background.)
-g                             (Set the X geometry window size (WIDTHxHEIGHT+X+Y).)
-s                                                  (Run gedit in standalone mode.)
-w                                        (Open files and block the gedit process.)

Of course, just like zsh (with correct configuration), it can expand more stuff. For example, kill command expands process IDs.

glitchmr@pineapple ~> kill 
1            (systemd)  127           (systemd-udevd)  479                (gconfd-2)
2           (kthreadd)  132         (systemd-journal)  508                   (gvfsd)
3        (ksoftirqd/0)  229               (hd-audio0)  512              (gvfsd-fuse)
5       (kworker/0:0H)  230               (kpsmoused)  527         (cinnamon [tty1])
7       (kworker/u:0H)  299              (irq/46-mei)  528                  (colord)
8        (migration/0)  307                (cfg80211)  534  (polkit-gnome-au [tty1])
9        (rcu_preempt)  308                    (hci0)  536          (dropbox [tty1])
10            (rcu_bh)  309            (kworker/u:1H)  539        (nm-applet [tty1])
11         (rcu_sched)  310               (scsi_eh_6)  540  (gnome-screensav [tty1])
12        (watchdog/0)  311         (rts5139-control)  558      (gsd-printer [tty1])
13        (watchdog/1)  312         (rts5139-polling)  566         (gvfs-udisks2-vo)
14       (ksoftirqd/1)  314                (ttm_swap)  568                 (udisksd)
15       (migration/1)  325          (NetworkManager)  598             (gvfsd-trash)
17      (kworker/1:0H)  329             (dbus-daemon)  728          (firefox [tty1])
18            (cpuset)  331          (systemd-logind)  744          (hexchat [tty1])
19           (khelper)  332                   (login)  746      (pxgsettings [tty1])
20         (kdevtmpfs)  335                 (polkitd)  797           (dconf-service)
21             (netns)  341                  (mysqld)  798   (gnome-terminal [tty1])
22       (bdi-default)  344          (wpa_supplicant)  805  (gnome-pty-helpe [tty1])
23           (kblockd)  348                   (nginx)  806            (fish [pts/0])
26        (khungtaskd)  349                   (nginx)  1374            (kworker/1:2)
27           (kswapd0)  351                 (php-fpm)  5790           (fish [pts/1])
28              (ksmd)  352                 (php-fpm)  10502        (gvfsd-metadata)
29        (khugepaged)  353                 (php-fpm)  13551          (fish [pts/2])
30     (fsnotify_mark)  373                (dhclient)  13635           (ssh [pts/2])
31            (crypto)  385             (fish [tty1])  13866           (kworker/1:0)
35          (kthrotld)  387                   (fishd)  18892            (gvfsd-http)
38           (deferwq)  412           (startx [tty1])  20044          (fish [pts/1])
62             (khubd)  429            (xinit [tty1])  20046        (python [pts/1])
63           (ata_sff)  430                       (X)  20405           (vim [pts/0])
64         (scsi_eh_0)  434    (gnome-session [tty1])  21370           (kworker/0:1)
65         (scsi_eh_1)  437      (dbus-launch [tty1])  21373           (kworker/u:2)
66         (scsi_eh_2)  438             (dbus-daemon)  22399          (fish [pts/3])
67         (scsi_eh_3)  440         (at-spi-bus-laun)  22472           (vim [pts/3])
68         (scsi_eh_4)  444             (dbus-daemon)  22521           (kworker/u:0)
69         (scsi_eh_5)  447         (at-spi2-registr)  22863           (kworker/0:0)
93      (kworker/0:1H)  455  (gnome-settings- [tty1])  22945           (kworker/u:1)
95      (kworker/1:1H)  464              (pulseaudio)  23238            (ps [pts/4])
103      (jbd2/sda6-8)  465            (rtkit-daemon)  23239          (grep [pts/4])
104  (ext4-dio-unwrit)  468                 (upowerd)  23240          (tail [pts/4])
110        (flush-8:0)  476            (gconf-helper)

Of course, fish has some disadvantages. One of disadvantages is the syntax. It’s not POSIX compatible by design. For example, the history substition doesn’t exist. Instead, you’re supposed (if you wanted, let’s say, sudo) to press Up, Home, and type ‘sudo’. Command substitution uses (), not `` or $(). Still, if you will accidentally use $() bashism, the shell will inform you with an error.

Also, the newest stable is really old and slow. Instead I would use version from git, which is usually more stable than stable version. In Arch Linux, it’s fish-shell-git from AUR, on other operating systems (like CentOS I use on my VPS), you have to compile it yourself. It isn’t so difficult. The GitHub repository is fish-shell/fish-shell.

As for why I’m mentioning fish shell, well, I have lately contributed a small patch to hint -C suboptions in perl - like -CSDL. Nothing special, but hey, why not make a blog post, considering I write them rarely.

Perl 6 changes - 2013W07

2013-02-16
> my $perl = Date.new: '1987-12-18' # Perl 1 release[1]
1987-12-18
> my $perl6 = Date.new: '2000-07-18' # Perl 6 announcement[2]
2000-07-18
> Date.today - $perl6
4596
> $perl6 - $perl
4596

Normally, I wouldn’t put irrelevant snippets of code[citation needed]. But this day is different - we have Perl 6 equidieversary (thanks, moritz). It’s 4596 days since Perl 6 was announced (Wikipedia says it was annouced 2000-07-19, but actually it was earlier). In 2000-07-19, Perl was 4596 days old. But I won’t discuss about this more, as masak already made perfectly fine article about that.

Let’s return to your regularly scheduled program.

New features

Perl 6 specification

Rakudo Perl

Perl 6 changes - 2013W06

2013-02-09

This time without any gimmicks (like five word sentences). This will be simple description of changes I do regularly.

New features (this time without building stuff part)

Rakudo Perl

Niecza Perl

I have Twitter account

2013-02-06

Yet another ignorable self promotion. http://twitter.com/GlitchMr

(perhaps I should have different news feed for Planet Six…)

Perl 6 changes article - 2013W05

2013-02-02

The changes are so fun. jnthn is working on porting. nqp will be on JVM. And then, Rakudo will be. Java is very, very fast. There are some interesting problems. But nothing impossible to solve. At least, I hope so. I would continue, but well. This is not the topic. This is article about changes. Changes in Perl 6, obviously. If you want, enjoy reading.

Rakudo Star 2013.01 was released. It’s based on Rakudo 2013.01. Those changes aren’t in.

On sidenote, a small note. Five word sentences are interesting. I am not stealing ideas. Well, actually, I am now. I should stop talking now.

New features to build stuff

Rakudo, a Perl 6 distribution

Perl 6 changes - 2013W04

2013-01-26

Today, the main features is .delta method in DateTime and Date. And as usually, bug fixes that make language do what you mean.

New features

Perl 6 specification

Rakudo Perl

Helpful error messages

2013-01-20

Rakudo lately got an interesting change. Consider following buggy code (for array binary search), written in functional style (I’m using recursion). The bug is that it doesn’t work because of two different identifiers binary-search and binary_search.

Trying to run it shows compile time error message. The compile part is important. If you would remove binary-search call at end, it still would report an error, unlike Python.

===SORRY!===
Undeclared routine:
    binary_search used at lines 2, 8, 9. Did you mean '&binary-search'?

Now you know what’s wrong and you can easily fix it. Unlike let’s say, Jekyll that I use for my blog. Not only it doesn’t work on my PC for some reason, but also refused to highlight my code - it gave some sort of XML error (it simply said “REXML could not parse this XML/HTML”). I gave up and put it on Gist. And the first attempt was failed, because embed code is <script> and Jekyll self-closed the tag (XML-style, but this is HTML). This is annoying.

Perl 6 changes - 2013W03

2013-01-19

It’s another Perl 6 changes article (at this point I wonder why I still do that). But as long the changes are impressive (and the cake is the lie), I guess mentioning changes is worth it.

Rakudo 2013.01 was tagged in the Git repository. It wasn’t yet released, but it’s really close to the releease (and frozen).

New features

Rakudo Perl (in Rakudo 2013.01)

Rakudo Perl (post Rakudo 2013.01)

Niecza Perl

Perl 6 changes - 2013W02

2013-01-12

I’m going to show another Perl 6 changes article. I’m so lazy, that I really don’t know what to put here, so I guess I’ll now show the list of new features.

New features

Perl 6 specification

STD.pm6

Rakudo Perl

Niecza Perl

Perl 6 changes - 2013W01

2013-01-05

I have finally updated the number before ‘W’. Well, we have the new year - 2013. And because of that I would like to say ‘Happy new year!’.

This is yet another article in “Perl 6 changes”. I lately don’t put articles other than those, but I don’t have many ideas for those, really.

By the way, I find it interesting that no new posts on Planet Six appeared between my previous Perl 6 changes article and current Perl 6 changes article.

Incompatible changes

Rakudo Perl

New features

Rakudo Perl

Niecza Perl

Perl 6 changes - 2012W52

2012-12-29

This is last “Perl 6 changes” update in this year. Enjoy.

New features

Perl 6 specification

Rakudo Perl

Perl 6 changes - 2012W51

2012-12-22

TODO: Insert the description of changes. Also, mention that Rakudo 2012.12 (Warszawa) was released and that Rakudo isn’t Rakudo Star.

Incompatible changes

Rakudo Perl (in Rakudo 2012.12)

Rakudo Perl (post Rakudo 2012.12)

New features

Rakudo Perl (in Rakudo 2012.12)

Perl 6 changes - 2012W50

2012-12-15

So, this is yet another article in Perl 6 Changes series. (I know, those introductions are really boring, but would you like to see Lorem Ipsum Dolor instead)? As in previous week, Rakudo mainly improves Perl 6 parsing.

By the way, if you don’t know about Perl 6 Coding Contest, check it out. The challenges are rather easy if you had any programming language experience (if you don’t know Perl 6, check out Using Perl 6 book). If you still have questions, people in #perl6 can help you.

Incompatible changes

Rakudo Perl

New features

Rakudo Perl

Niecza Perl

Perl 6 changes - 2012W49

2012-12-08

To begin with, I’ve made a post for Perl 6 Advent Calendar. If you were wondering why it was late, I will tell you - it’s actually early. Somebody else has claimed article for eighth day and forgot to upload it, so somebody had to put replacement article. I’ve moved my article from 12th day to 8th day, just so Perl 6 Advent Calendar could be continued. Moritz, to protect against that, put the just-in-case article about exceptions (it’s exceptional), if that would happen again.

Enough talking about Perl 6 Advent Calendar, as obviously this blog post isn’t about it. Every week, I describe changes in Perl 6 and its implementations. This is yet another article about changes.

Jonathan Worthington lately was working on improving syntax errors messages in Rakudo Perl. Now they are better and more accurate, just like they’re already in STD.pm6 or Niecza.

New features

Rakudo Perl

Niecza Perl

Perl 6 changes - 2012W48

2012-12-01

Rakudo Star 2012.11 was released with new impressive improvements (check my previous posts for more information). If you’re reading this, please check out the Perl 6 Advent Calendar - new posts are added daily.

Incompatible changes

Rakudo Star (post Rakudo Star 2012.11)

New features

Perl 6 specification

Rakudo Perl (in Rakudo Star 2012.11)

Rakudo Perl (post Rakudo Star 2012.11)

Niecza Perl

-2 6

2012-11-30

You know, -2 is highly connected to Perl 6. It’s valid syntax for -(2).

-2 6 in Google Search finds Perl 6

Perl 6 changes - 2012W47

2012-11-24

So, well, now that my code compiles (well, C code, not Perl 6 code :-)) I’ve time to describe Perl 6 changes, instead of simply doing what XKCD says - I shouldn’t waste time.

Rakudo Perl 2012.11 is now released. The change mentioned in this article is already in.

New features

Perl 6 specification

STD.pm6

Rakudo Perl

Perl 6 changes - 2012W46

2012-11-17

I’m already aware that my blog looks spammy because of all those Perl 6 changes posts. I would like to remove all that garbage, so I’m thinking about separate site for those posts (of course with proper redirects of my old URLs).

Deprecations

Rakudo Perl

New features

STD.pm6

Rakudo Perl

Niecza Perl

Perl 6 changes - 2012W45

2012-11-11

It’s another late Perl 6 changes article. Today the fun parts are adverbs, adverbs and adverbs. Oh, and blocks. And fixing bugs. Have fun playing with new features.

New features

Rakudo Perl

Perl 6 changes - 2012W44

2012-11-04

I apologize for being late, Gabor Szabo. I simply forgot about writing this. This week, the main attraction is proper quote constructs support.

Incompatible changes

Rakudo Perl

New features

STD.pm6

Rakudo Perl

Niecza Perl

Perl 6 changes - 2012W43

2012-10-27

Rakudo Star 2012.10 will be released soon, but before that will happen, I’ll list changes in Perl 6 specifications and implementations. Not many changes, but many of those are very important. Personally, I find custom operators precedences, << >> quotes and prototypes in core subroutines very impressive improvements - it was all done in one week.

New features

Rakudo Perl

Travis - add and forget

2012-10-21

So, you may have heard that Travis is nice build testing service. It is - I even use it for my JavaScript projects. But, guess what will happen if somebody uses Travis incorrectly.

The problem is about one of the most commonly languages made by bad developers for bad developers. But this article isn’t about why this language is bad - we all know it. Technically, I would use PHP instead of Brainfuck if I would have choice between PHP and Brainfuck, but it would be choice between very bad and worse.

6 months ago, Davey Shafik though - everybody uses Travis CI, why PHP source code doesn’t. He wanted to add Travis CI to his projects, but after quick look he noticed he doesn’t have test cases in his code and he was too lazy to add them. So, why not add Travis CI to some project that already has test cases so he could see how Travis CI would work.

And so he did. He decided to ask PHP to add Travis CI to its source code. Of course, the reaction is obvious.

This is awesome, thanks!

If this gets merged in and you guys are interested in pull-request testing then shoot us a note at contact@travis-ci.org. This feature is currently being rolled out manually but we’d love to turn it on for php.

Cool, Travis is awesome.

FYI looking into it. General idea is great, have to read about travis, etc first.

After general “awesome” comments (seriously, do you know other words?) the code review started. For example, David Soria Parra complained about !! usage

define('TRAVIS_CI' , !!getenv('TRAVIS_PHP_VERSION'));

Of course, version below is better. I mean, it’s longer so it’s definitely better. Yeah… is any programmer using Boolean() function anyway in JavaScript (warning: not Boolean constructor - Boolean constructor is something you shouldn’t ever use as it’s always truthy).

define('TRAVIS_CI', (boolean) getenv('TRAVIS_PHP_VERSION'));

I’ve decided to look for explicit booleans. So, I made a search query and I’ve found answer on Stack Overflow.

$test_mode_mail = $string == 'true'? true: false;

I seriously don’t know what to think about this. It got 8 upvotes. It works - but it would be seriously stupid code in any language that isn’t PHP. I mean - $string == 'true' is boolean, so why use ternary operator for it? And WHY use ternary operator for it even if it wouldn’t be ternary operator. I’m not going to mention usage of ==, instead of ===, it doesn’t really matter in this case.

My solution would be like this:

define('TRAVIS_CI', isset($_ENV['TRAVIS_PHP_VERSION']));

But good design should avoid dynamic constants.

Anyway, Davey Shafik has changed !! into (bool)… hey, hasn’t David Soria Parra said him to use (boolean)… check. Those PHP aliases attack again. Why? Why converting to boolean could be done using two casts with only different name? Why converting to float could be done using three casts with only different name - (float), (double) and (real)?

But that isn’t real problem. The Travis CI change was merged. Now README page of PHP contains the “build status: failing”. I’ve decided to click that image - every single change had either “build status: failing” or “build status: unknown” (because of failure while doing git clone (possibly GitHub went down?)). PHP wastes time of Travis CI just to get “build status: failing” again.

After some time, David Soria Parra has decided to add e-mailing about failures to php-qa@lists.php.net.

What went wrong? Well…

notifications:
    email:
        recipients:
            - php-qa@lists.php.net
        on_success: change # [always|never|change] default: change
        on_failure: always # [always|never|change] default: always

But… PHP always fails - so PHP Quality Assurance would get lots of useless messages. Well, the solution for PHP developers wasn’t to fix PHP issues, definitely not - that would be too clever for programmers that work on PHP. The fix for developers was to disable e-mail notifications.

notifications:
    email:
        recipients:
            - php-qa@lists.php.net
        on_success: never # [always|never|change] default: change
        on_failure: never # [always|never|change] default: always

Now, I wonder why simply didn’t removed notifications: section. I mean, they gave e-mail and told Travis - whatever happens, don’t e-mail. I’m going to call this brillant.

After some time, David Soria Parra has noticed that he doesn’t have to give e-mail to PHP Quality Assurance. So, he removed it.

notifications:
    email: false

Now I wonder why he didn’t removed whole section. He doesn’t want any notifications, so why have this section? So now, Travis CI does nothing and everybody ignores it. I mean, it compiles, but…

It has 1123 compilation warnings. It has 106 test failures (with 43 expected test failures), one expected SIGSEGV (wait…) and 70.4% code coverage. And it’s not about unimplemented features - those are simply SKIPed. No, it isn’t better in PHP 5.4 - I mean, PHP 5.4 has 103 test failures (with 43 expected test failures).

PHP developers - please fix every bug before implementing new features. Having codebase that constantly contains lots of test failures isn’t really fun.

If you are PHP user, I would advice you trying some other language, such as Perl (believe me or not, Perl is way better than PHP) or Python. Those languages are consistent and more structured than PHP. Annoyed by security issues? Those languages make it easier to protect against them.

If you still want to use PHP, use OOP everywhere and never use global variables (with the exception for $_GET, $_POST and $_SERVER of course). PHP is simply unusable without OOP. But still, I would recommend using other langauges. Also, use template engine and prepared SQL queries.

2012-10-29 update

The older version of article was mentioning following syntax.

const TRAVIS_CI = isset($_ENV['TRAVIS_PHP_VERSION']);

Turns out that it doesn’t work. Why? Because constant value isn’t constant - it depends on environment variable existing. All you get is cryptic syntax error. PHP stupidly uses its grammar to annoy developer, even if this syntax would be allowed in other sane languages. For example, you cannot do func()(), just because grammar forbids that. I haven’t heard of other language with similar problems.

PHP Parse error:  syntax error, unexpected 'isset' (T_ISSET)

Instead, the solution should be more like this.

$travis_ci = isset($_ENV['TRAVIS_PHP_VERSION']);

It’s not constant. It shouldn’t be because it isn’t real constant.

Perl 6 changes - 2012W42

2012-10-20

I know I’m early today. It’s always better than being late. Well, Gabor Szabo requested that I should make those articles early Sunday. I’m going to instead write their early version late Saturday and update them with Sunday changes instead - I hope it won’t be too problematic.

Obviously, Perl 6 has changed, otherwise I wouldn’t write this.

Rakudo 2012.10 was released (not star, just normal Rakudo version) - it has code-name Tokyo which is host of YAPC::Asia 2012.

Incompatible changes

Rakudo Perl

New features

Perl 6 specification

STD.pm6

Rakudo Perl

Niecza Perl

Perl 6 changes - 2012W41

2012-10-15

So, I apologize for forgeting about doing this yesterday. It’s another boring Perl 6 changes report. I’m going to make another blog post soon, but as you can see, I’m sort of lazy, so all I have for now is “Perl 6 changes” article. Enjoy.

New features

Rakudo Perl

Niecza Perl

Perl 6 changes - 2012W40

2012-10-07

So, well. At beginning of this week, Rakudo Star was released. All changes on this list aren’t in current Rakudo version. So, well. It’s time for another Perl 6 changes report. It’s not revolution, it’s evolution.

New features

Perl 6 specification

Rakudo Perl

Niecza Perl

Yet another DuckDuckDuck goodie

2012-10-05

Lately, I have made yet another plugin for DuckDuckGo (this time it isn’t connected with Perl 6 - but hey, it’s mine).

So, well, I have seen times like 11:00 EST. The problem is - what hour it is actually. So, I can do query like:

11:00 EST into GMT+1

And it will reply me.

11:00 (EST, UTC-5) is 17:00 (GMT+1)

Also, you can skip timezone and it will think it’s GMT - it’s rather common today. While fixing GMT is easy, it’s very likely that you meant that.

So, well. It’s likely to be very quickly applied to DuckDuckGo - they already have said they’re ready to deploy the plugin in pull request.

Perl 6 changes - 2012W39

2012-09-30

Rakudo Perl 6 still wasn’t released, but likely it will be released soon - currently it isn’t released because of bug in Parrot causing every line while reading files to be got when requesting one - using older Parrot version is considered too. If you’re waiting for Rakudo 2012.09 release, just be patient. Anyways, let’s mention Perl 6 changes for that week.

I’m aware that changes aren’t really impressive, but hey - not every week is impressive. And today it’s more important to make Rakudo Perl work for delayed 2012.09 release than add lots of new features.

Incompatible changes

Rakudo Perl

New features

Rakudo Perl

Niecza Perl

Perl 6 changes - 2012W38

2012-09-23

Another week, another Perl 6 changes report. I hope that changes mentioned on this list will be exciting. Developers still work on Perl 6 - actually they have worked since 2000. Rakudo is still slow, but it’s on average 30 times faster compared to Rakudo Star 2010.07 (but please note that 120% of statistics are made up).

This week is special because Niecza v22 was released - all changes on this list are in current Niecza release.

Incompatible Changes

Rakudo Perl

Deprecations

Rakudo Perl

New features

Perl 6 specification

STD.pm6

Rakudo Perl

Niecza Perl

Perl 6 changes - 2012W37

2012-09-16

Starting with this week, I plan mentioning changes in Perl 6 and its implementations just so you will know what to expect, so you could update your code and use new features in your code to simplify old logic.

Incompatible Changes

Perl 6 specification

Rakudo Perl

New features

Perl 6 specification

STD.pm6

Rakudo Perl

How I learned to stop worrying and install the panda

2012-09-15

So, do you want to install panda? You have managed to somehow install Rakudo using git. Well, you were doing it wrongly - you should instead have used Rakudo Star which includes it.

Oh, you don’t want to wait again for Parrot, NQP and Rakudo to install. Well, it’s possible. It’s not easiest thing ever, but it sort of works.

What you have to do depends on whatever you have installed panda before (so it worked) or you haven’t.

I haven’t installed panda before

Well, this is rather common. First, run following shell command.

which perl6

It will tell you what perl6 will be used. If it says location in home directory, you should be fine. But if it says stuff like /bin/perl6 or /usr/bin/perl6, you should fix it - in current version panda runs perl6 at certain points. You wouldn’t want panda to run outdated version of Rakudo your system could have (also, remove your system Perl 6 if you want to be safe - you won’t need it).

So, you want to fix. Let’s assume your shell is either bash or zsh - all you have to do is modify either .bashrc or .zshrc and add following line at end, where [bin-path] should be replaced with your path to Rakudo’s /bin directory (on my system it’s ~/rakudo/bin).

export PATH="[bin-path]:$PATH"

Close your shell and run it again. Just to be sure, run which perl6 again. If your perl6 is in correct location you can continue.

Download panda using following command if you haven’t already.

git clone https://github.com/tadzik/panda.git

And run bootstrap script.

cd panda
./bootstrap.pl

Congratulations, you have working panda now! If you want, add panda to your path, by modifying $PATH you have added before. Of course, as said before, modify [panda-bin-path] and [bin-path] with correct paths.

export PATH="[panda-bin-path]:[bin-path]:$PATH"

I have installed panda before

Just install panda like normal module.

panda install panda

Wasn’t that simple?

Breaking compatibility is not fun

2012-09-13

Four years ago November appeared. I’ve tried to use it. It simply doesn’t work today - Makefile tries to precompile Digest before Digest::SHA causing error (by the way, this module is called Digest::SHA256 when I’ve wrote this post, and it’s likely that it will change name to Sum::SHA256 in future and will use interface of other Sum:: namespace modules).

glitchmr@strawberry ~/g/november> env PERL6LIB=lib make
perl6 --target=pir --output=lib/Digest.pir lib/Digest.pm
===SORRY!===
When pre-compiling a module, its dependencies must be pre-compiled first.
Please pre-compile lib/Digest/SHA.pm
make: *** [lib/Digest.pir] Error 1

You would think that compiling Digest::SHA manually would solve the problem? Technically yes, but…

glitchmr@strawberry ~/g/november> perl6 --target=pir \
                                        --output=lib/Digest/SHA.pir \
                                                 lib/Digest/SHA.pm
===SORRY!===
pir::load_bytecode missing a signature

So, what’s wrong with Digest::SHA. Well, that was its source.

class Digest::SHA:auth<thou>:ver<0.01> {
    pir::load_bytecode('Digest/sha256.pbc');

    multi method sha256_hex (Str $str) {
        my $sha256_hex = Q:PIR {
            .local pmc f, g, str
            str = find_lex '$str'
            f = get_root_global ['parrot'; 'Digest'], '_sha256sum'
            $P1 = f(str)
            g = get_root_global ['parrot'; 'Digest'], '_sha256_hex'
            $S0 = g($P1)
            %r = box $S0
        };

        return $sha256_hex;
    }

    multi method sha256_hex (@strs) {
        return self.sha256_hex(@strs.join(""));
    }
}

As you can notice, it depends on Digest/sha256.pbc from Parrot. Because of that, this module is Rakudo specific, but in this case it doesn’t matter much (perl6 is Rakudo).

What is the problem? Well, error message explains it - in Rakudo, you have to specify types of input and output every time you call any Parrot function directly. Why it was working before? Well, Rakudo didn’t required you to specify types before, but now it does (Why? I have no idea, NQP doesn’t require you to specify signature in this case). Anyways, the fix would be to type pir::load_bytecode__vS instead (v means void return and S means boxed string as argument).

I could try continuing, but that would be waste of time - November is simply old. The source code is unlikely to work in current Rakudo version (current Rakudo version is simply too modern for November to work).

It’s not just November, many modules in modules list simply won’t work in newest Rakudo version. This is normal - authors are simply too lazy to update their modules or they don’t work on those anymore (by the way, if you’re interested, make a fork of one of those modules, fix them and send pull request - even small help is good for Perl 6 community).

Why? Well, Perl 6 Synopsis is changing to improve language. Most of those changes are minor and usually wouldn’t break any program that wouldn’t try to detect those changes. But in certain cases, Synopsis needs bigger chances which could break more complex programs (Perl 6 is still in development, sometimes design is just wrong enough to justify breaking backwards compatibility). Also, Rakudo developers took lesson from this breakage - since 2012.07 every incompatibility is mentioned.

Searching in p6doc

2012-09-07

First of all, I would like to apologize for my rather weak English. It’s not my native language and I still learn it (but, my English is way better than two years ago, so I guess it’s good enough).

So, you may have heard about p6doc, the project which started 2 months ago. According to moritz, it’s intended to be comprehensive place where you can direct people to. It doesn’t yet describe everything (for example Str.indent wasn’t described when I’ve wrote this blog post), but it’s very likely that when you read this blog post it’s already described - everything is added to documentation rather quickly :-). And you can contribute it with ease, just modify a page and send pull request.

But, while the p6doc is already easy to use, finding stuff in it takes time, you have to type doc.perl6.org in your browser bar, press CTRL+F (well, I usually press dot, but this only works in Opera), type name of method and click the method. While it’s fast already, it could be faster.

Of course, there is perl6doc tool activated from command line, but currently it’s rather slow (according to time utility rendering Str.split took 4 seconds). But when Perl 6 implementations will improve their performance, it could be acceptable.

The problem is - HTML page requires effort of entering it and perl6doc is currently too slow to be acceptable for anything. But perhaps there is possibility of nicer way which would combine performance (as in, pages render nearly instantly) of HTML version and performance (as in, you can easily access it) of perl6doc tool.

Lately, I have contributed module for DuckDuckGo (if you aren’t using DuckDuckGo, why not?), to add search for Perl 6 documentation. It shortens the process of entering p6doc to simply typing “perl6 chomp” in search bar (and pressing enter). If this isn’t simple, than what is?

Try it at DuckDuckGo.