Why is Ruby not using REPL style?

It seems that Lisp and Clojure programmers often develop programs directly in REPL. Wed Clojure Development: IDE or REPL?

My question is: why is this approach not more common in Ruby, via irb ? Is it just cultural difference or are there structural (language-specific) reasons why REPL-oriented development is more common with Lisps than with languages ​​like Ruby and Python?

+6
ruby lisp clojure read-eval-print-loop
source share
7 answers
Syntax

Lisp seems to be very well suited for the combined approach of REPL and the source file. It is much easier to move code snippets programmatically when the textual restrictions for each form are clear.

+8
source share

I use Emacs for Clojure and Ruby and often load my ruby ​​modules in irb and play emacs interactively the same way I do REPL.

+2
source share

I think a lot of this has to do with editors who usually use rubies. I am using vim which does not have a great way to interact with REPL. Textmate is in the same boat (AFAIK). Emacs, Dr Racket, etc., On the other hand, everyone has a wonderful mechanism for interacting with REPL. I believe that Lispers will use these types of editors / environments.

+2
source share

Often running your unit tests is less effort than entering data using Ruby, the equivalent of REPL. Again, sometimes I have to add printf debugging to the code ...

+1
source share

Perhaps this will help:

  • interactive_editor is an IRB extension that adds the ability to open vim, emacs, MacVim, nano and TextMate and edit irb buffers.
  • irbtools includes interactive_editor along with some other nice additions.
  • Utility Belt is another IRB gem collection that extends its functionality and also includes something that allows you to edit the buffer.

I am an old school, so I usually have an open editor and irb working in a terminal window; Old habits die, you know. I use irbtools, but intend to switch to Utility Belt to see how it feels in comparison.

+1
source share

This is actually my way of developing Ruby.

Usually I write my code, then paste it into irb, adapt them, paste it again, etc.

Is there a way in Lisps to print the "current state" in which you developed the REPL style in a program? I think this is impossible in a ruby.

0
source share

I am not a Ruby developer. However, I believe that the reason is Proportional Transparency.

Most Clojure's idiomatic functions are pure functions that obey referential transparency. As a result, I personally find it much easier to test functions that are independent autonomous units, and they somewhat provide the goal of unit tests. Clojure being a highly destructed language, prefers most features to be stateless. It makes a clear distinction between code in which side effects occur, and states are maintained using various other alternatives such as var , refs , agents , atoms , etc., Keeping most of your code clean, side effect and link transparent .

I feel that any code structured around link-transparent and stateless functions will automatically benefit from REPL, whether in Ruby or any other programming language.

Although the CLI provided by another language will be equally useful for most practical purposes, the concept of Read, Eval, Print and Loop not the same in LISP as in any other language. Any non-homoiconic language non-homoiconic not have a READ phase, and it would just read a text representation or string, however in LISP, the READ phase can actually parse any form of s-expression that you throw at it. For more details see below 2 answers:

Is LISP the only language with REPL?

How is the LISP read-eval-print loop different from Python?

0
source share

All Articles