Cocoa for Scientists

2,827 views

Published on

Matias Piipari from the Sanger Institute gave a short tutorial, aimed at a scientific audience, on using Apple's Cocoa framework for developing applications.

Published in: Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,827
On SlideShare
0
From Embeds
0
Number of Embeds
376
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Cocoa for Scientists

  1. 1. Cocoa for Scientists Matias Piipari Wellcome Trust Sanger Institute Friday, 21 May 2010
  2. 2. iMotifs Friday, 21 May 2010
  3. 3. Friday, 21 May 2010
  4. 4. Biomartify Friday, 21 May 2010
  5. 5. Outline Friday, 21 May 2010
  6. 6. Outline 1. What is Cocoa? Friday, 21 May 2010
  7. 7. Outline 1. What is Cocoa? 2. What can I do with it? Friday, 21 May 2010
  8. 8. Outline 1. What is Cocoa? 2. What can I do with it? 3. How can I learn more about it? Friday, 21 May 2010
  9. 9. Outline 1. What is Cocoa? 2. What can I do with it? 3. How can I learn more about it? BONUS: A GUI design tutorial Friday, 21 May 2010
  10. 10. What is Cocoa? Friday, 21 May 2010
  11. 11. What is Cocoa? • High-level object oriented collection of APIs for Mac OS X Friday, 21 May 2010
  12. 12. What is Cocoa? • High-level object oriented collection of APIs for Mac OS X • It is much more than a GUI framework Friday, 21 May 2010
  13. 13. What is Cocoa? • High-level object oriented collection of APIs for Mac OS X • It is much more than a GUI framework • Interprocess communication: UNIX pipes, distributed notifications Friday, 21 May 2010
  14. 14. What is Cocoa? • High-level object oriented collection of APIs for Mac OS X • It is much more than a GUI framework • Interprocess communication: UNIX pipes, distributed notifications • Networking: sockets, HTTP, service auto discovery... Friday, 21 May 2010
  15. 15. What is Cocoa? • High-level object oriented collection of APIs for Mac OS X • It is much more than a GUI framework • Interprocess communication: UNIX pipes, distributed notifications • Networking: sockets, HTTP, service auto discovery... • Data modelling & persistence (Core Data) Friday, 21 May 2010
  16. 16. What is Cocoa? • High-level object oriented collection of APIs for Mac OS X • It is much more than a GUI framework • Interprocess communication: UNIX pipes, distributed notifications • Networking: sockets, HTTP, service auto discovery... • Data modelling & persistence (Core Data) • Using multicore CPUs: multithreading, Grand Central Dispatch Friday, 21 May 2010
  17. 17. What is Cocoa? • High-level object oriented collection of APIs for Mac OS X • It is much more than a GUI framework • Interprocess communication: UNIX pipes, distributed notifications • Networking: sockets, HTTP, service auto discovery... • Data modelling & persistence (Core Data) • Using multicore CPUs: multithreading, Grand Central Dispatch • 2D drawing (Quartz) Friday, 21 May 2010
  18. 18. What is Cocoa? • High-level object oriented collection of APIs for Mac OS X • It is much more than a GUI framework • Interprocess communication: UNIX pipes, distributed notifications • Networking: sockets, HTTP, service auto discovery... • Data modelling & persistence (Core Data) • Using multicore CPUs: multithreading, Grand Central Dispatch • 2D drawing (Quartz) • Image / video processing (Core Image, Core Video, Quartz Composer) Friday, 21 May 2010
  19. 19. What is Cocoa? • High-level object oriented collection of APIs for Mac OS X • It is much more than a GUI framework • Interprocess communication: UNIX pipes, distributed notifications • Networking: sockets, HTTP, service auto discovery... • Data modelling & persistence (Core Data) • Using multicore CPUs: multithreading, Grand Central Dispatch • 2D drawing (Quartz) • Image / video processing (Core Image, Core Video, Quartz Composer) • Scripting bridge: script your app in Python, Ruby, AppleScript Friday, 21 May 2010
  20. 20. 1985 Friday, 21 May 2010
  21. 21. NeXSTEP Friday, 21 May 2010
  22. 22. NeXSTEP Friday, 21 May 2010
  23. 23. NeXSTEP Friday, 21 May 2010
  24. 24. NeXSTEP Friday, 21 May 2010
  25. 25. NeXSTEP Friday, 21 May 2010
  26. 26. NeXSTEP Friday, 21 May 2010
  27. 27. NeXSTEP Friday, 21 May 2010
  28. 28. NeXSTEP Friday, 21 May 2010
  29. 29. NeXSTEP OPENSTEP Friday, 21 May 2010
  30. 30. NeXSTEP OPENSTEP Cocoa Friday, 21 May 2010
  31. 31. GNUStep NeXSTEP OPENSTEP Cocoa Friday, 21 May 2010
  32. 32. Cocoa Touch GNUStep (iPhone OS) NeXSTEP OPENSTEP Cocoa Friday, 21 May 2010
  33. 33. NeXTSTEP legacy is clear • AppKit (AppKit.h) • FoundationKit (Foundation.h) • “NS” prefix in the Cocoa foundation classes (NSObject, NSArray, ... ) • Bundles (.app, .pages, .keynote, etc) • Interface Builder Friday, 21 May 2010
  34. 34. The Objective-C language Friday, 21 May 2010
  35. 35. The Objective-C language • Object oriented language bolted onto ANSI C Friday, 21 May 2010
  36. 36. The Objective-C language • Object oriented language bolted onto ANSI C • Dynamic language Friday, 21 May 2010
  37. 37. The Objective-C language • Object oriented language bolted onto ANSI C • Dynamic language • Class definitions can change (even during runtime) Friday, 21 May 2010
  38. 38. The Objective-C language • Object oriented language bolted onto ANSI C • Dynamic language • Class definitions can change (even during runtime) • Late binding: methods looked up during runtime Friday, 21 May 2010
  39. 39. The Objective-C language • Object oriented language bolted onto ANSI C • Dynamic language • Class definitions can change (even during runtime) • Late binding: methods looked up during runtime • Add or swap (‘swizzle’) methods during runtime Friday, 21 May 2010
  40. 40. The Objective-C language • Object oriented language bolted onto ANSI C • Dynamic language • Class definitions can change (even during runtime) • Late binding: methods looked up during runtime • Add or swap (‘swizzle’) methods during runtime • You need to manage your memory (GC exists, but it’s crap) Friday, 21 May 2010
  41. 41. The Objective-C language • Object oriented language bolted onto ANSI C • Dynamic language • Class definitions can change (even during runtime) • Late binding: methods looked up during runtime • Add or swap (‘swizzle’) methods during runtime • You need to manage your memory (GC exists, but it’s crap) • A language with some strong conventions Friday, 21 May 2010
  42. 42. Cocoa design patterns • Model-View-Controller • Dependency Injection • Target-Action • Delegation • Responder chain • Facade • Decorator • Command Friday, 21 May 2010
  43. 43. The APIs Friday, 21 May 2010
  44. 44. Quartz: drawing (DEMO) Friday, 21 May 2010
  45. 45. Quartz: drawing API Friday, 21 May 2010
  46. 46. Quartz: drawing API • Identical API for drawing into... • a window • an off-screen bitmap buffer • A PDF Friday, 21 May 2010
  47. 47. Quartz: drawing API • Identical API for drawing into... • a window • an off-screen bitmap buffer • A PDF • API available for C and Objective-C (or supported scripting languages) Friday, 21 May 2010
  48. 48. Quartz: drawing API • Identical API for drawing into... • a window • an off-screen bitmap buffer • A PDF • API available for C and Objective-C (or supported scripting languages) • Toll free bridging between C structs / Objective-C objects Friday, 21 May 2010
  49. 49. Image / video processing with Quartz Composer Friday, 21 May 2010
  50. 50. Image / video processing with Quartz Composer • A visual programming language for image / video processing Friday, 21 May 2010
  51. 51. Image / video processing with Quartz Composer • A visual programming language for image / video processing • Embeddable into your own application Friday, 21 May 2010
  52. 52. Image / video processing with Quartz Composer • A visual programming language for image / video processing • Embeddable into your own application • New in Snow Leopard: OpenCL kernels Friday, 21 May 2010
  53. 53. Image / video processing with Quartz Composer • A visual programming language for image / video processing • Embeddable into your own application • New in Snow Leopard: OpenCL kernels • It is powerful but documentation isn’t great Friday, 21 May 2010
  54. 54. Image / video processing with Quartz Composer • A visual programming language for image / video processing • Embeddable into your own application • New in Snow Leopard: OpenCL kernels • It is powerful but documentation isn’t great • (DEMO) Friday, 21 May 2010
  55. 55. Child processes, UNIX pipes stdout GUI process motif inference process (native Mac app) (crossplatform Java app) Friday, 21 May 2010
  56. 56. Networking & web services Friday, 21 May 2010
  57. 57. Networking & web services • High-level API for streams & sockets Friday, 21 May 2010
  58. 58. Networking & web services • High-level API for streams & sockets • HTTP client with asynchronous I/O Friday, 21 May 2010
  59. 59. Networking & web services • High-level API for streams & sockets • HTTP client with asynchronous I/O • XML handling Friday, 21 May 2010
  60. 60. Networking & web services • High-level API for streams & sockets • HTTP client with asynchronous I/O • XML handling • Event based parsing Friday, 21 May 2010
  61. 61. Networking & web services • High-level API for streams & sockets • HTTP client with asynchronous I/O • XML handling • Event based parsing • DOM based parsing, XPath queries Friday, 21 May 2010
  62. 62. Networking & web services • High-level API for streams & sockets • HTTP client with asynchronous I/O • XML handling • Event based parsing • DOM based parsing, XPath queries • SOAP OK Friday, 21 May 2010
  63. 63. Networking & web services • High-level API for streams & sockets • HTTP client with asynchronous I/O • XML handling • Event based parsing • DOM based parsing, XPath queries • SOAP OK • JSON OK Friday, 21 May 2010
  64. 64. Networking & web services Friday, 21 May 2010
  65. 65. Core Data Friday, 21 May 2010
  66. 66. Core Data Friday, 21 May 2010
  67. 67. Core Data • Data modelling framework Friday, 21 May 2010
  68. 68. Core Data • Data modelling framework • Serialise / deserialise data Friday, 21 May 2010
  69. 69. Core Data • Data modelling framework • Serialise / deserialise data • SQLite Friday, 21 May 2010
  70. 70. Core Data • Data modelling framework • Serialise / deserialise data • SQLite • XML Friday, 21 May 2010
  71. 71. Core Data • Data modelling framework • Serialise / deserialise data • SQLite • XML • Auto-generate model classes Friday, 21 May 2010
  72. 72. Core Data • Data modelling framework • Serialise / deserialise data • SQLite • XML • Auto-generate model classes • Query data Friday, 21 May 2010
  73. 73. Core Data • Data modelling framework • Serialise / deserialise data • SQLite • XML • Auto-generate model classes • Query data • Automatic undo / redo support Friday, 21 May 2010
  74. 74. Multicore Friday, 21 May 2010
  75. 75. Multicore • NSOperation: high level multithreading API Friday, 21 May 2010
  76. 76. Multicore • NSOperation: high level multithreading API • Grand Central Dispatch (10.6 only) Friday, 21 May 2010
  77. 77. Multicore • NSOperation: high level multithreading API • Grand Central Dispatch (10.6 only) • Use closures to represent independent work units Friday, 21 May 2010
  78. 78. Multicore • NSOperation: high level multithreading API • Grand Central Dispatch (10.6 only) • Use closures to represent independent work units • Lighter memory footprint than threads Friday, 21 May 2010
  79. 79. Multicore • NSOperation: high level multithreading API • Grand Central Dispatch (10.6 only) • Use closures to represent independent work units • Lighter memory footprint than threads • Easy: worry less about resources, syncing, locking Friday, 21 May 2010
  80. 80. Multicore • NSOperation: high level multithreading API • Grand Central Dispatch (10.6 only) • Use closures to represent independent work units • Lighter memory footprint than threads • Easy: worry less about resources, syncing, locking • POSIX threads Friday, 21 May 2010
  81. 81. Multicore • NSOperation: high level multithreading API • Grand Central Dispatch (10.6 only) • Use closures to represent independent work units • Lighter memory footprint than threads • Easy: worry less about resources, syncing, locking • POSIX threads • OpenCL: an extension to C for data-parallel computing Friday, 21 May 2010
  82. 82. Scripting bridge Friday, 21 May 2010
  83. 83. Scripting bridge • Python - Objective-C bridge: PyObjC Friday, 21 May 2010
  84. 84. Scripting bridge • Python - Objective-C bridge: PyObjC • Ruby - Objective-C bridge: RubyCocoa Friday, 21 May 2010
  85. 85. Scripting bridge • Python - Objective-C bridge: PyObjC • Ruby - Objective-C bridge: RubyCocoa • MacRuby: a ‘native’ Cocoa Ruby interpreter Friday, 21 May 2010
  86. 86. Scripting bridge • Python - Objective-C bridge: PyObjC • Ruby - Objective-C bridge: RubyCocoa • MacRuby: a ‘native’ Cocoa Ruby interpreter • Ruby or Python can also be used as a replacement for AppleScript Friday, 21 May 2010
  87. 87. Scripting bridge • Python - Objective-C bridge: PyObjC • Ruby - Objective-C bridge: RubyCocoa • MacRuby: a ‘native’ Cocoa Ruby interpreter • Ruby or Python can also be used as a replacement for AppleScript • My advice: keep away until you’re comfortable with Cocoa. Friday, 21 May 2010
  88. 88. BioCocoa Friday, 21 May 2010
  89. 89. BioCocoa • Sequence I/O (DNA / RNA / protein) Friday, 21 May 2010
  90. 90. BioCocoa • Sequence I/O (DNA / RNA / protein) • Annotations Friday, 21 May 2010
  91. 91. BioCocoa • Sequence I/O (DNA / RNA / protein) • Annotations • Sequence alignments Friday, 21 May 2010
  92. 92. BioCocoa • Sequence I/O (DNA / RNA / protein) • Annotations • Sequence alignments • Nothing like Bioruby / Bioperl... Friday, 21 May 2010
  93. 93. BioCocoa • Sequence I/O (DNA / RNA / protein) • Annotations • Sequence alignments • Nothing like Bioruby / Bioperl... • Alternatives: Friday, 21 May 2010
  94. 94. BioCocoa • Sequence I/O (DNA / RNA / protein) • Annotations • Sequence alignments • Nothing like Bioruby / Bioperl... • Alternatives: • scripting bridge + Bioruby / Biopython Friday, 21 May 2010
  95. 95. BioCocoa • Sequence I/O (DNA / RNA / protein) • Annotations • Sequence alignments • Nothing like Bioruby / Bioperl... • Alternatives: • scripting bridge + Bioruby / Biopython • pipe to a child process which does more complex manipulations with biol data Friday, 21 May 2010
  96. 96. Fine... but it’s Mac only Friday, 21 May 2010
  97. 97. ... or is it? Friday, 21 May 2010
  98. 98. Cocotron Friday, 21 May 2010
  99. 99. GNUStep Friday, 21 May 2010
  100. 100. Learning resources Aaron Hillegass: Stephen G. Kochan: Cocoa Programming Programming in for Mac OS X Objective-C 2.0 http://itunes.stanford.edu/ Stanford University iPhone SDK course Friday, 21 May 2010
  101. 101. Learning resources • http://mattgemmell.com/ • http://cocoawithlove.com/ • http://www.cocotron.org/blog/ • http://www.boyfarrell.com/tutorials/ • http://weblog.bignerdranch.com/ • http://abizern.org/ • http://cocoadev.com/ Friday, 21 May 2010
  102. 102. My experiences Friday, 21 May 2010
  103. 103. My experiences • It’s a lot of fun! Friday, 21 May 2010
  104. 104. My experiences • It’s a lot of fun! • It is just C with added decoration Friday, 21 May 2010
  105. 105. My experiences • It’s a lot of fun! • It is just C with added decoration • Documentation is not always great Friday, 21 May 2010
  106. 106. My experiences • It’s a lot of fun! • It is just C with added decoration • Documentation is not always great • ... but the community is: Friday, 21 May 2010
  107. 107. My experiences • It’s a lot of fun! • It is just C with added decoration • Documentation is not always great • ... but the community is: • blogs, forums Friday, 21 May 2010
  108. 108. My experiences • It’s a lot of fun! • It is just C with added decoration • Documentation is not always great • ... but the community is: • blogs, forums • plenty of open source code Friday, 21 May 2010
  109. 109. My experiences • It’s a lot of fun! • It is just C with added decoration • Documentation is not always great • ... but the community is: • blogs, forums • plenty of open source code • #macdev,#iphonedev on IRC (freenode) Friday, 21 May 2010
  110. 110. Interface Builder Tutorial Friday, 21 May 2010
  111. 111. Target - Action Friday, 21 May 2010
  112. 112. Bindings key-value observing Friday, 21 May 2010
  113. 113. Controllers Friday, 21 May 2010
  114. 114. Biomartify Friday, 21 May 2010
  115. 115. Biomartify • Goals Friday, 21 May 2010
  116. 116. Biomartify • Goals • Browse the Biomart registry: marts, their datasets Friday, 21 May 2010
  117. 117. Biomartify • Goals • Browse the Biomart registry: marts, their datasets • Build a Biomart query: filters & attributes Friday, 21 May 2010
  118. 118. Biomartify • Goals • Browse the Biomart registry: marts, their datasets • Build a Biomart query: filters & attributes • Save the query on disk, edit it later Friday, 21 May 2010
  119. 119. Biomartify • Goals • Browse the Biomart registry: marts, their datasets • Build a Biomart query: filters & attributes • Save the query on disk, edit it later • Submit the query Friday, 21 May 2010
  120. 120. Biomartify • Goals • Browse the Biomart registry: marts, their datasets • Build a Biomart query: filters & attributes • Save the query on disk, edit it later • Submit the query • ‘Migrate’ a query to a dataset Friday, 21 May 2010

×