Sunday, November 6, 2011

lepcpplib - lightweight embeddable portable cpp library

c/c++ has always been my primary choice of programming language. Although I started my career as an embedded platform developer, I used Visual Studio 6.0 extensively as my IDE, whenever I could. I used it mainly because I liked its editor and although when necessary, I have used vi/vim/emacs, I needed something that had a GUI. At that time, I recollect trying a couple of the other alternatives on Windows like Nebeans and JEdit, which were primarily IDEs for Java development but could be used for other languages as they had good syntax highlighting. However, what really kept me going back to VS was its powerful debugger. So, even though, the code that I wrote was for MIPS platforms, I landed up using VS for prototyping and unit testing my code first. Then, I would port this over to the embedded platform. This would, of course, break win32 compatibility. But after the porting of that particular module was complete, I normally did not have to go back to the prototyping/debugging/unit testing cycle. I would use whatever native tools were there for the embedded platform from that point on as I was confident that I had ironed out all the kinks during prototyping and had built a solid foundation. And I pretty much repeated this cycle for every module that I worked on.

This approach certainly had the drawback of having to write first for win32 and then having to port the code to the embedded platform. Since most of my code was on top of the standard libraries I could squeak by without having to write any win32 wrapper and if I had to implement code that talked to the hardware or interface with other modules, I just implemented mock objects. This approach started to get harder and more painful as the size of my module got bigger and tightly integrated with the hardware. I could almost never re-compile the code on VS after integrating the code with the rest of the project as I hated to use #ifdef's all over the code. Over time, I began to notice my pattern. I would start a new module prototype by first copying snippets from my original win32 versions as a starting point and build and debug it there as much as I could. This got worse as time progressed and I had a implemented a lot of handy utilities and classes that I could reuse but there were different versions and embedded deep in the various modules and ported to different platforms. Also, after programming a few of the interface modules in Java, C# and ObjectiveC, I liked their powerful libraries and higher level entities that they provided and wanted to have a means of using them in my c++ projects going forward.


Out of all my code snippets, utilities and learnings from Java/C#/ObjectiveC, I have decided to finally build a library for c++ with the hopes of achieving the following goals:

  • lightweight - design on demand. implement api's on a necessity basis not for completeness (for example, don't implement overloaded functions for all the possible datatypes that can potentially be passed in)
  • embeddable - compact enough to be used in an embedded device project.
  • portable - work across different OSs. initial goal is win32 and linux.
  • modern - provide libraries that have more modern api's and utilities (like an http client) found in newer languages like C# and Java.
  • configurable - provide an easy way of configuring implementation aspects.
  • customizable - be able to take only parts of the library that are needed.
  • unit tested - unit tests for all the classes and api's.

The default libraries in c++ lack abstractions for threads, synchronization objects, datatype converters, sockets etc. Additionally, some of the calls are not exactly the same across Windows and Linux (for example, shutting down of TCP sockets). There are a couple of good opensource alternatives like boost or poco but they do not seem to fit my needs of being lightweight, embeddable and portable. Presenting (drum roll please) lepcpplib. Pronounced - lepsy-pee-pee. You can make it sound French by speaking like Steve Martin in the Pink Panther movie. As of now, only the Apache MIT license file and a header with some of my thoughts on the namespace, the eventing scheme etc are checked in at code.google.com/p/lepcpplib. The next step is to start extracting my code snippets and finding homes for them and add abstractions as and when necessary.

Apart from the above reasons, I just wanted to build a utility library from scratch in which I made the judgement call on its how's, why's and what's. It's more fun this way to start to build something with these goals in mind and to violate each of these as time progresses by and end up with a gobbledygook of a bloated library!


Friday, October 14, 2011

TWIT Flipside - TWIG Episode 100

Privacy, Social Responsibility and Respect

This blog post is part of a series of blog posts that I plan to make over time. TWIT hosts a great set of podcasts with very knowledgeable and famous panelists. Sometimes, while listening to an episode, it makes me want to voice my thoughts as part of the discussion, when my opinion differs largely from that of the panel. These group of blog posts are my attempt at being part of the conversation. So, I call it "the flipside" - my view of things. It is my offline attempt to debate this more and take the mumbling out of my head and put it rest by jotting it down. I have a lot of respect for Leo Laporte and the rest of the hosts, so TWIT army, please don't take this the wrong way and bring down my site!

Background (for those who missed the show or don't watch it): One of the topics discussed in the podcast TWIG on Episode 100 was how the Google Street View cars were being blocked in Bangalore. Matt Cutts, the famous search-spam-buster from Google remarked TINAGI (This Is Not A Google Issue) and Prof. Jeff Jarvis and Leo Laporte commented how this was becoming another Blurmany.

Born in India and having grown up in Bombay (aka Mumbai) and having worked in Bangalore (aka Bengaluru), I understand some of the sentiments behind the request to stop these Google Street View cars. I also understand Google's urge to map the world and make it easy for everybody to find what they want, whenever they want and wherever they are. Google street view has been a great tool for all of us in the US and really revolutionized online mapping and GPS navigation services. But, whenever an application/service is launched in a different country, there are a variety of non-technical challenges such as social, political, geographical and security related considerations that come into play. The recent Mumbai terrorist attacks and bomb blasts in Bangalore and other parts of India has made the law enforcers there very nervous. The US has been largely successful in quashing terrorist activities in the world and has tightened its security to prevent antisocial elements from setting foot in the country. This has largely made our lifestyle in the US much safer. On the other hand, countries like India, which have a booming economy primarily due to the success of the private enterprise, have governments that are still way behind in attempts to plug terrorist activities and porous borders. Granted that all the street view cars are doing is capturing publicly available information but it is the scale and the ease of access that is the issue. I think there are some social responsibilities that come into play when launching a service like the street view. Due to tightening of security in India and other developing countries, it is probably hard for a terrorist organization to actually be able to get a detailed map of a city, leave alone the pictures of all the important and crowded locations. Making these street views, satellite imagery and detailed maps without consents of the local government could make a lot of these locations soft targets and motivate copycat mass murderers to pull stunts easily.

An analogy from the tech world is the Pwn2Own hacking contest that is organized to hack into different operating systems. Even though contestants exploit vulnerabilities in these OSs to win the prize, they are made to sign NDAs so that vendors can plug the security issues before these vulnerabilities are made public to prevent large scale exploits. I respect Prof. Jarvis's approach to privacy and I am anxious to read his new book - Public Parts. I totally understand the benefits of leading a public lifestyle and the huge benefits of the street view cars. However, in this case, I think that, unlike the privacy issue with Google Street View in Germany, this was more of an internal security issue. Additionally, in a lot of TWIG episodes, Jina Trapani correctly voices her concerns as a woman and as a famous tech person, about her preferences regarding privacy from a personal safety perspective. In TWIG Episode 115, Leo made a remark about how some personal information, if obtained by strangers (e.g. the names of his children), would make him feel creepy. I have children too and I realize that my public/privacy choices have implications when it involves my family and children. We want them to be safe and most information about them kept private, even if we like to be public about other aspects of our life.

Another related issue that gets discussed a lot on TWIG episodes, when the topic pertains to privacy, is Facebook. I dislike using that service primarily because of its privacy settings. It assumes that everything is public or essentially makes it as the default choice for you. It finds clever ways for innocent users to divulge personal information and then makes them public by making the settings complicated for even a geek to figure out. Privacy is a very personal choice. I respect the choice that a lot of people like Jeff and Leo make, to live in public. However, if it is my choice to stay private, then that choice needs to be respected by any service that I use - even if it is free. The example that Jeff correctly brings up frequently is the issue that occurs in real life - you tell your friend a secret but he/she in turn tells it to everybody else. In this very situation, don't you really hate this friend? Wouldn't you either confront him/her and ask them to never do this or probably never trust them anymore? What if divulging the secret caused personal harm to the person(s) involved? I think the same analogy and its implications apply to online privacy.

So, although, from a technical perspective, this may not be a Google issue, I think it does become an issue when you weigh in other aspects such as security and social responsibility.

Saturday, October 8, 2011

Steve Jobs - My Five Stages of Grief

Although it was not a secret that Steve Jobs was unwell, it came as a big shock to me when I heard the news of Steve's passing from a colleague at work. I felt like wind got knocked out of me and I was finding it really hard to believe the story. I was hoping it was one of the bad viral "jokes" that some people like to play on the internet. However, visiting the Apple website, confirmed the news and his photo there looking straight into you, served as an even harder blow to my already sad state of mind. As I drove home from work, I tried hard to distract my thoughts by trying to listen to some podcasts but it was really difficult to do take the news out of my thoughts. Various YouTube videos of his keynotes, his inspirational keynote at Stanford and the iconic devices that he launched kept running in my mind.

Once I got home, I was hoping that the routine of taking care of my 3 month old daughter and my 3 year old son would engulf my thought process and I would not have to deal with the grief at that time. On the contrary, as I sat there in the couch, I could not control my urge to browse the incoming stream on Facebook, Google+ and the posts on various websites. However, some of the posts that I saw made me angry such as posts from my friend "iSad" or a response to that "i2". I somehow felt these posts were mocking the iconic figure and the great products that he launched. Then I saw Jeff Jarvis's post on Google+ that said "iGratitude" and this somehow made me angrier and I stopped reading the posts. Taking care of the kids help me put the loss to the background and the rest of the evening I tried hard to not think about it. What I failed to realize was that everybody was going through the grieving process just like me but in different ways and were in its different stages.

I woke up really early next morning to take care of the crying infant but after feeding and burping her and putting her back to sleep, I could not get sleep myself and as any geek would do, I fired up my MacBook and resumed reading posts about the tragedy. There were so many posts by people I follow on G+ and reading each of them helped some of the healing process but I was on some sort of an emotional roller coaster. Some posts made me feel inspired, thinking about how great a person Steve was, while other posts made me sad thinking of how big a loss it was to technology, his family and to society at large. Reading through his Wikipedia entry, his lifestyle, his past, his career and his humble beginnings, about him sleeping on the floor in friends' rooms, returning Coke bottles for food money, and getting weekly free meals at the local Hare Krishna temple filled me with a mix of emotions.

I was never an Apple fanboy. On the contrary, I own and use an Android phone - DroidX and do not own an iPhone. In fact, way back in 2006, when I completed my Masters thesis, I decided to buy an MP3 player and although iPod's were the rage and style at that time, I chose to buy the Creative Zen as it was supposed to have superior specifications - better display resolution, bigger hard drive, FM tuner and the ability to record audio. However, as I started to use the device, it became abundantly clear why people chose the iPod over the other mass of MP3 players. It was a real pain in the rear to locate podcasts or other paid content on the web using its software and sync to the device. Sure enough, I stopped using the device in a couple of months but I chose to not buy any Apple device because it was "closed" and vertically integrated. A couple of years later, in order to familiarize myself with the iOS platform, I chose to buy a MacBook and over time, I started to see why people flocked in such large numbers to buy the latest devices that Steve convinced you that you really needed it. It was not about intentionally building "closed" systems but rather taking ownership and responsibility of all elements that go into building a system and delivering a product and consumer experience where the end user was more than satisfied and did not have to go through the maze of finding out who to contact in case there were issues - the hardware manufacturer, the OS vendor, the software vendor who wrote the app for managing the device or the clueless sales guy who was just driven by commission. Anybody who owns an Apple product or has visited an Apple store knows exactly what I mean.

Personally, I was very disappointed with the announcements in the Apple keynote the previous day with the iPhone 4S announcements. It seemed like Steve's absence from the keynote had somehow made it less interesting. Deep inside, live everybody else, I was hoping that Steve would show up at some point in the keynote and announce something that would shake up some aspect of our lives. As I mulled over the announcements at the keynote, Steve's loss and read through the huge amount of posts and discussions about him, it became abundantly clear that he had made such a huge impact on our lives, weather we liked it or not, weather you were an Apple fanboy or not. He was able to raise the bar of technology, smartphones and mobile computing to such high levels in such a short time. What he accomplished was so huge, so dramatic and so fundamentally game changing, it was something that most tech savvy CEOs would not be able to accomplish even if they all put their minds together and took double the amount of time.

Looking at the timeline of the key things he launched (iPhone, iPod Touch, iPad and iOS), it seemed like he had a huge burst of energy after he realized how short his stay was going to be. Most people in this situation would choose to do things that would give themselves and their near-and-dear ones happiness but this man chose to spend it in building revolutionary devices that would change the world. Sure, there were PDAs, smartphones and tablet computers with touch interfaces before the iPhone but his obsession to detail and with only the consumer and their experience in mind he was able to bring this to the masses. Consumers could now use a device that, although "closed", provided them with great features and functionality and made them want more. My 3 year old is so accustomed to the natural touch interface that he occasionally touches the movie icons on the TV assuming it to also have the same interface. Most iPhone/iPad users are not technically savvy but they now have access to technology and functionality that was only used by geeks. His tough years at college, his strange career struggles (being pushed out of a company that you founded), his battles with cancer, his simplistic lifestyle and his passion and obsession with technology, all showcase the multiple facets of this great person.



Steve Jobs, you have changed the world for generations to come. You will always serve as an inspiration, a constant motivator, to push us to raise the bar of technology, to excel at whatever we do and do it with passion. May your soul rest in peace. My deep condolences to your family and relatives. You will always be remembered.



Saturday, October 1, 2011

Hello World!

All literature on computer programming languages start with a "Hello World" example. I thought it would be appropriate to pay my homage to K & R as I start the first post on my blog. I am off to a really late start in the world of blogging, where everybody is a content creator and there is (fortunately or unfortunately) no master editor for the Internet who hand picks content that he/she thinks is worthy of being published, unless of course, you live in a country that filters the Internet. Fortunately for me, I live in a country that allows me to post my thoughts freely. 

It makes me wonder why I haven't really blogged in so many years? I have been a programmer since my high school, have had a computer and an Internet connection for the longest time that I can remember. I love reading blog posts and like to express my strongly biased opinions, whenever I am in a discussion! I am certainly not the next greatest writer but I have an opinion about the current happenings in technology and would like to share my thoughts with the rest of the Internet community.The beauty of blogging is that it costs me nothing (thanks to free blogging sites) and it is probably of no value to anybody but me. Despite that fact, I would really like to jot my thoughts and leave these footprints on "the URLs of the Internet" so that one day I can go back and take a peek at my flow of thoughts. So, back to the question, why not until now and why now, especially when most people have moved on from serious blogging to microblogging on Facebook, Twitter and lately on Google+?

My dilemma, for the longest time has been - am I the brand or am I part of my employer's brand? I have worked (and continue to work) for software companies but every time I wanted to blog about something, my constant worry was that I might inadvertently reveal some company secret or my opinion may not be the same as that of the company that I work for, causing some sorta PR heartburn. I have written a couple of blog posts in the past but left them in the draft state and never hit the "publish" button. I did not want to be "the guy who left the iPhone 4 prototype in a bar" or "the guy from Microsoft who got fired for tweeting about an upcoming Nokia phone". Additionally, there are all these "analysts" on the web who look for crumbs such as updates on LinkedIn or career postings on the web to interpret what a company is working on and I did not want to post something and inadvertently land up being be "that guy".

Now, don't get me wrong. I am not the big kahuna at the place where I work. I am one among the large army of trained monkeys who can program on command! Lately, I have been bumping into a bunch of blogs where employees of big companies blog as themselves instead of the company that they work for. For example, Matt Cutts, the search-engine-spam-crusher at Google, blogs and makes appearances at podcasts like TWIG, where he primarily comments as himself and not as a spokesperson for Google. I have also noticed some bloggers placing a disclaimer on their blog separating them from the company that they work for. What really inspired me to finally start publishing this post was the flood of thoughts that filled my mind after reading a post on my buddy's blog about "the need to code" and a link to another article that talked about this geeky urge to constantly program. This reminded me of my life as a programmer and I decided that I would finally start blogging and free those mindless mumblings that run in my head as I go through various tech news articles, program, read blog posts and tech articles or listen to podcasts which sometimes form some conflicting opinions in my head and keep spinning like an infinite loop. Blogging about it will help me CTRL+BREAK out, put the thought to rest and move on ...

So, if you are a hacker, hope you enjoy my mindless mumblings and comment on my posts but if you are somebody fishing for info, do yourself a favor, read the disclaimer on the header and move on - these are my thoughts and mine alone.

The praveenster has finally spoken.