RubyConf 2014 - Day 1
by
Keynote - Yukihiro “Matz” - “Feeding the Sharks”
- OSS developer community like sharks
- move or die, move somewhere else more interesting
- History of rubyconf announcement/discussions
- exciting new but uncertain ideas
- Ruby 3
- (Still lots coming in 2.2)
- Concurrency
- GIL
- JIT
- LLVM?
- Static typing
- ?
- Scala, Dart, Typescript, ECMA6, Go
- (python has hints, but not checked) - mypy has optional checker
- Performance
- do we need static typing for speed? Maybe JIT is enough
- Compile Time checking
- static analysis, refactoring
- Documentation
- better than comments/yard
- why not
- duck typing
- optional static to allow overload, but ended up a mess
- ruby should keep being ruby, w/ duck typing
- DRY
- would restrict require, define_method, method_missing (meta programming)
- -> Soft Typing
- type inference
- Type represented as set of methods signatures (or class/module, which are a set)
- closer communication between compiler and user (ide) - knows methods needed
- fallback
- static analyzer
Advanced - I <3 Promises in Ruby - Dinshaw Gobhai - @tallfriend
- https://github.com/dinshaw/promises-in-ruby - https://github.com/dinshaw/promises
- fn -> promise (respond_to :then) (lambdas)
- Uses Thread.new
- Fulfill and Reject
- in promise block, call fufill if ok, call reject if rejected
- uses method() turns method names into lambda
- catches all errors, calls reject
- All and Any on lists of promises (from spec)
- Return a promise immediately
- fulfill or reject
- chainable
Advanced - Letting Concurrency help you today - Richard Bishop - @rbondev
- Great language for getting feet wet in concurrency
- Concurrency about dealing with lots of things at once, Parallelism is doing a lot of things at once
- parallel - overlapping, no communiciation, concurrent - communication
- Primitives - Processes, Threads, Events
- Threads
- Libraries:
- Celluloid - Actor and Object - pass messages - pools and supervisors
- Actor -> mailbox -> messages (message queue)
- Sidekiq -
- Sucker_Punch - in memory
- Puma
- Celluloid - Actor and Object - pass messages - pools and supervisors
- Concurrent Design
- Elixr
- Erlang VM, Concurrency as paradigm - actors and message passing
- Supervision tree -
- (SOA) - separate processes, message queue
- gives modularity
- now coupled over the network, rely on reliability
- Defending ruby
- overall a bit too high level for an Advanced track talk. Wanted more actual solutions. Sounds like music would have been better (@lsegal Loren Segal)
Future proofing your 3rd party integrations - @idlehands - Jeffery Matthias
- Sendgrid - PHP app being refactored into Ruby (not Go, lol) - PivotalLabs helped them
- Keep 3rd party logic out of our code
- Make 3rd party behavior predictable
- Make 3rd party replacable
- Adapter - just a gem. use Gemfile
gem '', path: 'relativepath'
- Still wrap your own adapter around their gem
- Clearly define internal vocabulary
- Use internal vocab, adapt to external (prefer internal as needed)
- Use Data Transfer Object (put necessary parameters, validate attributes)
- Abstract Service - make interface for the adapter
- Adadapter/Interface (gem) - separate from implementation, contains DTO and abstracts. Helps enforce generic use
- gem - uptyped - type checking etc
- use sandbox when available
- create a fake service or user VCR - has to be consistently maintained
- use dependency injection - pass the class to be used underneath
- CI should hit the sandbox / real code regularly
- Flexibility + separation of concerns
- Portability (messgage bus, etc)
- DTO helps
- consistent Abstract Interface
GOING EVERGREEN - Kane Baccigalupi - @rubyghetto
- Greenfield - new and bright and interesting and easy to work with
- Brownfield - old project, ongoing maintenance
- how to get it green
- SOLID
- Single Responsibility - should only change for one reason
- Open / Closed - open for extension, closed for modification (inheritance)
- Liskov (Substitution) - parent more specific than child
- Interface segregation -
- Dependency Inversion - high level should not depend on low level. abstractions should not depend on details (dependency injection)
- help respond to change. rules are tightly coupled. motivated by change
- great guidelines if you know it already
- Sandi’s 5 Rules
- STD2
- Small - small classes, small methods. easier to read
- Test drive it
- D2 - Dependency Inject, Law of Demeter (low communication)
- Rules dont make code, teams make code
- Code is about communication
- affective metrics (hiring)
- communicative
- enjoyable
- motivated
- self aware
- impostor syndrome vs arrogance
- learning style
- impact control (how my behavior impact others)
- design - refactoring instinct
- faith - ?
Fighting Bugs with Hacks - Paul Gross - @pgr0ss
- If debugging is the process of removing bugs, then programming must be the process of putting them in - E. Dijkstra
- Testing is good for showing there are bugs, but bad at proving their absence
- Fail Fast (Martin Fowler)
- Structure systems to reduce severity
- Hazard mitigation
- add code to check things that shouldnt be needed, but would mitigate severity of bug
- check a few important things
- figure out invariants of system
- customer_id, patient_id
- add checks, fail fast, add alert
- scoped find hook - force ‘customers’ to be scoped to merchant (braintree)
- can bypass with special parameter (safety)
- focus on validity of data
- doublecheck calculations and allow for rerun
- write checks outside of normal flow of code
- keep very simple
- alerts on num transactions (old ones), high numbers, latency
- hacks at development time
- safe migrations
- unsafemigrationerror (alias old method)
- add/remove
- unsafe prefix to bypass
- TODO find gem for this?
- sanity specs
- doublecheck ids public_id indexes
- indexes on relations? automatic?
ActiveRecord.tables.indexes
- automated checks on crazy / dangerous operations
Your bright metaprogramming future - Betsy Haibel \w Optoro @betsythemuffin
- not skynet or magical or perl (lol)
- code that treats the program as just data
- Object.send(method, *args)
- sends a message to the object
- breaks grep (hard to find cause method names are obsured)
- cyclomatic complexity - paths that can take through code
- limit scope of dynamic method calls, keep closer to the code its calling
- method_missing
- need respond_to_missing
- call super (chaining)
- method_missing is slow by itself - define_method once found?
- if you’re gunna do this, maybe predefine these instead
- consider using a different paradigm
- good for objects (OpenStruct), delegators (Delegator mixin)?
- define_method
- performance at load is pretty slow - causes class / method table rebuild
- wrap in a method (
define_...
) so can be tested/redefined - Put these into an anonymous module?
- hooks
- normal: inherited, included, extended
- weird: method_added, method_removed, singleton_*
- dont?!
- consider using a simple macro and using a separate object