Immutable JS – Immutable Data Collections for Javascript.
Immutable data cannot be changed once created, leading to much simpler application development and enabling techniques from functional programming such as lazy evaluation.
A big part of my work has to do with code. I’ve worked as system administrator – installing, patching, and configuring someone else’s code. I’ve worked as independent programmer, writing code on my own. I also programmed as part of the team. And on top of that, I worked as Team Leader and Project Manager, where I had to interact a lot with programmers. Programming world on its own is as huge as the universe. There is always something to learn. When I find something worthy or something that I understand enough to write about, I share it in this category.
Immutable JS – Immutable Data Collections for Javascript.
Immutable data cannot be changed once created, leading to much simpler application development and enabling techniques from functional programming such as lazy evaluation.
Flight rules for git – a guide for programmers using git for what to do when things go wrong.
Tracking.js – different computer vision algorithms and techniques library for the browser.
I came across the goal() challenge this morning.
g()(‘al’) is a challenge whereby you need to write in as many languages as possible code which enables the code g()(‘al’) to return the string “goal”, the code g()()(‘al’) to return the string “gooal”, the code g()()()(‘al’) return the string “goooal”, etc.
Interestingly enough, the table of solutions for different languages lists my three least liked languages – Java, Ruby, and PHP – as the ones to be improbably used. These languages don’t support the necessary syntax to make it work.
Given that I spend most of my days around PHP developers, I decided to play around and see if I can figure out a way to do it in PHP. After all, the challenge allows breaking rules in a smart way. What exactly is smart – that’s not up to me.
My initial approach was to apply the technique I learned in my Perl days – using __DATA__ or __END__ special literals – to stop the processing of the script and adding more data to it. I’ve never tried that in PHP, but that turned out to be quite possible with the use of __halt_compiler() function. I’ve submitted the Pull Request, but it still felt like cheating.
So my second approach was completely different. If PHP doesn’t support the necessary syntax, why not just add it such support? A quick search for how write a lexer in PHP turned up with this handy article. I pretty much did a copy-paste of it and find-and-replace for the needs of the challenge. Hence the second Pull Request.
While both of the solutions aren’t exactly what the challenge was about, I think this was still useful as I’ve learned a thing or two.
git-fat – simple way to handle fat files without committing them to git, supports synchronization using rsync