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
360
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
160
The Bipolar Programmer
janogonzalez
4
590
Ruby for your two internal programmers
janogonzalez
4
240
Ruby for Java minds
janogonzalez
4
1.1k
Other Decks in Programming
See All in Programming
カオスに立ち向かう小規模チームの装備の選択〜フルスタックTSという装備の強み _ 弱み〜/Choosing equipment for a small team facing chaos ~ Strengths and weaknesses of full-stack TS~
bitkey
1
130
開発者フレンドリーで顧客も満足?Platformの秘密
algoartis
0
180
今話題のMCPサーバーをFastAPIでサッと作ってみた
yuukis
0
110
AIコーディングエージェントを 「使いこなす」ための実践知と現在地 in ログラス / How to Use AI Coding Agent in Loglass
rkaga
4
1.2k
AWS Summit Hong Kong 2025: Reinventing Programming - How AI Transforms Our Enterprise Coding Approach
dwchiang
0
110
状態と共に暮らす:ステートフルへの挑戦
ypresto
3
1.1k
Global Azure 2025 @ Kansai / Hyperlight
kosmosebi
0
110
KawaiiLT 登壇資料 キャリアとモチベーション
hiiragi
0
160
スモールスタートで始めるためのLambda×モノリス(Lambdalith)
akihisaikeda
2
370
Lambda(Python)の リファクタリングが好きなんです
komakichi
4
240
生成AIで知るお願いの仕方の難しさ
ohmori_yusuke
1
100
Amazon CloudWatchの地味だけど強力な機能紹介!
itotsum
0
240
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
71
4.8k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
YesSQL, Process and Tooling at Scale
rocio
172
14k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.8k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.6k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
120
52k
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.8k
Bash Introduction
62gerente
612
210k
Building an army of robots
kneath
305
45k
A better future with KSS
kneath
239
17k
Designing for humans not robots
tammielis
253
25k
Build The Right Thing And Hit Your Dates
maggiecrowley
35
2.7k
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!