Rafał Wrzeszcz - Wrzasq.pl

PopStack - copy-pasting from StackOverflow has never been as easy

Saturday, 19 March 2016, 00:05

I work in Berlin but live in Szczecin - commute to work by train and have something like 2 hours per day to spend on doing something on my laptop. I also cannot sleep until late hours (just like today) so I have few more hours. That gives me few hours per day after my regular work to spend on something on my laptop. Sometimes I do my private projects, sometimes I do spare-time freelance projects, but from time to time I like playing with new stuff. This is how PopStack was born.

PopStack

What PopStack is? It's the tool, that saves a significant percent of developer's time - one doesn't need to search with Google for a StackOverflow answer. Especially that this is usually not the end of your job. After finding proper quesiton, you need to find there a proper answer. Let's take a phrase sort unsorted array - first answer is one of the most epic answers on StackOverflow, it explains to you how railroad transportation worked in 19th century. What the hell? I just want to sort my array! You pick the second one. Viola! Guy added some random statement there, but most importantly, he included one line of code that does what you need it to do! Go check another one - for-each over array javascript: it has the four magic lines you need, but hey - that guy thinks he is fucking Shakespire! This blog post is most likely going to be shorter than his answer! And all you need are just those 4 lines. That's exactly what PopStack does for you! It saves you so much time, just take a look:

$ ./popstack for-each over array javascript
var a = ["a", "b", "c"];
a.forEach(function(entry) {
    console.log(entry);
});

Running

It is so critical tool, that it's implemented for developers regardless of technology they use, you can see list of available implementations to pick your favourite one, the one you will be most comfortable with.

Playground

Ok, seriously, it's done for fun. The overall idea seemed quite usefull to me, so I decided to spend few evenings implementing it. But I didn't implement it just once - I did it 21 times, plus some that I started but didn't finish. It was just a playground for me to test myself and some new technologies (sometimes not so new, but new to me). It was just an excuse.

Some hints for you

But as we are with it - it's not my first time, I'm doing something like that. Such a small tools are great to play with them a little. Both with the idea, the code itself and the tools. In my opinion it's important for a developer to keep up-to-date and play with new ideas - even if you are not going to use them widely, just investigating other ways of thinking, other approaches for solving similar problems or exploring new concepts allows you to find better solutions even for your old stack. If you are thinking about doing something similar, let me give you some hints.

Play with it empirically

Don't just read the documentation, watch screencasts, browse examples - just do it, feel it. Open a file, write some random stuff in given language, format some data, process it, or whatever tool you are going to play with - use it for real. Don't just download sample.zip and check what's there - try to build your own sample.

Pick a real-life problem

Don't just open a file and put there a solution for some common problem, like 99 bottles of the beer - you can start with it, but what else you can do with it? Not much. What's more - what if you have some problem? You Google, go to StackOverflow and end up with PopStack flow - you do copy-paste from SO, and viola!

I know Photoshop!

Pick a real problem to solve, preferably something small. Just think about what you are doing right now (or a moment ago, before you came here) - can it be automated? Or a stuff you do very often - is it easy to automate? What set of commands you execute often? Try to build a tool that does all of that at once. First of all, it will give you some benefit. But, what is more important, probably there is no solution for it on Google/StackOverflow/GitHub. You will have to search for some single aspects of your solution, but not for full solution itself, you will at least have to plug multiple parts together, which is usually already a big step. You will have to understand what you are doing.

Try to involve some commonly used technologies

Language is not enough nowadays. Without tools, libraries, it's usage is very limited. A good data storage, without support for common data formats will be hard to integrate. If you pick a real-life problem, you most likely want to solve it with some real-life solution. For exmple in PopStack I used HTTP client to download JSON data. I didn't want to write own client, or own parser - these are the problems that are solved, don't waste your time re-inventing the wheel (unless this is the problem you picked to solve)! Every developer is able to write a code, a good one can use already existing one. Do you have some data? Store it somewhere! Play with databases, file formats. Try to investigate not only the language - check out the ecosystem, like package manager, test suite. Find out the community.

Limit yourself to a reasonable time

It's just a research for your own satisfaction, it has to be fun! If after few hours, you are still unable to figure out how to compile, or after one day, your executable file segfaults just after running, and you spent whole night debugging it, maybe just leave it? It's not funny anymore - if you can't make it even working in one day, then think about how long will it take for you to build your full solution. Drop it (for now), think how many alternatives you could research in that time. Unless it's your full-time job task to research new technology, you probably have just few hours in the evening, or during the weekend to explore new area - use it wisely.

Don't start with the language/database/library/car that you know

If you know it, you don't have to research it. Pick something exotic. If you start with the technology that you know, you will most likely lock yourself on the solution you will build and you will try to reproduce it in other languages (or whatever kind of technology you are investigating). It's so wrong… If you will try implementing imperative approach in, for instance, Erlang you will fail badly (there is no PopStack for Erlang for a different reason). Try to be idiomatic. See what are the strong points of the new stuff. You must unlearn what you have learned.

Tags: Ciekawostki, Szczecin, Technologie, Teksty, Kod, Chillout, Projekty