Server Applications <ul>“Server Applications” =  programs with no GUI In GNUstep, server applications are based on  GNUste...
Objective-C <ul><li>it is a  programming language
it is a strict  superset of C </li><ul><ul><li>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 </li></ul></ul><li>it  adds Object-Oriented features to C </l...
Implementing methods
Instantiating classes and objects
Invoking class and object methods
Protocols, categories, selectors, forwarding </li></ul></ul></ul>
Why is Objective-C so special ? <ul><li>It is compatible with C libraries
Is is a simple extension of C
It is a  hybrid  between C and Smalltalk </li><ul><ul><li>It can be  as fast as raw C  if you avoid the object-oriented ex...
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 </li></ul></ul><li>It is  extrem...
Powerful “ Foundation ” class library </li></ul>
Why use Objective-C for Server Applications ? <ul><li>Very fast.   You can freely mix it with C and even assembler if you ...
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 fo...
OpenStep API - Foundation Kit (1994) <ul>Foundation Kit Non-graphical classes <ul><li>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... </li></ul></ul>Application Foundation Kit Application Kit Operating System OS Graphical System Objective-...
GNUstep-base Application GNUstep Base GNUstep GUI Operating System (Any!) Graphical System  (Any!) GNU Objective-C  Runtim...
Server Applications – what do you need ? <ul>gcc-objc <ul><ul><li>Objective-C compiler
Objective-C runtime </li></ul></ul>gnustep-make <ul><ul><li>Official GNUstep Building System
Makefile library that automatically takes care of configuring and building on different platforms </li></ul></ul>gnustep-b...
Upcoming SlideShare
Loading in...5
×

Building Server Applications Using ObjectiveC And GNUstep

8,937

Published on

By Nicholas Roard

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
8,937
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
100
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Building Server Applications Using ObjectiveC And GNUstep

  1. 2. Server Applications <ul>“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. <ul><ul><li>People often identify GNUstep only with the GUI framework/development environment. </li></ul></ul></ul>
  2. 3. Objective-C <ul><li>it is a programming language
  3. 4. it is a strict superset of C </li><ul><ul><li>it is C with some new additional constructs
  4. 5. C code compiles as Objective-C code
  5. 6. C libraries can be linked and used natively from Objective-C </li></ul></ul><li>it adds Object-Oriented features to C </li><ul><ul><li>Defining classes
  6. 7. Implementing methods
  7. 8. Instantiating classes and objects
  8. 9. Invoking class and object methods
  9. 10. Protocols, categories, selectors, forwarding </li></ul></ul></ul>
  10. 11. Why is Objective-C so special ? <ul><li>It is compatible with C libraries
  11. 12. Is is a simple extension of C
  12. 13. It is a hybrid between C and Smalltalk </li><ul><ul><li>It can be as fast as raw C if you avoid the object-oriented extensions
  13. 14. It can be as high-level and flexible as Smalltalk if you use the object-oriented extensions
  14. 15. It allows experienced programmers to mix different programming styles in the same program </li></ul></ul><li>It is extremely flexible
  15. 16. Powerful “ Foundation ” class library </li></ul>
  16. 17. Why use Objective-C for Server Applications ? <ul><li>Very fast. You can freely mix it with C and even assembler if you need.
  17. 18. High-level language. Organize your server code using high-level, object-orientated design patterns.
  18. 19. Powerful Foundation library (GNUstep-base). The API originates from OpenStep and the implementation has been polished for 13+ years. </li></ul>
  19. 20. OpenStep API - Foundation Kit (1994) <ul>Foundation Kit Non-graphical classes <ul><li>Root classes : NSObject, NSProxy
  20. 21. Basic data classes : NSString, NSNumber, NSData, NSNull
  21. 22. Collection classes : NSArray, NSDictionary, NSSet
  22. 23. Execution control classes : NSRunLoop, NSTimer, NSThread, NSLock
  23. 24. I/O classes : NSTask, NSFileHandle
  24. 25. Notification classes: NSNotification, NSDistributedNotification
  25. 26. Serialization classes: NSArchiver, NSCoder
  26. 27. Resource management classes: NSBundle, NSUserDefaults
  27. 28. Distributed Objects Classes: NSConnection, NSPort
  28. 29. And many more... </li></ul></ul>Application Foundation Kit Application Kit Operating System OS Graphical System Objective-C Runtime
  29. 30. GNUstep-base Application GNUstep Base GNUstep GUI Operating System (Any!) Graphical System (Any!) GNU Objective-C Runtime GNUstep Back
  30. 31. Server Applications – what do you need ? <ul>gcc-objc <ul><ul><li>Objective-C compiler
  31. 32. Objective-C runtime </li></ul></ul>gnustep-make <ul><ul><li>Official GNUstep Building System
  32. 33. Makefile library that automatically takes care of configuring and building on different platforms </li></ul></ul>gnustep-base <ul><ul><li>OpenStep Foundation Kit implementation
  33. 34. Provides “core” non-graphical Objective-C classes </li></ul></ul></ul>
  34. 35. Important dependencies <ul>libffi <ul><ul><li>Required by gnustep-base
  35. 36. You may need to download it and install it from www.gnustep.org </li></ul></ul>libxml <ul><ul><li>Required by gnustep-base
  36. 37. Install it from your GNU/Linux distribution </li></ul></ul>gnutls or openssl <ul><ul><li>Allow gnustep-base to support https://
  37. 38. Install it from your GNU/Linux distribution </li></ul></ul></ul>
  38. 39. Typical Quick Installation (Ubuntu) apt-get libgnustep-base-dev
  39. 40. 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'
  40. 41. “Hello World!” Program <ul>“Hello World” using Objective-C / GNUstep-base hello.m </ul>#import <Foundation/Foundation.h> int main (void) { NSLog (@“Hello world!”); return 0; }
  41. 42. “Hello World!” Program <ul>“Hello World” using Objective-C / GNUstep-base GNUmakefile </ul>include $(GNUSTEP_MAKEFILES)/common.make TOOL_NAME = hello hello_OBJC_FILES = hello.m include $(GNUSTEP_MAKEFILES)/tool.make
  42. 43. “Hello World!” Program <ul>“Hello World” using Objective-C / GNUstep-base Usual compilation commands </ul>make make clean make distclean make install make messages=yes make install messages=yes
  43. 44. “Hello World!” Program <ul>“Hello World” using Objective-C / GNUstep-base Compilation results are in ./obj Let's try it out: Tutorial Compilation Session </ul>
  44. 45. GNUstep-base coding: where to start <ul>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 </ul>
  45. 46. GNUstep-base coding: basic classes <ul>Class cluster Design <ul><ul><li>Transparent way of optimizing classes without changing the public API
  46. 47. When you create a NSString or NSArray you actually get an instance of a subclass optimized to perform best in your situation
  47. 48. Method dispatch is dynamic, so that works
  48. 49. You can implement your own subclasses for performance </li></ul></ul>Mutable and non-mutable Classes <ul><ul><li>NSString vs NSMutableString
  49. 50. NSString is for constant strings that never change
  50. 51. NSMutableString is for strings that might change
  51. 52. Allows a lot of optimizations inside the library </li></ul></ul></ul>
  52. 53. GNUstep-base coding: basic classes <ul>NSString, NSMutableString <ul><ul><li>String class
  53. 54. Full Unicode support
  54. 55. Class cluster implementation means ASCII strings are still extremely fast
  55. 56. Static strings </li></ul></ul></ul><ul><ul><li>NSString *string = @”This is a test string”; </li></ul></ul>
  56. 57. GNUstep-base coding: basic classes <ul><li>NSArray, NSMutableArray </li><ul><ul><li>Array class
  57. 58. NSMutableArray provides arrays that grow dynamically </li></ul></ul><li>NSDictionary, NSMutableDictionary </li><ul><ul><li>Hashtable/associative array class
  58. 59. NSMutableDictionary provides associative arrays that grow dynamically </li></ul></ul></ul><ul><ul><li>{ </li><ul><li>Name = “Gorm.app”;
  59. 60. Description = “GNUstep GUI Builder Application”;
  60. 61. } </li></ul></ul></ul><ul><ul><li>(“one”, “two”, “three”); </li></ul></ul>
  61. 62. GNUstep-base: Runloops and threads <ul>NSRunLoop <ul><li>NSRunLoop
  62. 63. Event-based model
  63. 64. NSFileHandle
  64. 65. NSTimer </li></ul>Threads <ul><li>NSThread
  65. 66. NSLock </li></ul></ul>
  66. 67. GNUstep-base: Notifications <ul><li>GNUstep-base supports notifications and observers </li><ul><ul><li>Flexible way to connect objects </li></ul></ul><li>NSNotificationCenter
  67. 68. Objects can “observe” a notification and specify which method
  68. 69. they want invoked when that notification is posted
  69. 70. Anything can “post” a notification
  70. 71. The notification is delivered to all “observer” </li><ul><li>See NSNotificationCenter documentation for more information </li></ul></ul>
  71. 72. GNUstep-base: Delegates <ul><li>Objective-C and GNUstep-base encourage using delegates
  72. 73. A delegate allows you to extend a class without subclassing it
  73. 74. Subclassing can be heavy, and not that flexible
  74. 75. Delegates are more flexible – you can delegate part of the code to
  75. 76. an object of any class
  76. 77. -setDelegate: (NSObject *)delegate;
  77. 78. -delegate; </li></ul>
  78. 79. GNUstep-base: Distributed Objects <ul><li>Remote method invocation
  79. 80. High-level
  80. 81. You can expose objects in one process to other processes
  81. 82. Other processes can then contact the object and invoke methods
  82. 83. of the objects, as if they were local objects
  83. 84. Very natural to use
  84. 85. Excellent for building networks of processes that work cooperatively
  85. 86. See http://www.gnustep.it/nicola/Tutorials/ for a tutorial on Distributed Objects. </li></ul>
  86. 87. A look at some useful libraries <ul><li>You can use any C library you want
  87. 88. Objective-C libraries provided by GNUstep </li><ul><ul><li>check the dev-libs module in subversion </li></ul></ul><li>Objective-C libraries provided by other parties </li><ul><ul><li>SOPE (opengroupware.org)
  88. 89. Apple Cocoa non-GUI frameworks can sometime be used </li></ul></ul></ul>
  89. 90. GNUstep Database Libraries <ul><li>You can use your own preferite C library
  90. 91. GNUstep Database Libraries </li><ul><ul><li>SQLClient
  91. 92. GDL2 </li></ul></ul><li>SOPE </li><ul><ul><li>The best choice if you use the SOPE application server
  92. 93. Not so interesting if you're not </li></ul></ul></ul>
  93. 94. GNUstep Database Libraries <ul>SQLClient <ul>SQL Layer (low-level) <ul><li>Standard SQL layer to execute SQL queries/commands
  94. 95. “Backend bundles” (plugins) for the different databases (standard bundles: PostgreSQL, MySQL, SQLite, Oracle) </li></ul>High-performance features <ul><li>Connection pooling
  95. 96. Advanced transaction support
  96. 97. Query caching
  97. 98. Update Batching </li></ul></ul></ul>
  98. 99. GNUstep Database Libraries <ul>GDL2 <ul><ul><li>(GNUstep Database Library v2) </li></ul><li>High-level features </li><ul><li>SQL layer with EOAdaptors (plugins) for different database (standard bundles: PostgreSQL, SQLite)
  99. 100. Object-to-relationship mapping
  100. 101. Extensive use of KVC
  101. 102. Supports and encourages MVC patterns </li></ul><li>Rapid development/integration support </li><ul><li>EOInterface
  102. 103. DBModeler (GUI program) </li></ul></ul></ul>
  103. 104. GNUstep Database Libraries <ul>SQLClient <ul><ul><li>SQL only
  104. 105. You have to write your SQL code
  105. 106. Performance-oriented
  106. 107. Excellent for very high-performance servers where you write and tune each and every single SQL command </li></ul></ul>GDL2 <ul><ul><li>High-level framework
  107. 108. You works with models and objects – you do not need to write SQL
  108. 109. Can be a bit hard to get into, but people love it once they get used to it
  109. 110. Excellent for large and properly structured OO projects
  110. 111. Performance is generally good </li></ul></ul></ul>
  111. 112. GNUstep WebServer Library <ul>WebServer Library <ul><ul><li>A library to implement quickly http/https server applications
  112. 113. Appropriate to develop efficient APIs for your system
  113. 114. Could be used for web pages but that is not the focus
  114. 115. Provides a full web server
  115. 116. Usually used with Apache in front as a reverse-proxy </li></ul></ul></ul>
  116. 117. Jigs: GNUstep Java Interface <ul><ul><li>What is it </li><ul><li>Allows you to use Objective-C libraries or objects from Java
  117. 118. And allows you to use Java libraries or objects from Objective-C
  118. 119. Objects and classes in Objective-C are mapped to objects and
  119. 120. classes in Java and vice versa </li></ul><li>Pros </li><ul><li>Is very cool </li></ul><li>Cons </li><ul><li>Can be slow, use it with moderation
  120. 121. Problems can be hard to debug
  121. 122. Limited support for cross-language subclassing
  122. 123. Not easy to port to other platforms </li></ul></ul></ul>
  123. 124. SOPE <ul><li>An extensive set of frameworks
  124. 125. A complete “Web application server” environment
  125. 126. Apple WebObjects compatible app server extended with Zope concepts
  126. 127. XML processing (SAX2, DOM, XML-RPC)
  127. 128. MIME/IMAP4 processing
  128. 129. LDAP connectivity
  129. 130. RDBMS connectivity
  130. 131. iCalendar parsing </li><ul><li>http://sope.opengroupware.org </li></ul></ul>
  131. 132. Questions ?
  132. 133. Thank you For more information <ul>www.gnustep.org </ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×