SlideShare a Scribd company logo
1 of 39
Download to read offline
Interpreting Objective-C
@timburks
ν
“What’s new (nu)?”

Interpreting Objective-C. © Tim Burks. March 4, 2014
c/λ
“C over lambda.”

Interpreting Objective-C. © Tim Burks. March 4, 2014
Usage

Desire

Craft

Insight

Interpreting Objective-C. © Tim Burks. March 4, 2014
Desire

Interpreting Objective-C. © Tim Burks. March 4, 2014
Beliefs about Better

Interpreting Objective-C. © Tim Burks. March 4, 2014
1
In any resource-constrained
environment,
performance is everything.

Interpreting Objective-C. © Tim Burks. March 4, 2014
2
All environments of value
are resource-constrained.

Interpreting Objective-C. © Tim Burks. March 4, 2014
3
Performance is
device performance and
developer performance.

Interpreting Objective-C. © Tim Burks. March 4, 2014
4
The number of developers
required to create a system
is its biggest weakness.

Interpreting Objective-C. © Tim Burks. March 4, 2014
5
Stability and productivity are a
developer's top two priorities,
in that order.

Interpreting Objective-C. © Tim Burks. March 4, 2014
6
•

Simplicity allows speed.
Speed increases opportunity.

•

Simplicity allows control.
Control reduces risk.

Interpreting Objective-C. © Tim Burks. March 4, 2014
7
•

The C platform has consistently offered
the best run time/power/capability
performance for developers.

•

Lisp-style languages have offered the
greatest capabilities of abstraction.

Interpreting Objective-C. © Tim Burks. March 4, 2014
Insight

Interpreting Objective-C. © Tim Burks. March 4, 2014
Observation
Objective-C solves many problems in bridging C with
high level languages.
•

Introspectable: no glue code is needed to bind to
compiled objects.

•

Dynamic: we can add to the Objective-C runtime
at run time.

Interpreting Objective-C. © Tim Burks. March 4, 2014
So What’s Nu?

•

Nu is an interpreted dialect of Lisp that parses into
Objective C objects that can be evaluated to
perform computations.

•

Nu interacts directly with the Objective-C runtime to
create and use classes, methods, and objects.
Interpreting Objective-C. © Tim Burks. March 4, 2014
Craft

Interpreting Objective-C. © Tim Burks. March 4, 2014
Parsing Nu
(puts (+ 2 2))!
NuCell

NuCell

puts
Nu_puts_operator
NuCell

NuCell

NuCell

+

2

2

Nu_add_operator

NSNumber

NSNumber

Interpreting Objective-C. © Tim Burks. March 4, 2014
Evaluating Nu
- (id) evaluateWithContext:(NSMutableDictionary *) context
NuCell

NuCell

puts
Nu_puts_operator
NuCell

NuCell

NuCell

+

2

2

Nu_add_operator

NSNumber

NSNumber

Interpreting Objective-C. © Tim Burks. March 4, 2014
Operators
(+ 2 (/ 14 7)) !
!

Objects
(UIStoryboard storyboardWithName:name bundle:nil) !
!

Interpreting Objective-C. © Tim Burks. March 4, 2014
Interacting with the Runtime
((UIView alloc) initWithFrame:’(0 0 100 100))!
!

Nu evaluation can resolve symbols by looking up classes and
methods in the Objective-C runtime.
Nu evaluation uses Objective-C method signatures to make
method calls with appropriately-typed arguments.

Interpreting Objective-C. © Tim Burks. March 4, 2014
Interacting with the Runtime
(class MyClass is NSObject !
(- hello is !
(puts “hello")))

The Nu class operator can be used to define new classes
and to add methods to existing ones.

Interpreting Objective-C. © Tim Burks. March 4, 2014
The Nu Shell
% nush!
Nu Shell.!
% (class MyClass is NSObject !
(- hello is (puts "hello")))!
()!
% (set myobject (MyClass new))!
<MyClass:7fdb6863dd10>!
% (myobject hello)!
hello!
()!

Interpreting Objective-C. © Tim Burks. March 4, 2014
Usage

Interpreting Objective-C. © Tim Burks. March 4, 2014
Generate a plist
!
(set me (dict name:"Tim Burks"!
company:"Radtastical Inc."!
address:(dict street:"220 South California Avenue, Suite 250"!
city:"Palo Alto"!
state:"CA"!
zip:"94306")!
projects:(array (dict name:"Silicon Valley iOS Developers' Meetup"!
url:"http://meetup.com/sviphone")!
(dict name:"Renaissance"!
url:"http://renaissance.io")!
(dict name:"Open Radar"!
url:"http://openradar.io")!
(dict name:"Nu"!
url:"http://programming.nu"))))!

!

((me XMLPropertyListRepresentation) writeToFile:"tim.plist" atomically:NO)!

Interpreting Objective-C. © Tim Burks. March 4, 2014
<?xml version="1.0" encoding="UTF-8"?>!
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">!
<plist version="1.0">!
<dict>!
!
<key>address</key>!
!
<dict>!
!
!
<key>city</key>!
!
!
<string>Palo Alto</string>!
!
!
<key>state</key>!
!
!
<string>CA</string>!
!
!
<key>street</key>!
!
!
<string>220 South California Avenue, Suite 250</string>!
!
!
<key>zip</key>!
!
!
<string>94306</string>!
!
</dict>!
!
<key>company</key>!
!
<string>Radtastical Inc.</string>!
!
<key>name</key>!
!
<string>Tim Burks</string>!
!
<key>projects</key>!
!
<array>!
!
!
<dict>!
!
!
!
<key>name</key>!
!
!
!
<string>Silicon Valley iOS Developers' Meetup</string>!
!
!
!
<key>url</key>!
!
!
!
<string>http://meetup.com/sviphone</string>!
!
!
</dict>!
!
!
<dict>!
!
!
!
<key>name</key>!
!
!
!
<string>Renaissance</string>!
!
!
!
<key>url</key>!
!
!
!
<string>http://renaissance.io</string>!
!
!
</dict>!
!
!
<dict>!
!
!
!
<key>name</key>!
!
!
!
<string>Open Radar</string>!
!
!
!
<key>url</key>!
!
!
!
<string>http://openradar.io</string>!
!
!
</dict>!
!
!
<dict>!
!
!
!
<key>name</key>!
!
!
!
<string>Nu</string>!
!
!
!
<key>url</key>!
!
!
!
<string>http://programming.nu</string>!
!
!
</dict>!
!
</array>!
</dict>!
</plist>!

Interpreting Objective-C. © Tim Burks. March 4, 2014
Call a Remote API
;;!
;; test google geocoding API !
;; API is limited to 2500 requests/(ip-address*day)!
;;!

!

(load "RadHTTP")!
(load "RadJSON")!

!

(set street "1675 Owens Street")!
(set city "San Francisco")!
(set state "CA")!

!

(set parameters (dict sensor:"false"!
address:(+ street " "!
city ", "!
state " "!
)))!
(set query (parameters urlQueryString))!
(set path (+ "http://maps.googleapis.com/maps/api/geocode/json?" query))!
(set string (NSString stringWithContentsOfURL:(NSURL URLWithString:path)))!
(set geocoding (string JSONValue))!

!

(puts (geocoding description))
Interpreting Objective-C. © Tim Burks. March 4, 2014
{!
results =

!

(!

…!
!
geometry =
{!
location =
{!
lat = "37.76800009999999";!
lng = "-122.3934754";!
};!
"location_type" = ROOFTOP;!
viewport =
{!
northeast =
{!
lat = "37.76934908029149";!
lng = "-122.3921264197085";!
};!
southwest =
{!
lat = "37.7666511197085";!
lng = "-122.3948243802915";!
};!
};!
};!
types =
(!
"street_address"!
);!
}!
);!
status = OK;!
}!
Interpreting Objective-C. © Tim Burks. March 4, 2014
Write Unit Tests
;; test_array.nu!
;; tests for Nu array extensions.!
;;!
;; Copyright (c) 2007 Tim Burks, Radtastical Inc.!

!

(class TestArray is NuTestCase!
!
(- testCreate is!
(set a (NSMutableArray arrayWithList:'(1 2)))!
(a << "three")!
(assert_equal 3 (a count))!
(assert_equal 2 (a 1))!
(assert_equal "three" (a 2)))!

!

(- testEach is!
(set i 0)!
(set a (array 0 1 2))!
(a each:!
(do (x)!
(assert_equal i x)!
(set i (+ i 1))))!
;; iteration with break!
(set a (array 0 1 2 3 4 5 6))!
(set sum 0)!
(a each:!
(do (x)!

Interpreting Objective-C. © Tim Burks. March 4, 2014
[hebephrenia:~/nu] tim% nutest test/test_array.nu!

!
TestArray: running!
--- testCreate!
--- testEach!
--- testEachInReverse!
--- testEachWithIndex!
--- testIndexing!
--- testSortUsingBlock!
--- testSortedArrayUsingBlock!
--- testSortedArrayUsingSelector!
TestArray: completed 8 tests/32 assertions/0 failures/0 errors!

!
2014-03-03 19:52:41.147 nush[10592:d07] All: completed 8 tests/32
assertions/0 failures/0 errors!

!
2014-03-03 19:52:41.148 nush[10592:d07] SUCCESS (0 failures, 0 errors)

Interpreting Objective-C. © Tim Burks. March 4, 2014
Build iOS apps
<dict>
<key>action</key>
<string>push sessions/2014/day/1</string>
<key>image</key>
<dict>
<key>filename</key>
<string>2014_bill_budge.jpg</string>
<key>mask</key>
<string>circle</string>
<key>position</key>
<string>left</string>
</dict>
<key>markdown</key>
<string>Wednesday, January 29, 2014n# Inspiration</string>
</dict>
Interpreting Objective-C. © Tim Burks. March 4, 2014
Interpreting Objective-C. © Tim Burks. March 4, 2014
Create Web Sites

Interpreting Objective-C. © Tim Burks. March 4, 2014
(get "/radarid:"!
(set radarnumber (radarid longLongValue))!
(authenticate)!
(set mongo (RadMongoDB new))!
(mongo connect)!
(set radar (mongo findOne:(dict number:radarnumber) inCollection:"openradar.radars"))!
(if (and (radarid longLongValue) radar)!
(then (set comments (mongo findArray:(dict $query:(dict radar_id:(radar _id:))!
$orderby:(dict created:1))!
inCollection:"openradar.comments"))!
(htmlpage (+ "Radar " (radar number:))!
(topbar)!
(&div class:"row"!
(&div class:"large-12 small-12 columns"!
(panel-for-radar radar)))!
(&div class:"row"!
(&div class:"large-12 small-12 columns"!
(&div class:"row"!
(&div class:"large-2 medium-2 small-12 large-push-10 medium-push-10 columns" style:"text-align:right"!
(if (eq (radar user:) screen_name)!
(then (&a class:"button" href:(+ "/radars/edit/" (radar _id:)) "Edit"))!
(else nil))!
(field "Number" (radar number:))!
(field "Originator" (mask-username (radar user:)))!
(field "Date Originated" (radar originated:))!
(field "Status" (radar status:))!
(field "Resolved" (radar resolved:))!
(field "Product" (radar product:))!
(field "Product Version" (radar product_version:))!
(field "Classification" (radar classification:))!
(field "Reproducible" (radar reproducible:)))!
(&div class:"large-10 large-pull-2 medium-10 medium-pull-2 small-12 columns" style:"padding:0 30px;"!
(&p style:"white-space: pre-wrap; word-wrap: break-word; font-family:Courier, monospace; font-size:80%"!
(if ((set description (radar description:)) length)!
(then (escape (radar description:)))!
(else (&em "No description provided."))))))!
(&div class:"row"!
(&div class:"large-10 medium-10 small-12 columns"!
(&div class:"comments"!
(comments map:!
(do (comment)!
(if (comment parent_id:)!
(then "") ;; skip replies!
(else (box-for-comment comment YES screen_name))))))))!
(if screen_name!
(then (&input id:"newcomment" type:"button" class:"button tiny" value:"Post a comment"))!
(else (&p (&a href:"/signin" "Sign in") " to post comments and radars.")))!
(&div style:"display:none;" id:"radar" (radar _id:))!
(&br)!
(&script type:"text/javascript" charset:"utf-8"!
"if(jQuery("#error").text() == "") jQuery("#error").hide();")))))!
(else nil)))!

Interpreting Objective-C. © Tim Burks. March 4, 2014
http://programming.nu/posts/2013/04/14/Nu-2.1.0
Interpreting Objective-C. © Tim Burks. March 4, 2014
Interpreting Objective-C. © Tim Burks. March 4, 2014
Anywhere Objective-C is run

Interpreting Objective-C. © Tim Burks. March 4, 2014
Usage

Desire

Craft

Insight

Interpreting Objective-C. © Tim Burks. March 4, 2014
MYNetwork
objective-git
UIKit
Pantomime CocoaYAML
NSURLRequest
OTRKit
MailCore
SpriteKit
SocketRocket
NSKeyedArchiver
google-api-objectivec-client
PDFKit SSKeychain FMDB
NSJSONSerialization
CorePlot
SSZipArchive PostgreSQL
NSXPCConnection
NSPropertyListSerialization
PocketSVG AFNetworking
MongoDB
NSRegularExpression NSXMLDocument
RestKit Xapian
NSFileHandle
MySQL
NSSet
PorterStemmer
NSValue
levelDB
NSProcessInfo
Simple-KML
redis
NSNumber
SQLite
NSDictionary
libevent
NSArray
OpenGL
libxml2
NSString
NSURLSession

AppKit

Usage

Desire

Batteries Nuclear Power Included
Craft

http://programming.nu

Insight

Interpreting Objective-C. © Tim Burks. March 4, 2014

More Related Content

Similar to Interpreting Objective C

WilliamBosch_2016Resume
WilliamBosch_2016ResumeWilliamBosch_2016Resume
WilliamBosch_2016Resume
William Bosch
 

Similar to Interpreting Objective C (20)

TDD Painkillers
TDD PainkillersTDD Painkillers
TDD Painkillers
 
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
 
20160913 cookpad ios_en
20160913 cookpad ios_en20160913 cookpad ios_en
20160913 cookpad ios_en
 
Driving development in PHP
Driving development in PHPDriving development in PHP
Driving development in PHP
 
ShwetaKBijay-resume
ShwetaKBijay-resumeShwetaKBijay-resume
ShwetaKBijay-resume
 
TDD and Getting Paid
TDD and Getting PaidTDD and Getting Paid
TDD and Getting Paid
 
Turbocharge your automated tests with ci
Turbocharge your automated tests with ciTurbocharge your automated tests with ci
Turbocharge your automated tests with ci
 
Tdd is not about testing
Tdd is not about testingTdd is not about testing
Tdd is not about testing
 
Testing with Docker
Testing with DockerTesting with Docker
Testing with Docker
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In Action
 
Techorama 2017 - Testing the unit, and beyond.
Techorama 2017 - Testing the unit, and beyond.Techorama 2017 - Testing the unit, and beyond.
Techorama 2017 - Testing the unit, and beyond.
 
Top Practices for Successful Mobile Test Automation
Top Practices for Successful Mobile Test AutomationTop Practices for Successful Mobile Test Automation
Top Practices for Successful Mobile Test Automation
 
End to End immutable infrastructure testing
End to End immutable infrastructure testingEnd to End immutable infrastructure testing
End to End immutable infrastructure testing
 
From Paper to Power using Azure Form Recognizer (Azure Sydney UG 2020)
From Paper to Power using Azure Form Recognizer (Azure Sydney UG 2020)From Paper to Power using Azure Form Recognizer (Azure Sydney UG 2020)
From Paper to Power using Azure Form Recognizer (Azure Sydney UG 2020)
 
FluentMigrator - Dayton .NET - July 2023
FluentMigrator - Dayton .NET - July 2023FluentMigrator - Dayton .NET - July 2023
FluentMigrator - Dayton .NET - July 2023
 
WilliamBosch_2016Resume
WilliamBosch_2016ResumeWilliamBosch_2016Resume
WilliamBosch_2016Resume
 
iOS Test-Driven Development
iOS Test-Driven DevelopmentiOS Test-Driven Development
iOS Test-Driven Development
 
Automated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and ChallengesAutomated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and Challenges
 
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted NewardArchitecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
 
Telephone directory in c
Telephone directory in cTelephone directory in c
Telephone directory in c
 

More from Tim Burks

Enforcing API Design Rules for High Quality Code Generation
Enforcing API Design Rules for High Quality Code GenerationEnforcing API Design Rules for High Quality Code Generation
Enforcing API Design Rules for High Quality Code Generation
Tim Burks
 

More from Tim Burks (15)

Governing APIs at Scale
Governing APIs at ScaleGoverning APIs at Scale
Governing APIs at Scale
 
Usable APIs at Scale
Usable APIs at ScaleUsable APIs at Scale
Usable APIs at Scale
 
Build your next REST API with gRPC
Build your next REST API with gRPCBuild your next REST API with gRPC
Build your next REST API with gRPC
 
Implementing OpenAPI and GraphQL services with gRPC
Implementing OpenAPI and GraphQL services with gRPCImplementing OpenAPI and GraphQL services with gRPC
Implementing OpenAPI and GraphQL services with gRPC
 
Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)
 
Networked APIs with swift
Networked APIs with swiftNetworked APIs with swift
Networked APIs with swift
 
Enforcing API Design Rules for High Quality Code Generation
Enforcing API Design Rules for High Quality Code GenerationEnforcing API Design Rules for High Quality Code Generation
Enforcing API Design Rules for High Quality Code Generation
 
Taming Cloud APIs with Swift
Taming Cloud APIs with SwiftTaming Cloud APIs with Swift
Taming Cloud APIs with Swift
 
OpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-SideOpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-Side
 
Fast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCFast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPC
 
Build Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCBuild Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPC
 
What I learned about APIs in my first year at Google
What I learned about APIs in my first year at GoogleWhat I learned about APIs in my first year at Google
What I learned about APIs in my first year at Google
 
CocoaConf: The Language of Mobile Software is APIs
CocoaConf: The Language of Mobile Software is APIsCocoaConf: The Language of Mobile Software is APIs
CocoaConf: The Language of Mobile Software is APIs
 
Deep Geek Diving into the iPhone OS and Frameworks
Deep Geek Diving into the iPhone OS and FrameworksDeep Geek Diving into the iPhone OS and Frameworks
Deep Geek Diving into the iPhone OS and Frameworks
 
Building Open Radar
Building Open RadarBuilding Open Radar
Building Open Radar
 

Recently uploaded

TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
Revolutionizing SAP® Processes with Automation and Artificial Intelligence
Revolutionizing SAP® Processes with Automation and Artificial IntelligenceRevolutionizing SAP® Processes with Automation and Artificial Intelligence
Revolutionizing SAP® Processes with Automation and Artificial Intelligence
Precisely
 

Recently uploaded (20)

The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Revolutionizing SAP® Processes with Automation and Artificial Intelligence
Revolutionizing SAP® Processes with Automation and Artificial IntelligenceRevolutionizing SAP® Processes with Automation and Artificial Intelligence
Revolutionizing SAP® Processes with Automation and Artificial Intelligence
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 

Interpreting Objective C

  • 2. ν “What’s new (nu)?” Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 3. c/λ “C over lambda.” Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 5. Desire Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 6. Beliefs about Better Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 7. 1 In any resource-constrained environment, performance is everything. Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 8. 2 All environments of value are resource-constrained. Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 9. 3 Performance is device performance and developer performance. Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 10. 4 The number of developers required to create a system is its biggest weakness. Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 11. 5 Stability and productivity are a developer's top two priorities, in that order. Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 12. 6 • Simplicity allows speed. Speed increases opportunity. • Simplicity allows control. Control reduces risk. Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 13. 7 • The C platform has consistently offered the best run time/power/capability performance for developers. • Lisp-style languages have offered the greatest capabilities of abstraction. Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 14. Insight Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 15. Observation Objective-C solves many problems in bridging C with high level languages. • Introspectable: no glue code is needed to bind to compiled objects. • Dynamic: we can add to the Objective-C runtime at run time. Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 16. So What’s Nu? • Nu is an interpreted dialect of Lisp that parses into Objective C objects that can be evaluated to perform computations. • Nu interacts directly with the Objective-C runtime to create and use classes, methods, and objects. Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 17. Craft Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 18. Parsing Nu (puts (+ 2 2))! NuCell NuCell puts Nu_puts_operator NuCell NuCell NuCell + 2 2 Nu_add_operator NSNumber NSNumber Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 19. Evaluating Nu - (id) evaluateWithContext:(NSMutableDictionary *) context NuCell NuCell puts Nu_puts_operator NuCell NuCell NuCell + 2 2 Nu_add_operator NSNumber NSNumber Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 20. Operators (+ 2 (/ 14 7)) ! ! Objects (UIStoryboard storyboardWithName:name bundle:nil) ! ! Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 21. Interacting with the Runtime ((UIView alloc) initWithFrame:’(0 0 100 100))! ! Nu evaluation can resolve symbols by looking up classes and methods in the Objective-C runtime. Nu evaluation uses Objective-C method signatures to make method calls with appropriately-typed arguments. Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 22. Interacting with the Runtime (class MyClass is NSObject ! (- hello is ! (puts “hello"))) The Nu class operator can be used to define new classes and to add methods to existing ones. Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 23. The Nu Shell % nush! Nu Shell.! % (class MyClass is NSObject ! (- hello is (puts "hello")))! ()! % (set myobject (MyClass new))! <MyClass:7fdb6863dd10>! % (myobject hello)! hello! ()! Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 24. Usage Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 25. Generate a plist ! (set me (dict name:"Tim Burks"! company:"Radtastical Inc."! address:(dict street:"220 South California Avenue, Suite 250"! city:"Palo Alto"! state:"CA"! zip:"94306")! projects:(array (dict name:"Silicon Valley iOS Developers' Meetup"! url:"http://meetup.com/sviphone")! (dict name:"Renaissance"! url:"http://renaissance.io")! (dict name:"Open Radar"! url:"http://openradar.io")! (dict name:"Nu"! url:"http://programming.nu"))))! ! ((me XMLPropertyListRepresentation) writeToFile:"tim.plist" atomically:NO)! Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 26. <?xml version="1.0" encoding="UTF-8"?>! <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">! <plist version="1.0">! <dict>! ! <key>address</key>! ! <dict>! ! ! <key>city</key>! ! ! <string>Palo Alto</string>! ! ! <key>state</key>! ! ! <string>CA</string>! ! ! <key>street</key>! ! ! <string>220 South California Avenue, Suite 250</string>! ! ! <key>zip</key>! ! ! <string>94306</string>! ! </dict>! ! <key>company</key>! ! <string>Radtastical Inc.</string>! ! <key>name</key>! ! <string>Tim Burks</string>! ! <key>projects</key>! ! <array>! ! ! <dict>! ! ! ! <key>name</key>! ! ! ! <string>Silicon Valley iOS Developers' Meetup</string>! ! ! ! <key>url</key>! ! ! ! <string>http://meetup.com/sviphone</string>! ! ! </dict>! ! ! <dict>! ! ! ! <key>name</key>! ! ! ! <string>Renaissance</string>! ! ! ! <key>url</key>! ! ! ! <string>http://renaissance.io</string>! ! ! </dict>! ! ! <dict>! ! ! ! <key>name</key>! ! ! ! <string>Open Radar</string>! ! ! ! <key>url</key>! ! ! ! <string>http://openradar.io</string>! ! ! </dict>! ! ! <dict>! ! ! ! <key>name</key>! ! ! ! <string>Nu</string>! ! ! ! <key>url</key>! ! ! ! <string>http://programming.nu</string>! ! ! </dict>! ! </array>! </dict>! </plist>! Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 27. Call a Remote API ;;! ;; test google geocoding API ! ;; API is limited to 2500 requests/(ip-address*day)! ;;! ! (load "RadHTTP")! (load "RadJSON")! ! (set street "1675 Owens Street")! (set city "San Francisco")! (set state "CA")! ! (set parameters (dict sensor:"false"! address:(+ street " "! city ", "! state " "! )))! (set query (parameters urlQueryString))! (set path (+ "http://maps.googleapis.com/maps/api/geocode/json?" query))! (set string (NSString stringWithContentsOfURL:(NSURL URLWithString:path)))! (set geocoding (string JSONValue))! ! (puts (geocoding description)) Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 28. {! results = ! (! …! ! geometry = {! location = {! lat = "37.76800009999999";! lng = "-122.3934754";! };! "location_type" = ROOFTOP;! viewport = {! northeast = {! lat = "37.76934908029149";! lng = "-122.3921264197085";! };! southwest = {! lat = "37.7666511197085";! lng = "-122.3948243802915";! };! };! };! types = (! "street_address"! );! }! );! status = OK;! }! Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 29. Write Unit Tests ;; test_array.nu! ;; tests for Nu array extensions.! ;;! ;; Copyright (c) 2007 Tim Burks, Radtastical Inc.! ! (class TestArray is NuTestCase! ! (- testCreate is! (set a (NSMutableArray arrayWithList:'(1 2)))! (a << "three")! (assert_equal 3 (a count))! (assert_equal 2 (a 1))! (assert_equal "three" (a 2)))! ! (- testEach is! (set i 0)! (set a (array 0 1 2))! (a each:! (do (x)! (assert_equal i x)! (set i (+ i 1))))! ;; iteration with break! (set a (array 0 1 2 3 4 5 6))! (set sum 0)! (a each:! (do (x)! Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 30. [hebephrenia:~/nu] tim% nutest test/test_array.nu! ! TestArray: running! --- testCreate! --- testEach! --- testEachInReverse! --- testEachWithIndex! --- testIndexing! --- testSortUsingBlock! --- testSortedArrayUsingBlock! --- testSortedArrayUsingSelector! TestArray: completed 8 tests/32 assertions/0 failures/0 errors! ! 2014-03-03 19:52:41.147 nush[10592:d07] All: completed 8 tests/32 assertions/0 failures/0 errors! ! 2014-03-03 19:52:41.148 nush[10592:d07] SUCCESS (0 failures, 0 errors) Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 31. Build iOS apps <dict> <key>action</key> <string>push sessions/2014/day/1</string> <key>image</key> <dict> <key>filename</key> <string>2014_bill_budge.jpg</string> <key>mask</key> <string>circle</string> <key>position</key> <string>left</string> </dict> <key>markdown</key> <string>Wednesday, January 29, 2014n# Inspiration</string> </dict> Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 32. Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 33. Create Web Sites Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 34. (get "/radarid:"! (set radarnumber (radarid longLongValue))! (authenticate)! (set mongo (RadMongoDB new))! (mongo connect)! (set radar (mongo findOne:(dict number:radarnumber) inCollection:"openradar.radars"))! (if (and (radarid longLongValue) radar)! (then (set comments (mongo findArray:(dict $query:(dict radar_id:(radar _id:))! $orderby:(dict created:1))! inCollection:"openradar.comments"))! (htmlpage (+ "Radar " (radar number:))! (topbar)! (&div class:"row"! (&div class:"large-12 small-12 columns"! (panel-for-radar radar)))! (&div class:"row"! (&div class:"large-12 small-12 columns"! (&div class:"row"! (&div class:"large-2 medium-2 small-12 large-push-10 medium-push-10 columns" style:"text-align:right"! (if (eq (radar user:) screen_name)! (then (&a class:"button" href:(+ "/radars/edit/" (radar _id:)) "Edit"))! (else nil))! (field "Number" (radar number:))! (field "Originator" (mask-username (radar user:)))! (field "Date Originated" (radar originated:))! (field "Status" (radar status:))! (field "Resolved" (radar resolved:))! (field "Product" (radar product:))! (field "Product Version" (radar product_version:))! (field "Classification" (radar classification:))! (field "Reproducible" (radar reproducible:)))! (&div class:"large-10 large-pull-2 medium-10 medium-pull-2 small-12 columns" style:"padding:0 30px;"! (&p style:"white-space: pre-wrap; word-wrap: break-word; font-family:Courier, monospace; font-size:80%"! (if ((set description (radar description:)) length)! (then (escape (radar description:)))! (else (&em "No description provided."))))))! (&div class:"row"! (&div class:"large-10 medium-10 small-12 columns"! (&div class:"comments"! (comments map:! (do (comment)! (if (comment parent_id:)! (then "") ;; skip replies! (else (box-for-comment comment YES screen_name))))))))! (if screen_name! (then (&input id:"newcomment" type:"button" class:"button tiny" value:"Post a comment"))! (else (&p (&a href:"/signin" "Sign in") " to post comments and radars.")))! (&div style:"display:none;" id:"radar" (radar _id:))! (&br)! (&script type:"text/javascript" charset:"utf-8"! "if(jQuery("#error").text() == "") jQuery("#error").hide();")))))! (else nil)))! Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 36. Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 37. Anywhere Objective-C is run Interpreting Objective-C. © Tim Burks. March 4, 2014
  • 39. MYNetwork objective-git UIKit Pantomime CocoaYAML NSURLRequest OTRKit MailCore SpriteKit SocketRocket NSKeyedArchiver google-api-objectivec-client PDFKit SSKeychain FMDB NSJSONSerialization CorePlot SSZipArchive PostgreSQL NSXPCConnection NSPropertyListSerialization PocketSVG AFNetworking MongoDB NSRegularExpression NSXMLDocument RestKit Xapian NSFileHandle MySQL NSSet PorterStemmer NSValue levelDB NSProcessInfo Simple-KML redis NSNumber SQLite NSDictionary libevent NSArray OpenGL libxml2 NSString NSURLSession AppKit Usage Desire Batteries Nuclear Power Included Craft http://programming.nu Insight Interpreting Objective-C. © Tim Burks. March 4, 2014