TechWire

Tag - Software

The perfect swap in C++

So you are coding this cool app and you need to swap two variables. How does a good programmer do that in C++? The STL (Standard Templates Library) provides the std::swap function which does exactly what we want.

[code language=”cpp”]int a = 10;
int b = 12;
std::swap(a, b);[/code]

That’s easy. But hey, why don’t we go ahead and see actually what std::swap does behind the scenes? A grep in the Apache STL implementation gives us:

[code language=”cpp”]template <class _TypeT>
inline void swap (_TypeT& __a, _TypeT& __b)
{
   _TypeT __tmp = __a;
   __a = __b;
  __b = __tmp;
}[/code]

Woah, all the underscores! But don’t panic just yet. All it does is the grade-school swapping:

[code language=”cpp”]T tmp = a;
a = b;
b = tmp;[/code]

Hmm. That is perhaps the most straight-forward swap implementation. But how does it perform? Look again.

[code language=”cpp”]T tmp = a; // a copy of ‘a’ is created
a = b;  // a copy of ‘b’ is created
b = tmp;  // a copy of ‘tmp’ is created[/code]

That’s a lot of copies for a simple function! What if we could just ‘swap’ the two values without copying?

We google around a bit and find out that the above std::swap implementation is actually the old way of doing things. The new C++11 implementations does this differently. So we check the C++11 include files.

[code language=”cpp”]template<typename _Tp>
  inline void
swap(_Tp& __a, _Tp& __b)
   {
   _Tp __tmp = _GLIBCXX_MOVE(__a);
  __a = _GLIBCXX_MOVE(__b);
   __b = _GLIBCXX_MOVE(__tmp);
  }[/code]

That’s more confusing than the previous one. Again, don’t panic. We can simplify the things. _GLIBCXX_MOVE is defined to be std::move. Let’s just call it ‘move’. So the above function is roughly similar to:

[code language=”cpp”]T tmp = move(a);
a = move(b);
b = move(tmp);[/code]

Now we are scratching our chins. At first glance, the implementation looks much similar to the grade-school swap. And then, there’s this move-thingy. Okay, looking back, we remember that the elements were ‘copied’ in the grade-school algorithm. Instead, it looks like the variables are ‘moved’ here.

And we are right! In the first line, tmp is set to the value of a, while the variable a is (temporarily) invalidated. No copying is done. The previous memory location of a is now the territory of tmp. In the next line, a is set to the value of b, while b is invalidated. Finally, b is set to the value of tmp, and tmp itself is invalidated, which we don’t need again anyway. And the result? The two values are swapped without any copy operations!

How does this moving really work? C++11 introduces the so called “rvalue references”. The ‘move’ function returns the rvalue of the input parameter without triggering a copy construction.

[code language=”cpp”]T &a = x; // normal (lvalue) reference
T &&b = y; // rvalue reference [/code]

A full description will not fit in this post, but you can go through this nice little introduction on rvalue references. You might also want to refresh your memory about lvalues and rvalues.

And let’s call it a day and meet again with another little C++ adventure.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2027.html

ලොව ජයගත හැකි සාර්ථක මෘදුකාංග ඉංජිනේරුවෙකු විය හැක්කේ කෙසේද?

දැනට වසර දෙක තුනක සිට පවතින ලෝක ආර්ථිකයේ පසුගාමී ස්වභාවය හමුවේ පවා “මෘදුකාංග ඉංජිනේරු” (Software Engineering) වෘත්තියෙහි රැකියා අවස්ථාවන් මේ ගෙවීයන දශකය (2011 – 2020) තුළදී 30% කින් වර්ධනය වනු ඇති බව එක්සත් ජනපදයේ කම්කරු සංඛ්‍යාලේඛන කාර්යාංශය පවසයි [1]. මෙය එරට සමස්ත රැකියා වර්ධනය පිළිබඳ බලාපොරොත්තු වන අගය (14%) මෙන් දෙගුණයකටත් වැඩිය. තවද Wall Street Journal පුවත්පත පළ කර ඇති සංගණනයක් මගින් එක්සත් ජනපදයේ වෘත්තීන් 200 ක් අතුරින් හොඳම වෘත්තිය ලෙස මෘදුකාංග ඉංජිනේරු වෘත්තිය නම් කර ඇත [2]. ලෝක ආර්ථිකයේ වත්මන් මන්දගාමී තත්ත්වය යටතේ පරිගණක මෘදුකාංග පද්ධති සහ සේවා සඳහා ඇති වෙළඳපොල තව තවත් වර්ධනය වනු ඇති බව ද වාර්තා වී තිබේ. වෘත්තියක් ලෙස මෘදුකාංග ඉංජිනේරු ශිල්පය සඳහා ඇති ඉල්ලුම පසුගිය දශක දෙක පමණ ඔස්සේ අඛණ්ඩ වර්ධනයක් ලැබූ අතර එය ඉදිරියටත් තව තවත් වර්ධනය වන බව ඉහත තොරතුරු මගින් මනාව සනාථ වේ. එම ශිල්පය මැනවින් අධ්‍යයනය කිරීමට සහ වෘත්තීය (professional) මෘදුකාංග ඉංජිනේරුවෙකු වශයෙන් සාර්ථකත්වයට පත්වීමට අවශ්‍ය කරන කුසලතා ගැන යම්කිසි මග පෙන්වීමක් ලබා දීම මෙම ලිපියේ අරමුණයි.

මෘදුකාංග ඉංජිනේරු වෘත්තිය යනු තොරතුරු තාක්ෂණ (IT) ක්ෂේත්‍රයේ ඇති විවිධ වූ වෘත්තීන් අතරින් එකකි. දෘඩාංග (hardware), පරිගණක ජාලකරණ (networking), දත්ත-ගබඩා (databases), පරිගණක පද්ධති (systems engineering) ආදී විවිධ අනු ක්ෂේත්‍ර රැසක විහිදී ඇති ඉංජිනේරු වෘත්තීන් රැසක් අතර මෘදුකාංග ඉංජිනේරු ශිල්පය ද එක් විශේෂිත (specialized) වෘත්තියකි. මේ එක් එක් අනු ක්ෂේත්‍රයක් සැලකුවද ඒවායේ අතිමහත් දැනුම් සම්භාරයක් දැනමටත් ගොඩ නැගී ඇත. එසේම තොරතුරු තාක්ෂණට අයත් වන ඉංජිනේරු හා තාක්ෂණ විෂයයන් අතිමහත් වේගයකින් වර්ධනය වන බැවින් නව දැනුම් හා ක්‍රමවේදයන් එක් වීමත් පවතින ක්‍රමවේදයන් භාවිතයෙන් ඉවත් වීමත් ඉතා ඉක්මනින් සිදුවේ. තත්ත්වය මෙසේ හෙයින් එක් පුද්ගලයෙකුට මේ සියළුම ක්ෂේත්‍රයන්හි පරතෙරට පැමිණීම ට නොහැකි බව ඉතා පැහැදිලිය. මේ සියළුම විෂයයන් සඳහා පොදු වන යම් දැනුම් ප්‍රමාණයක් ඇති නමුත් එක් එක් විෂයයෙහි ගැඹුරට යන විට එම විෂය සඳහාම සීමිත වන විශේෂිත දැනුම් සහ කුසලතාවන් අවශ්‍ය වේ. එසේම එක් විෂයයක විශේෂඥ වෘත්තිකයකු (expert professional) වීම සඳහා සෑම ක්ෂේත්‍රයකම ප්‍රවීණයෙකු වීම අවශ්‍ය නොවන බවත් මෙහිදී සඳහන් කල යුතුය. ඔබත් අනාගතයේ තොරතුරු තාක්ෂණ වෘත්තිකයකු වීමට බලාපොරත්තුවන අයෙකු නම් මෙහි දැක්වූ විවිධ අනු-ක්ෂේත්‍ර පිළිබඳ දැනුවත් විය යුතු අතර තම වාත්තීය අධ්‍යාපනයේ යම් අවස්ථාවක (උදාහරණයක් ලෙස, තොරතුරු තාක්ෂණ උපාධියක් හදාරණ සිසුවෙකු අවසන් වසරේ අධ්‍යයන කටයුතු ආරම්භ කරන කාලය වන විට) මේ එක් විශේෂිත ක්ෂේත්‍රයක් තමන් විසින් තෝරා ගැනීම යෝග්‍ය බවත් ප්‍රථමයෙන් ම ලබා දිය යුතු වෘත්තීය මාර්ගෝපදේශනය බව කිව හැකිය.

ඉහත සඳහන් විවිධ ක්ෂේත්‍ර අතරින් මෘදුකාංග ඉංජිනේරු ශිල්පය නම් විශේෂිත වූ ක්ෂේත්‍රය දෙස දැන් අපගේ අවධානය යොමු කරමු. ප්‍රථමයෙන්ම මෘදුකාංග ඉංජිනේරුවෙකුට දෘඩාංග සම්බන්ධයෙන් අවශ්‍ය වන දැනුම හා අවබෝධය කෙබඳු දැයි සලකා බලමු.

Software Engineering

රූපයේ දක්වා ඇති පරිදි පරිගණකයක් සම්බන්ධයෙන් දෘඩාංග (hardware) හා මෘදුකාංග (software) යනුවෙන් ප්‍රධාන අංග දෙකක් අපට හඳුනාගත හැකිය. මෘදුකාංගයක් යනු ගොඩනැගිල්ලක් නම්, CPU චිපය, මතකය (memory), දෘඩ තැටිය (hard disk) යනාදී උපාංග සියල්ලේ සංකලනය එම ගොඩනැගිල්ලේ අඩිතාලම (platform) ලෙස සැලකිය හැකිය. සාර්ථක මෘදුකාංග ඉංජිනේරුවෙකු වීම සඳහා දෘඩාංග නිර්මාණය (design) හා නිපදවීමට (construction) හැකි තරමි දැනුමක් අවශ්‍ය නොවේ. එවැනි දැනුමක් අවශ්‍ය වන්නේ දෘඩාංග ඉංජිනේරුවෙකු වීම සඳහායි. (පරිගණකයක උපාංග එකලස් කිරීම, අළුත් මතක පතක් සවිකිරීම වැනි ක්‍රියා hardware engineering නොවන බවත් ඒවා සරල නඩත්තු ක්‍රියා බවත් මෙහිදී විශේෂයෙන් සඳහන් කල යුතුය). දක්ෂ මෘදුකාංග ඉංජිනේරු‍වෙකුට අවශ්‍ය වන්නේ දෘඩාංග මගින් මෘදුකාංග වල නිවැරදි හා ඉක්මන් ක්‍රියාකාරීත්වය සඳහා සපයන සේවා හා යටිතල පහසුකම් පිළිබඳ නිරවුල් අවබෝධය යි. උදාහරණයක් ලෙස, මතක පද්ධතියේ වේගය හා විශාලත්වය අනුව ඇති වන ධූරාවලිය  (memory hierarchy) සහ ක්‍රියාත්මක වන මෘදුකාංගයක් මගින් එම ධූරාවලියේ විවිධ ස්ථර වල ඇති දත්ත කියවන/ලියන වේගයන් (read/write speeds) පිළිබඳ දැනුම දැක්විය හැක. විවිධ මතක චිපයන් හි දත්ත ගබඩා කෙරෙන තාක්ෂණය හා එක් එක් ස්ථරයේ මතක ගබඩා වල පිරිවැය (cost) පිළිබඳ දැනුවත් වීමද වැදගත් වේ. පිරිවැය පිළිබඳ දැනුවත්කම මගින් තමන් විසින් නිර්මාණය කරන මෘදුකාංගයක  ඉක්මන් හා සුමට ක්‍රියාකාරීත්වය සඳහා අධිබල CPU චිපයක් හෝ විශාල RAM චිපයක් මත පමණක්ම යැපීමේ අවධානම වැටහෙයි. බාල ගණයේ මෘදුකාංගයක් නිපදවා එහි ක්‍රියාකාරීත්වය වැඩිදියුණු කිරීම සඳහා මිළ වැඩි දෘඩාංග යොදා ගන්නට යැයි සේවාදායකයන්ට පවසන්නේ නම් එවැනි අයෙක් දක්ෂ මෘදුකාංග ඉංජිනේරුවෙකු වශයෙන් සැලකිය නොහැකිය. පරිගණක මතකය ගැන ගත් උදාහරණයට සමාන උදාහරණ අනෙකුත් දෘඩාංග සම්බන්ධයෙනුත් අදාළ වේ. රූප සටහනේ පහතින්ම දක්වා ඇත්තේ මෘදුකාංගයක ක්‍රියාකාරීත්වය සඳහා ඉතාම වැදගත් වන දෘඩාංග කුලකයන් ය. ඒ එක එකක් ගැන විස්තර වශයෙන් සඳහන් කිරීමට මෙම ලිපියේ ඉඩ නැති නමුත් මෘදුකාංග ඉංජිනේරුවකුට දෘඩාංග ගැන අවශ්‍ය වන දැනුම ගැන යම් වැටහීමක් දැන් තිබිය යුතුය.

Software and Hardware

දෘඩාංග විසින් සැපයෙන අත්තිවාරම උඩ ක්‍රියාත්මක වන මෘදුකාංග ද විවිධ ස්ථර කිහිපයක ට වෙන් කර හඳුනාගත හැකිය. භාවිත මෘදුකාංග (application software) හා පද්ධති මෘදුකාංග (system software) යන ප්‍රධාන කුලක දෙකකට මේවා වර්ගීකරණය වේ. මෘදුකාංග ඉංජිනේරුවෙකුට මේ කාණ්ඩ දෙකටම අයත් ස්ථර වල නිර්මෘණකරණයේ යෙදිය හැකි මුත් සාමාන්‍යයෙන් මෙම ක්ෂේත්‍රයේ රැකියා ඇත්තේ ඒවායින් එක කාණ්ඩයකට සීමා වන ලෙසයි. මේ විවිධ ස්ථර මෘදුකාංග ශිල්පයේ උප විශේෂිකරණයන් (sub specialization) ලෙස හැඳින්විය හැකිය.

පරිගණකයක පරිශීලකයා (user) හට අවසන් වශයෙන් අවශ්‍ය වන්නේ විවිධ කාර්යයන් ඉටු කර දෙන මෘදුකාංග (application software) ය. සිලිකන් පරිපථ හා චුම්භක කොටස් යනාදිය එකතු කොට නිපදවා ඇති උපාංග හරහා විදුලි ධාරාවන් ගමන් කරන විට ක්‍රියාත්මක වන දෘඩාංග සමූහයක් මත ධාවනය වන මෙහෙයුම් පද්ධතියක් (operating system) සහ තවත් විශේෂිත මෘදුකාංග සැකිලි (software frameworks) මත දිවෙන මෘදුකාංගයක් තමන් භාවිතා කරන බව පරිශීලිකයා හට දෘෂ්‍යමාන නොවේ. නවීන වාහනයකට නැග බොත්තමක් ඔබා එය පණ ගන්වා, ස්වයංක්‍රීය ගියරය දමා, වාහනය අභ්‍යන්තරයේ සිදුවන දහසකුත් එකක් ක්‍රියා ගැන කිසිදු අවබෝධයක් නැතිව ‍ එය ධාවනය කරවන රියදුරෙකුත් සාමාන්‍ය පරිගණක භාවිතා කරන්නෙකුත් අතර එතරම් වෙනසක් නැත. ඒ එසේ නමුත්, මෘදුකාංග නිර්මාණකරුවෙකුට තම වෘත්තියේ විශේෂඥයකු වීම සඳහා මේ විවිධ අන්තර් ස්ථර පිළිබඳ ඉතා නිරවුල්, ගැඹුරු අවබෝධයක් තිබීම අත්‍යවශ සාධකයක් වේ. සෑම අවස්ථාවක ම බිම් මට්ටමේ සිට සියළුම මෘදුකාංග තමන් විසින් ම නිර්මාණය කර ගත යුතු බවක් මින් අදහස් නොකෙරේ. යම් යම් අය විසින් පෙර නිමවා ඇති යටිතල මෘදුකාංග හා මෘදුකාංග සැකිලි යොදා ගනිමින් භාවිත මෘදුකාංග නිර්මාණය කිරීමෙහි කිසිම වරදක් නැත. ඵලදායි මෘදුකාංග නිර්මාණකරණයක් සඳහා එසේ යොදා ගැනීමත් අත්‍යවශ්‍ය කාරණයකි. අප විසින් නොකල යුත්තේ එම පහත ස්ථරයන් ගැන අනවබෝධයෙන්, උඩින් පල්ලෙන් අතගාමින් මෘදුකාංග නිර්මාණකරනයේ යෙදීම යි. තමන් නිපදවූ මෘදුකාංගය නිසි පරිදි ක්‍රියාත්මක නොවන මොහොතක ඒ ඇයිදැයි සොයා බැලීමට බිමි මට්ටමට එබී බලා ඒ නිවැරදි කිරීමේ හැකියාව හා අවබෝධය (ability to look under the hood) ඇතිව ඒවා යොදා ගැනීම දක්ෂ මෘදුකාංග ශිල්පියෙකුගේ ලක්ෂණය යි. එසේ නොමැතිව, යම් මෙහෙයුම් පද්ධතියක් මත දුවන අතථ්‍ය යන්ත්‍රයක (virtual machine) සේවා යොදා ගනිමින් ලියා ඇති මෘදුකාංග සැකිල්ලක ආධාරයෙන් යම් භාවිත මෘදුකාංගයක් නිපදවූ පමණින් තමන් මෘදුකාංග ඉංජිනේරුකරණයේ යෙදුනු බව සිතා නොගත යුතුය. සැබැවින්ම එය සරල වූ වැඩසටහන්කරණයක් (a mere programming job) පමණි.

SW_languages

රූප සටහනේ දක්වා ඇති විවිධ ස්ථර පිළිබඳ නිවැරදි දැනුම ට අමතරව මෘදුකාංග නිර්මාණකරනය ට අදාළ වන විෂයයන් හා මෙවලම් ගැන හොඳ න්‍යායාත්මක හා ප්‍රායෝගික දැනුමක්ද තිබීම අත්‍යවශ වේ. Computer Architecture, Operating Systems, Data Structures and Algorithms, Object Oriented Analysis and Design, Compiler Theory, Programming Theory සහ Database Designing වැනි විෂයයන් ගැන නිවැරදි දැනුම දක්ෂ මෘදුකාංග ඉංජිනේරුවෙකුගේ දැනුම් ගබඩාවේ නිත්‍ය හා ප්‍රමුඛ අංගයන් වේ. එසේම compilers, debuggers සහ test tools වැනි මෙවලම් (මේවාද තවත් විශේෂිත මෘදුකාංගයන් ය) ගැන ප්‍රායෝගික දැනුම ද මෘදුකාංග නිර්මාණ ක්‍රියාවලිය (software development life cycle) ගැන අවබෝධය ද ඉතා වැදගත් වේ.

මේ කරුණු සලකා බලන විට විවිධ කෙටිකාලීන පරිගණක පාඨමාලා හැදෑරීම හරහා මාසිකව ලක්ෂ ගණනින් ආදායම් උපයා ගත හැකි මෘදුකාංග ඉංජිනේරුවන් විය හැකි බව පවසමින් සිසුන් නොමග යවන විවිධ දැන්වීම වර්තමානයේ දැකිය හැකි වීම කණගාටුවට කරුණකි. මෙබඳු වෙළෙන්දන් ගෙන් මුලා නොවීමට සිසුන් හා දෙමව්පියන් වග බලා ගත යුතු අතර එබඳු පාඨමාලා යම් කිසි ප්‍රමිතිකරණයකට හා නියාමනකට ලක් කිරීමට බලධාරීන් ක්‍රියා කල යුතු බව අපගේ අදහසයි.

Facebook, Twitter වැනි සමාජ ජාල වල කරක් ගසමින් හෝ පරිගණක ක්‍රීඩා වල යෙදෙමින් නිකරුණේ තම අගනා කාලය අපතේ යැවීම වත්මන් සිසු පරපුර අගාධයට යවන්නක් බව කිව යුතුය. ඊමේල් යවන්නට දැන ගැනීම, අන්තර්ජාලයේ සැරිසැරීම හෝ MS Office වැනි මෘදුකාංග පැකේජයක් අත පත ගා යමක් කර ගැනීමට හැකි වීම ඉහළ මට්ටමේ තොරතුරු තාක්ෂණ වෘත්තිකයෙකු වන්නට සුදුසුකමක් නොවේ. එම දැනුම මගින් යම් අයෙකුට දත්ත ඇතුළත් කරන්නෙකු (Data Entry Operator) වැනි ආරම්භක ශ්‍රේණියක ලිපිකාර රැකියාවක් ලබා ගත හැකි වනු ඇත. කෙනෙකු ලබන අධ්‍යාපනය හා පුහුණුව අනුව ඕනෑම ක්ෂේත්‍රයක වැඩි හා අඩු වැටුප් තල වල ඇති රැකියාවන් තිබෙන අතර තොරතුරු තාක්ෂණයේදීත් මේ තත්ත්වය එලෙසම පවතී. CPU Chip Designer, Software Architect වැනි වැඩි වැටුප් ඇති වෘත්තීන් හි සිට Computer Assembler, Programmer වැනි ආරම්භක වැටුප් ඇති වෘත්තීන් දක්වා ඇති විශාල පරාසයක මෙම රැකියා විහිදේ.

SW_Programmer

සාරාංශ වශයෙන්, දෘඩාංග මගින් මෘදුකාංග වෙත සැපයෙන් සේවා ගැන පැහැදිලි අවබෝධය, විවිධ මෘදුකාංග ස්ථර සහ ඒවා අතර ඇති අන්තර්ක්‍රියා පිළිබඳ අවබෝධය සහ තම වෘත්තිය දැනුමෙහි අරටුව ලෙස සැලකිය හැකි විෂයයන් හා මෙවලම් ගැන නිවැරදි න්‍යායාත්මක හා ප්‍රායෝගික දැනුම යන කාරණා සාර්ථක මෘදුකාංග ඉංජිනේරුවෙකු වීමට අවශ්‍ය ප්‍රධාන අමුද්‍රව්‍ය ලෙස ඉදිරිපත් කළ හැකිය. මෘදුකාංග ක්ෂේත්‍රයේ දක්ෂ වෘත්තියකුට වීමට ඔබත් බලාපොරොත්තු වන්නේ නම් මෙම කරුණු පිළිබඳ හොඳ අවධානයක් යොමු කල යුතු බව පැවසිය හැකිය. ලොව ජයගන්නා සාර්ථක මෘදුකාංග ඉංජිනේරුවන් අප රටෙන් බිහි කල හැකි බව දැනටමත් සනාථ වී ඇත. ඒ කාර්යය තව තවත් ඔප් නැංවීමට යම් කිසි අත්වැළක් මෙම ලිපියෙන් සැපයෙනු දැකීම අපගේ අවසන් ප්‍රාර්ථනය යි.

 

ඉෂාන් ද සිල්වා

ඉංජිනේරු විද්‍යාවේදී‍ (ගෞරව)

ලේඛකයා මොරටුව විශ්ව විද්‍යාලයේ පරිගණක ඉංජිනේරු උපාධියෙන් ප්‍රථම පන්තියේ සාමාර්ථයක් ලබා ඇත.  ලංකාවේ ප්‍රමුඛතම මෘදුකාංග සමාගමක සේවය කරන හෙතෙම මෘදුකාංග නිපදවිමේ ක්‍රියාවලියේ විවිධ මට්ටම් වල නිරත වෙමින් වසර දහයක පමණ අත්දැකීම් ලබා ඇත්තෙකි.

 

යොමු ලිපි:

[1] http://www.bls.gov/ooh/computer-and-information-technology/software-developers.htm#tab-6

[2] http://online.wsj.com/article/SB10001424052702303772904577336230132805276.html

Title image credits: timeunion.com

Barriers to Entrepreneurship in the Sri Lanka Software Industry – Part 2

Note from the Author : This post is based on a paper that was presented at the International Research Conference on Management and Finance 2011. I had the privilege of co-authoring this paper with Prof. Gamini de Alwis and Dr. R. Senathirajah from the Faculty of Management and Finance, University of Colombo. The references in this post may seem dated as the research was conducted nearly two years ago. However, the underlying observations and the derived conclusions are still relevant today. 

This article is a continuation from the Part I.

As we showed in Part 1 of this article, the general tendency among Sri Lankan software professionals is to shy away from entrepreneurship. We presented our research findings on how wealth or industry expertise alone, would not influence this mindset. We also discussed how they prefer not risk failure by experimenting in entrepreneurship, and stick to their jobs where they feel comfortable.

A brief note about our data analysis…

In our last post, we explained why wealth, is theoretically considered a positive influence towards entrepreneurship. On the other hand, considering the earning potential, we expected to see a professionals be more reluctant to leave their jobs as they accumulate more and more industry expertise. However, we did not observe either in our research.

Since this was a dead-end, we moved on to scanning our data for interesting patterns. Before, we go in to the details, let’s establish the definitions.

  • Wealth is the total value of the person’s property, savings, etc.
  • Industry Expertise (or the Professional Human Capital) is a measure of the professional’s skills and competencies. The measure includes academic qualifications and the years of experience.
  • Entrepreneurial Intent (EI) is a measure of the desire the professional has in setting up his/her own business within the foreseeable future.

“Twenty years from now you will be more disappointed by the things that you didn’t do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover.”-Mark Twain

Depending on whether a person scored high or low on each of the 3 variables, we grouped the sample in to 8 segments. We’ll ignore the segments that scored low on EI and concentrate on those who have at least a slight interest towards entrepreneurship.

We also had to leave out the Low Wealth / Low Expertise group as the size of that segment was too small for analysis. So, we ended up looking at the following segments in depth:

  1. Superstars : High wealth, high expertise
  2. Hesitants: Low wealth, high expertise
  3. Fanatics: High wealth, low expertise

entrepreneurship_2_graph

Fanatics group was made up of fresh graduates who came from wealthy backgrounds. We felt that their willingness to get in to business was too premature. We believe that they should remain as professionals until they have the expertise to launch a high tech business with a high growth potential. Premature entrepreneurs are very likely to create unsuccessful ventures. And when those fail, they leave behind a popular belief that Sri Lanka is a hostile environment for tech startups.

Professionals that fell in to the Hesitant category, had both the industry expertise as well as the financial motivation to start a business. Some even felt that there was only a slim potential for further career growth.  Most of them had done some freelance work on the side but, had not taken any concrete steps towards full-time entrepreneurship. From the common patterns emerging from their responses, we believed that these individuals had the most desire to become entrepreneurs. The fear of failure and the lack of financial strength may have been holding them back.

The Superstars, on the other hand, consisted of experienced and top ranking professionals; majority being over 30 years of age. With the high level of industry expertise and the higher tolerance for financial risk, this group had the highest potential to set up high-tech, high growth businesses. Majority of the group, however would consider setting up a business in the next 5 to 10 years. This again, demonstrates that despite being indifferent to the financial risk, they were unwilling face the risk of failure. They would consider entrepreneurship as a retirement plan, not a career choice.

So, what would it take to break this barrier? We’ve established that the possible financial/social consequences of failing are the reasons holding you back from starting a business. So, would you start a business if we give you:

  1. The ability to share your risk?
  2. Peer recognition and validation at the onset of the business?

The result was a near 30% increase across all segments on the likelihood of starting a business. Surprisingly, this increase was even higher (33%) among the low-EI/high-wealth/high-expertise group. We had initially labeled them as the “Carefree” as they seemed to be looking forward to retirement without any interest in complicating their lives with entrepreneurship activity.

The twist in this is that, we didn’t really ask the above question. What we did ask was, whether they’ll set up a business if they can have a co-founder for their startup. Let’s see how this question translates in to the above.

A partnership is an opportunity to share the financial risk of the business. You are no longer the only person liable for the losses. Maybe, your co-founder can bring the capital while you contribute the expertise to the business. Not only that, it may even be possible for the partners to tag-team in running the business so that initially, both can minimize the career risk by staying employed at lease on a part-time basis.

Either way, the “peer recognition” aspect is the most interesting part of the question.

By agreeing to come onboard, a fellow professional is taking an equally risky career choice. In order to accept he/she must evaluate and recognize the validity of your business case. This validation and the sense of social acceptance, is a great motivator for the entrepreneur and adds momentum to the startup effort.

“Your time is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma – which is living with the results of other people’s thinking. Don’t let the noise of other’s opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.”- Steve Jobs

How do we translate this in to action?

So, sparking entrepreneurship among software professionals isn’t really an expensive problem. It’s not a problem of building infrastructure, setting up seed funds or affecting policy reform. It’s a matter of bringing likeminded people together and nurturing collaboration towards setting up businesses. The obvious challenge is creating an environment of trust, in which they feel confident about sharing ideas and strategies. Existing startup incubators can take the lead on such an initiative as they have the means to support the partnership from the immediate next steps in the process.

Alternatively, a great initiative would be to rally up high wealth / high expertise segments in to Angel Networks. As Angel Investors, these professionals will have the opportunity to gain the benefits of business-ownership, while being able to distribute the risk of failing across several companies and co-owners. Such Angels will motivate Hesitants to take up more responsibility in the operational side of running the business; all of which would speed up the cycle of new businesses getting off the ground.

Crippling emotions

Entrepreneurship

As we’ve found out in this research, we have only ourselves to blame for the lack of entrepreneurship among our software professionals. Yes, ourselves; not the lack of infrastructure, lack of funding, or messy political landscape. The problem and the solution aren’t financial; they are emotional. It’s unreasonable for us to demand that people change and get over their fear of failure and the fear of being criticized for failure. Therefore, we’ve conceptualized a strategy to build emotional support to take this first step, by identifying the critical role a co-founder could play. We hope that what’s presented here, lead to a healthy discussion on enhancing collaboration among workforce segments and eventually lead to a vibrant startup culture.

References and Recommended Reading

[1] Iyigun, M.F. & Owen, A.L., 1999. Entrepreneurs, Professionals, and Growth. Journal of Economic Growth, 4, pp.213-32.

[2] Hurst, E. & Lusardi, A., 2004. Liquidity Constraints, Household Wealth, and Entrepreneurship. Journal of Political Economy, 112(2), pp.319-47.

 

Image credits:

http://www.imasocialentrepreneur.com/

http://georgeessien.com

Auto-matic typing in C++

C++ is a statically typed language by design. In other words, you have to specify which data type your dear variable is supposed to be. If you declare myCoolVar to be an integer, you can’t let him play with his string friends. Type checking is done at the compile time. So myCoolVar will soon be caught red-handed if it goes matchmaking with a string or a vector.

This is contrast to the radical kids in the block like Python and Ruby who don’t care whom their variables play with. They call themselves dynamically-typed. A washed up floating point might become a variable with a character in a few moments.

Cool as it may sound, dynamic typing is not for everyone. C++ is mostly used where performance and reliability are key factors. Thus the C++ standard has always insisted on strong, static typing. But even if you haven’t been programming since the dinosaurs roamed the earth, you may know that it’s not always easy to remember and explicitly declare the correct variable type. The new C++ standard, or C++11  as it’s known, aims to change this.

C++11 isn’t exactly new to the city. Most compilers around, including gcc and Microsoft C++ compilers, now include support for C++11. Among the dozens of improvements it has brought, let’s have a look at the auto keyword.

Suppose you want to take the length of a C++ string called myStr. Easy-peasy. myStr.length() is the way to go. But wait. The return value of the length() function is string::size_t. Besides from being hard to type in, it’s not easy to remember all these return types either. That’s when the auto keyword comes handy. Instead of,

[code language=”cpp”]string::size_t len = myStr.length();[/code]

you can simply write

[code language=”cpp”]auto len = myStr.length();[/code]

The compiler detects the return type of myStr.length() and makes len a variable of that type. So very convenient.

Not convinced? Suppose you have a map of objects that you need to iterate. How do you initialize the iterator?

[code language=”cpp”]std::map<char,int>::iterator it = myMap.begin();[/code]

Ugh. That isn’t the nicest code snippet you’ve written. But hey, we have our friend auto:

[code language=”cpp”]auto it = myMap.begin();[/code]

Skadoosh! Auto has automagically made it an std::map<char,int>::iterator, because that’s the return type of myMap.begin()! Now that does look nice.

What if I want to declare a variable with a default value?

Suppose you want to declare a variable that holds the length of a string. But you first need to set it to zero.

[code language=”cpp”]auto len = 0;[/code]

Ha! That is wrong! This would make len an int, not string::size_t. But C++11 has an answer for that as well. You can use the decltype keyword like this:

[code language=”cpp”]decltype(myStr.size()) len = 0;[/code]

This declares len as a variable of type returned by myStr.size(), but still initializes it to zero.

Is this dynamic typing?

No, not really. Even though it appears as if auto changes a variable’s type dynamically, it actually happens during the compile time. It’s just that you don’t have to explicitly code the type of the variable, the compiler does that for yourself. Which is mighty sweet of C++11.

Is it safe to use auto?

Isn’t letting your variables roam free considered as bad parenting? No. Not only is it safe to use auto in your C++ code, it’s even recommended that you use it wherever possible. Bjarne Stroustrup, the creator of the C++ language himself, advocates its use. Just make sure that your compiler is updated to support C++11.

Image Credits : http://geekandpoke.typepad.com/geekandpoke/2010/01/best-of-both-worlds.html

Barriers to Entrepreneurship in the Sri Lankan Software Industry – Part 1

Note from the Author : This post is based on a paper presented at the International Research Conference on Management and Finance 2011. I had the privilege of co-authoring this paper with Prof. Gamini de Alwis and Dr. R. Senathirajah from the Faculty of Management and Finance, University of Colombo.  This post was written exclusively in the hope that this would be useful to the TechWire.lk readers.

The global Tech Industry has it’s share of success stories of wealthy and powerful companies that grew out of garage-office start-ups. You’ve no doubt heard of the early days of Apple and Microsoft, Facebook’s humble beginnings from Zukerberg’s dorm room, and of the billion dollar cash-ins of Instagram and Tumblr. At a glance, Tech Industry seem to be the best place to be if you are a startup. But, if that’s the case, why does the Sri Lankan tech-startup landscape look so depressingly flat?

Entrepreneurship has always been a hot research topic in Sri Lanka. But, the focus has always been on assisting the unemployed and underprivileged to be self-employed. So, there’s a wealth of research data on low-tech/low-income industries and almost none on high-tech industries. This lack of insight and the burning question highlighted above, lead us to the research that’s presented here.

Why do we need to care about entrepreneurship in the Software Industry?

Entrepreneurship Future

Entrepreneurs and professionals carry out two distinct and vital functions in an economy. Entrepreneurs push the technology boundaries of a nation through product or process innovation. Professionals turn these innovations in to implementations that deliver actual economic benefit. Therefore, the ratio of entrepreneurs to professionals, is a key factor for the growth rate of an economy. When there’s a high percentage of entrepreneurs, the rate of innovation is expected to be high. This generates high demand for professionals which leads to higher salaries that attract more and more people to these professions. The excess supply of professionals causes the salaries to drop, encouraging some professionals to switch to entrepreneurship in search of better income. As the economy would now be consolidating, these new entrepreneurs will be forced to innovate even more aggressively. This cycle will eventually stabilize once the optimum ratio of entrepreneurs to professionals is reached [1].

This is where the IT Outsourcing Industry hurt us the most. We did not innovate locally and allow the cycle to run its course. Instead, we “rented” out our professionals’ to foreign entrepreneurs. Much like the Garment Industry and the Rubber Industry before that, the Software Industry exported professional skills and competencies on a Time and Materials basis. As the supply of professionals kept growing, the industry worked tirelessly to bring more outsourcing jobs. Until the day a cheaper outsourcing destination pops up and steal our jobs, this model is likely to continue.

Professionals vs. Entrepreneurs

Researchers Hurst and Lusardi [2], found that for the general public, a person’s wealth had almost no impact on whether that person desired to become an entrepreneur. However, they found that this was not the case for professionals whose entrepreneurial aspirations increased with wealth. The researchers believed that as professionals became more affluent, they saw “business ownership” as a way to gain flexible work schedules and freedom in decision making. To them business ownership was also a “luxury good” that symbolizes success and power.

This is a very interesting argument. Would the same hold true for Sri Lankan software professionals? If so, we can identify the ideal period in their careers where they’ll be open to setting up their own business. We approached our research from this angle and built a conceptual model based on motivation theories, with a focus on variables such as personal wealth and industry expertise.

Entrepreneurship is an unattractive  career choice

A professional has to face two types of risks when to investing full-time in a business: One is the obvious financial risk; the other is the risk of disrupting his/her professional career growth.

The financial risk is easy to understand and quantify. If the business was to fail, he risks losing the invested capital and the earnings that he/she could have made as a professional. The impact of the career disruption is somewhat indirect. It’s caused by the fact that entrepreneurial skills and professional skills have to be accumulated at the expense of each other. By focusing on business operations as an entrepreneur,  the individual has to give up the opportunity to enhance his/her professional skills and keep abreast with new technology. In a fast evolving high-tech industry, being disconnected for an extended period, could lead to a significant competency gap.

So, imagine that you as a Software Professional, is interested in starting your own business. You are willing to invest some money in to it and dedicate the next five years to make the business a success. You are reasonably wealthy and the possible financial losses are not a major concern for you. Since this is your first venture, you make a backup plan to go back and get a job as a Software Professional, say in five years, if the business keeps losing money and you no longer feel it can succeed.

entrepreneurship23jpg

Here’s where the above competency gap comes in to effect.

The competencies you hold now will be obsolete in five years. When you return to the industry as a professional, you’d have fallen far behind your current peers. This means lower pay and lower status than those who may have worked with you or under you if, you were to take a job under this circumstances. In our analysis, we found that this possible loss of “esteem” was so overbearing in our Software Industry that even when combined with other positive influences towards entrepreneurship, the net effect was still negative.

In a culture that has a low tolerance for failure, it is not difficult see why professionals prefer to stick to the “safety” of their jobs than to venture out and fend for themselves as business owners. Given the earning potential of a software professional, the choice is perhaps a no-brainer.

When we planned our research, we made an effort to confine ourselves to objectively measurable variables. We especially wanted to steer clear of the “cultural effect” which is often the scapegoat for  anything. Sadly, even after a methodical research we found ourselves staring back at this elephant in the room. But then again, we cannot dwell on this aspect; culture is not something we can take upon ourselves to change.

Where do we go from here?

Unsurprisingly, our data showed a genuine disinterest towards entrepreneurship among Sri Lankan software professionals. There was no upward trending curve between entrepreneurship intent and wealth or expertise. Consequently, there’s no threshold on either variable to earmark possible entrepreneurship candidates. And we’ve found evidence that this is not due to lack of skill or financial or political factors, that we could have addressed.

As  the goal of the research was an implementable strategy, we kept looking at other variables we captured during our data gathering. Cross tabulation of this data led us to uncover an interesting trend that could be used to mobilize more professionals in to setting up their own software businesses.

Please stay tuned for the Part 2 of this article for the details.

entrepreneurship

References and Recommended Reading

[1] Iyigun, M.F. & Owen, A.L., 1999. Entrepreneurs, Professionals, and Growth. Journal of Economic Growth, 4, pp.213-32.

[2] Hurst, E. & Lusardi, A., 2004. Liquidity Constraints, Household Wealth, and Entrepreneurship. Journal of Political Economy, 112(2), pp.319-47.

 

Photo credits:

http://img.bhs4.com/a9/d/a9d3eaf892944ce4c774df34ff87a9461620510e_large.jpg

http://kennysilva.net/wp-content/uploads/2011/01/doubt.jpg

http://nanyate.com/internet-memes/bill-gates-mad-respect-steve-jobs-is-sexy

http://wall.alphacoders.com

WSO2 qualified as “visionary” in Gartner’s magic quadrant research on web application development and integration infrastructure

Gartner Research in their 2013 research report “Comparing Vendors of Comprehensive Application Infrastructure Suites” has tagged WSO2 in the “Visionary” quadrant in their magic quadrant relative positioning with big players like IBM, Microsoft and Oracle. WSO2 is the smallest company of the 7 vendors selected. Yet, it is the only company selected among open source vendors with broad enough product suits in all the three application infrastructure sections under analysis. This research provides insights to today’s vendor market and offers basic profiles with the strengths and weaknesses of vendors considering the next three to five years time frame.

Gartner Magic Quadrant

Among many graphical representations of research statistics, Gartner Magic Quadrant is a graphical positioning based on the completeness of the vision and the ability to execute in the global market. It serves the bird eye view of technology providers for interested clients as a starting point of an analysis.

Magic quadrant

Vendor Selection

Vendors were selected based on the broader coverage of the application infrastructure suits and they were rated for the following aspects:

    1. Systematic SOA application projects
    2. Shared SOA interoperability and governance infrastructure
    3. Systematic and comprehensive application integration projects

 

While both IBM and Oracle secured Leader category in all 3 aspects, WSO2 was selected as Visionary in all of them. Visionaries understand where the market is going or have a vision for changing market rules, but do not yet execute to the same level.  Compared to IBM and Oracle who are the market giants who have hundreds of thousands of employees and many years of experience behind them, WSO2 have shown their colors with just 160 employees and 8 years since inception.

Gartner table

According to Gartner’s report, they recommend their clients specially for building systematic SOA infrastructures and for developing SOA applications and composites. Following are some of the strengths highlighted in the report.

 

1. With successful deployments in high-volume environments, WSO2 has earned credibility as a provider of solutions for larger enterprises and mission-critical systems.
2. WSO2’s highly standardized and open architecture gives substantial freedom for organizations to combine and enhance solutions with existing integration technology. Its minimalist approach, as well as its use of OSGi for integration of WSO2 product modules, simplifies deployment and operational complexity.
3. Offerings are available both on-premises and in the cloud. The multitenant and elasticity enabled for its cloud deployment are also available in its on-premises products.
4. The vendor is growing and has acquired capital, which it has invested in geographic expansion and field and support organizations.
5. By embracing the concept of providing a platform that includes only broadly required functionality and that can be tailored to the needs of individual deployments, WSO2 dramatically simplifies the onboarding and operation of its solutions.

 

About Gartner

Gartner, Inc. is the world’s leading IT research and advisory company. They provide the technology related insight for their clients to make the right decisions with up to date research findings.  Gartner is trusted by more than 12,000 clients worldwide including an incredible percentage of fortune 500 companies.

Please click here to access the full research report.

About WSO2

Founded in August 2005 by Dr. Sanjiva Weerawarana, WSO2 is a global enterprise middleware corporation with offices in USA, UK and Sri Lanka. Providing the only complete open source middleware platform from on-premise to cloud, WSO2 is revolutionizing the industry by putting traditional middleware on a diet and introducing lean, powerful and flexible solutions to address the 21st century enterprise challenges.

US C++ developer caught outsourcing his work to China

In 2012, Verizone security team received a call from a US company specializing mission critical infrastructure services saying that they see traces of abnormal VPN activity. That company was promoting telecommuting instead of typical office environment for their workforce; hence they had a VPN solution for their developers to work from home in some days. They had setup a VPN concentrator solution sometime in 2010 and their IT department started actively monitoring its usage logs from May 2012. They were surprised to see an active and live VPN connection to their facility from Shenyang, China!

 

They were highly unnerved as they were one of the US’s mission critical infrastructure providers and they were probably under the threat of an initiated VPN attack initiated from China.

The security mechanism used is a fairly standard two factor method; User’s credentials and then rotating RSA token generated from a hand held token generator.

And surprisingly at the same time the user who’s credentials were used to login was seen in the office working at his desk staring at the monitor just as usual. Before coming to Verizone, the company security specialists were convinced that there is some malware routing traffic to China through their proxy by some strange means; they wanted Verizone to catch the malware.

The Verizone security team started digging into the issue and they found that this strange connection is not new. It was there active during working days for the past 6 months where VPN logs were available. Surprisingly it was active during the full span of office hours almost all those days. When the investigation team found that the connection initiation uses user credentials, they started studying about the employee as well.

He was a software developer in his mid 40s, experienced with C, C++, perl, Java etc. who was there for a while. He was a quite family man who is not very noticed, but was a good asset to the company. Verizon security team called him “Bob” in their case study.

As a basic forensic measure, Verizone wanted to check whether there was malicious software activity in Bob’s PC. So they managed to get an image of the hard disks and recovered many files from the free disk space which might have been freed after deleting those files. Hoping to see an accidently downloaded malware which could have caused this, they were astonished seeing hundreds of deleted invoice pdf files from a third party contractor in Shenyang, China.

It’s revealed that Bob has outsourced his work to a Chinese outsourcing firm and got his work done for just a 20% of his paycheck. No wonder there is an ever increasing trend to outsource! To cover the authentication, Bob has FedExed his RSA token generator to China so that the Chinese developer who is supposed to work on behalf of him could use the token generator along with his credentials to login to the VPN during each workday.

So what was Bob doing all day without doing his job? Investigators later found his web browsing history, which explains that. He was used to surf Reddit for a few hours, then watch cat videos until lunch. After lunch he starts browsing EBay, FaceBook and Linked in where at the end of the 8 hour day he send an end of the day email to the management before he leave the office.

Bob was smart enough to do the same across few other companies as well while earning few hundred thousand dollars by spending only $50,000 for the Chinese developers per annum. It was a well run outsource business!

This is the coolest part of the story:

Bob was identified as the best developer in the building; His code was well written and clean and always on time! Bob has received continuous positive remarks for excellence at work several years in a row.

Some say outsourcing can reduce efficiency, long term maintainability blah blah… but, Bob showed that it’s not the case with his case study! We never know what really happened after the incident.

Was he convicted of the breach of the company NDA policy? Or was he being promoted as an outsourced development account manager role and the development work was outsourced to the same Chinese sub-contractor?  Then you better find the name of the company and buy their shares! Cos, they are going to go profit this year with a fivefold cost reduction!

What was the highest risk that you’ve taken in your workplace?

If you are dare to open up, use our comments section to tell us your views.