career’s funs – 8

he computer industry is the only industry that is more fashion – driven than women’s fashion. (Larry Ellison) => right, so much dogmas, lies and myths.

Well, it has been said over and over again that the tremendous cost of programming is caused by the fact that it is done by cheap labor. (Edsger W. Dijkstra) => needless to say, another so true dilemma!

I do believe I have post-traumatic Java syndrome. (Renae Blair) => me too, though not very serious!

One of my most productive days was throwing away 1000 lines of code. (Ken Thompson) => with me even more

Deleted code is debugged code. [Jeff Sickel] => 😬

Before code can be reusable it first has to be usable. (Ralph Johnson) => certainly!

The goal of Software Engineering is to build something that will last at least until we’ve finished building it. (unknown) => applied to many projects!

Better train people and risk they leave – than do nothing and risk they stay. (unknown) => it’s worse when they stay and untrained!

Benchmarks don’t lie, but liars do benchmarks. (unknown) => countless cases!

Why do we never have time to do it right, but always have time to do it over? (unknown) => the question answers itself!

Evolution always seems to win out over revolution when it comes to technology. (Rick Hightower) => don’t believe in one who screams for revolution!

If you have too many special cases, you are doing it wrong. (Craig Zerouni) => solving is not creating more problems (special cases = problems)!

C++ is popular because it is like C. Java is popular because it is like C++ and C. C# is popular because it is like Java. See a pattern! (Rick Hightower) => many techies fanboys forgets this!

What it comes down to is that Rails developers are just that: they’re not software developers, at least not most of them… Their framework dictates how their systems are designed instead of the problems the systems are designed to solve. (Samuel Tesla) => said this several years ago

Suppose you went back to Ada Lovelace and asked her the difference between a script and a program. She’d probably look at you funny, then say something like: Well, a script is what you give the actors, but a program is what you give the audience. (Larry Wall) => 😀

The structure of software systems tend to reflect the structure of the organization that produce them. (Douglas Crockford) => 😀 absolutely!

engineering dogmas

ver the years in our software community, I’ve seen a lot of dogmas, myths and lies that spread like ‘cholera’. That only reflects the fact that many programmers just repeat like parrots what they ‘learned’ from school, news, books… without their own justification, and to some extent, reflect their lacking of experiences. A good engineer should, at least, have some abilities to judge the pros and cons, weak points and strong points, when to use, and when not to use a method, a language or a technology.

Design first, then code!

The principle is, in general, not wrong. However, pragmatically, a software’s final structure, architecture… is not achievable as product of an immediate thought or a single design cycle. In most cases, the “first design” is certainly not the correct one. It’s not in a deterministic process that we can build software, complex product would always requires a lot of trial and fail. And from my experiences, good designs are sustainable solutions after a tedious process of experiments to eliminate wrong directions. We need coders of strong analysis and experimental skills rather than the “evangelic designers”!

Where are the documents?

We are going to make clear distinction: do we need coders who really understand what they are doing, or we just need some paper to present to customers? In countless cases did I see that coders do not understanding what they are doing: they don’t understand a feature, they don’t know how to archive that, they are unable to judge the pros and cons, they just mechanically copy and paste code from somewhere. Documents only provide rough, general views on the matters. If you’re going to mention about a static-web-page project, I would agree that document is something. But if you’re mentioning system programming, it’s the code that is the document!

Poor skills and wrong knowledges

This is simply put: countless! Just to name a few:

Poor skills: once, a coder being asked to fix a “null pointer exception”. What he did is adding a “if (pointer != NULL)” line into the code. It’s not fixing, it’s just hiding, fixing is find out why the pointer is NULL, not prevent it from being executed! Another time, another coder, getting frustrated under a crash situation, place a “try… catch” around the buggy code segment. This is again, not fixing, with this way of hiding, we’re just going to accumulate faultinesses until the software crashes silently for no reasons!

Object oriented programming rules: OOP is more beautiful in theory than in practice. OOP provides a nice way for modeling, but it come at costs: bloating code. It is not until the project grows above 1M LOC that OOP become a burden, that we would need to do the “functional decomposition” optimization tasks. It’s the execution (functional) tree that decides performance, not the inheritance tree that obscures runtime characteristics!

Design pattern rules: this is again, not true! I agree that patterns reflect some good coding practices, but software could never be built from the so call “patterns” (there hasn’t been any such proven process). I really don’t understand what is a “singleton” if it’s essentially (in C/C++ syntax) a static variable, I also don’t understand what we need from a “factory” if it’s essentially a “switch… case” structure!?

Management myths

Managers tend to forget what they’d learned when they were coders. There’re lots of myths in software management, just some examples:

  • Software people is of a same type and the same background.

  • We already have a book that’s full of standards and procedures for building software. That provide out people with everything they need to know!

  • If we get behind schedule, we can add more programmers and catch up.

  • Project requirements continually change, but change can be easily accommodated because software is flexible.

There have been extensive criticisms on various OOP models and OOP implementations (Java, C#, C++, MFC, Objective C, glib…) The AntiPatterns wiki and many other authors provide good anti-examples on the uses of patterns!

Linus Torvalds, being criticised: “the kernel has no obvious design”, had replied: “Linux is evolution, not intelligent designs”! The same applied for similarly complex projects!

Document is for understanding, but is not the understanding itself.

Software project management is the domain of vast diversity! No simple rules applied to a software process!

Win vs. Mac font rendering (and the way for Linux)

We could easily see the very poor font rendering quality of Windows right on Windows itself using Safari. Safari has different smoothing modes (image above) and another mode named “Windows’ standard” (image below)


Differences between font rendering on Ubuntu (above) and Windows (below).

everal years ago, on earlier versions of Fedora, Ubuntu… font rendering is just a crap! Many people would find Windows better at text rasterization, and both are far inferior compared to Mac. In latest versions of Linux desktop, things are much improved, while Windows (Vista, Win7) is still much lagging behind, Linux made bold advances from lessons learned from both Win and Mac!

Novice users on Windows would find its text sharper, clearer and easier to read, while Mac’s one is a bit blurry! That is because Mac and Win have different origins and targets! Apple has deep legacy in graphics designs and desktop publishing, its algorithms try to preserve the nature of typefaces as much as possible, which implement true sub-pixel rendering aiming at high-resolution output devices. Meanwhile, Win sticks to pixel unit and aims at low-resolution device (like computer screen which usually less than 100 dpi in resolution).

The consequence is that while Win’s text look sharper and clearer on screen, it would turn into a whole crap when come to printing, where Mac’s publishing products are closer to its screen look! Even worse, Windows text rendering solutions are just suitable for simple typefaces, when complex, high-quality font is needed, the output is usually very poor due to various wrong implementations in hinting, anti-aliasing, kerning algorithms. This paper (2007) addresses in details many Microsoft’s implementation problems, and suggest the correct ways for text rasterization, resulting in a now-much-better Linux desktop!

(If you’re using a Mac or a Linux desktop, you would see this blog text in VN URW Gothic L, a aesthetically fine font. Windows readers would only see the text in Arial, as I have to turn off font embedding for Windows due to its very poor presentation.)

Update, Feb, 20th, 2011

The font used now is Tex Gyre Adventor, an enhanced font based on URW Gothic L, you can see the hinting is quite better, especially for Vietnamese text. The trade – off is that file size is much larger, almost triple the URW Gothic L’s size.

career’s funs – 7

If programming languages are cutleries, still some high respect for Ruby… My experience is that if some languages or technologies come with much bells and whistles, noone would mention about them in the next few years. I just need to keep with me a katana!

here are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. (Charles Antony Richard Hoare)

A good programmer is someone who looks both ways before crossing a one-way street. (Doug Linder)

Being abstract is something profoundly different from being vague… The purpose of abstraction is not to be vague, but to create a new semantic level in which one can be absolutely precise. (Edsger Dijkstra)

It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter. (Nathaniel S. Borenstein)

Measuring programming progress by lines of code is like measuring aircraft building progress by weight. (Bill Gates)

There are only two kinds of programming languages: those people always bitch about and those nobody uses. (Bjarne Stroustrup)

The C programming language, a language which combines the flexibility of assembly language with the power of assembly language. (unknown)

The last good thing written in C# was Beethoven’s Moonlight Sonata. (unknown)

The problem with using C++ … is that there’s already a strong tendency in the language to require you to know everything before you can do anything. (Larry Wall)

A system composed of 100,000 lines of C++ is not be sneezed at… The real test of OOP will come when systems of 1 to 10 million lines of code are developed. (Ed Yourdon)

Computer language design is just like a stroll in the park. Jurassic Park, that is. (Larry Wall)

3d particles

ome funs with 3D effects. Just some years ago, rendering 3D particles like water, smoke, fire, fog… was an extremely hard task. I remember how struggling it was for me to build 3D models for a waterfall (with moving water) or a shouting-crowd stadium. It’s enjoyable to see how graphics has advanced in the past few years, these effects are now easily achievable.

Video above: the classical Utah teapot with steam coming out from its spout, rendered with Panda3D, the well-known open-source game engine originally released by Disney, which has a feature-rich C++ core with Python scripting for application development.

basic algorithms

The book is my primary source of interest while being a freshman, which presents a wide range of algorithms in a very coherent and systematic way. I remember “rescuing” this hard-copy from a Fahasa‘s junk pile for about 4 USD, which from that time on became a student’s most precious thing! You can read the soft-copy here.

his is among the subjects I was very fascinated the early years at university: algorithms, graph theory, geometry, image processing… I was not quite good at “symbolic” math (like algebra), but “visual” math offered me much inspiration. The thing I would remember most is Robert Sedgewick‘s Algorithms, a book that I’ve read through over and over again many many times. It is indeed the most important Computer Science textbook that beginners MUST read until today.

The Java applet below is “refurbished” from the code I wrote the first year at college, which visualizes the nature of different sorting algorithms (original code was written in Borland C++ 3.1 with BGI – Borland Graphics Interface). This is among my various attempts to visualize the knowledge collected from the book, which had taught me that even a simple thing like “bubble sort” is not that “very simple”! Let select an algorithm in the dropdown list and click ‘Start’ and see the differences!

My visualizations above are very early (1997), much prior to those demonstrations on wiki. Later on, I’d learned that the author R.Sedgewick put a great emphasis on algorithms’ visualizing himself, his work used PostScript. Many new ways of visualization are really impressive and easy to understand, such as this (using JavaScript).

I started with with C/C++ at school, then continue with C/C++, Java, Design Patterns… on various projects. Later I abandoned Design Patterns (and Java), then I abandoned C++. To me there’s no Design Patterns, there’s only data structures and algorithms! Would write another post on the bloating and non-sense usages of Design Patterns later on!

It seems that most software engineers today lack fundamental knowledges and skills. It’s quite apparent that you could not rely on a guy talking about architecture, GoF’s design patterns… all the time but can not state the algorithmic differences between a DFS (depth first search) and a BFS (breadth first search).

parallax

“3D clip” made by myself just for fun, strictly speaking, this is not 3D video but rather a pseudo – 3D effect, parallax, (tiếng Việt: thị sai) created totally from still images (see on the left). My video is partially inspired by this excellent CSS – only parallax. It’s quite easy to figure out how to acquire this, but let read about the definition from wiki.

This is also a popular technique in game programming, some early (and current) games choose to reduce a full 3D scene to several layers, some use parallax – mapping to acquire a pseudo – spatial effect, all helps eliminating excessive 3D computations. Clip made from random still images captured at Khe Gà, Phan Thiết.

typeface resources

Classical typesetters have delivered custom typography since the 15th century. Internet could not until now… Western typography had professional typefaces since the 15th century. Vietnamese still not has good-looking publishing fonts until now…

n my career, it’s among my habits to ask people whether they really understand basic things, it turned out many many times that it’s not so easy with even the basic programming techniques, basic algorithms & data structures… 😢 Just like the a, b, c… in the alphabetical table, even write a character down in a beautiful manner is not easy! Below I would try to cover some resources in learning the use of typefaces in designing.

3d graphical user interface

The code is written in C++ base on Clutter 1.2.4 library. It shows basic widgets: tabbed container, scrolling container, list box, combo box, check box, edit box, button, label, radio button…

his is my personal project in which I tried to evaluate some new ideas and concepts in using 3D techniques for GUI (Graphical User Interface). It’s quite tiny indeed (about 6000 LOC – line of code), all written by myself in about a month (mostly in my free times at weekends). So please don’t blame me on some un-completed or un-polished features, they are just for testing the ideas only. I would try to examine the trend of applying 3D graphics to GUI, but first, let have a look at the video below.

1.   The first thing to consider is not 3D engines or hardwares, it is about usability. Many traditional (2D) GUI out there are already complex and obstructive. GUI is about information presentation and presentation should be really simple and clear so that even my grand mother can understand and use. I’ve been seeking, trying to explore many new ways invented to represent information in 3D (or 2.5D) space, and I could say only a very very small percent of them could make a usable value. Users have long been familiar with 2D, and yet 3D hasn’t been very much persuasive.

2.   3D hardwares can be categorized into 3 groups (as listed on the left), and the 3D engine can be configured to off-load calculations to hardware. With the 1st type of device, only bitmap operations could be off-loaded. With the 2nd type of device, many drawing operations (the path_xxx functions) can be off-loaded. The 3rd type of hardware is most valuable since we can have its finish for ourselves a lot of work.

It’s important to understand the target device our software stack would be running on. If it is an out-date machine with just some blitters, we should use paint-like (aka: bitmaps) operations, while on most modern PC, draw-like (aka: 2D vector) operations are more encouraging. While bitmaps may offer nicer and more customizable GUI, the cons is it lacks the scalable ability that vector has.

3.   The last is about software implementation. Many of the graphics concepts are first introduced in software, which then embedded to hardware, which then standardized by software (like OpenGL or DirectX) again. Thus, many elements of a graphics pipeline is the production of a long history of interactive evolution. A graphics pipleline is not a general framework, it depends on very detailed, in-depth techniques to be operational in real-world application.

Game & graphics are the domains where most formal software methods would easily failed. 3D graphics developers should have good knowledge on graphics in general (bitmap and vector drawing), geometry, linear algebra & discrete maths, deep understanding on data-structures and algorithms… are strong pluses, advanced tips & tricks in coding and optimization is a must (game & graphics programming has always been a hell of tricks from the age of dawn) and finally good understanding on 3D techniques (model, scenegraph, projecting, shading, clipping, lighting, effects…)

linux sound server

1. Configure the PulseAudio server to broadcast itself and receive connections from clients. Configure the PulseAudio client to redirect audio output to server.

2. GMPC remotely play music on a MPD server.

ome funs with Linux sound system. Today, a small, lightweight laptop is well – suited for all my everyday need: email, web, office, music, video… A home PC is mostly used as file server or backup system. However, one thing you could never be pleased with the laptop is its sound, at least you still need a PC with good soundcard & speakers to enjoy music! Being lazy to plug-in the speaker jack most of the time, and in order to get rid of all those cables, we can choose two following approaches:

Setup a Sound server

1. Setup PulseAudio server on the PC machine and configure it to accept client connections. 2. setup PulseAudio client on the laptop. 3. We can choose to direct audio to local laptop headphone or to the remote PC (with our beloved good – quality speakers). PulseAudio can be a pain on some systems since Linux sound has always been a mess: ALSA, OSS, ESD, PulseAudio… As of Ubuntu 10.04 (Lucid Lynx), PulseAudio is quite stable, you would only need to:

sudo apt-get install padevchooser
# this will install PulseAudio device chooser
# which then trigger other dependency packages

Some old Linux apps (like XMMS, the music player I loved) would not know about PulseAudio. We need to configure it to use ALSA, which has been re-configured to work in bridge mode (ALSA would simply redirect signal to PulseAudio then).

Setup a Music server

Using MPD (Music Player Daemon – a music player working in client / server mode using a simple TCP text protocol) and a client like GMPC (Gnome Music Player Client). Though it may take some times tweaking around to get MPD working with PulseAudio, this would play very well mp3 files you stored on the server. I’ve been using all these 2 methods to have my music played while lying on sofa or in bed!

(And if you’re a vim – addicting user, you could use vimmpc to serve music for yourself while working inside vim).