pwmarcz.pl

Book: The Clean Coder by Robert C. Martin


Yes, the "r" is no mistake - this is a book on what it means to be a professional programmer, someone who has a programming job and takes it seriously.

The book teaches you to take pride in what you're doing, to stick to good practices (especially under pressure) because that's the ethical thing to do, to not cave in and "just try to do it faster", but at the same time to take responsibility for what you're committing to. It reminds you that requirements are not set in stone, that the client might not know really well what they want and it's your duty to help them figure that out.

It also gives good advice on several subjects both technical and soft, like estimation, TDD and different kinds of testing, mode of work, and time management. The author shares many war stories from his 40-year-long software engineering experience, talking about how to avoid his mistakes.

Some of it is very opinionated (it's Uncle Bob, what'd you expect) and I didn't agree with everything, but some things rang very true for me and actually were painful to read. I had to look at the areas where I'm not behaving like a responsible professional; overlooking broken windows, not managing my time properly, concentrating on broken requirements instead of the overall goal.

On the other hand, it was nice to see some confirmation about things that I'm just discovering for myself now, like the effectiveness of pair programming or that one person shouldn't juggle several projects.

I highly recommend the book to all professional programmers.

Some of my takeaways:

Conference: PolyConf 2014


I just finished PolyConf, a two-day "polyglot programing conference", and I'm really excited. There were a lot of really interesting talks so I want to share it all with you. Here are some of the things I saw:

And that's not even mentioning everything (there was also F#, some Rails Girls and PyLadies, a few more philosophical talks…) So all in all, a great conference that I'll definitely attend again next year.

I hope you enjoyed this write-up and feel encouraged to attend more events like that!

Book: Clean Code by Robert C. Martin


The examples are "very Java" at times, and you might not agree with all the choices the author makes, but don't be discouraged: the book gives you some very useful principles about how to structure your code, split it into simple parts, and generally avoid making a mess (I think the most valuable one was operate on a single level of abstraction at a time). The book includes real-life examples that are really helpful for understanding.

Overall, I think my time reading this book was well spent.

Some important points:

Writing a roguelike in Lua


(adapted from a post on Reddit)

I recently wrote a seven-day roguelike in Lua. It was my first project in Lua, and second roguelike (after coding one in Python a year before). I don't have much to base this on, but believe dynamic languages like this are the fastest and best way to write a roguelike game. You write relatively little boilerplate and have much freedom with how to design the engine, compared to, say, endless classes bureaucracy in Java or manual memory management in C.

Coming from Python, several things irritated me. The language feels lower-level. There are less primitives available from the start. Everything takes more code to write. While the tables are a nice concept, often I missed working with real lists, tuples and arrays. Also list comprehensions, everything being a sequence. Ternary if. Multiple return values, and unpacking, instead of simple tuples. Optional arguments… the list goes on.

Most of the things I wanted I could actually do in Lua, but it seemed more verbose and more prone to failure. Of course, in part this is probably due to my inexperience. And I was probably trying to mimic the previous (Python) engine's architecture too closely.

I loved being "close to the metal" - actually understanding how the tables/methods I use actually work. Classes in Python feel too heavy sometimes (and definitely more magical, harder to understood, and uglier). In Lua, the whole thing seems very malleable. This is a language you can make every object system you can think of, after all.

As for having to define all the OOP-style mechanisms from scratch - this is, IMO, a non-issue. After writing an object system, using it was as easy as everywhere else. I even managed to hack some field-imitating class properties.

It frightens me how easy it is to make an error in Lua. All it takes is to forget a local before a variable, or mix up foo:bar() with foo.bar() - and the error may not surface at all until much later (unless you bother to make tests… I probably should have): the system doesn't complain if you do .bar() instead of :bar(). It doesn't complain if you give it wrong number of arguments. Reading an uninitialized variable gives you a silent nil. Bugs not failing early enough are a problem in most dynamically-typed languages, but somehow in Lua it seemed especially bad.

(Some of these are fixable, for example you can easily forbid making global variables, ensuring that leaving out a local will blow up).

There is no built-in module/namespace system, just loading files. Well, actually there is the module() function, but from what I've read, it's considered deprecated and harmful…

Numbering arrays starting from one is an ugly wart. Of course, everyone tells you that you get used to it, and they're probably right… but I haven't seen any argument about it being superior, just about not being important. Still looks ugly. Especially when if you interface with a library that counts from zero. But this is nitpicking, the language seems very well designed apart from that.

Keep in mind that I'm a beginner and I don't know what I'm talking about. If I stayed with Lua for some more projects, I probably would've stopped whining about it not being Python and learned to appreciate it more. Also, the experience wasn't as bad as my negative comments here would make it seem.

tl;dr Try it.

ADOM playthrough: Vicious, a human assassin


(originally posted on Reddit)

This is a story of Vicious, a human assassin who managed to save the world.

As he enters the Drakalor Chain, he has no name yet… He will have to earn it.

Starting equipment. Not bad, I think. We'll start with daggers - both in melee and thrown.

Ogre mage - has invisibility and frost bolt. I was certain the death is close. Fortunately he turned out to be friendly…

Somehow I managed to reach Dwarftown. As you can see, dwarf grandpa's first quest is a rather easy one.

This is me having some trouble with the animated trees. I seriously thought I'm out of luck when they suddenly refused to let me pass. Fortunately when I calmed down, the solution turned out to be simple - potion of invisibility.

Rehetep, the mummy lord, was quickly dealt with. Assassins are very good at shooting.

The character has been quite successful, I think he deserves a name. Meet… Vicious.

Trying my luck with steel golems in Darkforge. As you can see, a bad idea. I could damage them only with arrows of construct slaying and they quickly run out.

One of the golems refused to let me go. Fortunately…

Most of the time "True Aim" and "Thunderstroke" are useless shit. Come on… artifact ARROW? But somehow this time, being the weapon with best damage I had, it proved quite useful - shoot the golem, run around, pick up the arrow, shoot it again…

Digging some graves on the dwarven graveyard. No good loot, only a troublesome master lich sleeping in one of them.

My visit to Gremlin Cave was more fruitful - I managed to find seven league boots. A very useful item - doubles your movement speed.

And now…

You slip...
You fall...
*BLAMMMM!!!*
You have reached the bottom.

This is how you usually enter the Rift - Climbing at 100, and still the landing is quite hard.

Having in mind the sad story of Tesuji the drake assassin (destroyed his only climbing set in this jump, then spent rest of his miserable life trapped beyond the mountains trying to find a new one - and finally petrified by a gorgon) this time I took two climbing sets. Both survived the fall.

And that's why you enter the rift. Awesome library filled with useful scrolls and books. And, sometimes, artifacts - here I found the sapphire amulet "Preserver".

Drinking from pools can get you a free wish. Or a dooming curse. They say the probability is the same. Somehow, I don't believe it.

This was scary. Never fall asleep at the wheel. I started playing "on autopilot" and suddenly found myself face to face with a gorgon. One more turn and I would turn into a statue.

The Casino. Lots of gambling machines and a huge shop. There is a way to get practically unlimited money playing on the machines - just find the best one, put something on your Enter key and wait some time… I consider it terrible, anticlimatic farming bordering on cheating.

Cat Lord was generated when I had 18 cat souls on my conscience. I was afraid direct confrontation would be my end - so I Acidballed him through a wall :)

Acid Ball rocks. Did you know you can kill even the Elder Chaos God with it?

A room full of Ghost Kings… If I started to fight them, the poor human would die of old age in no time… Fortunately I managed to escape without being noticed.

You feel truly excited.

And for a good reason - these greater vaults often contain artifacts and much good loot. Not to mention lots of exp.

Here we see a vault of fire creatures - dragons, fire elementals and such.

This is me remembering that fire burns. That was my best bow…

One more extremely annoying location - the blue dragon caves. Full of lightning-breathing dragons ready to destroy every burnable item you have.

But for killing this fellow I get a certain rune-covered dagger called "Needle". And once I obtain another one called "Sting"… Neither of them is very powerful on its own. But when I wield both of them:

Right hand: +230 bonus to hit, 3d4+116 damage
Left hand: +228 bonus to hit, 3d4+116 damage

Sting & Needle - the deadliest combo in the game.

Emperor moloch in his castle. In all his armor he's like a walking tank. I guess assassin's arrows are better than anti-tank missiles.

Time to save the world!

First time a balor has ever surrendered to me. I had to kill him anyway - he kept opening the Chaos Gate and I couldn't leave the level with him around.

This time I wiped out the whole level. For a moloch-armor-covered (81 PV!), Sting-and-Needle-wielding walking tank it was very easy.

THE END


Character dump

Photos, full recording (in DOS Recorder) and final savegame

I think this was the strongest PC I ever played. High-level assassin is easier than a barbarian. And because of Backstabbing and other class skills he doesn't even need an artifact/slayer weapon - he manages to score critical hits with everyting. Most of the game, Vicious used a plain sword of sharpness.

Hope you liked it!