Building Server Applications Using ObjectiveC And GNUstep
Upcoming SlideShare
Loading in...5
×
 

Building Server Applications Using ObjectiveC And GNUstep

on

  • 10,164 views

By Nicholas Roard

By Nicholas Roard

Statistics

Views

Total Views
10,164
Views on SlideShare
10,118
Embed Views
46

Actions

Likes
1
Downloads
93
Comments
0

4 Embeds 46

http://www.slideshare.net 39
https://twitter.com 4
https://si0.twimg.com 2
https://twimg0-a.akamaihd.net 1

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Building Server Applications Using ObjectiveC And GNUstep Building Server Applications Using ObjectiveC And GNUstep Presentation Transcript

  •  
  • Server Applications
      “Server Applications” = programs with no GUI In GNUstep, server applications are based on GNUstep-base. GNUstep-base is the most complete and extensively polished and tested part of GNUstep ... … but is little known to the public.
        • People often identify GNUstep only with the GUI framework/development environment.
  • Objective-C
    • it is a programming language
    • it is a strict superset of C
        • it is C with some new additional constructs
        • C code compiles as Objective-C code
        • C libraries can be linked and used natively from Objective-C
    • it adds Object-Oriented features to C
        • Defining classes
        • Implementing methods
        • Instantiating classes and objects
        • Invoking class and object methods
        • Protocols, categories, selectors, forwarding
  • Why is Objective-C so special ?
    • It is compatible with C libraries
    • Is is a simple extension of C
    • It is a hybrid between C and Smalltalk
        • It can be as fast as raw C if you avoid the object-oriented extensions
        • It can be as high-level and flexible as Smalltalk if you use the object-oriented extensions
        • It allows experienced programmers to mix different programming styles in the same program
    • It is extremely flexible
    • Powerful “ Foundation ” class library
  • Why use Objective-C for Server Applications ?
    • Very fast. You can freely mix it with C and even assembler if you need.
    • High-level language. Organize your server code using high-level, object-orientated design patterns.
    • Powerful Foundation library (GNUstep-base). The API originates from OpenStep and the implementation has been polished for 13+ years.
  • OpenStep API - Foundation Kit (1994)
      Foundation Kit Non-graphical classes
      • Root classes : NSObject, NSProxy
      • Basic data classes : NSString, NSNumber, NSData, NSNull
      • Collection classes : NSArray, NSDictionary, NSSet
      • Execution control classes : NSRunLoop, NSTimer, NSThread, NSLock
      • I/O classes : NSTask, NSFileHandle
      • Notification classes: NSNotification, NSDistributedNotification
      • Serialization classes: NSArchiver, NSCoder
      • Resource management classes: NSBundle, NSUserDefaults
      • Distributed Objects Classes: NSConnection, NSPort
      • And many more...
    Application Foundation Kit Application Kit Operating System OS Graphical System Objective-C Runtime
  • GNUstep-base Application GNUstep Base GNUstep GUI Operating System (Any!) Graphical System (Any!) GNU Objective-C Runtime GNUstep Back
  • Server Applications – what do you need ?
      gcc-objc
        • Objective-C compiler
        • Objective-C runtime
      gnustep-make
        • Official GNUstep Building System
        • Makefile library that automatically takes care of configuring and building on different platforms
      gnustep-base
        • OpenStep Foundation Kit implementation
        • Provides “core” non-graphical Objective-C classes
  • Important dependencies
      libffi
        • Required by gnustep-base
        • You may need to download it and install it from www.gnustep.org
      libxml
        • Required by gnustep-base
        • Install it from your GNU/Linux distribution
      gnutls or openssl
        • Allow gnustep-base to support https://
        • Install it from your GNU/Linux distribution
  • Typical Quick Installation (Ubuntu) apt-get libgnustep-base-dev
  • Typical Manual Installation (RedHat) yum install gcc-objc libxml-devel openssl-devel wget ftp://sourceware.org/pub/libffi/libffi-3.0.1.tar.gz tar xfvz libffi-3.0.1.tar.gz cd libffi-3.0.1 ./configure make su -c 'make install' <edit /etc/ld.so.conf adding /usr/local/lib, then run ldconfig as root> wget ftp://ftp.gnustep.org/pub/gnustep/core/gnustep-make-2.0.8.tar.gz tar xfvz gnustep-make-2.0.8.tar.gz cd gnustep-make-2.0.8.tar.gz ./configure make su -c 'make install' . /usr/GNUstep/System/Library/Makefiles/GNUstep.sh wget ftp://ftp.gnustep.org/pub/gnustep/core/gnustep-base-1.18.0.tar.gz tar xfvz gnustep-base-1.18.0.tar.gz cd gnustep-base-1.18.0 ./configure –enable-openssl make su -c 'make install'
  • “Hello World!” Program
      “Hello World” using Objective-C / GNUstep-base hello.m
    #import <Foundation/Foundation.h> int main (void) { NSLog (@“Hello world!”); return 0; }
  • “Hello World!” Program
      “Hello World” using Objective-C / GNUstep-base GNUmakefile
    include $(GNUSTEP_MAKEFILES)/common.make TOOL_NAME = hello hello_OBJC_FILES = hello.m include $(GNUSTEP_MAKEFILES)/tool.make
  • “Hello World!” Program
      “Hello World” using Objective-C / GNUstep-base Usual compilation commands
    make make clean make distclean make install make messages=yes make install messages=yes
  • “Hello World!” Program
      “Hello World” using Objective-C / GNUstep-base Compilation results are in ./obj Let's try it out: Tutorial Compilation Session
  • GNUstep-base coding: where to start
      GNUstep Mini Tutorials (Introduction): http://www.gnustep.it/nicola/Tutorials/index.html GNUstep Base Documentation (API Reference): http://www.gnustep.org/resources/documentation/Developer/Base/Reference/index.html
  • GNUstep-base coding: basic classes
      Class cluster Design
        • Transparent way of optimizing classes without changing the public API
        • When you create a NSString or NSArray you actually get an instance of a subclass optimized to perform best in your situation
        • Method dispatch is dynamic, so that works
        • You can implement your own subclasses for performance
      Mutable and non-mutable Classes
        • NSString vs NSMutableString
        • NSString is for constant strings that never change
        • NSMutableString is for strings that might change
        • Allows a lot of optimizations inside the library
  • GNUstep-base coding: basic classes
      NSString, NSMutableString
        • String class
        • Full Unicode support
        • Class cluster implementation means ASCII strings are still extremely fast
        • Static strings
      • NSString *string = @”This is a test string”;
  • GNUstep-base coding: basic classes
    • NSArray, NSMutableArray
        • Array class
        • NSMutableArray provides arrays that grow dynamically
    • NSDictionary, NSMutableDictionary
        • Hashtable/associative array class
        • NSMutableDictionary provides associative arrays that grow dynamically
      • {
        • Name = “Gorm.app”;
        • Description = “GNUstep GUI Builder Application”;
        • }
      • (“one”, “two”, “three”);
  • GNUstep-base: Runloops and threads
      NSRunLoop
      • NSRunLoop
      • Event-based model
      • NSFileHandle
      • NSTimer
      Threads
      • NSThread
      • NSLock
  • GNUstep-base: Notifications
    • GNUstep-base supports notifications and observers
        • Flexible way to connect objects
    • NSNotificationCenter
    • Objects can “observe” a notification and specify which method
    • they want invoked when that notification is posted
    • Anything can “post” a notification
    • The notification is delivered to all “observer”
      • See NSNotificationCenter documentation for more information
  • GNUstep-base: Delegates
    • Objective-C and GNUstep-base encourage using delegates
    • A delegate allows you to extend a class without subclassing it
    • Subclassing can be heavy, and not that flexible
    • Delegates are more flexible – you can delegate part of the code to
    • an object of any class
    • -setDelegate: (NSObject *)delegate;
    • -delegate;
  • GNUstep-base: Distributed Objects
    • Remote method invocation
    • High-level
    • You can expose objects in one process to other processes
    • Other processes can then contact the object and invoke methods
    • of the objects, as if they were local objects
    • Very natural to use
    • Excellent for building networks of processes that work cooperatively
    • See http://www.gnustep.it/nicola/Tutorials/ for a tutorial on Distributed Objects.
  • A look at some useful libraries
    • You can use any C library you want
    • Objective-C libraries provided by GNUstep
        • check the dev-libs module in subversion
    • Objective-C libraries provided by other parties
        • SOPE (opengroupware.org)
        • Apple Cocoa non-GUI frameworks can sometime be used
  • GNUstep Database Libraries
    • You can use your own preferite C library
    • GNUstep Database Libraries
        • SQLClient
        • GDL2
    • SOPE
        • The best choice if you use the SOPE application server
        • Not so interesting if you're not
  • GNUstep Database Libraries
      SQLClient
        SQL Layer (low-level)
        • Standard SQL layer to execute SQL queries/commands
        • “Backend bundles” (plugins) for the different databases (standard bundles: PostgreSQL, MySQL, SQLite, Oracle)
        High-performance features
        • Connection pooling
        • Advanced transaction support
        • Query caching
        • Update Batching
  • GNUstep Database Libraries
      GDL2
        • (GNUstep Database Library v2)
      • High-level features
        • SQL layer with EOAdaptors (plugins) for different database (standard bundles: PostgreSQL, SQLite)
        • Object-to-relationship mapping
        • Extensive use of KVC
        • Supports and encourages MVC patterns
      • Rapid development/integration support
        • EOInterface
        • DBModeler (GUI program)
  • GNUstep Database Libraries
      SQLClient
        • SQL only
        • You have to write your SQL code
        • Performance-oriented
        • Excellent for very high-performance servers where you write and tune each and every single SQL command
      GDL2
        • High-level framework
        • You works with models and objects – you do not need to write SQL
        • Can be a bit hard to get into, but people love it once they get used to it
        • Excellent for large and properly structured OO projects
        • Performance is generally good
  • GNUstep WebServer Library
      WebServer Library
        • A library to implement quickly http/https server applications
        • Appropriate to develop efficient APIs for your system
        • Could be used for web pages but that is not the focus
        • Provides a full web server
        • Usually used with Apache in front as a reverse-proxy
  • Jigs: GNUstep Java Interface
      • What is it
        • Allows you to use Objective-C libraries or objects from Java
        • And allows you to use Java libraries or objects from Objective-C
        • Objects and classes in Objective-C are mapped to objects and
        • classes in Java and vice versa
      • Pros
        • Is very cool
      • Cons
        • Can be slow, use it with moderation
        • Problems can be hard to debug
        • Limited support for cross-language subclassing
        • Not easy to port to other platforms
  • SOPE
    • An extensive set of frameworks
    • A complete “Web application server” environment
    • Apple WebObjects compatible app server extended with Zope concepts
    • XML processing (SAX2, DOM, XML-RPC)
    • MIME/IMAP4 processing
    • LDAP connectivity
    • RDBMS connectivity
    • iCalendar parsing
      • http://sope.opengroupware.org
  • Questions ?
  • Thank you For more information
      www.gnustep.org