Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming Software Apache Technology

APR 1.0.0 Goes Gold 111

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."
This discussion has been archived. No new comments can be posted.

APR 1.0.0 Goes Gold

Comments Filter:
  • APR (Score:4, Interesting)

    by cbrocious ( 764766 ) on Saturday September 04, 2004 @01:47PM (#10158144) Homepage
    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?
    • Re:APR (Score:5, Informative)

      by Electrum ( 94638 ) <david@acz.org> on Saturday September 04, 2004 @01:49PM (#10158156) Homepage
      Any comparisons out there between APR and things like SDL?

      APR is for servers, SDL is for games.
      • Re:APR (Score:4, Informative)

        by cbrocious ( 764766 ) on Saturday September 04, 2004 @01:53PM (#10158170) Homepage
        But SDL provides cross-platform threading and such. It's been used in many things other than just games (which is why it's not just sound and video)
        • Re:APR (Score:2, Informative)

          by Anonymous Coward
          Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer. It is used by MPEG playback software, emulators, and many popular games, including the award winning Linux port of "Civilization: Call To Power."

          Simple DirectMedia Layer supports Linux, Windows, BeOS, MacOS Classic, MacOS X, FreeBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX. There is also code, but no official support, fo
    • Re:APR (Score:5, Insightful)

      by FooAtWFU ( 699187 ) on Saturday September 04, 2004 @01:49PM (#10158157) Homepage
      I don't think APR and SDL have much of the same market. The Apache Portable Runtime is used in the Apache httpd. Simple DirectMedia Layer is used for graphics and sounds and the link.
    • Re:APR (Score:5, Interesting)

      by Anonymous Coward on Saturday September 04, 2004 @02:09PM (#10158247)
      Other notable portable runtimes include:

      NSPR (Netscape Portable Runtime) http://www.mozilla.org/projects/nspr/index.html [mozilla.org]

      ACE (Adaptive Communication Environment http://www.cs.wustl.edu/~schmidt/ACE.html [wustl.edu]

      wxWidgets http://www.wxwidgets.org [wxwidgets.org]

      Those are just a few, there are others out there as well

      Choosing one to use is a difficult exercise. The important things to consider are what you want to use it for and how it fits in with your existing software and experience.

      If you'll be doing GUI programming, wxWidgets is a good way to go. In addition to the file io/threads/networking portability you get GUI portability as well. The NSPR fits into this area as well.

      The APR is obviously a well tried and proven framework, since the Apache HTTP server uses it. If you want cross platform server software, APR is probably a good choice. NSPR fits in this area as well.

      The biggest consideration when choosing one of these libraries is how well you can pick it up and understand it. If you look at the API and it doesn't make any sense to you, it won't be pleasant to integrate with it. Documentation varies in quantity and quality. Also, how well supported is the library by the development community?. (Actually not much of an issue for APR,NSPR and wxWidgets as they are all very actively maintained and used).

      On another note, it certainly would be nice to get more of a standardized set of cross platform libraries on the scale of the Java API. There's no reason why this can't be done. Most of the pieces are already out there. 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...

      Perhaps I'll have to get started on that...
      • Re:APR (Score:3, Funny)

        by Anonymous Coward
        On another note, it certainly would be nice to get more of a standardized set of cross platform libraries on the scale of the Java API.

        Do you mean something like Java?

      • by Anonymous Coward
        ---
        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 ev
      • Re:APR (Score:2, Informative)

        by Anonymous Coward
        NSPR, ACE, and the wxWidgets toolkit are all for C++. APR is for C. About the only thing that comes close is glib, and it's actually a pretty poor fit on non-unix platforms.
      • The biggest consideration when choosing one of these libraries is how well you can pick it up and understand it.

        Indeed. Important observation.

        In addition most libraries impose a way of doing things that might not fit your application. In the C/C++-world this situation often arises. For instance you might want to use two libraries together, that both need to be in charge of thread- or signal handling etc, so you end up kludging together the bits you need and it never feels quite right.

        Then, of

    • I'd also like to know how much and in which ways it differs from wxWidgets [wxwindows.org]
    • Re:APR (Score:3, Informative)

      by BaldBass ( 49775 )
      BOOST [boost.org] certainly deserves mention
  • java-ish? (Score:4, Insightful)

    by BoldAC ( 735721 ) on Saturday September 04, 2004 @01:48PM (#10158148)
    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?

    • Re:java-ish? (Score:5, Informative)

      by dollargonzo ( 519030 ) on Saturday September 04, 2004 @01:53PM (#10158169) Homepage
      this a C library, not a virtual machine/language like jvm/java. the idea is not to have code run without recompile on all platforms, but rather that *all* you need is a recompile. more specifically, you don't need to have platform specific cases in your code. code becomes pretty unmaintainable when it is littered with #ifdefs
    • A portalable runtime (like the APR) would be a good place to start if you were going to write a Java interpreter.
  • Neat! (Score:1, Insightful)

    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
    • It is NOT java! (Score:3, Informative)

      by damm0 ( 14229 )
      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!
  • glib? (Score:3, Interesting)

    by JamesKPolk ( 13313 ) on Saturday September 04, 2004 @01:52PM (#10158164) Homepage
    Does anyone know why Apache didn't just use glib?
    • Re:glib? (Score:5, Informative)

      by DylanQuixote ( 538987 ) <dylan@nOSpAM.hardison.net> on Saturday September 04, 2004 @01:57PM (#10158189) Homepage
      glib didn't exist at the time the APR was started. Also glib is still not quite useful on windows.
    • Re:glib? (Score:5, Informative)

      by E-Lad ( 1262 ) on Saturday September 04, 2004 @02:02PM (#10158214)
      You have the wrong idea of what APR is.

      APR is a library which, at its basic level, provides wrapper functions to syscalls of many different operating systems. Why? because the same syscall on one OS sometimes behaves differently, have bugs, or take slightly different arguments from the same syscall on other OSes.

      APR addresses these differences and provides you, the app developer, with a common set of functions.

      So if you're say coding your own FTP server project and you main development platform is linux or what have you, if you use APR's wrtite() or APR's sendfile(), you know that your call to that will also work on Solaris, FreeBSD, Darwin, etc... because APR takes care of all the abstraction at compile time. /dale
      • Re:glib? (Score:4, Informative)

        by Junta ( 36770 ) on Saturday September 04, 2004 @02:06PM (#10158231)
        That is *exactly* the sort of stuff glib was intended for, to wrap system calls on specific platforms and provide a cross-platform API for basic syscalls. It was the low-layer abstraction of cross-platform things GTK/GDK needed, and has grown from there.
      • Re:glib? (Score:5, Interesting)

        by Anonymous Coward on Saturday September 04, 2004 @02:17PM (#10158283)
        APR is a library which, at its basic level, provides wrapper functions to syscalls of many different operating systems. Why? because the same syscall on one OS sometimes behaves differently, have bugs, or take slightly different arguments from the same syscall on other OSes.

        All true. But you didn't mention the other huge thing it does - pools. They're a completely different way of managing memory than other systems use. The Apache people would say they're higher-performance (more locality -> better cache behavior, big groups of stuff can be deallocated at once, etc.), less error-prone (fewer leaks), etc.

        And then a bunch of pool-using code. Like string functions that replace the standard C strcpy() and such but return new pool-allocated strings rather than potentially overflowing a buffer.

    • does glib distribute with GNU license?
      • 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?
    • apr_pool_t (Score:5, Interesting)

      by multipartmixed ( 163409 ) * on Saturday September 04, 2004 @02:18PM (#10158286) Homepage
      > 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..
      • That's exactly the kind of answer I was hoping for. Thank you.
      • In glib2 just set your own GMemVTable by g_mem_set_vtable() such as by g_mem_chunk_*() set of functions (=pool allocations).
        I see APR as a dupe, the same as NSPR or non-graphical part of Qt.
        They at least try to provide some generic portability/utility layer, most of the projects just reimplement it always from the scratch for themselves.
        Your "Not only is it cross-platform, but code tends to suffer from fewer ..." sentence is not related to the GLib vs. APR question at all. Otherwise clarify it.
      • by Ristretto ( 79399 ) <emery@c[ ]mass.edu ['s.u' in gap]> on Saturday September 04, 2004 @09:38PM (#10160124) Homepage
        Ugh. Although pools are plenty useful, they have lots of problems. The inability to free individual objects can be a real deal-breaker. Since you can't free objects within a pool until all of them are no longer in use, dead memory can just accumulate. For lots of reasonable situations, this means unbounded memory consumption. It also makes it very hard to incorporate existing code that uses malloc/free.

        I wrote a paper about this, and problems with custom (special-purpose) memory allocators in general, called Reconsidering Custom Memory Allocation [umass.edu] (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 [umass.edu] infrastructure)...

        -- emery

        Emery Berger [umass.edu]
        Assistant Professor
        Dept. of Computer Science
        University of Massachusetts, Amherst

        • Considered Sending them a version of it written in C instead of C++? ;-p

          While I understand your complaint, there are a *LOT* of projects with this exact same stance. All code must be written in C. Trying to get them to implement code that will lower their audience (not to mention considering some of the new 'differences' in C/C++ syntax in gcc 3.4+ suddenly dropping a piece of C++ code in not only forces users to have a C++ compiler handy, but also might force developers who are used to C syntax to find th
      • ...why the APR hash functions are so slow for large tables..
        Last time I looked - about a year ago - they (APR hash functions) weren't really hashed. They are (were?) arrays of key-value pairs. Hence the slow lookup...

        P.S. Oh, they can be called hash tables, though with a hash function that returns the same value for all its keys ;-)

      • Apache's pools are pretty cool. You can also do the same thing with GNU's obstacks.
  • Usefull... (Score:3, Interesting)

    by doublebackslash ( 702979 ) <doublebackslash@gmail.com> on Saturday September 04, 2004 @02:11PM (#10158259)
    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."
  • Yipee! (Score:4, Interesting)

    by Ann Coulter ( 614889 ) on Saturday September 04, 2004 @02:16PM (#10158279)
    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.
    • > Subversion finally has a fully stable base if I'm not missing anything.

      You're missing that APR 1.0.0 is not compatible with APR 0.9.x.

      So Subversion cannot upgrade to APR 1.0.0 without breaking binary compatibility, which the Subversion people have guaranteed not to do before Subversion 2.0.0.

      Also, Subversion depends on the Apache web server, so it must use the same version of APR as the Apache web server. AFAIK the web server is still using APR 0.9.x.

      • Re:Yipee! (Score:4, Informative)

        by breser ( 16790 ) on Saturday September 04, 2004 @11:59PM (#10160726) Homepage
        Actually Subversion trunk can already build against APR 1.0.0. We had a lengthy discussion about this a while back. I'm not sure we ever really resolved it. But the general consensus seemed to be that enforcing majors of our dependency to always be the same wasn't something we were enforcing binary compatability for.

        I.E. Subversion's compatability guarantees are only good to the degree that you don't go changing major versions of the libraries.

        You are correct that Apache 2.0.x will continue using APR 0.9.x, but Apache 2.2.x (currently called 2.1.x) will use APR 1.0.0. If we enforce the major of APR we can only function with Apache 2.0.x, which is not a requirement we really want to limit ourselves to.

        • While thinking about version numbers, I wonder what awaits us in APR 2.0? Most of the common portability concerns seemd to have been wrapped up pretty well in APR 1.0 (for the basic features Apache needed). What's left?
  • Some info on APR ... (Score:5, Informative)

    by pikine ( 771084 ) on Saturday September 04, 2004 @02:20PM (#10158292) Journal

    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.

    • by DrXym ( 126579 ) on Saturday September 04, 2004 @02:33PM (#10158337)
      The NSPR offers similar functionality. Info about the NSPR is here [mozilla.org].

      I'm guessing by this stage that both the APR and NSPR are industrial strength libs to write cross-platforms against. Both have similar functionality because both underpin web servers (yes NSPR is used by the AOL/Sun iPlanet webserver, and not just Mozilla).

      What it might boil down to in the end is which runtime's licence is most compatible with what you have in mind.

    • by r6144 ( 544027 )
      As other posts have pointed out, what GLib does is mostly the same; although GLib seems to be used mostly in client-side apps, I have written quite a few server programs quite comfortably with it.

      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 f

  • by xyote ( 598794 ) on Saturday September 04, 2004 @02:24PM (#10158302)
    The atomic operations while nice are basically useless without memory visibility rules or semantics. This is something that get discussed a lot on comp.programming.threads. I suppose you can assume they are there but that's assuming a lot.

    Also, doing condvars on windows isn't that easy as Douglas Schmidt writes up here [wustl.edu].

    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.

    • by xyote ( 598794 ) on Saturday September 04, 2004 @03:32PM (#10158560)
      For the atomic operations, the intel based code is ok since the lock prefix serializes memory. The powerpc load reserved / store conditional do not however and explicit memory barriers are required and they are not there. That's bad.

      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 [wustl.edu] 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.

      • You may want to consider filing a few bugs or something to bring these issues to their attention, if you've not done so.

        Dropping a link to Schmidt's work in there might not be a bad means of stealth education, either.
      • Please, if your comments are creative, and useful, forward them to the team who are doing it (give them plenty of easy links to the resources so they don't instantly dismiss you).

        I don't know enough in this field to help, but if somone sent me some details on any project I'm working on which allows me to improve it, I'd be greatful, though not likely to give you pizza tokens :)
      • For the atomic operations, the intel based code is ok since the lock prefix serializes memory.
        Well, yes, that is true, but only for uniprocessors or Pentiums. P5 is a strongly-ordered architecture. Unfortunately this is not the case for P6, which are weekly-ordered, and hence for multiprocessors require much more expensive synchronization - typically LOCKed CMPXCHG that is followed by CPUID.
  • by Anonymous Coward on Saturday September 04, 2004 @02:28PM (#10158320)
    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
    • by DarkMan ( 32280 ) on Saturday September 04, 2004 @09:54PM (#10160212) Journal
      Disclaimer: Your not paying for this; this is not legal advice. For that, contact a lawyer in your juristriction.

      By my reading of the liscence, it makes absolutly no distinction between static and dynamic linking. Therefore, the only way that it could cause a difference is within the definition of a 'derived work'. To quote the licence:

      "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.


      If you link, or bind by name, to the interfaces of the Work, then your code is not a derived work. Thus, the only applicable terms in the licence are those that govern use and distribution of the code. The licence grants you the right to distribute in source or object form the work.

      Accordingly, my reading is that this is semantically virtually equivlent to the BSD licence for case specified (and, in fact, the same as BSD for pretty much any case of use and distribution).

      Short answer: Stick a mention of it in the NOTICE text file, tell people what liscene the Work (in this case the APR) was under, and go ahead.

      Interestingly, this licence would, as I read it, allow you to make a derived work, and redistribute that in binary form only. It doesn't grant you the right to change liscence, or apply restrictions, so a Derived Work wouldn't work as a commerical product (as the first purachaser can redisribute it).

      But, as it specifically excludes linking to the interfeces specified, then for a Work which is a library [0], the only clause that imparts any restriction is 4(d) [1]

      In fact, I can see no part of the liscence that would prevent one from taking a program under this liscence, creating a Derived Work that is that program implemented as a library, with well defined interfaces, and then linking to said library from a commercial/closed program. There is no requirement to publish Derived Works [2]. The only mildly non-obvious outcome is that if the library was extracted from the final disribution, the licence allows for its free distribution and use, which is not a restriction.

      Of course, if this is for commerical software, you'll have the money to speak to a lawyer licence to practice in your juristriction first.

      [0] And where that library is used unmodified
      [1] And the expiration of patent licences in event of you issuing a patent suit.
      [2] Only that you make any changes clear if you do publish.
  • 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.
    • by Billly Gates ( 198444 ) on Saturday September 04, 2004 @05:18PM (#10158930) Journal
      Unfortunatly g++ is not a good c++ compiler so all the Unix nerds look at the size of the compiled program and time to execute and assume the problem is with C++ itself and then continue to work in C.

      There is alot of anti c++ sentiment in the unix community because of that.

    • by Anonymous Coward
      C++ suffers from all the memory bugs of C, because it allows all the same things.
      A good C++ programmer wont use those things, just like a good C programmer wont do stupid stuff in C.

      But C++ is not inherently safer than C, it's just as dangerous as C and has the added bonus of being complicated, unweildy and inconsistent.

    • 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

  • by TheInternet ( 35082 ) on Saturday September 04, 2004 @06:22PM (#10159206) Homepage Journal
    I looked through the API reference for about 15 minutes -- it reminds me of Apple's Core Foundation [apple.com]. Not that I think they copied Apple, but there are some interesting parallels.

    - Scott
  • And I won't be using APR because the Apache license suxors.

What is research but a blind date with knowledge? -- Will Harvey

Working...