Showing posts with label hardware. Show all posts
Showing posts with label hardware. Show all posts

Tuesday, July 19, 2011

Hardware metaphors

Computer metaphors do not always work well in real world.

Here's an example of a metaphor that produces good results when transported in life: RAM vs. permanent storage. Each productivity system (e.g. Getting Things Done) worth its salt recognizes that our brains have limited RAM and we cannot keep in mind too many things at once. But we can use what is called an exocortex - an extension to our brain to augment our capabilities - namely, the Internet, but even a sheet of paper where to write our calculations, or diagrams.
One of the uses of the exocortex is storage: a simple paper notepad that is always with you will be able to function as an hard disk, and your brain RAM will be freed and available for other purposes. The point is not only to avoid forgetting an idea or a TODO, but to avoid worrying about forgetting at all.

Here's an example which doesn't work. Real time notifications are more and more embedded in our system; the sources of input are instant messaging system like email and Twitter. Technology does wonder: compare snail mail to an email being delivered in seconds.
Yet we find ourselves avoiding the wonderful technology of real time communications: interruptions are considered a menace for our flow and our Pomodoros. In order to get large batches, I visit GMail only few times a day, and I'm working on lowering this number; I avoid any kind of GMail or Twitter applet in my panel (although they may work for managers: I'm talking about creative work as put in danger by interruptions).
Polling is often a waste of CPU cycles for computers, and in fact they are built from the ground up on an event-based model: hardware interrupts. Yet the model fails miserably when, due to the inability of humans to multitask like a machine.

Wednesday, March 17, 2010

How improved hardware changed programming

This is a follow-up to the previous post, CPUs speed and technology innovations.

As we have outlined in the previous post, the memory size and computing power available to the average programmer has increased thousands of times from the first years of his art, at least in the boundaries of a single machine (network is a common bottleneck.)
This performance improvement has made radical changes to the style we use in writing software and in its development process.
The first notable change is the progressive introduction of higher-level programming languages. C is near the raw metal of a machine, but upon it portable languages have been written, such as Java and Python. They are still third-generation programming languages but they sacrifice performance for portability by providing a virtual machine and an interpreter respectively.
This is a general trait of higher-level languages: trading machine time to save the developers' time, which with the hardware improvements is now the most expensive resource. At the time of his release to the public in 1995, Java applications were considered slow programs with an extensive memory footprint (with reasons). However today this is no longer significant for a vast set of applications, and the same is true for other high-level languages like Python and Php. Premature optimization is now the evil, not the Java Virtual Machine.

Some people say that software bloats faster than Moore's law can help it: we went to the Moon in 1969 with 4 kilobyte of Ram, now we need 100-200MB to run an operating system. But the features and power of our machines is now much greater (discounted by the amount that runs software's bloated parts), we can do things that were only dreams in 60s.
Continuos integration of software project and immediate feedback via tests are two things that derive from a large amount of computing power available. Donald Knuth is a magician in algorithms, but back in the 60s he has to write a program by hand during the day, and let the machine compile it at night. Now we have the whole process of building and testing for a moderate size program run in minutes from every code check-in. Algorithms were proved on paper: now they are tested on large datasets.
Object-oriented programming is a practice fundamentally less performant than "classical" structured programming, because it stores pointers to virtual methods in every variable, even a wrapped integer. But it lets you have a real domain model in an application, where different entities, both represented as integers, cannnot be mixed up. Few of us will start a serious enterprise application without this paradigm available: the hardware improvements again made possible to simplify the programmer's life, even if sometimes bloat would be introduced.

And the list goes on: every best practices post you can find today (also mine) is in part generated by the continuous hardware improvements that have occurred, and it is a good thing, because it means we are leveraging the machines' power. Meaningful naming for entities? Try it with an 8 character limit. Iterative development, refactoring? Made possible by the insulation layers between components, which are a form of "bloat". Distributed version control? Thank you, cheap space on hard disks.
Moore's law won't save anyone introducing bloat in software. But it makes new programming practices feasible, directly borrowing them from your dreams.

Tuesday, March 16, 2010

CPUs speed and technology innovations

The number of transistors that can be placed inexpensively on an integrated circuit doubles approximately every two years. (Moore's law)
This empirical law is primarily known for the increasing trend of processors speed, which is widely influenced by the capacity of miniaturizing transistors in silicon-based chips. However, the general formulation of the law affects all semiconductor technologies, such as CPUs and electronic memories.
We may also note that similar laws exist for magnetic disks, which storage density doubles annually, and for network capacity (optical fiber's bandwidth doubles every nine months.) This set of empirical laws describe the exponential growth that we have been experiencing for many years.

But do limits to these exponential laws exist?
When miniaturization is involved, atomic limits are usually the ultimate frontier. The current most advanced production process for semiconductor devices is the 45 nanometer technology, which length refers to half of the average distance between memory cells. Each cell consists of two or four transistors, whose size is in the range of 100-200 nm.
For comparison, the size of an hydrogen atom is roughly 0.1 nm, and it is indeed the smallest existent atom. The average distance between silicon atoms arranged in a crystal like the ones used in chips is about 0.5 nm.
The predicted technology for 2015, according to the International Technology Roadmap for Semiconductors, is the 11 nanometer one. This means miniaturized components will be electrically insulated by a layer of... twenty atoms.
The consequences for the inner working of these devices are disastrous. As you may know, the physics models that govern modern integrated circuits are not classical: their design follows quantum mechanics. At such a small scale, quantum tunneling (the same process that charges flash memory cells) can make insulated cells interact. Silicon (and its doped derivates) usage cannot scale to the atomic sizes.

But limits are made to be infringed. For example, the integrated circuits are manufactered by photolithography. Without descending into the details, let's just say that a photoresistive material is "painted" over some area of the chip, which is then exposed to a light flash so that excess material is somehow eliminated from the chip, like if it were a chunk of photographic film. What remains under the shielding layer are the tracks and soon-to-be components of the integrated circuit.
Cool. What's the problem? The light used for this process, as all the other forms of light, has a minimal wavelength of about 200 nm. Thus transferring patterns of elements smaller than this size should not be feasible: it should be like revealing the presence of a 1-inch hole in a wall by launching basketballs at it, in the darkness. But it has been made possible with new techniques and tricks when the limit was reached.
And the same has been done with multi-core architectures: the power consumption of a CMOS cpu is proportional to its clock frequency, and the external components do not increase in speed as a cpu. So when an effective barrier in frequency was reached, the electronic engineers started increasing the processors in a single package instead of having them run faster. The result are the current dual- and quad-core architectures (and the new problem: how to parallelize tasks efficiently to keep all cores busy?)
Maybe Moore's law in its current form will cease to work in the future, but the technology level and the computing power it brings along are still likely to increase for a long time. There were, and still are, great business incentives to continue to enhance computing devices, and clever men always find another way to make money.

Saturday, October 24, 2009

How to transform a broken laptop into a server

I bought my second-hand Toshiba Tecra A3 for about 500 Euros while still in high school, with the earning of my first web projects. During the sebsequent years, it slowly fell into pieces, one step at the time:
  • the first things that failed were the speakers;
  • then, the Combo Dvd reader and Cd writer suddenly was unable to read an entire disk;
  • third, the hard disk began to be unreliable, as files saved on a particular portion of it became corrupted instantly;
  • then the lcd screen suffered a hit and was rendered useless, as only a big stain of color filled (and still now fills) all the screen.
In this situation, I ordered a new ASUS Eee PC from eBay to substitute my former portable working station. This was one of my best purchases, and the Tecra A3 was put in a box and forgotten. However I am glad that I did not throw it away.

Towards the end of 2008, I felt the need for a development/staging server at home, as part of my freelancer work with php applications. The server did not need to run 24/7, but only during my work sessions and with only me and a few other people to work for. I was aware that servers which run Apache and Subversion do not need high-end components and I started to gather ideas on how to recycle my old laptop.
The CD reader was not required for a server, and I could not change it easily anyway. The screen and the speakers were useless for the same reasons, but the hard disk is something a server usually needs. So I bought a cheap 10 gigabytes Eide unit on eBay for less than 30 Euros. Substituting the old drive with this one restored Indy status as a working machine.

The next problem was how to install software on a blank machine like this one, without a CD drive and a screen to complete the graphical or command line installation process.
For the screen problem, I temporarily attached my primary machine monitor and figured out quickly that installing a command-line interfaced system like Ubuntu Server would have given me a system accessible via ssh, without the need for a real screen as I would be able to use the server via other machines like the Eee PC and my primary computer.
The installation was more difficult as I had to find another medium for the Ubuntu iso image. My laptop is not capable of booting via Usb, so I chose an installation with a boot via Ethernet (PXE). This involved setting up a tftp server on my desktop machine to host the installation files, and I suggest you to use a Usb card installation if you want to do the same thing.

Normally, Ubuntu systems run the NetworkManager application in the user bar of Gnome providing a list of wireless network to connect to. I wanted to have a connected system at startup, since without a already existing connection the ssh login is not available. Thus, I configured wpa_supplicant, the daemon used by NetworkManager as a backend, to automatically connect to my home WPA wireless network. Obviously I installed the ssh daemon and after this step I was able to remove the temporary monitor and use my new server remotely.

Once I had a working machine, I installed apache, php, mysql and subversion via the Ubuntu repository, running apt-get over ssh, that is the interface I administer the server still today. Now I had a web and source control server that I periodically backup just in case something goes wrong. Reliability is nor critical as even is the server explodes I can roll out my backups the next day on my desktop machine.

There is an enormous amount of electronics garbage out there to dispose of, and recycling an old pc is by far cheaper than buying full-featured servers just for testing purposes (unless you're doing a stress test): the servers on the market are meant for production sites and php development activities, which do not require compilation, do not stress even a poorly equipped machine as they include only a few http requests per second to satisfy. If you manage to reuse old hardware, you are doing a favor to yourself and to the environment.

Monday, August 31, 2009

The frugal programmer

In the current (2009) economic recession, many blogs about frugality have encountered their major success, aiding people to track and control their spending. A specific frugal approach for programmers and system administrators can help saving bucks, especially if you are exploring the freelancing world or bootstrapping a new business, and every dollar counts.

A side business can be an interesting adventure, and since many new business fail in the first years a little budget is the way to reduce risk to a fixed amount of money and time, playing with what you can afford to lose only. Since this strategy will result in a tight budget, here are some tips on how to manage your freelancer tools along with keeping an eye on how much you are spending.
  • upgrade boxes with crucial hardware. Instead of purchasing a brand new pc, in many cases a pair of new parts (Ram and disk space) can extend the box life of some years; of course a lighter OS will contribute to the revitalization.
  • recycle old machines. Lan servers do not have big requirements and a source control server can be built from nearly anything. I use a old laptop with broken lcd screen and automatic connection to the wireless lan as a http server for staging php applications without weighing down my development box.
  • recycle peripherals from previous machines. Many pieces of equipment have follow the same standard for decades and can be ported from an old machine to empower a new one. Printers and scanners are obviously regained but also keyboard, mouse and monitor can be attached to a new box as they have no performance penalties.
  • use Open Source Software. Ubuntu Linux is a very solid distribution and it contains many application for every kind of usage; I use only Ubuntu on my home pcs: Apache, Php, Mysql, Subversion are examples of what Open Source can do. The expertise that you learn using Open Source tools is also a good know-how that can be useful in your future jobs and projects.
  • buy consumables in bulk. Faster networks and flash cards are killing compact discs and other old media, but when they are still useful you should buy them in large packages (50, 100 pieces) as the total cost can go down to half of the original.
  • do not buy Apple. I think quality is why a Mac cost so much, but an Apple product comes with little upgrading capability, and with a stable but fixed Os where you have to use port of popular applications. I know Macs have nice curves and a good user experience but it does not help when you have to save money: for instance I mainly use command line and vim, where a Mac does not excel more than a old pc with Ubuntu Jaunty installed.
I hope these strategies can help you spend your money better. You should make investments in your tools by spending where you feel a return, such as a comfortable and well designed chair or a lcd monitor for preserving your eyes; only ensure you are not throwing money down the drain.

Featured post

A map metaphor for architectural diagrams

It is a (two-dimension) representation of a pipe. The map is not the territory , but in software engineering terms they are models of it....

Popular posts