SlideShare une entreprise Scribd logo
1  sur  38
YOUR LIBRARY SUCKS.
   jsconf.eu :: 25 Sept 2010 :: Peter Higgins
BUT YOU SHOULD USE IT.
    jsconf.eu :: 25 Sept 2010 :: Peter Higgins
Me.
Dojo Toolkit Project Lead

JavaScript Engineer @joost / Adconion

Blogs Infrequently :: http://higginsforpresident.net

Codes @GitHub :: http://github.com/phiggins42

Twitter: @phiggins

Beer Drinking Expert
It’s Just JavaScript   TM




Lovable, Simple

Self Healing

Promiscuous

Ubiquitous
The Good Parts


Context :: apply/call/hitch/partial

AOP, FTW. (duck punch...)

Prototypes, also FTW

Module Loading (/me jokes)
The Bad Parts


Date() :: designed with evil.

The DOM :: also designed with evil.

with() and eval() :: allegedly evil.
Teh Libraries

Dojo
YUI
Mootools / Prototype
FuseJS (?)
EmbedJS (?)
jQuery
Your own
LOVABLE, SIMPLE.
Libraries are a crutch

Learn JavaScript first

Know enough to dislike parts

  Supplement those parts

Don’t be afraid of the word `prototype`

  If you don’t know $.fn === $.prototype, quit (or learn)
PROMISCUOUS
  Also known as Loose Typing
SELF-HEALING
BASIC AOP <3
// I can fix anything:
var oldfunction = some.oldFunction;
some.oldFunction = function(){
    oldfunction.apply(some, arguments); // closures, ftw.
}
Philosophically

   Fixes on the Natives vs Namespaced fixes

      SomeString.trim() vs mylibrary.trim(SomeString)

mylibrary = {};
mylibrary.trim = String.prototype.trim ? function(str){
  return str.trim();
} : function(str){ /* do the “fun” stuff */ };
Bind/Curry/Whatever
        Context manipulation, FTW
mylibrary.bind = Function.prototype.bind ? function(fn, context){
    return fn.bind(context);
} : function(fn, context){
    return function(){
         return fn.apply(context, arguments);
    }
}
EASY TO ABUSE :(
DON’T DO THIS:
$(“div button#bar”).click(function(){
  $(‘#bam’).addClass(“bar”);
  $(‘#bam’).css(“width”, “200px”)
  $(‘#bam’).animate({ width: “+=100” })
}).click();
To be fair ...
// easy to write bad code in any library:
var $ = dojo.query;
$(“div button#bar”).onclick(function(){
  $(‘#bam’).addClass(“bar”);
  $(‘#bam’).css(“width”, “200px”)
  $(‘#bam’).animate({ width: 300 })
}).trigger(‘click’);
Why not:
var clicker = function(){
    $(“#bam”)
     .addClass(“bar”)
     .css({ width:”200px” })
     .animate({ width:”300px” })
}
$(“#bar”).click(clicker);
clicker();
UBIQUITOUS
 “But can it run JavaScript?”
Device Penetration
Browsers, Now

  Desktop, Mobile, Device

Server

  Rhino

  V8

  Spidermonkey
Future Browsers?


Kitchen Crap

Televisions

Washer / Dryer?

...
COMMONJS
  is piggybacking.
CommonJS

Modules should be in the language, not here.

Forgot about the browser (see: Modules)

  Though has nothing to do with the DOM

A bit late?

  Only more time will tell.
STANDARDS.
 Yep. We (kinda) have them.
MDC: Array.prototype


Array.forEach / map / filter / indexOf / etc etc

  None of us handle sparse arrays to spec

  jQuery.map vs jQuery().map offends my senses

  dojo.map(ar, “return item * 2”) is too much magic
“Portability”

[1,2,3].forEach(function(item, index){ ... }, context);

dojo.forEach([1,2,3], function(item, index){ ... }, context);

jQuery.each([1,2,3], function(index){ /* this == item */ });

Y.Array.each([1,2,3], function(item, index){ ... }, context)

Fuse.win([1,2,3], function(item, index){ ... }, context);
MDC: Fn.proto.bind
                                        “this” is important.

var obj = {
     counter:0,
     inc: function(howmuch){ this.counter += howmuch || 0; }
};
var pfn = obj.inc.bind(obj, 5); // native, moo, proto way
var dfn = dojo.hitch(obj, “inc”, 5), // dojo
var dfn2 = dojo.hitch(obj, obj.inc, 5); // dojo is backwards
var jfn = jQuery.proxy(obj, “inc”); // so is jq. only w/ strings (also can’t pass args)
var jfn2 = jQuery.proxy(obj.inc, obj); // this is just plain inconsistent (no args here either)
I’M MISSING THE POINT?
       No, i’m not being clear.
Your library sucks, still.
I’m a grumpy old man. </rant>

No compelling reason for YOU not to use them

  If you understand what it’s doing

  If you don’t MIX

  Non-trivial tasks

  Portability
Library Benefits


Deferred development cost

  Open Source / Many Eyes

  Battle-tested

Common / Consistent APIs
I WANT TO CHANGE TOPICS
       Really. Let’s move forward, instead.
Propose: CommonBrowserJS
Reduce what we’ve learned over the years

Common Library to build upon

No Magic, Pure Standards

No UA sniffs, pure `feature detection`

Can load CommonJS modules/packages

Try to be agnostic? Back to Dojo beginnings.
Small Problems are Easy


MDC / ECMA standards are easy. What next?

  Modularity

  Stability (regressions, deprecation, sane versioning)

  Localization/Internationalization? (l10n, i18n)
First pass: has.js


Agnostic Core

pure Feature Detection framework

API not as important as converging on test implementations

Naming shit is hard.
DOJO ALREADY DID IT.
    @dojodidit - Really, We probably have.
DISCUSS.
Done talking. Ask questions if you like.
AAAAND THANKS.
#jsconfeu FTW, 2010 - enjoy the rest of the conference.
Me, again:

http://dante.dojotoolkit.org

http://higginsforpresident.net

http://twitter.com/phiggins

http://github.com/phiggins42

phiggins @ irc.freenode.net

Contenu connexe

Tendances

ATS language overview
ATS language overviewATS language overview
ATS language overviewKiwamu Okabe
 
NYPHP March 2009 Presentation
NYPHP March 2009 PresentationNYPHP March 2009 Presentation
NYPHP March 2009 Presentationbrian_dailey
 
jQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & CompressionjQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & CompressionPaul Irish
 
Moose - YAPC::NA 2012
Moose - YAPC::NA 2012Moose - YAPC::NA 2012
Moose - YAPC::NA 2012xSawyer
 
Getting Started With Puppet - Chad Metcalf
Getting Started With Puppet - Chad MetcalfGetting Started With Puppet - Chad Metcalf
Getting Started With Puppet - Chad MetcalfPuppet
 
Evolving Software with Moose
Evolving Software with MooseEvolving Software with Moose
Evolving Software with MooseDave Cross
 
Crystal: Fundamentos, objetivos y desafios - Cacic 2019
Crystal: Fundamentos, objetivos y desafios - Cacic 2019Crystal: Fundamentos, objetivos y desafios - Cacic 2019
Crystal: Fundamentos, objetivos y desafios - Cacic 2019Brian Cardiff
 
Barcelona 2010 hidden_features
Barcelona 2010 hidden_featuresBarcelona 2010 hidden_features
Barcelona 2010 hidden_featuresAnis Berejeb
 
Introduction to CoffeeScript
Introduction to CoffeeScriptIntroduction to CoffeeScript
Introduction to CoffeeScriptStalin Thangaraj
 
Dario Faggioli - Virtualization in the age of speculative execution HW bugs
Dario Faggioli - Virtualization in the age of speculative execution HW bugsDario Faggioli - Virtualization in the age of speculative execution HW bugs
Dario Faggioli - Virtualization in the age of speculative execution HW bugslinuxlab_conf
 
Ruby - Uma Introdução
Ruby - Uma IntroduçãoRuby - Uma Introdução
Ruby - Uma IntroduçãoÍgor Bonadio
 
Tame your Infrastructure with Puppet
Tame your Infrastructure with PuppetTame your Infrastructure with Puppet
Tame your Infrastructure with Puppetdelimiter
 
My Adventures In Objective-C (A Rubyists Perspective)
My Adventures In Objective-C (A Rubyists Perspective)My Adventures In Objective-C (A Rubyists Perspective)
My Adventures In Objective-C (A Rubyists Perspective)abdels
 

Tendances (20)

ATS language overview
ATS language overviewATS language overview
ATS language overview
 
NYPHP March 2009 Presentation
NYPHP March 2009 PresentationNYPHP March 2009 Presentation
NYPHP March 2009 Presentation
 
jQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & CompressionjQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & Compression
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 
Moose - YAPC::NA 2012
Moose - YAPC::NA 2012Moose - YAPC::NA 2012
Moose - YAPC::NA 2012
 
Troubleshooting Puppet
Troubleshooting PuppetTroubleshooting Puppet
Troubleshooting Puppet
 
Getting Started With Puppet - Chad Metcalf
Getting Started With Puppet - Chad MetcalfGetting Started With Puppet - Chad Metcalf
Getting Started With Puppet - Chad Metcalf
 
Beginner's Sinatra
Beginner's SinatraBeginner's Sinatra
Beginner's Sinatra
 
Evolving Software with Moose
Evolving Software with MooseEvolving Software with Moose
Evolving Software with Moose
 
Crystal: Fundamentos, objetivos y desafios - Cacic 2019
Crystal: Fundamentos, objetivos y desafios - Cacic 2019Crystal: Fundamentos, objetivos y desafios - Cacic 2019
Crystal: Fundamentos, objetivos y desafios - Cacic 2019
 
Barcelona 2010 hidden_features
Barcelona 2010 hidden_featuresBarcelona 2010 hidden_features
Barcelona 2010 hidden_features
 
A Blink Into The Rails Magic
A Blink Into The Rails MagicA Blink Into The Rails Magic
A Blink Into The Rails Magic
 
An introduction to Ruby
An introduction to RubyAn introduction to Ruby
An introduction to Ruby
 
Introduction to CoffeeScript
Introduction to CoffeeScriptIntroduction to CoffeeScript
Introduction to CoffeeScript
 
Dario Faggioli - Virtualization in the age of speculative execution HW bugs
Dario Faggioli - Virtualization in the age of speculative execution HW bugsDario Faggioli - Virtualization in the age of speculative execution HW bugs
Dario Faggioli - Virtualization in the age of speculative execution HW bugs
 
Moose
MooseMoose
Moose
 
Ruby - Uma Introdução
Ruby - Uma IntroduçãoRuby - Uma Introdução
Ruby - Uma Introdução
 
Trio of Gems
Trio of GemsTrio of Gems
Trio of Gems
 
Tame your Infrastructure with Puppet
Tame your Infrastructure with PuppetTame your Infrastructure with Puppet
Tame your Infrastructure with Puppet
 
My Adventures In Objective-C (A Rubyists Perspective)
My Adventures In Objective-C (A Rubyists Perspective)My Adventures In Objective-C (A Rubyists Perspective)
My Adventures In Objective-C (A Rubyists Perspective)
 

Similaire à Your Library Sucks, and why you should use it.

jQuery Anti-Patterns for Performance
jQuery Anti-Patterns for PerformancejQuery Anti-Patterns for Performance
jQuery Anti-Patterns for PerformanceAndrás Kovács
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
[FT-7][snowmantw] How to make a new functional language and make the world be...
[FT-7][snowmantw] How to make a new functional language and make the world be...[FT-7][snowmantw] How to make a new functional language and make the world be...
[FT-7][snowmantw] How to make a new functional language and make the world be...Functional Thursday
 
Everything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-insEverything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-insAndrew Dupont
 
5 Tips for Better JavaScript
5 Tips for Better JavaScript5 Tips for Better JavaScript
5 Tips for Better JavaScriptTodd Anglin
 
JavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good PartsJavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good PartsKonrad Malawski
 
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...Doug Jones
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e bigAndy Peterson
 
Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.Alberto Naranjo
 
Why Every Tester Should Learn Ruby
Why Every Tester Should Learn RubyWhy Every Tester Should Learn Ruby
Why Every Tester Should Learn RubyRaimonds Simanovskis
 
Building android apps with kotlin
Building android apps with kotlinBuilding android apps with kotlin
Building android apps with kotlinShem Magnezi
 
Ember background basics
Ember background basicsEmber background basics
Ember background basicsPhilipp Fehre
 

Similaire à Your Library Sucks, and why you should use it. (20)

"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues
 
jQuery Anti-Patterns for Performance
jQuery Anti-Patterns for PerformancejQuery Anti-Patterns for Performance
jQuery Anti-Patterns for Performance
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
[FT-7][snowmantw] How to make a new functional language and make the world be...
[FT-7][snowmantw] How to make a new functional language and make the world be...[FT-7][snowmantw] How to make a new functional language and make the world be...
[FT-7][snowmantw] How to make a new functional language and make the world be...
 
Everything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-insEverything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-ins
 
5 Tips for Better JavaScript
5 Tips for Better JavaScript5 Tips for Better JavaScript
5 Tips for Better JavaScript
 
Java 8: the good parts!
Java 8: the good parts!Java 8: the good parts!
Java 8: the good parts!
 
JavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good PartsJavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good Parts
 
Clipboard support on Y! mail
Clipboard support on Y! mailClipboard support on Y! mail
Clipboard support on Y! mail
 
JavaScript ES6
JavaScript ES6JavaScript ES6
JavaScript ES6
 
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
 
All of javascript
All of javascriptAll of javascript
All of javascript
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 
JavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talkJavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talk
 
Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.
 
Why Every Tester Should Learn Ruby
Why Every Tester Should Learn RubyWhy Every Tester Should Learn Ruby
Why Every Tester Should Learn Ruby
 
Building android apps with kotlin
Building android apps with kotlinBuilding android apps with kotlin
Building android apps with kotlin
 
Ember background basics
Ember background basicsEmber background basics
Ember background basics
 
Demystifying Maven
Demystifying MavenDemystifying Maven
Demystifying Maven
 

Plus de Peter Higgins (9)

Jsconf.us.2013
Jsconf.us.2013Jsconf.us.2013
Jsconf.us.2013
 
has("builds")
has("builds")has("builds")
has("builds")
 
has.js
has.jshas.js
has.js
 
Just JavaScript
Just JavaScriptJust JavaScript
Just JavaScript
 
Txjs
TxjsTxjs
Txjs
 
dojo.things()
dojo.things()dojo.things()
dojo.things()
 
dojo.Patterns
dojo.Patternsdojo.Patterns
dojo.Patterns
 
Trimming The Cruft
Trimming The CruftTrimming The Cruft
Trimming The Cruft
 
Zero To Dojo
Zero To DojoZero To Dojo
Zero To Dojo
 

Dernier

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 

Dernier (20)

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 

Your Library Sucks, and why you should use it.

  • 1. YOUR LIBRARY SUCKS. jsconf.eu :: 25 Sept 2010 :: Peter Higgins
  • 2. BUT YOU SHOULD USE IT. jsconf.eu :: 25 Sept 2010 :: Peter Higgins
  • 3. Me. Dojo Toolkit Project Lead JavaScript Engineer @joost / Adconion Blogs Infrequently :: http://higginsforpresident.net Codes @GitHub :: http://github.com/phiggins42 Twitter: @phiggins Beer Drinking Expert
  • 4. It’s Just JavaScript TM Lovable, Simple Self Healing Promiscuous Ubiquitous
  • 5. The Good Parts Context :: apply/call/hitch/partial AOP, FTW. (duck punch...) Prototypes, also FTW Module Loading (/me jokes)
  • 6. The Bad Parts Date() :: designed with evil. The DOM :: also designed with evil. with() and eval() :: allegedly evil.
  • 7. Teh Libraries Dojo YUI Mootools / Prototype FuseJS (?) EmbedJS (?) jQuery Your own
  • 9. Libraries are a crutch Learn JavaScript first Know enough to dislike parts Supplement those parts Don’t be afraid of the word `prototype` If you don’t know $.fn === $.prototype, quit (or learn)
  • 10. PROMISCUOUS Also known as Loose Typing
  • 12. BASIC AOP <3 // I can fix anything: var oldfunction = some.oldFunction; some.oldFunction = function(){ oldfunction.apply(some, arguments); // closures, ftw. }
  • 13. Philosophically Fixes on the Natives vs Namespaced fixes SomeString.trim() vs mylibrary.trim(SomeString) mylibrary = {}; mylibrary.trim = String.prototype.trim ? function(str){ return str.trim(); } : function(str){ /* do the “fun” stuff */ };
  • 14. Bind/Curry/Whatever Context manipulation, FTW mylibrary.bind = Function.prototype.bind ? function(fn, context){ return fn.bind(context); } : function(fn, context){ return function(){ return fn.apply(context, arguments); } }
  • 16. DON’T DO THIS: $(“div button#bar”).click(function(){ $(‘#bam’).addClass(“bar”); $(‘#bam’).css(“width”, “200px”) $(‘#bam’).animate({ width: “+=100” }) }).click();
  • 17. To be fair ... // easy to write bad code in any library: var $ = dojo.query; $(“div button#bar”).onclick(function(){ $(‘#bam’).addClass(“bar”); $(‘#bam’).css(“width”, “200px”) $(‘#bam’).animate({ width: 300 }) }).trigger(‘click’);
  • 18. Why not: var clicker = function(){ $(“#bam”) .addClass(“bar”) .css({ width:”200px” }) .animate({ width:”300px” }) } $(“#bar”).click(clicker); clicker();
  • 19. UBIQUITOUS “But can it run JavaScript?”
  • 20. Device Penetration Browsers, Now Desktop, Mobile, Device Server Rhino V8 Spidermonkey
  • 22. COMMONJS is piggybacking.
  • 23. CommonJS Modules should be in the language, not here. Forgot about the browser (see: Modules) Though has nothing to do with the DOM A bit late? Only more time will tell.
  • 24. STANDARDS. Yep. We (kinda) have them.
  • 25. MDC: Array.prototype Array.forEach / map / filter / indexOf / etc etc None of us handle sparse arrays to spec jQuery.map vs jQuery().map offends my senses dojo.map(ar, “return item * 2”) is too much magic
  • 26. “Portability” [1,2,3].forEach(function(item, index){ ... }, context); dojo.forEach([1,2,3], function(item, index){ ... }, context); jQuery.each([1,2,3], function(index){ /* this == item */ }); Y.Array.each([1,2,3], function(item, index){ ... }, context) Fuse.win([1,2,3], function(item, index){ ... }, context);
  • 27. MDC: Fn.proto.bind “this” is important. var obj = { counter:0, inc: function(howmuch){ this.counter += howmuch || 0; } }; var pfn = obj.inc.bind(obj, 5); // native, moo, proto way var dfn = dojo.hitch(obj, “inc”, 5), // dojo var dfn2 = dojo.hitch(obj, obj.inc, 5); // dojo is backwards var jfn = jQuery.proxy(obj, “inc”); // so is jq. only w/ strings (also can’t pass args) var jfn2 = jQuery.proxy(obj.inc, obj); // this is just plain inconsistent (no args here either)
  • 28. I’M MISSING THE POINT? No, i’m not being clear.
  • 29. Your library sucks, still. I’m a grumpy old man. </rant> No compelling reason for YOU not to use them If you understand what it’s doing If you don’t MIX Non-trivial tasks Portability
  • 30. Library Benefits Deferred development cost Open Source / Many Eyes Battle-tested Common / Consistent APIs
  • 31. I WANT TO CHANGE TOPICS Really. Let’s move forward, instead.
  • 32. Propose: CommonBrowserJS Reduce what we’ve learned over the years Common Library to build upon No Magic, Pure Standards No UA sniffs, pure `feature detection` Can load CommonJS modules/packages Try to be agnostic? Back to Dojo beginnings.
  • 33. Small Problems are Easy MDC / ECMA standards are easy. What next? Modularity Stability (regressions, deprecation, sane versioning) Localization/Internationalization? (l10n, i18n)
  • 34. First pass: has.js Agnostic Core pure Feature Detection framework API not as important as converging on test implementations Naming shit is hard.
  • 35. DOJO ALREADY DID IT. @dojodidit - Really, We probably have.
  • 36. DISCUSS. Done talking. Ask questions if you like.
  • 37. AAAAND THANKS. #jsconfeu FTW, 2010 - enjoy the rest of the conference.

Notes de l'éditeur