Our life around REPL – Read–Eval–Print Loop

Bookmark this on Digg
Bookmark this on Delicious
Share on Facebook
Post to Google Buzz
Bookmark this on Yahoo Bookmark
Share on FriendFeed
[`tweetmeme` not found]

Whenever I see my niece so comfortable with iPhone, Mac, Advance Toys; I usually wonder almost similar feeling our parents must have pondered about us. But what is the biggest disadvantage of being part of GEN X. What? We have best things in the world but the irony is that we don’t enjoy or embrace the inventions/creations done by our forefathers generation. For us TV, Radio, Telephone, Mobile, Desktop was little obvious, now for next generation iPhone, iPad, Smartphone, DSLR, Laptops, Tablets et al are very obvious. Its clearly visible our parents struggle with our generation widgets and I have now started to struggle with next-generation gadgets.

You must be thinking what is it had to do with REPL. During college days, I started coding in C, bit of Java (to clear job interviews incase required), then majorly on PHP, RUBY, PYTHON, JAVASCRIPT, BASH. The moment I started coding on these languages, which are derived from their forefathers C & Lisp, I sensed a sheer bliss while working on them and started promoting them in peer group as soon as I realized the language is always available and it was obvious not to look back at C, C++, Java and many others. We can easily compare it to Gramophone, cassettes, VCR , VCP, Landline but these inventions were the foundation of where we stand today in our life or in programming world.

I was not clear about the term REPL when I started working on these languages and thought of it as a jargon of programming world. Recently, wrote a smallest code on ruby and a REPL was created. This is when I realized the power of REPL and thought to read about their forefathers. Let’s first have a sneak-peek into that smallest piece of ruby repl code.REPL

#!/usr/bin/env ruby
loop {p eval gets }

 

Now read this piece of code in reverse order, READ (gets), EVAL, PRINT (p), LOOP. Save this file as repl.rb and run as`ruby repl.rb`

─$ ruby repl.rb 1 ↵
"akshay Gupta".upcase
"AKSHAY GUPTA"
1+2*3
7

Congratulations, now you understand REPL and underlying fact of  language is always available i.e. no real distinction between read-time, compile-time and run-time. Now, when I start working on any new language, it’s easier to pick up if it’s REPL based and I truly thank Mr. John McCarthy father of Artificial Intelligence, creator of LISP (where lies the roots of REPL) for his immense contribution in the field of computer science, AI, programming languages and so many programming paradigm. If i’m not wrong, he is also the inventor of if-then-else conditional construct and we take these for granted now.

Running code at read-time lets users reprogram; running code at compile-time is the basis of macros; compiling at runtime is the basis of Lisp’s use as an extension language in programs like Emacs; and reading at runtime enables programs to communicate using expressions.

There have been two really clean, consistent models of programming so far: the C model and the Lisp model. As computers have grown more powerful, the new languages being developed have been moving steadily toward the Lisp model. A popular recipe for new programming languages in the past 20 years has been to take the C model of computing and add some parts taken from the Lisp model, like runtime typing and garbage collection.

repl-loop

It’s equally important to look forward and innovate in coming time and respect, embrace the efforts of our remarkable forefathers. To read and practice different languages that support REPL please follow the below links. I primarily depend heavily upon irb and PRY.

In our everyday life we do nothing more than READ (consume knowledge), EVAL ( between right and wrong), PRINT (discuss around), LOOP (day everyday) i.e. REPL 🙂

 

24 thoughts on “Our life around REPL – Read–Eval–Print Loop

  1. Today, I went to the beachfront with my children. I found a sea
    shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She placed the shell to her ear and
    screamed. There was a hermit crab inside and it pinched her ear.
    She never wants to go back! LoL I know this is entirely off topic but I had to
    tell someone!

    My web-site Orthodontist Gilbert

  2. After I originally commented I appear to have clicked on the -Notify
    me when new comments are added- checkbox and now each time a comment is added I
    get four emails with the same comment. There has to be a way you can remove me from that service?
    Cheers!

  3. Just desire to say your article is as astonishing. The clarity in your post is simply great and i can assume
    you’re an expert on this subject. Well with your permission let
    me to grab your RSS feed to keep up to date with forthcoming post.
    Thanks a million and please continue the gratifying work.

  4. Hey There. I found your blog the usage of msn. This is a very neatly written article.

    I’ll make sure to bookmark it and return to learn extra
    of your helpful information. Thanks for the post. I’ll certainly return.

  5. Excellent blog you have here but I was curious about if you knew of
    any user discussion forums that cover the same topics discussed in this article?
    I’d really like to be a part of online community
    where I can get responses from other knowledgeable individuals that share the same interest.
    If you have any recommendations, please let me know. Appreciate it!

    Feel free to surf to my web site … 24 hour emergency hvac repair 08077

  6. Having read this I believed it was really enlightening.

    I appreciate you finding the time and effort to put
    this article together. I once again find myself personally spending a
    significant amount of time both reading and leaving comments.
    But so what, it was still worth it!

  7. Today, I went to the beach with my kids. I found a sea shell and gave it to my 4 year old daughter
    and said “You can hear the ocean if you put this to your ear.” She placed the shell to her ear and screamed.
    There was a hermit crab inside and it pinched her ear.
    She never wants to go back! LoL I know this is entirely off topic but I had to tell someone!

  8. You discover a many things ake money home at a reasonably cheapp rate in local yard sale and variety stores.

    If tthe ites do not have aany major defect, however repair them if required,
    and and selling them oon eBaay to fund a profit.

  9. I believe this is among the most significant info for me. And i’m happy studying your article. However wanna commentary on few common issues, The web site taste is wonderful, the articles is in point of fact nice : D. Good process, cheers

  10. PC Repair, Laptop Repair, Tablet Repair, Virus Removal, Spyware Removal, Malware Removal, repair, removal, laptop, pc, desktop, tablet, spyware,virus, malware, web site hosting, web site design, email server, web page design, kent, west malling, me19, me20, PC Setup, Software Installation, Hardware Installation, Wi-Fi Setup,Network Configuration, Web Site Hosting & Development,Email Server Setup, Home Media Installation

  11. You’ll discover incredible benefits including boosting your defense mechanisms to perhaps weight loss of
    using whey protein every day.

Comments are closed.