SlideShare a Scribd company logo
prettier-ruby? 

ruby formatters overview
"Good programmers" are those 

who aleady have learned a set of rules that
ensures good style; (…)

The Elements of Programming Style 1974
Piotr Wasiak
Ruby programming style history
At the beginning there was chaos
We got some ruby styling guides
CodeReview focused sometimes more on style than the
logic
We got linters (PR services, overcommit, text-editor plugins)
Should we now follow e.g. JS world 

with using automatic formatters?

Code formatter
It enforces a consistent style 

by parsing your code and 

re-printing it with its own rules
✴ Rubocop
✴ Rufo
✴ Prettifier
✴ Rubyfmt
RIP
✤ Ruby Script Beautifier (2008)
✤ eden (2011)
✤ ruby-beautify2 (fork: 01. 2018)
Formatters ruby
Parsers
Ripper to STD LIB - written in C so
faster



ruby-parse to CLI do gem parser:

production-ready written in pure
Ruby. It recognises as much or more
code than Ripper, Melbourne,
JRubyParser or ruby_parser, and is
Rubocop
heavy, but very good advanced configuration
parameters to use as formatter:

-a --auto-correct Auto-correct offenses.
--safe-auto-correct Run auto-correct only when it's safe.
-x, --fix-layout
Run only layout cops, with auto-correct on.
(currently 81 cops)
--only-guide-cops
Run only cops for rules that link to a style
guide.
--only [COP1,COP2,...] Run only the given cop(s).
Ruby test
by rubocop
RuFo
Not a simple find and replace one, very fast
Was implemented in a similar fashion to Crystal's
formatter.



Started 2 years ago, but currently is getting less
updates / issues than prettier



There are some problems with chained heredocs, (…)



config options: trailing_commas, parens_in_def
Ruby test
by Rufo
“uglifier” part
Rufo is fast
Less strict than prettier, but it seems that it formats less
Rubyfmt
Fast, integrated with shell (no ruby gem)


Project development started 5 months ago


no config options. 



No max chars/line, removes additional enters



Broke on some files (also especially @ rspec specs)
Fast per file - 175 ms

many files at once is not a case
Ruby test
by Rubyfmt



Rubyfmt problems
user_context&.role&.in? %w(Admin Company)
AddActivityService.new(candidate: candidate, **keywords).call
expect(email.body).to match 'His/her search can be shown'
Prettier-ruby
Fast and opinionated in many languages as plugin to
text editors
Ruby plugin development started 7 months ago


config options:

printWidth, tabWidth, addTrailingCommas,
inlineConditionals, inlineLoops, preferHashLabels,
preferSingleQuotes
Fast per file - 170 ms

many files at once is not a case
Ruby test
by Prettier



*designed by them : )
“uglifier” part
Prettier problems
Speed
command User time
System
time
Total time
rufo ruby.rb 0.14s 0.05s 0.202s
./node_modules/.bin/
prettier
0.38s 0.08s 0.462s
Rubocop -a 1.09s 0.25s 1.349s
command User time
System
time
Total time
rufo **/*.rb 1.16s 0.20s 1.379s
Rubocop -a 3.18s 0.41s 3.635s
Rubocop -a 

—cache false
14.34s 0.64s 15.174s
./node_modules/.bin/
prettier
36.23s 13.51s 51.606s
Format rails api project LOC: 2644 Format 1 file (ruby test)
Rubyfmt - total time 30.s with some
errors during parsing
Formatter triggers
✓ On file save
✓ On code paste
✓ On demand
Sum up: How to live?
Use still linter
Chillout with code style wars
Try prettier formatter on demand/paste 

and report issues on GitHub
Thanks for listening

More Related Content

What's hot (19)

PDF
Ruby and Rails short motivation
jistr
 
PDF
If programming languages were hot babes
Greg Moreno
 
PPTX
Extending Ruby using C++
Tristan Penman
 
PDF
Metaprogramming in Ruby
jonromero
 
PPS
Ruby Introduction
Prabu D
 
PDF
Ola Bini J Ruby Power On The Jvm
deimos
 
PDF
Lets get started by Leif Gensert
Rails Girls MUC
 
PDF
Ruby an overall approach
Felipe Schmitt
 
PDF
FunScript: Why bother?
Alfonso Garcia-Caro
 
KEY
Using Aspects for Language Portability (SCAM 2010)
lennartkats
 
PDF
The Spoofax Language Workbench (SPLASH 2010)
lennartkats
 
PPT
Jug dynamic languages_in_jvm
Dmitry Buzdin
 
KEY
Ruby On Rails Overview
jonkinney
 
KEY
Language Engineering in the Cloud
lennartkats
 
KEY
Wed Development on Rails
James Gray
 
PPT
Building scalable and language independent java services using apache thrift
Talentica Software
 
PPTX
Coffee scripts with rails
Devilal Dheer
 
PPTX
IronRuby: Ruby on the .NET Platform
Andre John Cruz
 
Ruby and Rails short motivation
jistr
 
If programming languages were hot babes
Greg Moreno
 
Extending Ruby using C++
Tristan Penman
 
Metaprogramming in Ruby
jonromero
 
Ruby Introduction
Prabu D
 
Ola Bini J Ruby Power On The Jvm
deimos
 
Lets get started by Leif Gensert
Rails Girls MUC
 
Ruby an overall approach
Felipe Schmitt
 
FunScript: Why bother?
Alfonso Garcia-Caro
 
Using Aspects for Language Portability (SCAM 2010)
lennartkats
 
The Spoofax Language Workbench (SPLASH 2010)
lennartkats
 
Jug dynamic languages_in_jvm
Dmitry Buzdin
 
Ruby On Rails Overview
jonkinney
 
Language Engineering in the Cloud
lennartkats
 
Wed Development on Rails
James Gray
 
Building scalable and language independent java services using apache thrift
Talentica Software
 
Coffee scripts with rails
Devilal Dheer
 
IronRuby: Ruby on the .NET Platform
Andre John Cruz
 

Similar to Ruby formatters (20)

PDF
Ruby formatters 2019
Poznań Ruby User Group
 
ODP
Ruby
Aizat Faiz
 
PDF
Ruby tutorial
Ánh Nguyễn
 
PPTX
Ievgenii Narovlianskyi - Ruby is not just a gem
SeniorDevOnly
 
PDF
ruby_vs_perl_and_python
tutorialsruby
 
PDF
ruby_vs_perl_and_python
tutorialsruby
 
ODP
Ruby style
Bethany Rentz
 
PPT
eJADA web development the Ruby way
Mustafah Elbanna
 
PDF
How to check valid Email? Find using regex.
Poznań Ruby User Group
 
PDF
Ruby tutorial
HarikaReddy115
 
PDF
Let's Learn Ruby - Basic
Eddie Kao
 
KEY
Intro to Ruby (and RSpec)
Blazing Cloud
 
PDF
Book of ruby
phongbk1609
 
PDF
The secret of programming language development and future
Hiroshi SHIBATA
 
PDF
How to Begin to Develop Ruby Core
Hiroshi SHIBATA
 
ODP
Ruby for perl developers
Ido Kanner
 
PDF
Ruby training day1
Bindesh Vijayan
 
DOCX
Page List & Sample Material (Repaired)
Muhammad Haseeb Shahid
 
PPTX
Ruby for .NET developers
Max Titov
 
PDF
Ruby Best Practices Increase Your Productivity Write Better Code 1st Edition ...
forbahchonev
 
Ruby formatters 2019
Poznań Ruby User Group
 
Ruby tutorial
Ánh Nguyễn
 
Ievgenii Narovlianskyi - Ruby is not just a gem
SeniorDevOnly
 
ruby_vs_perl_and_python
tutorialsruby
 
ruby_vs_perl_and_python
tutorialsruby
 
Ruby style
Bethany Rentz
 
eJADA web development the Ruby way
Mustafah Elbanna
 
How to check valid Email? Find using regex.
Poznań Ruby User Group
 
Ruby tutorial
HarikaReddy115
 
Let's Learn Ruby - Basic
Eddie Kao
 
Intro to Ruby (and RSpec)
Blazing Cloud
 
Book of ruby
phongbk1609
 
The secret of programming language development and future
Hiroshi SHIBATA
 
How to Begin to Develop Ruby Core
Hiroshi SHIBATA
 
Ruby for perl developers
Ido Kanner
 
Ruby training day1
Bindesh Vijayan
 
Page List & Sample Material (Repaired)
Muhammad Haseeb Shahid
 
Ruby for .NET developers
Max Titov
 
Ruby Best Practices Increase Your Productivity Write Better Code 1st Edition ...
forbahchonev
 
Ad

More from Visuality (20)

PPTX
3 issues that made 30 test workers take 40 minutes
Visuality
 
PPTX
Czego nie robić przy pisaniu testów
Visuality
 
PDF
Introduction to Domain-Driven Design in Ruby on Rails
Visuality
 
PDF
Active Record .includes - do you use it consciously?
Visuality
 
PDF
Introduction to Event Storming
Visuality
 
PDF
Jak programowanie może pomóc na co dzień?
Visuality
 
PDF
SVG Overview - How To Draw, Use and Animate
Visuality
 
PDF
How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...
Visuality
 
PPTX
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał Łęcicki
Visuality
 
PPTX
What is NOT machine learning - Burak Aybar
Visuality
 
PPTX
Do you really need to reload?
Visuality
 
PDF
How to check valid email? Find using regex(p?)
Visuality
 
PPTX
Fantastic stresses and where to find them
Visuality
 
PDF
Fuzzy search in Ruby
Visuality
 
PDF
Rfc process in visuality
Visuality
 
PDF
GraphQL in Ruby on Rails - basics
Visuality
 
PPTX
Consumer Driven Contracts
Visuality
 
PDF
How do we use CircleCi in Laterallink?
Visuality
 
PDF
React Native - Short introduction
Visuality
 
PDF
Risk in project management
Visuality
 
3 issues that made 30 test workers take 40 minutes
Visuality
 
Czego nie robić przy pisaniu testów
Visuality
 
Introduction to Domain-Driven Design in Ruby on Rails
Visuality
 
Active Record .includes - do you use it consciously?
Visuality
 
Introduction to Event Storming
Visuality
 
Jak programowanie może pomóc na co dzień?
Visuality
 
SVG Overview - How To Draw, Use and Animate
Visuality
 
How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...
Visuality
 
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał Łęcicki
Visuality
 
What is NOT machine learning - Burak Aybar
Visuality
 
Do you really need to reload?
Visuality
 
How to check valid email? Find using regex(p?)
Visuality
 
Fantastic stresses and where to find them
Visuality
 
Fuzzy search in Ruby
Visuality
 
Rfc process in visuality
Visuality
 
GraphQL in Ruby on Rails - basics
Visuality
 
Consumer Driven Contracts
Visuality
 
How do we use CircleCi in Laterallink?
Visuality
 
React Native - Short introduction
Visuality
 
Risk in project management
Visuality
 
Ad

Recently uploaded (20)

PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PPTX
Knowledge Representation : Semantic Networks
Amity University, Patna
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PPTX
Thermal runway and thermal stability.pptx
godow93766
 
PPT
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PPTX
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
DOCX
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PPTX
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
PPTX
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
Knowledge Representation : Semantic Networks
Amity University, Patna
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
Thermal runway and thermal stability.pptx
godow93766
 
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
Design Thinking basics for Engineers.pdf
CMR University
 

Ruby formatters

  • 1. prettier-ruby? 
 ruby formatters overview "Good programmers" are those 
 who aleady have learned a set of rules that ensures good style; (…)
 The Elements of Programming Style 1974 Piotr Wasiak
  • 2. Ruby programming style history At the beginning there was chaos We got some ruby styling guides CodeReview focused sometimes more on style than the logic We got linters (PR services, overcommit, text-editor plugins) Should we now follow e.g. JS world 
 with using automatic formatters?

  • 3. Code formatter It enforces a consistent style 
 by parsing your code and 
 re-printing it with its own rules
  • 4. ✴ Rubocop ✴ Rufo ✴ Prettifier ✴ Rubyfmt RIP ✤ Ruby Script Beautifier (2008) ✤ eden (2011) ✤ ruby-beautify2 (fork: 01. 2018) Formatters ruby
  • 5. Parsers Ripper to STD LIB - written in C so faster
 
 ruby-parse to CLI do gem parser:
 production-ready written in pure Ruby. It recognises as much or more code than Ripper, Melbourne, JRubyParser or ruby_parser, and is
  • 6. Rubocop heavy, but very good advanced configuration parameters to use as formatter:
 -a --auto-correct Auto-correct offenses. --safe-auto-correct Run auto-correct only when it's safe. -x, --fix-layout Run only layout cops, with auto-correct on. (currently 81 cops) --only-guide-cops Run only cops for rules that link to a style guide. --only [COP1,COP2,...] Run only the given cop(s).
  • 8. RuFo Not a simple find and replace one, very fast Was implemented in a similar fashion to Crystal's formatter.
 
 Started 2 years ago, but currently is getting less updates / issues than prettier
 
 There are some problems with chained heredocs, (…)
 
 config options: trailing_commas, parens_in_def
  • 11. Rufo is fast Less strict than prettier, but it seems that it formats less
  • 12. Rubyfmt Fast, integrated with shell (no ruby gem) 
 Project development started 5 months ago 
 no config options. 
 
 No max chars/line, removes additional enters
 
 Broke on some files (also especially @ rspec specs) Fast per file - 175 ms
 many files at once is not a case
  • 14. Rubyfmt problems user_context&.role&.in? %w(Admin Company) AddActivityService.new(candidate: candidate, **keywords).call expect(email.body).to match 'His/her search can be shown'
  • 15. Prettier-ruby Fast and opinionated in many languages as plugin to text editors Ruby plugin development started 7 months ago 
 config options:
 printWidth, tabWidth, addTrailingCommas, inlineConditionals, inlineLoops, preferHashLabels, preferSingleQuotes Fast per file - 170 ms
 many files at once is not a case
  • 19. Speed command User time System time Total time rufo ruby.rb 0.14s 0.05s 0.202s ./node_modules/.bin/ prettier 0.38s 0.08s 0.462s Rubocop -a 1.09s 0.25s 1.349s command User time System time Total time rufo **/*.rb 1.16s 0.20s 1.379s Rubocop -a 3.18s 0.41s 3.635s Rubocop -a 
 —cache false 14.34s 0.64s 15.174s ./node_modules/.bin/ prettier 36.23s 13.51s 51.606s Format rails api project LOC: 2644 Format 1 file (ruby test) Rubyfmt - total time 30.s with some errors during parsing
  • 20. Formatter triggers ✓ On file save ✓ On code paste ✓ On demand
  • 21. Sum up: How to live? Use still linter Chillout with code style wars Try prettier formatter on demand/paste 
 and report issues on GitHub