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
Deep Dive into ~/.claude/projects
hiragram
8
1.5k
たった 1 枚の PHP ファイルで実装する MCP サーバ / MCP Server with Vanilla PHP
okashoi
1
190
GoのGenericsによるslice操作との付き合い方
syumai
3
690
既存デザインを変更せずにタップ領域を広げる方法
tahia910
1
240
Select API from Kotlin Coroutine
jmatsu
1
190
ruby.wasmで多人数リアルタイム通信ゲームを作ろう
lnit
2
270
エンジニア向け採用ピッチ資料
inusan
0
160
WindowInsetsだってテストしたい
ryunen344
1
190
AIエージェントはこう育てる - GitHub Copilot Agentとチームの共進化サイクル
koboriakira
0
380
なぜ適用するか、移行して理解するClean Architecture 〜構造を超えて設計を継承する〜 / Why Apply, Migrate and Understand Clean Architecture - Inherit Design Beyond Structure
seike460
PRO
1
690
関数型まつりレポート for JuliaTokai #22
antimon2
0
150
第9回 情シス転職ミートアップ 株式会社IVRy(アイブリー)の紹介
ivry_presentationmaterials
1
240
Featured
See All Featured
Balancing Empowerment & Direction
lara
1
370
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
20k
Intergalactic Javascript Robots from Outer Space
tanoku
271
27k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
181
53k
Faster Mobile Websites
deanohume
307
31k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
700
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Music & Morning Musume
bryan
46
6.6k
Speed Design
sergeychernyshev
32
1k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3k
Git: the NoSQL Database
bkeepers
PRO
430
65k
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!