Kartones Blog

Be the change you wanna see in this world

Book Review: Code - The Hidden Language of Computer Hardware and Software

As now I travel to work via underground, I have more time to read. The first book I've fully read is Code, from Charles Petzold, and I really encourage anybody wanting to learn how computers evolved up to late 90s to go grab it.

Review

Code: The Hidden Language of Computer Hardware and Software book cover

Title: Code: The Hidden Language of Computer Hardware and Software

Author: Charles Petzold

Although the description of the book is a bit dumb, the title hints the contents: Learning from where do computers come, at both hardware level from morse code and the telegraph to current computers, and software level from raw circuit-based "programming" to assembler and high level languages. One note needs to be made, as the book was written in 1999 some technologies have changed (and even dissapeared), some numbers are obsolete and in general you shouldn't expect the book to teach you how an SSD hard drive work, but more instead a deep but general overview of the fundamentals of a computer.

The hardware level is what takes most of the book, starting with morse code and the telegraph to teach us basics of both data transmission and from where the integrated circuits come. This is the biggest and I guess hardest part to learn, because it is like taking your first half of the first year of university of computer science inside a book: Electronics, circuits, boolean algebra, binary, octal and hexadecimal systems and conversions... At least in Spain you learn this contents in 3 different subjects, so be prepared for some heavy circuit diagrams and calculations to repeat if you don't already know the topics. It is also the most beautiful part and where you will learn most of the amazing evolution path to personal computers.

The softwar level sadly suffers from having much less space, and while the internals of how old operating systems worked, how to manage files or input and output devices or how to draw pixels at old monitors are really interesting, I feel like it could have had a few more chapters digging more into details of old OSes, more old programming languages, etc. We learn about Assembler, C, LISP and a few others but very briefly (except ASM). Also some chapters are a mixed bag, where you are told about screen resolutions and then jump to digital audio, then disk storage... surely it is all I/O but I would have prefered a clear separation. That said, it is still great and I've learned some interesting facts.

Nostalgia also kicks in for me, but having lived the AMSTRAD PC/W & CP/M era, MS-DOS and the surge of GUI-based operating systems, I really enjoyed learning how simpler computers designed the hardware interruptions mechanisms, loaded the BIOS, why Macintosh was always different from PCs and other low-level details not usually taught anywhere else (at least condensed and in a simple language).

Really recommended read, mandatory if you like to know how things work under the hood. And also curious to read 17 years later and see how some technologies have been surpassed and their limits solved.


A few articles and tools about ZX Spectrum programming

The ZX Spectrum was a classic from the eighties, with its long loading times and 15 colors. It wasn't the fastest nor the best but it definetly had really good games and it's relatively cheap price made it common when I was young (before videoconsoles took its place).

Double Dragon on the Spectrum

While I don't have much time to learn how to code for it (and if I had, I'd focus on learning more original GameBoy development), I love when people write tutorials and/or posts about how certain stuff from old machines worked, and I just found some jewels which are also quite up to date (as a matter of fact, the author is still writing posts in the series). Just take a look at them and learn how things worked in the Speccy, and how more actual techniques can be applied to squeeze some extra speed or improve the development process:

Also, I went on to read a bit about the sprite color glitches and found that after the link's main article, in the comments section there are a few examples of how to minimize the problem, make sure not to skip them as the article only mentions the issue but doesn't provides solutions.

The full toolset to develop for the spectrum can be found at https://github.com/jarikomppa/speccy, including some custom-made tools, an image conversor for the Spectrum, and even a sample game, Solargun.

An interesting game programming library recently made is libzx; It provides drawing and buffering techniques, fonts management, keyboard handling, audio and music... Definetly worth a look.

Another toolset I've found is the spanish La Churrera, which includes not only a C framework but also tools to manage graphics, sound, and even a map editor.

Update #1: Added img2spec repo link.

Update #2: Added libzx library link.

Update #3: Added La Churrera framework link.


Code and style checks for Python at Sublime Text

As now I'm coding with Python (and learning it), here comes a similar post as the one I did for Ruby but adapted. Basically I want to centralize my coding to use if possible just one IDE for every language and file, so while probably PyCharm is better (as usually JetBrains tools are awesome) I get more flexibility with Sublime Text. Here are the specific packages I use:

  • Package Control: Plugin/package manager, required for the other components
  • SublimeLinter 3: Generic text linter for the editor. Required for the specific linters
  • PEP8 (Style guide for Python coding): pip install pep8
  • SublimeLinter-PEP8: To have the PEP8 rules inside the editor
  • MyPy (Static type checker): pip install mypy
  • SublimeLinter-contrib-mypy: To have the MyPy rules inside the editor (might conflict with PEP8 ones)

Despite having a tox.ini pep8 configuration file, if you see Sublime ignoring you, you can force some configuration settings for any linter going to:

Preferences -> Package Settings -> SublimeLinter -> Settings – User

And then adding custom rules under the pep8 section, e.g.:

"pep8": {
"max-line-length": 120
}

I have also pending review another pack, as flake8 is sometimes very very strict:

And that's all for now, if I add more interesting packages I'll update the post, and of course comments and suggestions are welcome.


UEFI, NVMe and being stubborn

This weekend I wanted to install Linux on my new work laptop (a Dell XPS 13 9350, just in case someone else runs into similar issues). As in the past I had some issues with UEFI booting and Ubuntu (versions 12 & 14), the first thing I did was to go to the BIOS and proceed to unenforce secure boot and enable legacy boot (the classic BIOS), tried to install Unbutu 15.10 from a USBdrive... and it was broke trying to install GRUB after the install itself.

An initial research about the failure trying to setup the bootloader at /dev/nvme0p1 (instead of the classic /dev/sda1) taught me about NVM Express controllers (aka NVME). I thought that maybe updating gparted to 0.24 (which supports MVNE) would be solved. To do that I:

  1. Booted Ubuntu 15.10 from the USB
  2. Installed this package
  3. sudo apt-get install gparted
  4. Create the partitions from gparted and when installing just use them (wiping the data but not recreating anything)

It didn't worked out :( I could see the hard disk partitions but install would still fail at the bootloader (final) step.

Next I tried to just reinstall GRUB bootloader (using Boot-Repair), with some retries recompiling GRUB and even updating the partition Linux kernel to latest one to be sure... without luck. Bootloader was installed but couldn't boot the OS.

Two afternoons later I decided to do one last attempt before giving up: As the laptop's boot menu allows me to run the USBdrive Ubuntu install using UEFI (instead of "legacy boot"), I just tried running it to see what would do... And it worked!

If I had just RTFM about ubuntu UEFI support I would have seen that now it works and that Ubuntu 15.10 can somehow manage NVME partitions at install time (despite having an old version of gparted...). Anyway, I learned about some recent developments in "BIOS" and HDD firmwares so not all was wasted time & effort.

Also it is interesting to see how Intel seems to be leading in this evolutionary changes by presenting specifications and opening them to others so they become standards.

Note: A the time of this writing, everything works fine in the XPS 9350 model with the mentioned Ubuntu 15.10 except the wifi, which seems to be a "too new" Broadcom model and doesn't even gets detected, so I'm stuck for the time being with having to rely on an external USB wifi donge.


Does the term adultescent even make sense (regarding videogames)?

My grandfather spent a lot of hours every week playing cards while drinking beers at the bar downstairs of his home. Every time we went to visit my grandparents we would get him first.

My father spent hours every weekly watching movies and TV series from the sofa. I knew how to do the vulcan salute before knowing how to tie my shoelaces because he was always watching some Star Trek episode, and nobody could beat me at a movie names hangman (until early 2000s) because he was a film critic so we watched lots of movies together.

At the time of writing this post I'm 34 and I do still play videogames whenever I have time, usually some late nights or at weekends.

Did my grandfather was less adult for playing cards? No, because it was considered ok in the society.

Did my father was "still an adolescent" because of keeping watching TV & films past his mid-20s? Neither.

So why it feels strange to be an adult and "still play videogames"? What I think is that they are a relatively young and new entertainment compared with other forms of entertainment. If videogames were a century old instead of having appeared at the 70s, they would be so deeply integrated in our daily lives and culture they wouldn't be seen as for adolescents.

After all, I now see a lot of "adults" playing games on their phones every day, so why playing a videogame instead of for example watching a movie is different?

I focused on just videogames regarding "adultescents" because at other topics I do think is an appropiate term (or at least I'm not in a position to judge it). I just dislike how it's applied here.

Random rant because of this spanish article.


Previous entries