APR 1.0.0 Goes Gold
cliffwoolley writes "After several years of development, the Apache Portable Runtime, which is the portability library underlying the Apache HTTP Server 2.x, has finally reached its own 1.0.0 release. If you want to write a portable app without the headaches, APR is the way to do it. Grab a copy and check it out. The full announcement is here."
It's a great set of libraries called 'glib' and 'gnet'. Perhaps you've heard of them:)
APR is quite interesting, but there are many existing libraries out there that duplicate the features. Any comparisons out there between APR and things like SDL?
Disconnect and self-destruct, one bullet at a time.
The mission of the Apache Portable Runtime Project is to create and maintain software libraries that provide a predictable and consistent interface to underlying platform-specific implementations. The primary goal is to provide an API to which software developers may code and be assured of predictable if not identical behavior regardless of the platform on which their software is built, relieving them of the need to code special-case conditions to work around or take advantage of platform-specific deficiencies or features.
This is competition for java?
Sorry... can somebody give me some insight on what this is?
Hooray for compatibility layers!
...I wonder what the performance of this stuff is like as compared to Java. My knee-jerk reaction is "wow, it should be much faster!", but I suppose time will tell. Could make for some interesting new PHP/JSP/etc. type things, or wider compatibility for them.
Of course, it may also remain relatively obscure and unused. Given the attention they've paid to detail on it, that would be a shame, imho.
-Matt
Does anyone know why Apache didn't just use glib?
This is a C library that provides cross-platform compatibility with respect to file IO, threading, and other fundamental actions. It is not a virtual machine!
I think this is a rather bloody usefull thing, it seems to relate to specific things beyond the stdlib. This would allow c-programers to have an open and completely portable library for all of their applications specific to apache webservers. I think that this is a great idea. I could test a module on my linux box, and then take the souce to my bsd webserver and compile without a hitch, and with a guarntee of it working.
That is a vauge example, but I can see the use in this, and if it becomes common it will be trivial to move web apps between servers, upgrades, etc.
I like this, they aren't trying to give us a whole new language to use, but instead a tool to use with our other existing tricks and tools.
Also the quote on the botom of the page is quite appropriate, "My folks didn't come over on the Mayflower, but they were there to meet the boat."
md5sum
d41d8cd98f00b204e9800998ecf8427e
Subversion finally has a fully stable base if I'm not missing anything. The prerelease of APR has been giving me headaches when I have to install Subversion. Hopefully, Subversion will make another patch release soon.
> Does anyone know why Apache didn't just use glib?
Does glib provide pools-based memory allocation for all its functions?
Somehow, I doubt they do. To me, a good pool-based allocator that handles *everything* is really, really, really freakin' handy. Not only is it cross-platform, but code tends to suffer from fewer memory-allocation-related defects (such as using freed pointers, leaking core, leaking descriptors, etc).
Of course, you have to design your code properly from the outset to take full advantage of hierarchical pools. Apache 1.3 (and presumably 2.x -- I haven't studied the source) are *excellent* examples of code designed to take advantage of pools, and the HTTP request model is almost naturally suited for it as well. Write a few complex modules in C some time, you'll see what I mean.
Now, if only I could could figure out why the APR hash functions are so slow for large tables..
Do daemons dream of electric sleep()?
First of all, APR is not a virtual machine or bytecode interpreter like that of .NET common language runtime or JVM. APR is a library (collection of functions) written in C, for C programs. It contains a lot of wrappers to the real standard C library functions, because some conventions of standard library still varies from OS to OS.
For example, the path separator is different in Unix ("/"), Windows ("\"), MacOS (":" - pre X, but also Finder in OS X). Another example is loading dynamically linked libraries (DSO in APR speech). Yet another example is threads.
Besides wrappers, APR has its own memory management routines. APR also adds utility functions not found in the standard library, such as hash table.
By the way, it would be helpful if someone can post a comparison between NSPR (netscape portable runtime) and APR.
I once had a signature.
Did they just say "entirely in C" and "assured of predictable behavior" in the same context?
o_0
The only thing better than writing everything in C is how it supports BEOS and OS/2!
on freebsd 5.2.1.... APR is required to build:
devel/gmake
devel/automake18
devel/autoconf259
devel/libtool15
so I guess most people don't even realize that APR is one of the fundamental building blocks of all open source applications.
Its too bad it only incldes basic low-level data structure functionality so far.
list of all APR modules
But then again I guess that's the point of this project. Anything to make C coders lives easier is a good thing!
To blog is sublime
Also, doing condvars on windows isn't that easy as Douglas Schmidt writes up here.
Writing portable thread libraries seems to be a popular activity. It would be nice if the authors of those packages documented that they were aware of the issues as a first step in convincing those of us who know about those issues that they know what they are doing. Yeah, I know that the Apache authors are considered experts, but it wouldn't be the first time some rather well known experts got tripped up on multi-threading.
"Life isn't about the number of breaths we take; it's about the moments that take our breath away. Like choking."
I'm interested in using the library but confused by the terms of the license.
If I *statically* link to the APR in a commercial software product, what are the consequences? Especially when the commercial software is distributed in binary form only.
http://www.apache.org/licenses/LICENSE-2.0
Download here: /RH
http://www.apache.org/mirrors/
For the win32 version of condvar, I don't think a win32 Event isn't going to hack it. The current logic allows a condvar to remain signaled until the all waiters have woken up and have decremented the use count to zero. This could lead to a lot of spurious wakeups if some waiting thread takes it time to wake up. The APR authors need to read that Schmidt document I mentioned earlier and maybe also look at Schmidt's ACE project and see how he did it.
This is not a comprehensive critique as I only took a cursory look but what I did see indicates that APR needs some more work.
---
It's too bad someone hasn't yet taken the effort to integrate all of this stuff into a super library for GUI, networking, io, threads, email, video, blah blah blah...
---
Well, I and others have built HTTP servers using just the sockets provided in wxWidgets - and it's not that difficult.
As for email - you've got wxSMTP
http://www.frank-buss.de/wxwindows/
Also, one of the core developers wrote an entire cross-platform e-mail program with it
http://mahogany.sourceforge.net/
In addition, wxWidgets supports everything you mentioned except video - however, there is a lot of development in that area at the moment... there is a contrib that does this for windows, and there are already a couple of competing libs to do it on mac - linux of course is a different story since native libs don't support it.
In fact, if you use it with allegro (alleg.sourceforge.net) you have a fairly complete solution for pretty much anything.
That'd make too much sense, though.
There is more than one GNU license -- the GNU General Public License, which disallows proprietary derivatives, and the GNU Lesser General Public License, which allows proprietary derivatives. Then there's the GNU Free Documentation License which is intended for something else.
If you meant a license the Free Software Foundation calls a "free software" license, then there's even more licenses to consider. All this raises the question: which license are you referring to?
Digital Citizen
I know I'll get flamed/modded down for this, but it needs to be said: there is no reason for new apps to be written in C. C++ can do everything that C can do, just as efficiently; it's easier to read, which means a code review is more effective; language features and the STL reduce the need for explicit dynamic memory allocation, which is a source of bugs in C; the language is a better match than C to modern, object-oriented methods of analysis and design; - I could go on, but shouldn't need to.
Yes.
It is the first post.
It has "first post" as subject.
The only content in the post is "first post"
I think that qualifies as redundant.
Be wary of any facts that confirm your opinion.
OH come on. This is hilarious.
I just lost another loan to Ditech.com!
I looked through the API reference for about 15 minutes -- it reminds me of Apple's Core Foundation. Not that I think they copied Apple, but there are some interesting parallels.
- Scott
Scott Stevenson
Tree House Ideas
ah, thank you. and here i thought the mods' favourite modifier switched from offtopic to redundant...
Looking at the API it seems that GLib is a bit easier to use, while APR has some features that may lead to better performance, in particular memory pools (GLib does not have it, so all memory allocation are done by malloc(), saving a parameter but also losing a little flexibility).
Both are quite complete; but from a quick glance I can't find any data structure in APR that implements a sorted set/map, such as balanced binary trees or red-black trees or heaps, which seems to be quite handy when implementing timeouts (you always need to get the timeout that will expire first in order to provide the "timeout" parameter for "select"). Does anyone know how to solve this problem?
I wrote a paper about this, and problems with custom (special-purpose) memory allocators in general, called Reconsidering Custom Memory Allocation (OOPSLA 2002). In it, I also describe a new memory allocation scheme, called reaps . This is a hybrid of regions (pools) and heaps that acts just like pools except you can still free individual objects.
In fact, for a case study, I put reaps into Apache (adding a ap_pfree call), and showed how using reaps made it simple to incorporate a piece of existing C code (namely, bc) into Apache. Without reaps, an invocation consumed 7.4MB of memory (since every free had to be disabled). With reaps, 240KB.
I did send a message to the Apache folks about this a while back, but they balked because the implementation is in C++, rather than C (developed with my Heap Layers infrastructure)...
-- emery
Emery Berger
Assistant Professor
Dept. of Computer Science
University of Massachusetts, Amherst
And I won't be using APR because the Apache license suxors.
there is no reason for new apps to be written in C.
By "new apps" do you mean this to include "new versions of g++" as well? If so, then how would you recommend bootstrapping a C++ compiler on a system with only GCC?
language features and the STL reduce the need for explicit dynamic memory allocation
To a developer who has to fit algorithms and data structures into a handheld computer's 32 KB of fast RAM when all other RAM in the system has horrible wait state behavior, every byte still counts. I've read horror stories that use of the STL tends to bloat code size. Have modern STL implementations addressed this issue other than just to deprecate a widely deployed handheld computer?
I tried to integrate C++ components into the APR framework and eventually gave up because the APR memory pool concept is not very compatible with C++'s memory management scheme. You would have to register callbacks for object cleanup all over the place for every C++ class type in order to get the C++ destructors called. You can do it, of course, but it makes C++ programming painful with APR. As for pool memory locality in APR - it is good for streaming web pages, but not much else. All locality is lost when you are dealing with objects that span multiple HTTP connections.
I agree that the pools scheme used in APR is completely unusable for integrating traditional C or C++ code - pools are only good for traditional HTTP-like request-response processing. Where can I find an implementation of APR with your Reaps hooks? By the way - your research rocks.
NSPR is proven to run on a dozen platforms in the past 5 years. APR is not nearly as mature as NSPR - nevermind that the apr_pool_t concept does not work very well in non-HTTP based multithreaded servers - it wastes too much memory and makes it extremely difficult to integrate traditional malloc/free based code.
Everyone I know is still playing 'wait and see' with Apache 2.x, and the same can be said for its infrastucture.