The fallacy of high-level programming

For the last 5 years or so, I’ve stopped writing on technical subjects on this blog. But that doesn’t mean I stop writing completely, in fact, I keep on writing a lot, but keep them to myself instead of posting out. For reasons too numerous to tell, or to be short, just because I’m lazy. Software engineering is a still a relatively – young industry, hence, naivety, untruthfulnesses, deceptions, myths, lies, and dogmas are… countless. In that environment, writings could be controversial and misleading, so I choose to note down my ideas in private.

I started with Turbo-C on DOS, then move on to different dialects of the C language: Watcom C, Borland C++, C++, glibC, Obj-C… For me, the most important thing in programming is… crashes. It crashes right away to tell you that you’ve done something wrong! It crashes when you access a null pointer, it crashes when you use an API the wrong way, it crashes when you allocate an infeasible amount of memory, it crashes when you access a dangling pointer referencing to an object which has gone out of scope, just because you can’t track on the life-cycle of that object. It doesn’t even throw an exception and try going on until the situation is unmanageable. Simply put, there’s NO exception, you’re punished immediately, as soon as you’ve done something wrong!

I strongly advocate the use of ARC for memory management, in fact, I would call it the most brilliant feature of the Obj-C language for the last 25 years or so, ARC makes life much more easier. But I also advocate the use of crashes as a “graceful” way to tell that you’ve done something wrong with the deallocated blocks. It crashes right away when you allocate an unbearable amount of memory so that you would know that your algorithms and data – structures are not efficient enough, and you will need to improve, to do tuning, optimization! For me, modern languages are good and friendly, the down side is that it’s also too friendly to the developers, without punishments, how can the devs’ skills could be improved!

Thus, by the interacting between you – the coder and the computer & compiler combination, the reward – punishment model will help greatly boost the devs’ skills over time, and help producing good code. There’re huge differences between an experienced programmer who write good code, and foresee possibilities of bugs, and a novice one who only try to make it… just run. I really want to emphasize here, that the “reward – punishment” model of programming is what made a good programmer! Also by learning to handle memory problems by yourself give you opportunities to follow and understand the life cycles of objects, of memory blocks, understand the precise flows of code, understand the cost-and-benefits of each coding approaches.

e-ink display

Hiện tại, giá còn hơi chát, nhưng tương lai 1, 2 năm nữa, có một viễn cảnh như thế này: máy tính của coder nên có hai màn hình, một LCD truyền thống, và một e-ink, trong ảnh là màn hình e-ink Dasung, cty trụ sở tại Bắc Kinh, TQ (đã có màn hình kích cỡ 25.3 inch). Tất nhiên, nhiều thao tác máy tính vẫn cần đến màn hình đầy đủ mầu sắc.

Nhưng với một coder – lập trình viên mà nói, một ngày có khi hơn 12 tiếng, phần nhiều chỉ edit text, thì màn hình e-ink hoàn toàn không phát sáng, đúng nghĩa là “giấy trắng mực đen”, có thể bảo vệ mắt tốt hơn rất nhiều, càng tốt hơn nữa nếu có thể hiển thị 256 mức xám! Xứ sở phát minh ra giấy, đương nhiên sẽ làm giấy điện tử thật tốt!

giáo dục thể chất, 1

Đây là hệ quả của cái lối: “chơi thể thao một cách triết học, và suy nghĩ triết học một cách thể thao”! Ai cũng biết sức khoẻ, thể chất là nền tảng của mọi điều, ấy thế mà vẫn chỉ “thể dục, thể thao” trên giấy, vẫn cố viết “sách”! Riết rồi suốt ngày chỉ loanh quanh với ba cái ngôn từ vớ vẩn, tìm cách “chơi chữ”, tìm cách “hơn người” bằng hoạt ngôn xảo ngữ, chứ động tay động chân thì không muốn và không làm được!

Không chỉ thế, nó ảnh hưởng suốt phần đời sau của đứa học sinh! Học cái gì cũng không có “hành”, chỉ lải nhải một mớ lý thuyết, ngôn từ chết! Học cái gì cũng lớt phớt bề mặt, không có chiều sâu, không có công phu! Nói đâu xa, ngay trong giới lập trình viên hiện tại, 10 người thì hết 9.5 người, hỏi gì cũng biết, công nghệ nào cũng biết, trên trời dưới đất, chỉ có là những kỹ năng lập trình phức tạp, thực tế không làm được!

panorama

Hồi đó, không nhớ là năm nào, xài cái iPhone 4S (dạng cũng rất hiện đại lúc đó) chụp ảnh panorama, chất lượng tệ, không hài lòng nên đi mua cái Sony NEX5R, chiếc máy ảnh không gương lật đầu tiên, chụp panorama khá tốt. Hôm nay thử dùng chỉ 1 cái iPhone 7 cũ rích chụp pano thử xem, cho ra một cái ảnh 15000 x 4000 pixel (chờ ảnh load hơi lâu), má ơi, đúng là mình lạc hậu về công nghệ thật rồi! Haiza, đúng là thời thế, công nghệ đi quá nhanh, đẹp hơn hẳn máy ảnh chuyên nghiệp ngày xưa!

P/S: nói có vẻ ngược đời, nhưng từ xưa giờ vẫn quan niệm rằng: tôi chẳng cần phải biết cái éo gì về công nghệ cả! Tôi chỉ biết về kỹ thuật (techniques) thôi! Vâng, nói rõ ràng như vậy! Tôi chỉ biết những mánh mẹo, kỹ xảo lập trình xa xưa, những thủ pháp cấu trúc dữ liệu, tối ưu hoá li ti, thời của “programming pearls” – những viên ngọc lập trình ấy! Coder giờ toàn ở “trên trời”, công nghệ này kia, AI, Machine learning, Big data, nói như vẹt, chỉ có điều mấy cái “căn bản” lại không biết!

Ảnh lớn, cuộn theo phương ngang để xem.

analog computers

Một chủ đề ưa thích của tôi là lịch sử Khoa học Kỹ thuật. Lên Đại học, tiếp xúc với các khái niệm automata, tự động hoá và điều khiển, tôi được học chung về các nguyên tắc đầu vào và đầu ra của các hệ thống máy tính điện tử. Tất cả các tín hiệu “in và out” (sensor, control, actuator…) được “lượng hoá” từ tín hiệu analog thành digital, vì máy tính hoạt động trên nguyên tắc tín hiệu số, dĩ nhiên có một số bộ chuyển đổi AD, DA đâu đó. Nhưng mãi lâu về sau, tôi mới được biết đến cái gọi là “analog computer”, ngược hẳn với “digital computer”, đó là những “máy tính tương tự”, hoạt động trên các “tín hiệu tương tự”, sử dụng những nguyên tắc cơ, điện, quang… Một ví dụ “kinh khủng” nhất cho các “analog computer” là các “máy tính” sử dụng trong điều khiển tàu vũ trụ của Liên Xô, mở ra bên trong thấy toàn các bánh xe cơ giới!

Một sự thật làm tôi há hốc mồm vì kinh ngạc! Tàu con thoi Soyuz được phóng lên vũ trụ và hạ cánh xuống mặt đất, được tự động hoá từ A đến Z, không cần người điều khiển, sử dụng những bánh xe, cánh tay đòn hoàn toàn cơ giới như thế. Trong khi “Tàu con thoi – space shuttle” của Mỹ, sử dụng “digital computer” hẳn hoi – hiện đại hơn Liên Xô cả một thế hệ, nhưng không thể tự động hoá hoàn toàn, phải có người điều khiển! Các hình dưới đây, bảng điều khiển tàu vũ trụ Liên Xô, một quả địa cầu được xoay bằng các trục và bánh xe, để chỉ cho phi công biết con tàu đang ở đâu so với mặt đất! Mở ra bên trong trông như một cái đồng hồ, một kỳ quan thực sự về cơ khí phức tạp! Phải mất rất lâu ta mới hiểu ra rằng, có nhiều hơn một cách để làm “chuyện ấy”, và những “cách khác” ấy đôi khi rất “dị” so với “quan điểm thông thường”!

quy tắc 10,000 giờ

Quy tắc 10,000 giờ liệu có đúng!? Từ lâu các “bài” trên internet “kháo nhau” rằng, dù là lĩnh vực gì, tập trung cho nó đủ 10,000 giờ, bạn sẽ trở thành “chuyên gia” trong lĩnh vực đó!? Mới nghe tôi đã phì cười… Như tôi, lập trình C: Borland C++, Visual C++, Objective-C, glibC… xoay quanh mỗi ngôn ngữ C hơn 20 năm, thời gian bỏ vào đó hơn 10,000 giờ nhiều lần.

Hay thời gian dành cho thuyền bè 6, 7 năm qua cũng đã hơn 10,000 giờ, mà cũng chưa nên cơm cháo gì! Cuộc sống ko dể dàng đến thế! Thật ớn ăn cho các “tác giả” – “giả cầy” của thời buổi marketing, PR, sale, SEO… những lĩnh vực lúc nào cũng chỉ muốn “mì ăn liền” và hiệu quả nhanh chóng. Họ đang nô dịch chúng ta từ trong suy nghĩ… 10,000 giờ ư, chuyện nhỏ!!!

goat cart

The two sides of my life: The world wide web and The wide wild wet, a heavy – loaded feeling like the donkey in the image below!

algorithms

Một phần quan trọng của 4 năm ĐH nằm trong cuốn này. Sách ngoại văn bìa cứng, bản in đẹp giấy tốt, đồng giá 50K/cuốn. Những năm 199x, FAHASA nhập sách ngoại về, bán chẳng ai mua, canh me đi qua lúc nó sale off, xúc luôn một lúc cả chục cuốn, từ Algorithms, Data structure, Computer graphics… cho đến Algebra, Advanced Calculus, Statistics, Mathematical Analysis, etc… Cũng là lý do tại sao thuật ngữ Toán, Tin… ko hề biết tiếng Việt. Cũng chưa thấy cuốn sách Tin học nào hay và bổ ích như cuốn này. Nói cho đúng là cái cách hành văn khoa học tiếng Anh của nó ám ảnh mình, ít khi thấy được một cách hành văn hay, súc tích, dể hiểu đến như thế, cộng thêm minh hoạ cực kỳ xinh đẹp.

Nếu nói mức độ hiểu vấn đề nó thể hiện qua khả năng diễn đạt, trình bày lại để cho người khác cũng hiểu thì tác giả cuốn này đúng là siêu đẳng! Về sau phát hiện ra, cả thư viện Đại học Khoa học Tự nhiên cũng chỉ có đúng một cuốn này, mình có riêng một cuốn! Không có thói quen đọc nhiều sách, theo mình, cả ĐH chỉ cần đọc chừng 3, 4 cuốn, và cả cuộc đời chắc không cần đến 20 cuốn. Đọc nhiều phí hoài tuổi xanh đi! Dự định sau này mình sẽ đóng cái kệ sách cao đến sát trần nhà, bỏ bớt những cuốn không đọc lên trên cao để không phải đụng đến chúng! Sách hay thì ít như sao buổi sớm, mà sách lôm côm lại nhiều như… lá rụng mùa thu! Sau bác nào đó thấy sách ngon, mượn ko trả, tiếc đứt ruột!

the man of wisdom delights in water…

仁者樂山
智者樂水

Written with a Bamboo stylus on iPad, using my inking mentioned earlier! A quote from Confucius’ Analects, and its partial, literal equivalence in English on this post’s title. Looks like there’s still lots of space for improvements on creating real, good looking strokes (for Chinese round brush and other kinds of brushes). Really discontent with my Chinese handwriting, it’s never been good enough for me, it’s been degrading greatly over time without practicing! My handwriting reflects my messy, chronically — undisciplined character!

inking

My proudly – announced achievement for the last 6 working months, now is a registering (pending) patent in the U.S. It’s about create inking effect to handwriting on iPad (ideally with a stylus): you can apply many pen styles: ball pen, fountain pen, calligraphy pen, Chinese round brush, and different levels of ink wetness. You may have seen my handwriting in severalpreviousposts, but this is completely different, a big step forward, much more a realistic look like ink on paper. You need to see it in action to witness how interesting the “beautification effect” it is!

Different pen styles:

Different ink wetness:

Another writing example, a poem in both Vietnamese and Chinese:

And now, a real world application, my new year greeting card, hand – written on iPad, printed on paper, with my signature and personal seal on it. Old vintage things are not to be perished, they just come back in new neoclassical forms, to have “inflated”, “degraded” contemporary values reprimanded!

styli

I was playing around with some iPad’s styli lately: the Wacom Bamboo stylus, TruGlide, Adonit Jot, Adonit Jot Touch, Jaja, Cregle’s iPen and ByZero. I’ve been loving the smoothness of Bamboo, but TruGlide is really an excellent one! The new Adonit Jot Touch seems to be promissing, and on the second position is Jaja (for pressure sensitive styli).

wwdc 2012

It would start within a week from now, the well – expected event of Apple’s world – wide developers conference of 2012 – WWDC 2012. To welcome the tech fair, on the left is a screen capture of what I’ve been working hard on for the whole last month (the video is not really clear since it’s shot with my phone), a photo browser UI like iPad’s Photos app. It takes time to learn insights into Core Graphics, Core Animation, and I’m still learning. For all those years of graphics I’ve been through, Apple UI and its graphics sysem are still sooo… brilliant and amazing to me! (and “our love has just begun”!) Keep heading North!

chuyện tình tự kể

Ngày nào, cho tôi biết, biết yêu em rồi, tôi biết tương tư, sau đây là câu chuyện tình tôi tự kể, ngày nào, biết mong chờ, biết rộn rã buồn vui đợi em dưới mưa… Chúng tôi quen nhau tính về thời gian chưa phải là quá lâu, chỉ một vài năm gì đó. Nhưng nguồn cơn, nguyên do câu chuyện có lẽ đã được vun vén, manh nha từ lâu rất lâu về trước, tôi thương em dễ có từ thủa mẹ về với cha.

Bao giờ biết tương tư - Tuấn Ngọc 

Những lý do, ngọn nguồn chẳng thể nào mà giải thích và truy nguyên cho được đã dần đưa chúng tôi lại với nhau tự lúc nào. Tình yêu nào rồi cũng sẽ đi qua nhiều thăng trầm, đã có lúc tôi cảm giác chẳng hiểu gì về em, nhiều khi sự khó khăn của em làm tôi nản chí, cũng có khi tôi đã hoang mang, nghi ngờ em và chính mình.

Nhưng với tình cảm chân thành, bằng trực giác tự nhiên mách bảo, chúng tôi đã vượt qua nhiều sóng gió, để đến một ngày: ngày nào, cảnh thiên đường, đã mở hé tình yêu là trái táo thơm, tôi ghé răng cắn vào… Đến đây thì hẳn các bạn đã đoán ra nàng thơ của tôi tên là… Apple –  hiện diện trên các MacBook, iPhone, iPod, iPad xinh xắn!

writing on the margins

This is just a post of my truly nonsense and random thought. Some notions are just interesting in their own forms, like writing on the margins or sub luna saltamus – dance beneath the moon… I just particularly like the phrase writing on the margins, the action and its meaning, that’s why this website layout is designed with that notion in mind, the left column is reserved for additional and complementary information, as side notes along main content.

Take a look at the two iPad’s screenshots on the left and you would see how nice it is, writing on the margins in a modern and digital form, especially when you could still use your own handwriting with it. You may have noticed the two classical masterpieces (one in mathematics and the other in literature) referenced in those notes!

the new ipad

Just got the new iPad (or we called it: the iPad 3) in hand today and I’m stunned by it’s new retina display. There’s not such a fever like when the iPad 2 was released, I guess since the new iPad is almost identical to iPad 2 in appearance, people will consider about the fact that they won’t be able to show it off. In term of general performance, iPad 3 does not stand out to the previous iPad, or it could be worse in term of 3D – OpenGL performance according to some reviews. From a programmer’s point of view, this could easily be understood since doubling the resolution means 4 times the memory and processing power for each graphics API, which also means Apple has been pushing things over the Moore law’s limit!

Personally I’m not really a passionate fan of these Mắc – Xinh – Tốt (Macintosh) assets, but professionally as a computer – graphics coder, I’ve always admired the prestigous 2D graphics tradition come with Apple’s products. Back to the retina display, on the left is a reduced – size screenshot of this blog taken on the iPad 3 (see full version here, it would take some times to load).

2048 x 1536 is a huge resolution that does magic to the vector things, e.g: displaying fonts! Not only the screen is much sharper, even at first look, its color tone appears to be truer, and the new iPad gamut covers 44% more into the sRGB color space compared to the previous iPad. The second picture: funny capture of Walter Isaacson’s Steve Jobs autobiography put on – top the God of Wealth’s altar in our office!

⓵⏎Mắc – Xinh – Tốt: a phonetical transcription of the name: Macintosh, which is a play–on–words, Mắc means: expensive, Xinh means: cute and Tốt means: good in Vietnamese.


ios-widgets

Having written myself numerous UI widgets, from simple to complex, from Windows to Linux, from 2D to 3D… but I’ve just started writing iOS widgets not too long ago. Making iOS widgets is really fun, for we have supports from the most powerful 2D graphics system ever built, that is CoreGraphics (Quartz 2D). The code, hosted on github, is released under MIT license, check it out for a demo project, I hope that these widgets would be useful somewhere, but yes, I know, don’t complain about the code quality, most is written in a rush and still have flaws in it, use at your own discretion!

1.   XFilePathHeader

This tabular header let you quickly browse a hierachy structure (like file system directories). The levels are shown as tabs, tap on a tab to jump to a parent folder, tap on the “Home” icon to jump to root folder.

2.   XSegmentedControl

The Apple’s standard UISegmentedControl only displays text, not image. This class lets you use image along with text (or image or text alone) in any orders (image then text, or text then image).

3.   XProgressTextField

This is a copy of Safari’s address textfield which shows a progress bar while the webpage is loading. Would continue to add more of these miscellaneous tiny widgets just for fun when I have time.

kindle touch

Well, having played with this “irresistible” Kindle Touch for almost two weeks. The good thing is that I can now continue with my favorite readings on e – ink display like before. The even better thing is that there’s no more clumsy buttons, only “touches”. I’m trying to keep my habit of reserving 4 ~ 6 hours a week for reading, and reading only, no email, no web surf meanwhile, just to be a little bit calm, slow and undistracted. The device now is smaller and fits into my jacket’s pocket so that I can carry it anywhere, just like a small notebook. Image on the left: Kindle Touch, next to an iPad 2 to compare the form – factors.

Updated, Jan 8th

A perfect complement for Kindle touch would be this SolarKindle, a cover and solar charger which would be available on the market next January to eliminate your need for charging a Kindle ever again!

handwriting

This is part of the really fascinating broader concept of neo – analog as mentioned in a previous post. Below is my handwriting with a stylus on my iPad (click to see large version), not too bad after 10 years of solely keyboard and mouse, not pen, right? Also, I’m quite excited with the coming Kindle touch (which should be delivered at end of the month). My thought is that it’s just a matter of time before e – ink would have color and refresh rate capabilities near those of conventional displays, and serious applications would be feasible within the vintage look and feel of e – ink!

the world is not flat

The book title reminds me of the same stupid question: how to put an elephant into a refrigerator. I still insist that you can not put a normal elephant into a normal refrigerator, no matter how people is arguing about that! The question: how to eat an elephant (answer: one bite at a time) actually makes more sense to me!

Friedman is right that there have been dramatic changes in the global economy, in the global landscape; in some directions, the world is much flatter than it has ever been, with those in various parts of the world being more connected than they have ever been, but the world is not flat… Not only is the world not flat: in many ways it has been getting less flat. (Nobel Prize – winning economist Joseph Stiglitz)

The popular expression that a capitalist will even sell you the rope you need to hang him with seems to be becoming increasingly true. Aronica and Ramdoo’s book is an important addition to the literature of globalization and a necessary therapy for all those whose minds have been in touch with Friedman’s glib phrases. (blogcritics.org)

I would tell you how I usually encounter a dialogue taken place in Vietnamese, a pattern that repeats over and over again, and people never learns a thing, neither do they actually have a little sense about real things behind it. Here’s how the dialogue would go on, taken an example to describe the pattern: A (a certain person): I’ve recently read the book “The world is flat”, and really love it! Ah ha, the world is truly flat!   Me: No, the world is not flat!   A: I would suppose you don’t mean it geographically, think about it like a metaphor to get the philosophy of the book, man!   Me: No, the world is not flat!   A: You never get a thing, you crazy!

By now, anyone with a second thought should recognise my meaning either geographically or metaphorically. After that I asked him something into the content of the book. It turned out he knows almost nothing of the book except its name, and parrots the name as if he had found a “holy truth”! Yes I would certainly understand, while everyone was reading and everyone was saying the world is flat, he wouldn’t dare saying (or even thinking) the opposite. My opinion about the book could be right, or it could be wrong, but actually I won’t argue on the surface of phrases, flat or not flat is just a matter of words, what important is the book’s content.

I’d read through the more than 300 pages of the book which takes its examples, facts… exclusively in the Information Technology contexts, either in India, China or other Asian, Latin countries. It is full of details of only the IT industries, details about out – sourcing, internet, software work flow, email, network phone… the things usually seen in outsourcing service. Obviously the author meant a similarity for other fields, other industries, which seems to be a too restrictive point of view, we all know that IT in fact is only a very small fraction of the economy (taken the VN textile industry alone for an example, its estimated yearly revenue is roughly 12 ~ 15 times bigger than the IT counterpart).

The book concentrates on globalisation: the trends of out – sourcing, the way people communicates, the way firms process information… The author propagates it as “a way to be”, a trend, a life style that is absolutely irreversible. Also Friedman considers open source software the most disruptive force of all of the trends since it allows knowledge to be freely distributed and decentralised efforts could be cooperated. Friedman also encourages young American to become scientists, engineers, mathematicians… leaving low – level labour jobs to other countries. The author also tried to relate those vast details with other profound social and political problems.

I have never read anything so “colonial” like that book. It takes a lot of facts, truths… in a small sector of the economy and tries to provide a biased and exaggerated point of view. To exactly quote the author: When the walls came down, and the windows came up, windows can not come from thin air, there’re always “invisible” walls somewhere, and most of the times, those invisibles are much more overwhelming than the visible ones. In fact the book only receives “warm appreciations” in the field it’s related with, and aiming to, that is IT, it does tremendously receive negative reviews right in the country of its author (you can easily check out the web for that).

The world has never been flat, anywhere, anytime. It’s not flat in the sense of people about their living conditions and standards. It’s not flat in everyone’s mental and psychological status. It’s not flat in different life styles, in people’s hugely diverse definitions and pursuits for happiness. It’s not flat even in the American (or any Western) societies, whose tradition has always been the supporting for personal values, think and do differently. It’s not flat as human as a physical and mental objects are bounded to geological and social constraints, and human is more a complex creature rather than, over copper wires, a piece of (possibly cleverly falsified) transmitted information.