WaitForMultipleObjects and WIN32 events for Linux/OS X/*nix and Read-Write Locks for Windows

As every programmer worth his salt knows, synchronization primitives form the very building blocks of multithreaded programming. Without them, the world as we know it would cease to exist and chaos would reign free and unchecked.

All joking aside, synchronization objects such as mutexes and semaphores are essential to safe multithreading and are found on just about any platform under the sun. Mutexes and semaphores alike have one purpose: to keep different threads from messing around with bits and bytes at the same time another thread is, keeping your code free of segfaults and memory access violations alike. But that’s about where the similarities between the synchronization primitives on different platforms end.

POSIX-compliant operating systems with pthreads offer additional really neat synchronization primitives not found on Windows, such as condition variables and read-write locks (the latter is now available on Windows Vista+). And Windows programmers have at their disposal automatic and manual reset events, which make designing certain types of multithreaded software incredibly easy, abstracting away much of the hard-core synchronization logic that lies beneath the hood.

Continue reading

My Thoughts on Sutter’s “C++ and Beyond 2011″

Around a month ago, Herb Sutter gave a talk on why C++ is once more gaining relevance in the world of programming, and how after a decade of neglect and abandonment, it is set to pave the way into the future. I downloaded it a while ago and finally had a chance to watch it last night; the talk itself is most-excellent and is around 40 minutes long, you can stream it online or download it in a higher-resolution format on Channel 9. Or click below to watch:

As someone that’s been using both C/C++ and .NET extensively over the past years, I found there was one very important point that Sutter glanced on, danced around, and did everything short of actually naming in his talk and it’s that if you’re doing anything remotely intricate or complicated, leaky abstractions in managed languages will bite you in the ass, and end up lowering your productivity, some times (and if what you’re working on is truly complicated, often times) to a point where you’d have been more productive using C or C++ in the first place.

The concept of leaky abstractions isn’t anything new and I’m hardly the first to point out how it can turn a knight in shining armor into a harbinger of doom and destruction. It’s the number one problem fundamentally present in almost any framework, but even more so in managed languages where the framework is all you have, and you’re not allowed to side-step it and build your own foundations to work with (p/invoke and interop aside). But lately it’s becoming more and more of a problem as the “push” for innovation that Sutter speaks of has become a fundamental requirement in just about all corners of the industry.

Continue reading

Contributing to the Open Source Community

A week ago, we tweeted a promise to contribute more to the open source community. As a Research & Development organization, there’s a lot of random code samples, small libraries, forks/modifications of popular scripts, and more that’s just lying around, begging to be open sourced.

While a lot of these may prove to have little to no value to anyone, given how easy it is to make things open source thanks to github, there’s no real drawback to throwing them out there for anyone that may benefit at some unknown point in the future.

We have a couple of hundred miniature projects, test code samples, and other such content across a number of drives to sort through, and whenever we find something useful, this is our promise to the community to share it. To that end, we’ve set up a github repository at http://github.com/neosmart where we’ll be uploading the code, and from where you’re all more than welcome to check it out and contribute back.

Continue reading

Android: A Fragmented Platform or Not?

Android RobotIf you were to believe the latest headlines at Business Insider, Android is a fragmented mobile platform and has a negative effect on the applications, for developers and end-users alike. Android is currently in a heated battle with the other two big names in mobile technology (the iPhone and the BlackBerry being the other two), and this is a serious matter definitely worthy of discussion.

But Dan Frommer’s allegations in his latest post on BI don’t really add up. Frommer contends that the official twitter app for Android, which only works on Android v2.1 and up, is proof that Google’s mobile OS isn’t as “unified” as the competitors, and that this is a sign of early-onset serious fragmentation that will only get worse down the line. The thing is… it’s not.

It’s true that Android, available for deployment on any device manufacturers are willing to bundle it with, faces certain compatibility issues. With a multitude of devices, each with its own mostly-unique set of hardware and features, creating software that will run the same for everyone isn’t as easy as it is on the iPhone. But it’s nowhere near as much of an issue as Frommer makes it out to be.

Continue reading

On the matter of Firefox and memory leaks…

Recently our original article/rant on Firefox’s legendary memory abuse has seen an increase in comments and views; and I had intended to post the following comment in light of the article’s rebirth and the ensuing discussions in the comments.

The reply turned out to be longer than I’d originally intended, so here it is as its own post.

I’ll try to be as objective as possible in this reply:

The most important thing for frustrated end users to keep in mind is that Mozilla/Firefox cannot be held responsible for cases where incorrectly written plugins and/or extensions cause Firefox to abuse system memory – that’s the trade-off between empowering developers and keeping the code squeaky clean.

Most of the cases reported are indeed caused by one or more extensions or plugins gone awry, doing something they shouldn’t be doing, or something they don’t know how to do properly. Some of the most popular plugins for Firefox are notorious for their memory leaks; but few users realize just how dangerous they can be, and that the Firefox devs cannot really do anything about it.

At the same time, there can be no doubt that Firefox has some memory leaks in the codebase itself. They’re clearly not easily reproducible and they don’t happen very readily nor often enough because the developers have clearly spared no effort in their attempts to address this problem for once and for all. But they’re there, nevertheless.

Continue reading

Programmers Should Trust Their Instincts

People are either cut out to be programmers or they’re not. How to know, what to do if you’re not, and where to go from there is a huge issue and not the subject of discussion. But one of the signs of a good programmer is good programming instincts. The right instincts can save hours of work and provide creative solutions to even the most difficult problems; and “gut feelings” in programming are not something you should ignore lightly.

One of the first thing Computer Science teachers drill into the heads of their students is that it’s important to map everything out beforehand. Design the algorithm. Draw the UML diagrams. Decide the entire flow of data and the relationships between everything before you even touch the IDE. While this is integral advice for anything above a small-complexity project, there is an exception: if you have a gut feeling, follow it.

For instance, the other day I sat down to write a simulator for a MIPS datacache, with different replacement policies. “Ideally,” the planning procedure would have involved designing the sequence diagram, a flowchart detailing the method used by the cache to determine expired entries, and generally-speaking a lot of time down the hole just visualizing what happens beforehand.

Continue reading

Internet Explorer 7 “Updated” – But Not Really…

Steve Reynolds, program manager of the Microsoft [[MSFT]] Internet Explorer development team, has just announced an “update” of sorts to Internet Explorer 7 a year or so after its original release in 2006. Never mind the fact that we were promised regular updates and that “Internet Explorer 7 won’t be like IE6″ with regards to lack of new features and updates, what’s up with the list of the things that have changed with this new version!? Have a look for yourself at the “changelog:”

  1. No need for WGA verification in order to get Internet Explorer 7
  2. The menu bar is now visible by default.
  3. The Internet Explorer 7 online tour has updated how-to’s. Also, the “first-run” experience includes a new overview.
  4. We’ve included a new MSI installer that simplifies deployment for IT administrators in enterprises. Learn more about it here.

Interesting… Here’s our take on these “updates” 

  1. It really shouldn’t have required WGA in the first place – Microsoft (for some odd reason) guarantees users of pirated versions of Windows “immediate” access to any security-related patches, upgrades, and hotfixes. Doesn’t Microsoft tout Internet Explorer 7 as a security-prioritized upgrade?
  2. Noooo! We love the hidden menu bar! It’s clean, it’s clutter-free, and it gives IE7 a great look. Obviously the reason they’ve put it back is that users had trouble getting the menu to show (hint: press `alt` to make it appear), but who actually uses the menu bar anyway?! At least make it a first-run option… please? Sure, you can make it hidden again by flicking a switch in the options panel, but that’s just so wrong on so many levels…
  3. Not exactly what we’d call an upgrade to Internet Explorer itself so much as it is an improvement to the external documentation. It’s just a file hosted on MS servers that users can opt to view.
  4. Nothing more than an upgrade to the packaging/deployment for Internet Explorer 7, albeit a most-welcome one for sysadmins and software integrators everywhere.

Continue reading

Apple’s New Animation Framework

Although we try our best to be impartial when it comes down to OS wars, and we have, throughout the years, presented the pros and cons of Windows, Linux, and other operating systems, you’ve probably noticed that NeoSmart Technologies isn’t too big on Apple. Well, color us purple, but this we have to talk about.

Apple [[AAPL]] has a new technology due to ship in Leopard that is pretty damn impressive to hear some of the developers (or at least those at liberty to discuss what they’ve been told) talk about it. According to this Wired News article, this framework will focus on making it easy for developers to add Next (Delicious) Generation graphics to their applications, bringing the concept of UI to a whole new playing field.

While it sounds just plain awesome, we can’t help but look at it with mixed feelings. Since this is Apple and not Microsoft we’re talking about, we’re pretty darn sure everything they say can and will be found in the RTM release of OS X Leopard *cough* WinFS *cough*, but whether or not it will revolutionize the concept of user interfaces everywhere remains to be seen.

Granted, the effects are supposed to be astounding. But that’s not the question, next-gen UIs (hereby dubbed “Desktop 2.0″) are almost always a matter of how and not what. As the Wired article states, these same “amazing” graphical innovations with the UI do already exist in certain programs (like Disco, the CD burning utility for OS X), the only difference is, Apple promises to make it much easier to get the same end results.

Continue reading

“Spare Cycles” or Selfless Souls?

Chris Anderson (Wired Magazine, The Long Tail) posted an interesting article yesterday, comparing bored humans to spare CPU cycles – and more importantly, just how much they can accomplish. But while the article – as a whole – was really interesting and scientific and is a topic that has been discussed in scientific forums, dozens of publications, and is the basis for a lot of research, there was one paragraph that stood out:

Who knew there was so much untapped energy all around us, just waiting for a catalyst to become productive? But of course there was. People are bored, and they’d rather not be. [......]

That sheriff is watching a movie because he has spare cycles. Spare cycles are the most powerful fuel on the planet.  It’s what Web 2.0 is made up of. User generated content? Spare cycles. Open source? Spare cycles. ((Emphasis added.)) MySpace, YouTube, Facebook, Second Life? Spare cycles. They’re the Soylent Green of the web.

While we’re sure that Chris probably didn’t mean anything by it and it was just a passing reference made without much thought, it does beg the question: do people actually believe that open source exists only because we [the developers, the contributors, the testers, the documenters, and just about everyone else involved in the process] are too bored and have nothing better to be doing?!

Continue reading

Please Microsoft, Stop Holding .NET Back!

As dedicated developers, end-users, and champions of Microsoft’s .NET Framework, we’re making a final plea to Microsoft and the .NET Framework team to save .NET and make it a real multi-platform framework. Please!

Sun could (and did) do it with Java, so why can’t Microsoft just swallow the pill already and provide real support for the .NET Framework on all operating systems? Yes, that includes Linux and Mac too. It’s ironic, because the .NET Framework has so much potential as a platform with its unique multi-language structure, nifty features, excellent libraries, (relatively) well-performing output, and darn-good innovative technologies like LINQ coming-up and XAML already here. Yet Microsoft just doesn’t realize that if they truly want .NET to succeed, they’ll have to bite the bullet and stop pretending that only officially supporting Windows won’t make users leave Linux/Mac/BSD/Whatever and buy licenses for Windows instead.

Continue reading