Our life around REPL – Read–Eval–Print Loop

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 🙂

 

Vim, TextMate and Gedit, make your editor rich featured

Editors => Idioters

There are hundreds of editors available in the market, both free and paid, depending upon ones need. I mostly work on Ruby or ROR, Web2.0 stuff and I prefer to work fast, efficient and effective way and editor plays a very important role for every developer, so as system (OS) but its a different discussion as of now.

I’ll make my assumptions on the basis you like working either on MacOS X or linux (Ubuntu, fedora or any other flavour) and can dig yourself to get your things working like the way you want to work on your machine. Sorry, I don’t recommend Windows for development and I presume that you like to learn shortcuts and emphasize more upon your keyboard instead of mouse.

I started development during my college days on Vim or GEdit on Linux. Truly speaking VIM seemed flamboyant with its unmatched capabilities. I always wanted to work/handson/try Emacs there after, but still lazy enough to start exploring it.

After college, I started development on Mac OS X and got paid version of TextMate and as said its best for development for Ruby on Rails application. I was pretty happy and used to install some bundles from time to time to make it work the way I want to code fast and effective and started coding with as many shortcuts I can learn and remember. As a rescue I used Vim and always feel overwhelmed about Linux community and such a powerful and fast editor, which can’t be replaced by anything (with same regard for Emacs).

With time I worked more on Vim and TextMate and trying to point some of their key features which I liked and used the most.

Vim (all terminal based and though fast):

  • Searching (/search_string)
  • Search and replace (:%s/search/replace/gi)
  • Macro (record and play on a file of any size), at par feature
  • Practically open file of any size (tried with gigs of sql files)
  • Use of CTags (extremely powerful feature when working on a project)
  • GVIM with more additional feature
  • Split (horizontal and vertical) views (:sp or :vsp <filename>)
  • Automated indentation
  • Color schema makes one feel geeky developer 🙂 especially after watching MatriX
  • Thousands of other feature and plugin and it makes it extremely powerful and fast to work till now

TextMate (a high-hyped editor):

  • Snippets to call your programming structures e.g. def+tab will complete the function block
  • Supports almost all languages and frameworks
  • It can open your whole project (in a side pane, left or right side), I prefer right side. I love this feature
  • Allows you to remove reference certain files or folders from project to apply search upon e.g logs, images etc
  • except common feature, it allows full project search (even regular expression)
  • Star Me and CmdT allows to reach any part of the file and to file in your open project by just typing some literals
  • Auto file indent (Cmd] or SftCmd[ )
  • Cmd/ to auto comment line or lines
  • Most importantly, it won’t annoy you some red or green light here and there or extra fancy stuff and provide more space to code and keep it elegant
  • I like the twilight theme to work upon
  • Takes up very less memory(as compared to most rich featured editors) and its pleasant to work upon it

Textmate

Recently, I moved to Delhi and started working on Linux and to be frank its a hard transition to work without TextMate. Thanks to VIM again, it wasn’t a hard transition. Gedit is good but its like Notepad of windows and reasonably nothing is there. Than I started making it feature rich owing to the fact its always fast to load and can be my textmate on linux. Thanks to hundreds of plugins available and for such a vibrant community around and the research already done by other folks.

So lets talk about different plugins for Gedit to make it work fast, efficient, elegant and more like TextMate

Gedit (conventional and basic editor):

Here are hundreds of plugins available but choosing the right one is important.

How to install additional Gedit plugins

While Gedit ships with a set of default plugins, you can surely add as many as you like. To install a plugin for Gedit, you must first download it to a local folder and then extract the contents to ‘~/.gnome2/gedit/plugins/’ directory. Also look for a package named “gedit-plugins” in your distribution’s package manager, this package contains some additional plugins for gedit. Once you have installed the plugin you want, you need to enable it via Edit -> Preferences and then the Plugins Tab.

  • Snippets -> allows you to insert frequently typed phrases and text by using hotkeys or a shortcode, it supports mostly all the languages
  • Auto Tab  -> detects the indent/space settings in a file and adjusts tabbing accordingly on the fly
  • File Browser Pane -> It open up a whole project in directory structure ( file structure)
  • Right Pane -> For right hand side pane for project viewer
  • Code Comment -> To comment your code (CTL+m)
  • External Tools -> Execute external commands and shell scripts


  • Quick Open -> Its good but not as good as CMDT of textmate
  • Regex Search and replace -> CTL + H for regex search and replace
  • Gemini -> character completion
  • Change Case -> for fast switching case for selected text
  • Class Browser -> List all the methods of class or module, uses Ctags and side pan view
  • Commander -> to provide command line interface
  • Document Statistics -> Analyses the current document and reports the number of words, lines, characters and non-space characters in it.
  • Embedded Terminal and Open terminal here
  • File Search -> Search for text in all files in a directory
  • Session Saver -> Session saver allows you to save you current workspace
  • Snap Open -> A regex open file dialog that resembles that of Textmate
  • Tag List -> Provides a method to easily insert into a document commonly used tags/strings without having to type them
  • Word Completion -> suggestions from all words in all documents in all windows, annoying sometimes

Colors and fonts:

Get all themes from here. But I prefer these two.

  • Rubycious
  • Twilight

So, after go through of important features of all these editors. Its one like and dislike or any editor (other than these three). Vim is always the winner, as it comes with these features and the moment you do code review or sit on someone else computers, it takes no time to work on new machine. Vim is a must for any programmer (If I infer it right, it makes you think above conventional ways). On top of it, while working on a project and other than terminal TextMate (Mac) and Gedit (Linux) is no-doubt a better option.

To comment on Windows based editors GVim, e-text editor with cygwin and notepad ++  seems to be better and fast option.
Happy Coding!

Individual Globalization….


Voyage:

The term mostly related with Christopher Coumbus on his voyage in 1492 who sailed with the Nina, the pinta and the Santa Maria in an effort to discover a shorter, more direct route to India to confirm that the world is round not flat!!
U know Y he did the Voyage???Just to encounter a New World, to search Indian Riches: precious metals , silks, spices. Era of The Globalizaton of countries and power.

World:

Then from 19th to 20th century the expansion of world via telephones, media, electronics world, Stock exchange, the PC’s, satellite, Multi national Companies headed while being interrupted by the great depresson(colonization and bombing on Hiroshima and Nagasaki) and World Wars I &II the life never stopped and the key factor “Change” resulted in the
Globalization of Companies and their Integration

Flat World:

The Playing Ground Is Being Leveled: Mr Nilkani, CEO Infosys”
Now the 21st Century and the world shrinking is to nano size and the storage expanding to Terabytes. Asians, especially Indian professional outsourcing the work and Indian IT market and Software graduates encomplishing tons of work while its night in the Developed Countries has set the world for a individual to Expand Its Horizon and

The Era Of INDIVIDUAL Globalization, the newfound power to collaborate and compete globally has now Leveled the GROUND.