Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
¿Dónde están mis interfaces?
Search
Jano González
October 20, 2012
Programming
6
1.6k
¿Dónde están mis interfaces?
RubyConf Argentina 2012 - Charla de Ruby para programadores Java y C#
Jano González
October 20, 2012
Tweet
Share
More Decks by Jano González
See All by Jano González
Containerizing your monolith
janogonzalez
0
350
Migrando a Microservicios
janogonzalez
1
290
Extracting services from a monolith
janogonzalez
3
250
¿Después de 10 años, realmente entiendo esta industria?
janogonzalez
3
450
Microservices in Practice
janogonzalez
7
650
Two programmers in one
janogonzalez
1
150
The Bipolar Programmer
janogonzalez
4
590
Ruby for your two internal programmers
janogonzalez
4
240
Ruby for Java minds
janogonzalez
4
1k
Other Decks in Programming
See All in Programming
趣味全開のAITuber開発
kokushin
0
190
gen_statem - OTP's Unsung Hero
whatyouhide
1
200
SwiftUI API Design Lessons
niw
1
260
「影響が少ない」を自分の目でみてみる
o0h
PRO
2
1k
Chrome Extension Techniques from Hell
moznion
1
160
リアルタイムレイトレーシング + ニューラルレンダリング簡単紹介 / Real-Time Ray Tracing & Neural Rendering: A Quick Introduction (2025)
shocker_0x15
1
290
コンテナでLambdaをデプロイするときに知っておきたかったこと
_takahash
0
180
SEAL - Dive into the sea of search engines - Symfony Live Berlin 2025
alexanderschranz
1
130
これだけは知っておきたいクラス設計の基礎知識 version 2
masuda220
PRO
24
6.2k
「”誤った使い方をすることが困難”な設計」で良いコードの基礎を固めよう / phpcon-odawara-2025
taniguhey
0
120
AI Agents with JavaScript
slobodan
0
220
英語 × の私が、生成AIの力を借りて、OSSに初コントリビュートした話
personabb
0
190
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
328
21k
Faster Mobile Websites
deanohume
306
31k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.3k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
21k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Visualization
eitanlees
146
16k
Making the Leap to Tech Lead
cromwellryan
133
9.2k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.2k
Building a Modern Day E-commerce SEO Strategy
aleyda
40
7.2k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.1k
Transcript
¿DÓNDE ESTÁN MIS INTERFACES?
RUBY PARA PROGRAMADORES JAVA (Y C#)
0 EL CHARLISTA
@janogonzalez
HopIn
@dynlangchile
1 LA HISTORIA
JAPÓN 1993
·ͭͱΏ͖ͻΖ
YUKIHIRO MATSUMOTO
MATZ
“RUBY IS DESIGNED TO MAKE PROGRAMMERS HAPPY” - MATZ
LA MEZCLA Smalltalk Perl Lisp
EL RESULTADO
USA 2001
PICKAXE
DINAMARCA 2005
DAVID HEINEMEIER HANSSON
DHH
RAILS 1.0
CHILE 2010
JANO
“RUBY SE VE BUENO, ¿PERO CÓMO SE HACEN LAS INTERFACES?”
- JANO
Este slide se ha dejado en blanco de forma intencional
2 EL LENGUAJE
ES UN LENGUAJE DINÁMICO
SINTAXIS CONCISA Y EXPRESIVA
ORIENTADO A OBJETOS
CON PODEROSAS CUALIDADES DE METAPROGRAMACIÓN
ALGUNAS CARACTERÍSTICAS FUNCIONALES
3 ENTENDIENDO RUBY
SINTÁXIS Y CONVENCIONES
NombreDeClaseOModulo CONSTANTE @nombre_de_atributo @@atributo_de_clase $variable_global nombre_de_metodo metodo_peligroso! metodo_que_pregunta?
OBJETOS
TODOS LOS VALORES SON OBJETOS
"RubyConf Argentina".length(); Java
"RubyConf Argentina".length # => 18 Ruby
Arrays.sort(new String[] {"Hugo","Paco","Luis"}); Java
["Hugo","Paco","Luis"].sort # => ["Hugo","Luis","Paco"] Ruby
Math.abs(-100); Math.abs(new Integer(-100)); Java
-100.abs # => 100 Ruby
foo == null Java
foo.nil? # => true nil.nil? # => true Ruby
NIL OMG
nil.class # => NilClass
Date d = new Date(); Java
d = Date.new Ruby
POO A VECES OCULTA
HAY MUCHOS LITERALES
# Números 3 3.14 0b1000_1000
# Strings 'Hola RubyConf Argentina' "Hola #{conferencia}"
# Símbolos :name :+
# Arrays ['Hugo','Paco','Luis']
# Hashes { :nombre => 'Jano', :apellido => 'González' }
{ nombre: "Jano”, apellido: "González” }
# Expresiones Regulares /^[a-f]+$/
# Rangos 0..1 0...10 “a”..”z”
# Lambdas lambda { |n| n * 2 } ->(n){
n * 2 } ->(n=0){ n * 2 }
EN TODOS LADOS HAY MENSAJES
class Flojo def method_missing(method, *args, &block) puts "Alguien dijo que
hiciera esto: #{method}" end end f = Flojo.new f.tender_la_cama # => "Alguien dijo que hiciera esto: tender_la_cama"
MÉTODOS COMO OPERADORES
4 - 3 # => 1
4.send :-, 3 # => 1
Arrays.asList("Hugo","Paco", "Luis").remove("Luis"); Java
['Hugo','Paco','Luis'] - ['Luis'] # => ['Hugo','Paco'] Ruby
# Ejemplo Set def -(enum) dup.substract(enum) end
# Ejemplo Set require 'set' s = Set.new [1, 10,
100] #=> #<Set: {1, 10, 100}> s - [1] #=> #<Set: {10, 100}>
EXPRESIONES x+y-z
CASI TODO RETORNA UN VALOR
if (estado.equals("Feliz")) { cara = ":)"; } else if (estado.equals("Triste"))
{ cara = ":("; } else { cara = ":|"; } Java
face = case estado when “Feliz” then ":)" when “Triste”
then ":(" else ":|" end # => ":)" Ruby
case estado when “Feliz” then ":)" when “Triste” then ":("
else ":|" end # => ":)" Ruby
a = 3.14159 # => 3.14159
def foo “bar” end # => nil
# Ejemplo gema Sequel def schema @schema ||= get_db_schema end
BLOQUES
3.times do |i| puts i end # 0 # 1
# 2 # => 2 3.times { |i| puts i }
PROGRAMANDO DE FORMA DECLARATIVA
(1..10).select { |n| n.even? } # => [2, 4, 6,
8, 10] (1..10).select(&:even?) # => [2, 4, 6, 8, 10]
(1..100).map { |n| n*2 } (1..100).select { |n| (n %
3) == 0 } (1..100).reduce { |sum,n| sum + n } (1..100).reduce(:+)
AUMENTANDO LA FLUIDEZ
File.open('my.txt').each do |line| puts line if line =~ /jano/ end
DUCK TYPING
public interface DuckLike { Cuack cuack(); } ... public void
doSomething(DuckLike d) { d.cuack(); ... } Java
def do_something(obj) if obj.respond_to? :cuack obj.cuack ... else ... end
end Ruby
MONKEY PATCHING
class Range def even self.select(&:even?) end end (0..10).even # =>
[2, 4, 6, 8, 10]
MÓDULOS
MÓDULOS COMO NAMESPACES
module MyAPI class User ... end def self.configuration ... end
end
user = MyAPI::User.new puts MyAPI::configuration
MÓDULOS COMO MIXINS
module Model def persist ... end end
class Admin < User include Model ... end
3 HERRAMIENTAS
JARS Java
GEMS Ruby
$ ant Java
$ rake Ruby
$ mvn Java
$ gem $ bundle Ruby
Java
$ rbenv o $ rvm Ruby
BUSCANDO GEMAS
4 JRUBY
RUBY + JVM
LO MEJOR DE 2 MUNDOS
require 'java' java_import 'java.util.Date' d = Date.new d.to_gmt_string JRuby
Date d = new Date(); d.toGMTString(); Date.parse("20/03/1982"); Java
d = Date.new d.to_gmt_string Date::parse "20/03/1982" JRuby
MUCHAS OPCIONES DEPLOYMENT WEB
WARBLER
TRINIDAD
TORQUEBOX
PARAÍSO POLÍGLOTA
JRUBY + AKKA
JRUBY + NETTY
JRUBY + HADOOP
JRUBY + STORM
JRUBY + *
1.7.0 COMING SOON
5 LO QUE FALTÓ
EL MODELO DE OBJETOS METAPROGRAMACIÓN BLOQUES, PROCS Y LAMBDAS CHUNKY
BACON
NOS VEMOS EN RUBYCONF AR 2013
SÍ, LOS ESTOY MIRANDO A UDS ORGANIZADORES
6 CONCLUSIONES
ELIGE LA HERRAMIENTA ADECUADA
Y ÚSALA BIEN
7 ¡GRACIAS!