-1

I'm starting to move from Windows to Linux development. In the process, I need to "forget" all of the familiar Windows APIs (WaitForSingleObject, CreateTimer etc.) and learn a bunch of Linux specific APIs instead.
So, my question is... should I?
I mean, if cross platform libraries like Boost are commonly used in the Linux community, do I really need to learn ahead the Linux-specific APIs?

I'm well aware that it would be a good idea to be at least familiar with the APIs, but... what is most common in the professional industry? Do most Linux-focused software companies use cross platform libraries, or OS specific APIs?

2
  • Maybe you should differentiate between Linux for desktop/server appliances and Linux for embedded devices. I just know that for embedded devices, Boost has too many dependencies and is too heavy weight.
    – Shi
    Aug 19, 2012 at 14:11
  • @Fairview Also, it will depend on the projects you work on. In your professional career you can open many more doors by having the additional knowledge (or at least enough to use it with the right references). I've seen projects that are Windows-specific APIs, Linux-specific APIs, Boost non-specific, and custom non-specifics.
    – MartyE
    Aug 19, 2012 at 14:27

2 Answers 2

3

It depends on how complicated things you are going to use/need. For example Linux has SEM_UNDO option for System V semaphore, which is not available, when boost is used. In general, boost portability does not come for free, you will be able to use only common subset of different O/S possibilities. If this is enough for you, go for boost and do not handle (sometimes) obscure low level API. This should not only make your programs more portable (to some extent), but also less error-prone.

1
  • 1
    +1 for mentioning SEM_UNDO, so finally someone learned from the sick mistakes of UNIX. Without SEM_UNDO cross process usuage of semaphors is almost useless. Run into it 5min after i planned to use - nobody in the UNIX Posix design committe obviously did ever thing about how to use it before. Dammit i hate UNIX so much and for very good technical reasons.
    – Lothar
    Aug 19, 2012 at 14:52
3

As a pure C programmer, I rely on the long-time-successful POSIX standard. This is, for me, the best portable API I have ever used across UNIX-based systems. As @Shi points out in a comment, whether you're developing for embedded or desktop/server computers is important because Boost is quite heavy. I'm also an embedded systems developer and the POSIX standard is also quite portable even for uCLinux (a tiny tiny Linux port for embedded systems).

I think the strength of the POSIX standard resides on its low-level of implementation. It deals with fundamental computer concepts (device I/O, memory management, IPC,...) that unlikely change along the years. We are used to see changes in the way we interact with computers, not in the way computers actually work, and the POSIX standard is powerful due to its maturity on dealing with how computers work. Indeed, I'm in love with those magic functions as fork(), pipe(), read() and write() :-)

5
  • 1
    POSIX has also been good for near-realtime programming for decades because of that light-overhead. Incredibly useful for highly parallelized programs.
    – MartyE
    Aug 19, 2012 at 14:29
  • Well it's the best because isn't it the only one? Even Single Unix Specification was POSIX.
    – Lothar
    Aug 19, 2012 at 14:54
  • Yeah, it is indeed the only one, but do we need another one? It would be an interesting topic to discuss.
    – Claudi
    Aug 19, 2012 at 15:03
  • While we are talking about read() and write(), I love handling EINTR, which are generated or not depending on actual Unix flavor being used and how it could be changed when signal handlers are installed. Portability-purity :)
    – Greg
    Aug 19, 2012 at 17:38
  • Yeah, read() and write() are another one of those pieces of the original UNIX legacy which seem elegantly pure at first glance (I used to be in love with them too...), until you really work with them carefully. Why, when I have a partial write, do I have to call write again - the kernel knows why it failed when it returns the partial write. (And no, there's no reason why the system call couldn't leave the errno in a separate register on exiting with a partial write, or why your C library wrappers couldn't move that into the errno variable).
    – mtraceur
    Jul 28, 2016 at 6:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.