SlideShare ist ein Scribd-Unternehmen logo
1 von 113
Why MacRuby Matters
Patrick Thomson

C4[3]

September 2009
Edsger Dijkstra
“Go To Statement Considered Harmful”
Dijkstraʼs Algorithm
“The effective exploitation of the
powers of abstraction must be
regarded as one of the most vital
activities of a computer
programmer.”
Objective-C
insufficiently powerful abstraction
What does Objective-C lack?
1. code reuse
inheritance alone
  is not enough
singletons
inheritance
In Objective-C:
1. create a static, shared instance
2. initialize once and only once
3. add an sharedInstance accessor method


       …for every singleton class.
               Tedious.
tedium sucks
mixins
units of behavior;
mix-in common functionality
 across unrelated classes
With mixins:

class Example
 include Singleton
 # your methods here
end
foo = Example.instance
not a new idea
Symbolics Lisp
1980
1. code reuse
2. safety
C is powerful.
C is powerful. (At the price of safety.)
We see Cʼs unsafeness throughout Objective-C.
raw pointers: bad news.
easily-confusable garbage collection
exceptions
creation, @try, and @throw are all expensive
Cocoa isnʼt exception-safe.
mishmash of NSError**,
NSException, and error codes
1. code reuse
2. safety
3. syntactic abstraction
[NSArray arrayWithObjects: @"a", @"b", @"c", nil];




                       vs.



                 ["a", "b", "c"]
[NSDictionary dictionaryWithObjectsAndKeys:
  @"Chicago", @"location", @"C4", @"event", nil];




                       vs.


   {"location" => "Chicago", "event" => "C4"}
[foo compare:bar] == NSComparisonResultAscending




                      vs.



                   foo < bar
I want a language that lets
       Cocoa shine.
MacRuby.
new Ruby implementation
+



powered by LLVM
+               +



on top of CoreFoundation
irb(main):001:0> "c4".class
=> NSMutableString
irb(main):002:0> [1, 2, 3].class
=> NSMutableArray
irb(main):003:0> {:tollfree => "bridging"}.class
=> NSMutableDictionary
irb(main):004:0> "/usr/local/bin".pathComponents
=> ["/", "usr", "local", "bin"]



 Ruby objects            Cocoa objects
irb(main):001:0>   3000.class
=> Fixnum
irb(main):002:0>   3000.is_a? NSNumber
=> true
irb(main):003:0>   3000.is_a? NSObject
=> true
irb(main):003:0>   3000.class.is_a? NSObject
=> true



    Everything is an NSObject
Laurent Sansonetti

Vincent Isambart


Rich Kilmer


Eloy Duran


Ben Stiglitz


Matt Aimonetti
MacRuby isnʼt…
a bridge
MacRuby != RubyCocoa
a toy
provides real solutions to
  real-world problems
example: threading
Global Interpreter Locks
only one system thread can touch
 the interpreter at any given time
prevents true multithreading
MacRuby has no GIL!
So why should you, as Cocoa
 developers, use MacRuby?
itʼs fast
historically slow
fib(40)
static int fib(int n)
{
  if (n < 3) {
    return 1;
  } else {
    return fib(n - 1) + fib(n - 2);
  }
}
@implementation Fib

- (int)fib:(int)n
{
  if (n < 3) {
    return 1;
  } else {
    return [self fib:n - 1] + [self fib:n - 2];
  }
}

@end
C        Objective-C
                     4




                     3
execution time (s)




                     2




                     1




                     0
                             fib(40)
def fib(n)
  if n < 3
    1
  else
    fib(n-1) + fib(n-2)
  end
end
C   MacRuby      Objective-C
                     4




                     3
execution time (s)




                     2




                     1




                     0
                                fib(40)
Faster than Objective-C‽
macruby --compile
first ahead-of-time compiler
         for Ruby
C       MacRuby (compiled)        Obj-C   MacRuby (interpreted)
                               JRuby   Ruby
                           9
execution time (seconds)




                           6




                           3




                           0
                                                            fib(35)
C     MacRuby (compiled)       Obj-C          MacRuby (interpreted)

                           0.3
                                                                                          0.28
execution time (seconds)




                                                                        0.24
                           0.2
                                                      0.2


                                     0.15

                           0.1




                            0
                                                            fib(35)
itʼs beautiful
Objective-C:




[obj setValue:val forKey:key]
Bridges:



obj.setValue_forKey(val, key)


     READABILITY FAIL
no_underscores_plz_k_thx
MacRuby:



obj.setValue(val, forKey:key)
HotCocoa
mapping Cocoa to idiomatic Ruby
[[NSImage alloc] initWithContentsOfFile:path];




                   becomes




             image(:file => path)
[[NSGradient alloc]
 initWithStartingColor: [NSColor greyColor]
           endingColor: [NSColor blueColor]];



                     becomes


gradient(:start => color(:name => "grey"),
         :end   => color(:name => "blue"))
a real, robust macro system
itʼs conceptually sound
single inheritance
open classes
message-based object model
dynamically typed
garbage-collected
Objective-C is C with the Smalltalk
     object model attached.


 Ruby is Smalltalk with C syntax.
itʼs fully integrated with the
       Cocoa toolchain
Yeah, We Got That
itʼs 100% compatible with every
        Cocoa framework
BridgeSupport lets you call any
 C-based API from MacRuby
CFStringGetLength("hello C4")
=> 8
queue = Dispatch::Queue.concurrent

queue.dispatch do
  puts "Asynchronous dispatch FTW!"
end
it provides features that
    Objective-C lacks
regular expressions,
tail-call optimization,
     namespaces,
        mixins,
operator overloading,
runtime evaluation…
What do you lose when going
from Objective-C to MacRuby?
static typing
JVM : Scala   Cocoa : ?
Where are we now?
almost 0.5
SVN trunk is stable
  (macruby.org)
nightly builds for 10.6 at
 macruby.icoretech.org
What does the future hold?
Last summer I had an internship at Apple.
  My views here, however, represent that of an open-source contributor,
 and not an Apple employee. Any speculations on the future of MacRuby
are entirely mine and are in no way representative of any plans, attitudes,
   or future directions that Apple may take. This presentation is neither
                     sponsored nor endorsed by Apple.

                       Apple: please donʼt sue me.
performance improvements
compatibility
not yet
Possible? Yes.
 Certain? No
ahead-of-time compiler
MacRuby → x86/ARM machine code
full mode: packed with interpreter
restricted mode:
no eval(), no interpreter
compliant with Appleʼs restrictions
  on interpreters in iPhone apps
we need garbage collection on
         the iPhone
Stay Informed
                      @lrz
                 @importantshock
                   @benstiglitz
@MacRuby         @vincentisambart
                 @mattaimonetti
                     @alloy

Weitere ähnliche Inhalte

Was ist angesagt?

"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, UkraineVladimir Ivanov
 
Ruby3x3: How are we going to measure 3x
Ruby3x3: How are we going to measure 3xRuby3x3: How are we going to measure 3x
Ruby3x3: How are we going to measure 3xMatthew Gaudet
 
Medical Image Processing Strategies for multi-core CPUs
Medical Image Processing Strategies for multi-core CPUsMedical Image Processing Strategies for multi-core CPUs
Medical Image Processing Strategies for multi-core CPUsDaniel Blezek
 
あなたのScalaを爆速にする7つの方法
あなたのScalaを爆速にする7つの方法あなたのScalaを爆速にする7つの方法
あなたのScalaを爆速にする7つの方法x1 ichi
 
Compilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVMCompilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVMLinaro
 
L Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformaticsL Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformaticsJan Aerts
 
C++ amp on linux
C++ amp on linuxC++ amp on linux
C++ amp on linuxMiller Lee
 
JCConf 2020 - New Java Features Released in 2020
JCConf 2020 - New Java Features Released in 2020JCConf 2020 - New Java Features Released in 2020
JCConf 2020 - New Java Features Released in 2020Joseph Kuo
 
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...Frank Nielsen
 
12 分くらいで知るLuaVM
12 分くらいで知るLuaVM12 分くらいで知るLuaVM
12 分くらいで知るLuaVMYuki Tamura
 
Modern C++ Lunch and Learn
Modern C++ Lunch and LearnModern C++ Lunch and Learn
Modern C++ Lunch and LearnPaul Irwin
 
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonLow-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonAMD Developer Central
 
Cray XT Porting, Scaling, and Optimization Best Practices
Cray XT Porting, Scaling, and Optimization Best PracticesCray XT Porting, Scaling, and Optimization Best Practices
Cray XT Porting, Scaling, and Optimization Best PracticesJeff Larkin
 
Parallelization using open mp
Parallelization using open mpParallelization using open mp
Parallelization using open mpranjit banshpal
 
GEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkGEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkAlexey Smirnov
 
Q4.11: NEON Intrinsics
Q4.11: NEON IntrinsicsQ4.11: NEON Intrinsics
Q4.11: NEON IntrinsicsLinaro
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisWhy scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisRuslan Shevchenko
 

Was ist angesagt? (20)

"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
 
OpenMP
OpenMPOpenMP
OpenMP
 
Ruby3x3: How are we going to measure 3x
Ruby3x3: How are we going to measure 3xRuby3x3: How are we going to measure 3x
Ruby3x3: How are we going to measure 3x
 
Medical Image Processing Strategies for multi-core CPUs
Medical Image Processing Strategies for multi-core CPUsMedical Image Processing Strategies for multi-core CPUs
Medical Image Processing Strategies for multi-core CPUs
 
あなたのScalaを爆速にする7つの方法
あなたのScalaを爆速にする7つの方法あなたのScalaを爆速にする7つの方法
あなたのScalaを爆速にする7つの方法
 
Compilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVMCompilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVM
 
L Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformaticsL Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformatics
 
C++ amp on linux
C++ amp on linuxC++ amp on linux
C++ amp on linux
 
JCConf 2020 - New Java Features Released in 2020
JCConf 2020 - New Java Features Released in 2020JCConf 2020 - New Java Features Released in 2020
JCConf 2020 - New Java Features Released in 2020
 
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
 
12 分くらいで知るLuaVM
12 分くらいで知るLuaVM12 分くらいで知るLuaVM
12 分くらいで知るLuaVM
 
MPI n OpenMP
MPI n OpenMPMPI n OpenMP
MPI n OpenMP
 
Basic Packet Forwarding in NS2
Basic Packet Forwarding in NS2Basic Packet Forwarding in NS2
Basic Packet Forwarding in NS2
 
Modern C++ Lunch and Learn
Modern C++ Lunch and LearnModern C++ Lunch and Learn
Modern C++ Lunch and Learn
 
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonLow-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
 
Cray XT Porting, Scaling, and Optimization Best Practices
Cray XT Porting, Scaling, and Optimization Best PracticesCray XT Porting, Scaling, and Optimization Best Practices
Cray XT Porting, Scaling, and Optimization Best Practices
 
Parallelization using open mp
Parallelization using open mpParallelization using open mp
Parallelization using open mp
 
GEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkGEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions Framework
 
Q4.11: NEON Intrinsics
Q4.11: NEON IntrinsicsQ4.11: NEON Intrinsics
Q4.11: NEON Intrinsics
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisWhy scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with this
 

Andere mochten auch

Oficio CRAS dinomar miranda
Oficio CRAS dinomar mirandaOficio CRAS dinomar miranda
Oficio CRAS dinomar mirandaDinomar Miranda
 
Pastoors 2011 setting objectives for fisheries management
Pastoors 2011 setting objectives for fisheries managementPastoors 2011 setting objectives for fisheries management
Pastoors 2011 setting objectives for fisheries managementMartin Pastoors
 
10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer Experience10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer ExperienceYuan Wang
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionIn a Rocket
 
How to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanHow to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanPost Planner
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting PersonalKirsty Hulse
 

Andere mochten auch (6)

Oficio CRAS dinomar miranda
Oficio CRAS dinomar mirandaOficio CRAS dinomar miranda
Oficio CRAS dinomar miranda
 
Pastoors 2011 setting objectives for fisheries management
Pastoors 2011 setting objectives for fisheries managementPastoors 2011 setting objectives for fisheries management
Pastoors 2011 setting objectives for fisheries management
 
10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer Experience10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer Experience
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
 
How to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanHow to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media Plan
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting Personal
 

Ähnlich wie Modified "Why MacRuby Matters"

Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deploymentThilo Utke
 
Macruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich KilmerMacruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich KilmerMatt Aimonetti
 
Mac ruby to the max - Brendan G. Lim
Mac ruby to the max - Brendan G. LimMac ruby to the max - Brendan G. Lim
Mac ruby to the max - Brendan G. LimThoughtWorks
 
MacRuby to The Max
MacRuby to The MaxMacRuby to The Max
MacRuby to The MaxBrendan Lim
 
MacRuby & HotCocoa
MacRuby & HotCocoaMacRuby & HotCocoa
MacRuby & HotCocoaThilo Utke
 
GUI Programming with MacRuby
GUI Programming with MacRubyGUI Programming with MacRuby
GUI Programming with MacRubyErik Berlin
 
Experiments in Sharing Java VM Technology with CRuby
Experiments in Sharing Java VM Technology with CRubyExperiments in Sharing Java VM Technology with CRuby
Experiments in Sharing Java VM Technology with CRubyMatthew Gaudet
 
Ruby Meets Cocoa
Ruby Meets CocoaRuby Meets Cocoa
Ruby Meets CocoaRobbert
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015Charles Nutter
 
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012rivierarb
 
MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?Joshua Ballanco
 
Java Keeps Throttling Up!
Java Keeps Throttling Up!Java Keeps Throttling Up!
Java Keeps Throttling Up!José Paumard
 
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...Yandex
 

Ähnlich wie Modified "Why MacRuby Matters" (20)

Why MacRuby Matters
Why MacRuby MattersWhy MacRuby Matters
Why MacRuby Matters
 
MacRuby, an introduction
MacRuby, an introductionMacRuby, an introduction
MacRuby, an introduction
 
Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deployment
 
Macruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich KilmerMacruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich Kilmer
 
Mac ruby to the max - Brendan G. Lim
Mac ruby to the max - Brendan G. LimMac ruby to the max - Brendan G. Lim
Mac ruby to the max - Brendan G. Lim
 
MacRuby to The Max
MacRuby to The MaxMacRuby to The Max
MacRuby to The Max
 
MacRuby & HotCocoa
MacRuby & HotCocoaMacRuby & HotCocoa
MacRuby & HotCocoa
 
Jvm internals
Jvm internalsJvm internals
Jvm internals
 
GUI Programming with MacRuby
GUI Programming with MacRubyGUI Programming with MacRuby
GUI Programming with MacRuby
 
Experiments in Sharing Java VM Technology with CRuby
Experiments in Sharing Java VM Technology with CRubyExperiments in Sharing Java VM Technology with CRuby
Experiments in Sharing Java VM Technology with CRuby
 
Ruby Meets Cocoa
Ruby Meets CocoaRuby Meets Cocoa
Ruby Meets Cocoa
 
MacRuby
MacRubyMacRuby
MacRuby
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015
 
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
 
MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?
 
Java Keeps Throttling Up!
Java Keeps Throttling Up!Java Keeps Throttling Up!
Java Keeps Throttling Up!
 
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
 
ruby-cocoa
ruby-cocoaruby-cocoa
ruby-cocoa
 
ruby-cocoa
ruby-cocoaruby-cocoa
ruby-cocoa
 
Ruby Under The Hood
Ruby Under The HoodRuby Under The Hood
Ruby Under The Hood
 

Kürzlich hochgeladen

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Kürzlich hochgeladen (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Modified "Why MacRuby Matters"

Hinweis der Redaktion

  1. Introductions. Thank Wolf. Banter.
  2. Many of you may recognize this person.
  3. contributions to structured programming
  4. revolutionary graph-search algorithm that powers just about every network routing protocol
  5. this quote of Dijkstra&amp;#x2019;s draws attention to a central conundrum facing Cocoa programmers today
  6. the conundrum is this: Objective-C, the language we all know and love&amp;#x2026;
  7. &amp;#x2026;provides us with an insufficiently powerful level of abstraction. We build the best desktop apps out there, but we do it in spite of ObjC.
  8. So, as a language, what does ObjC lack?
  9. I submit that perhaps the most fundamental problem with ObjC is its lack of support for code reuse. At the Objective-C level of abstraction, effective code reuse is like pulling teeth.
  10. And sure, inheritance provides a good measure of code reuse. But for many use cases, it simply doesn&amp;#x2019;t apply.
  11. Consider the singleton. It&amp;#x2019;s a great example of a common Objective-C pattern which cannot be abstracted out, forcing us to resort to boilerplate code.
  12. Every singleton class needs its own static, shared instance. Single inheritance can&amp;#x2019;t solve the problem, and it&amp;#x2019;s questionable that multiple inheritance is the right solution in this case.
  13. So, creating a singleton in Objective-C is really tedious. Add to the fact that very few people agree on the right way to go about this tedium - should you synchronize on sharedInstance, or init? Should you check for NULL or use pthread_once or dispatch_once? - and ensuring proper behavior seems hardly worth the trouble. It&amp;#x2019;s too tedious.
  14. And tedium sucks.
  15. A sufficiently powerful language would provide us with a code reuse mechanism like mixins.
  16. Mixins, for those who haven&amp;#x2019;t heard of them, provide another level of abstraction into class definitions. Like classes, you define them and define method implementations in them; however, instead of including them in the class hierarchy, you mix them into classes - the resulting class copies the methods you defined in your mixin.
  17. Here&amp;#x2019;s an example. In this language, the &amp;#x201C;include&amp;#x201D; keyword mixes a mixin into a class. By including the Singleton mixin in this class, it defines initialization and accessor methods as well as setting aside a static, shared instance.
  18. Now we can access the shared instance. Easy.
  19. And sure, I understand that the Objective-C language designers held off on implementing New and Fancy Ideas. And I agree with them.
  20. But mixins have been around since Symbolics Lisp. Anyone remember that? I don&amp;#x2019;t. I wasn&amp;#x2019;t even born yet.
  21. That was a while ago. And we, as Mac programmers, should ask more from our development tools.
  22. Though Objective-C has a huge advantage in that it&amp;#x2019;s based on C, it also has a huge disadvantage - that it&amp;#x2019;s based on C.
  23. Being a representation of a Von Neumann machine, C can solve any computable problem. But what&amp;#x2019;s interesting is that C is actually pretty expressive, even when you need to do fancy, comp-sci-sexy things. You&amp;#x2019;ve got a reasonable approximation of continuations with setjmp, of exceptions with sigsetjmp, and first-class functions with function pointers.
  24. But all of these things are hideously unsafe. We&amp;#x2019;re programmers, not superheroes - if our tools allow us to make a mistake, we will make it.
  25. And C&amp;#x2019;s unsafeness is visible in almost every part Objective-C.
  26. We program in a high-level language. Why do we still have the ability to shoot ourselves so profoundly in the foot with raw pointers? You, or the library functions you call, can stomp all over memory silently and watch as you drown in bizarre and irreproducible behavior.
  27. C&amp;#x2019;s ability to treat just about anything as a memory address means that you can bamboozle the hell out of the garbage collector.
  28. Nowhere is the unsafe and backwards nature of C - and consequently, Objective-C - more apparent than exceptions. C really doesn&amp;#x2019;t play nice with the notion of exceptions at all, and has therefore hobbled ObjC exception support throughout ObjC&amp;#x2019;s lifetime.
  29. ObjC exception handling is horrifically inefficient. Since on 32-bit exceptions are based on setjmp and longjmp, pretty much everything about them are expensive. Exception creation and try-blocks got much faster with 64-bit C++-compatible exceptions, but throwing them got even slower.
  30. And the kicker is that the vast majority of Cocoa frameworks aren&amp;#x2019;t exception-safe. So there is absolutely no guarantee that objects will be cleaned up or finalized properly if you throw an exception.
  31. So thanks to this, nobody ever checks for exceptions - honestly, when was the last time you checked for alloc throwing an NSMallocException? - and we make do with functions that take pointers to NSErrors and some functions that return either Carbon, Cocoa, POSIX, or Mach error codes.
  32. Go ahead. Call me lazy.
  33. But I&amp;#x2019;m tired of creating arrays manually. I want a language that has sufficient syntactic abstraction so that I can just create arrays inline. I mean, imagine if we had to do this to create NSStrings - it would be endlessly tedious!
  34. And don&amp;#x2019;t even get me started on how tedious NSDictionary creation is. These may seem like syntactic quibbles to some of you, but I know that in the past I&amp;#x2019;ve avoided using dictionaries in favor of long if-else statements, just because creating dictionaries is so tedious!
  35. Similarly, I want operator overloading, because it lets me say what I mean. I want the less-than sign to be transformed into a call to compare - and let&amp;#x2019;s be frank, operator overloading is never going to come to Objective-C.
  36. Basically, I want a language that&amp;#x2019;s as well-designed as Cocoa.
  37. And so far, the closest I have come to that ideal is when I write code in MacRuby.
  38. For those of you that haven&amp;#x2019;t heard of it, MacRuby is a new implementation of Ruby, a scripting language from Japan.
  39. MacRuby differs from the standard implementation of Ruby 1.9 in that its its virtual machine, optimization routines, bytecode generation, and just-in-time compilation are all implemented on top of LLVM, the Low-Level Virtual Machine project. LLVM is already blazingly fast, and I&amp;#x2019;m confident that its performance will only continue to improve.
  40. In addition to replacing the Ruby 1.9 VM with the LLVM one, we also reimplemented the standard Ruby data structures on top of CoreFoundation. In addition to providing us with a set of memory-efficient, fast, and mature set of data structures, implementing MacRuby on top of Core Foundation also ensured that&amp;#x2026;
  41. &amp;#x2026;Ruby objects are absolutely indistinguishable from Cocoa objects - they even respond to the same API calls! NS/CFStrings are Ruby strings, NS/CFArrays are Ruby arrays, NS/CFDictionaries are Ruby hashes.
  42. But we go beyond what Objective-C offers, and return to a Smalltalk heritage where there are no primitive types. Everything descends from NSObject, even floats and integers.
  43. Though MacRuby is an Apple-supported project, it is released under the Ruby license so you can embed it into your commercial applications.
  44. The MacRuby team is one of the smartest and most focused I&amp;#x2019;ve ever seen. Laurent Sansonetti, an employee at Apple, started MacRuby just as an experiment to see how well Ruby would run on top of the Objective-C runtime and garbage collector. Yet in its current form, I truly believe that it&amp;#x2019;s stable enough
  45. Clarification!
  46. Bridges, as Tim pointed out in C4[1], are unreliable, difficult, and tend to be slow.
  47. Explain the differences.
  48. not a toy!
  49. everyone has to deal with it sooner or later
  50. explain what they are, what systems (Python, Ruby, Lua) use them
  51. explain how much they suck
  52. green threads suck
  53. So. The big question.
  54. MacRuby is fast. Not just Fast Enough, but fast.
  55. This may surprise many of you, as most people know Ruby as &amp;#x201C;that weird, slow, Japanese space-Perl.&amp;#x201D; And the conception that Ruby is slower than other comparable languages has been true - up until now.
  56. A good example of the speed boosts that we aim for is the Fibonacci sequence.
  57. Take na&amp;#xEF;ve implementations of the Fibonacci sequence, using recursion, in C&amp;#x2026;
  58. and in Objective-C (using ObjC message sending),
  59. and, predictably, C is going to be a lot faster. And trying to get MacRuby faster than C for everything is beyond the scope of this project.
  60. But take the same Fibonacci implementation in Ruby, run it under MacRuby&amp;#x2026;
  61. and we see that MacRuby is, in this benchmark, faster than Objective-C.
  62. The answer lies in the --compile flag. MacRuby can compile Ruby source down to Mach-O x86 executables.
  63. This is hugely exciting. Nobody else has done this before. And up until now, shipping a closed-source desktop application written in Ruby has been a Bad Idea - but now you can hide your source code from prying eyes.
  64. For completeness, let&amp;#x2019;s compare the C, compiled MacRuby and Objective-C performance and interpreted MacRuby, JRuby, and the stock OS X 10.6.1 ruby interpreter. OK... ouch. I dialed back from fib(40) to fib(35) because otherwise the stock ruby interpreter would still be calculating. JRuby&amp;#x2019;s better but still no competition for MacRuby (interpreted or compiled).
  65. So let&amp;#x2019;s throw out the stock ruby and JRuby data to get a better look at MacRuby (compiled and interpreted) vs. C and Objective-C.
  66. keyword syntax is readable.
  67. worst of both worlds: verbosity of keyword syntax and unreadability of ALGOL-style syntax
  68. syntactic extensions to make ObjC calls look gorgeous.
  69. optional set of layers
  70. to make common idioms concise
  71. nestable, elegant, yet completely optional
  72. like in Lisp and Scheme
  73. Ruby and Objective-C are almost absurdly similar - how similar, you ask?
  74. look at these features!
  75. practically cousins
  76. first-class environment
  77. xcode templates, interface builder integration, instruments templates, dtrace scripts
  78. leave nothing behind
  79. mention that Laurent wrote it
  80. contrived example, but talk about CoreImage, CoreGraphics, PDF documents
  81. hooray for my GCD layer
  82. talk about how things just work, and plug topfunky&amp;#x2019;s MacRuby screencast
  83. hooray
  84. whine about all of these features
  85. be honest!
  86. Though one can obviously treat Objective-C like a dynamic language, and give the &amp;#x2018;id&amp;#x2019; type to everything, well-written and idiomatic Objective-C code takes advantage of static typing to catch errors before they happen. And because Ruby is a duck-typed language, you&amp;#x2019;re going to lose some power.
  87. And rather than viewing this as a problem for MacRuby, I think this is a great opportunity for another language to come in and apply all the innovations in the world of static typing - type inference, currying, existential types - to the world of Cocoa. So, uh, someone get on that.
  88. The 0.5 release of MacRuby is almost upon us. This release will be the first one based on the new virtual machine.
  89. If you want to play with the new features now, I recommend checking out the source from MacRuby.org
  90. or get builds for Snowy.
  91. DISCLAIMER! I&amp;#x2019;m here to talk about what is TECHNICALLY POSSIBLE, not what&amp;#x2019;s *going* to happen.
  92. we want to be the fastest Ruby implementation around
  93. we still need continuations, fibers, and to make all C exts compatible
  94. The first thing people usually ask about MacRuby is &amp;#x201C;Does it run Rails yet?&amp;#x201D;
  95. No. It doesn&amp;#x2019;t. And though we&amp;#x2019;d like to have it run Rails in the future, there&amp;#x2019;s still a lot of work to be done in that direction - revamping the sockets interface, improving IO speed and flexibility, and making sure that MacRuby supports all the maddening little metaprogramming quirks of which Rails takes advantage.
  96. Much more interesting to me is the question of whether or not
  97. it&amp;#x2019;s up to the lawyers
  98. i mentioned this already
  99. for metaprogramming and eval
  100. hopefully that will come soon