1

Why isn't there the Unix API? I mean, as there is the Windows API.

I know a lot of things in the Unix world is modular, and those things put together creates a whole system. This sounds good but does create some problems when you try to make a native Unix app.

For example, you want to program a nice word processor with a cool name WP. The Windows version of WP will be built by calling the Windows API. You can either code this directly in C, or use any of the various wrapper libraries out there. But still, the program must be constructed by calling winapi, which provides every single functionality that a programmer may need to build a Windows app, from basic system calls to GUI, 3D, multimedia or anything else with more than a decade of backwards compatibility. If it weren't like this, Wine could never exist.

Now you want to create a Unix version of WP. The standard C and C++ library and the POSIX API is very stable and well supported in any Unix variants. The problem occurs when you try to do more. So you need to create a window for WP, but how? There is X11, but this is not the only one. People think X11 should be replaced and now are making two incompatible replacements, Wayland and Mir. Even for X11, there is Xlib and xcb. xcb claims they are 'better', and it is true in some ways, but where is the documentation? You eventually choose Xlib to do the task, but the X11 standard by itself only defines very basic features. Anything else you'd expect for a GUI application such as window events or clipboard support needs to be dealt with extensions, by calling XInternAtom. This sentence is merely my personal opinion, but the use of Atoms in X is extremely unintuitive. And another problem is that not every window manager for X support these extensions well. So let's just leave this dirtiness to the developers of GTK+ and Qt, who break backwards compatibility per each new version. Is it even possible to have portable drag-and-drop support in Linux?

It really seems to me that the Unix community is killing themselves in the Desktop world. I know that the things I mentioned doesn't even matter to set up a BSD server, but it does matter if you ever try to build a portable native Linux app.

What is making up all of this mess? Is there really an effort to clean this up and standardize things for the modern desktop environment of Unix? Why isn't there the Unix API? Will there ever be one?

steve
  • 21,892
  • 1
    Btw. If you say Windows API, it is a bit ambiguous what you mean. Because Windows API was deprecated completely, it is now called Win32 and ComAPI and the new Windows API works from Windows 8 upwards. – Šimon Tóth Aug 06 '15 at 10:42
  • 1
    Do you know POSIX? See http://man7.org/tlpi/index.html for The Linux Programming Interface which a superset of POSIX. It is standardized in LSB (Linux Standard base). – Ho1 Aug 06 '15 at 11:12

3 Answers3

14

To be called UNIX you need to go through a certification process that requires (among other things) that you implement the POSIX standard.

So your question is completely invalid. There is UNIX API, it's called POSIX.

EDIT: Here is the list of requirements: http://www.unix.org/version4/overview.html

Šimon Tóth
  • 8,238
  • To be perfectly fair, POSIX is not an API, but it's a standard of basic system functionality, utilities, system calls, and system interfaces which a UNIX-like OS should implement in order to be POSIX-compliant and call itself UNIX-like. So there is no one single API that you can download, e.g. OS developers are free to implement the things mentioned but within the specs. See also https://unix.stackexchange.com/a/423123/85039 – Sergiy Kolodyazhnyy Jan 13 '19 at 07:15
5

It really seems to me that the Unix community is killing themselves in the Desktop world.

I think there is a misconception that any form of Unix exists in order to compete in the home PC market. There are some linux distros which have this focus; the first one was really Ubuntu, but it is worth considering that part of Ubuntu's original vision was to develop a user friendly operating system that could be used in parts of the world where having to pay hundreds of dollars per computer for a Microsoft license was not feasible and could mean the difference between having computers (in schools, government, etc.) and not having them.

I have not stayed up to date with how successful that's been, but in any case, it seems to me that it is a very different goal than wanting to out Apple Apple or something. Apples and oranges, as they say. Or apples and aardvarks.1 This aardvark is nothing like an apple! No, it isn't. Why would you think it is?

Now you want to create a Unix version of WP [...] You eventually choose Xlib to do the task

Only if you are a crazy person who is unlikely to complete a word processor with mass consumption potential.

Software exists in distinct layers that are assembled in stacks. X is a layer that is used on various platforms as part of the GUI stack. On those platforms, X lib is used to implement higher level libraries such as Gtk and Qt, both of which have a portable API; they can be used on OSX and Windows, neither of which uses X. On those platforms, a different lower level library/API is used to implement Gtk and Qt. This means higher level programs, such as end user GUI applications, written for Gtk or Qt, can be used anywhere with relatively minor changes.2

Those are the libraries that are used directly to implement GUI applications on POSIX systems, which is why most such applications are usually not that hard to port from one "near compliant" POSIX system to another.

So the "problem" you are referring to does not actually exist in the way you've presented it. The Unix community is not killing itself, it's doing exactly what it intends to do.


1. To explain better what I mean by this, consider the role of the free market in the evolution of GNU/Linux vs. Windows. The latter clearly is, by intention, the product of free market forces, but the former case is much more ambiguous. As good Westerners, we of course then put theory first and say, "Well obviously a product that is shaped by the free market is better than one that is not." But this is not quite true -- what it really means is that one will be prone to sell better. You seem to be asking why there's not more of an effort to make the product sell better in this sense. The answer, of course, is that there's less motivation to do so, which raises the question of what there is motivation to do. The development of GNU/Linux (in particular) has been guided a lot by developers out to please themselves, and not so much other people or a mass market. Whether or not this produces a better system I guess depends on how close your perspective is to the people who created it. The history of UNIX does involve more market forces, but it is/was a highly specialized audience. Put another way: It's a technical OS for technical people, but there is a rabbit hole available for the general public.

2. In contrast, if you write something with the Windows API, there is only one place you can use it without some very major changes..

goldilocks
  • 87,661
  • 30
  • 204
  • 262
  • 1
    The problem of GTK and Qt is that it's not easy to run a GTK1 or Qt3 app in the most recent Ubuntu, while a 32 bit Windows 98 executable will still run in Windows 8. Having 2 sets of incompatible libraries necessary to make a native GUI application is also a problem by itself. I mentioned all of this in my original question also. –  Aug 06 '15 at 12:57
  • "It's not easy* to run..."* -> But that's not "can't", even if in fact some people "can't". I would never argue that most any and every GNU/Linux distro is going to be harder to configure and use than Windows. I don't recommend it to friends, for instance, even though it is certainly my first choice of OS. This is part of my point about the "misconception" some people have that it is meant to compete with Windows. It mostly is not, and realistically, while there may be an overlap in their "target audience", again, you have apples and aardvarks. – goldilocks Aug 06 '15 at 14:59
  • WRT "2 sets of incompatible libraries necessary to make a native GUI application" if you mean, X and the higher layers, no, this is the opposite of a problem, this is in accord with some basic principles of good software engineering. If they were not separate, replacing X with Wayland (e.g.), would be infeasible, as would having highly portable POSIX applications. It includes more than one distinct OS, after all. If you are talking about Gtk and Qt, you don't need both of them to create an application and there is hardly a problem with choices. – goldilocks Aug 06 '15 at 15:04
3

Unix has specifications/a standard they hope you'll follow, POSIX, ways things should be implemented, though up to the developer, it's a standard we should follow if we want our code to work on many architectures/platforms/systems whatever, up to the developer at the end of the day to follow what (hopefully) majority of developers are following.

Windows has a library of functions, the so called API, it is set in stone as per financial dictation by upper management (many will argue, but everything microsoft is about the bottom dollar AFAIK...whereas posix is about trying to get along)

POSIX is like an API, just with no financial consideration, just about code trying to work together...that is not a microsoft concept, it is there way or the highway.

That's is the way I see it ;-}

EDIT:::

After reading my post, I realize that I might be a little biased, that was not the intention as fingers just move with the truth, but I do mean what I said, biased removed...if possible

gwillie
  • 1,151
  • 2
    I don't have a problem with your bias, I just don't think it has much to do with this question. POSIX is controlled by The Open Group, which are an authoritative body (and they do not exist for free, either). That Microsoft is a corporation and The Open Group an "industry consortium" is a immaterial with regard to the nature of the Windows and POSIX APIs. – goldilocks Aug 06 '15 at 11:46
  • well, you are most likely right. we are only here (inet wise) to purport what we perceive. when I look at freebsd and the like, and its overall posix compliance outlook, and its overall compliance outlook to the community, posix becomes a grain of salt. its up to the developer to implement what some theoretical standard implies. that doesn't exist in microsoft world. I work with software that is microsoft gold partner in austrailia and its features are so archaic in 2015 that i wonder. posix is about attempting to get along to some degree, microsoft is about internal management decisions. – gwillie Aug 06 '15 at 13:02