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.7k
¿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
370
Migrando a Microservicios
janogonzalez
1
300
Extracting services from a monolith
janogonzalez
3
250
¿Después de 10 años, realmente entiendo esta industria?
janogonzalez
3
460
Microservices in Practice
janogonzalez
7
660
Two programmers in one
janogonzalez
1
160
The Bipolar Programmer
janogonzalez
4
600
Ruby for your two internal programmers
janogonzalez
4
250
Ruby for Java minds
janogonzalez
4
1.1k
Other Decks in Programming
See All in Programming
VS Code Update for GitHub Copilot
74th
1
320
deno-redisの紹介とJSRパッケージの運用について (toranoana.deno #21)
uki00a
0
140
XP, Testing and ninja testing
m_seki
3
180
Deep Dive into ~/.claude/projects
hiragram
8
1.4k
DroidKnights 2025 - 다양한 스크롤 뷰에서의 영상 재생
gaeun5744
3
320
0626 Findy Product Manager LT Night_高田スライド_speaker deck用
mana_takada
0
100
Gleamという選択肢
comamoca
6
760
技術同人誌をMCP Serverにしてみた
74th
0
290
なんとなくわかった気になるブロックテーマ入門/contents.nagoya 2025 6.28
chiilog
1
190
既存デザインを変更せずにタップ領域を広げる方法
tahia910
1
240
PostgreSQLのRow Level SecurityをPHPのORMで扱う Eloquent vs Doctrine #phpcon #track2
77web
2
300
すべてのコンテキストを、 ユーザー価値に変える
applism118
2
760
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
Statistics for Hackers
jakevdp
799
220k
We Have a Design System, Now What?
morganepeng
53
7.7k
Balancing Empowerment & Direction
lara
1
370
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Become a Pro
speakerdeck
PRO
28
5.4k
BBQ
matthewcrist
89
9.7k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
For a Future-Friendly Web
brad_frost
179
9.8k
Automating Front-end Workflow
addyosmani
1370
200k
Scaling GitHub
holman
459
140k
Designing for Performance
lara
609
69k
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!