Google Summer of Code 2017 Final Report – Pharo Consortium – Rajula Vineet Reddy

index

Finally, after three months of coding, discord, mailing list discussions, blogging, brain storming and documenting, my Google Sumer of Code 2017 Project comes to an end. This blog post is like a final report of my work covering what I have done over the past months and about the future work on my project.

Introduction:

Pharo is an object oriented programming language with a super cool live and immersive IDE. Pharo has a lot of awesome projects both in production phase and in development phase. Pharo has a really incredible community with contributors from around the world. It was a great experience working for Pharo, collaborating with the community over the last three months.

Project Details:

Title of the project is ‘Enhance Pharo Command Line Interface‘. The project is divided into three sections

  1. Writing a new implementation of the currentWorkingDirectory
  2. Pharo integration of the new implementation
  3. Writing a clap command line handler for clap-st

Overall, the project aims to improve the command line interface of Pharo thereby improving the capability of writing scripts in Pharo and building things on command line.

Mentors:

Guillermo Polito

Philippe Back

eMBee

Initial Proposal:

https://docs.google.com/document/d/1W-o8K7xD8WmSjtO0AAKrhkc8CMn8fywuVwPG2czijM4/edit?usp=sharing

Accomplishments:

ezgif-3-44b3dfc7bb

(NOTE: The timeline described below should be approx. not exact )

I started to work on my project in the month of May itself. I spent a good amount of time trying to understand the existing implementation of working directory for my 1st goal. So, around June I was done with the first two goals of my project. The rest of June I spent understanding the existing code base of clap and collaborating with a fellow contributor who started working on clap way before me. By the mid of July I started to implement the handler. And I was almost done by the third week of August.

Goals Status

Writing a new implementation of the currentWorkingDirectory

Completed

Pharo integration of the new implementation

Partially completed except for File logging

Writing a clap command line handler for clap-st

Completed

Let me brief about what I have done in each of these goals.

  1. The new current working directory implementation

    In Pharo, the old currentWorkingDirectory implementation is not perfect and it has a few drawbacks because of which 

    • Pharo wrongly reads and writes files relative to the ‘working directory’
    • Pharo cannot be installed as a normal application in a read-only environment
    • And also makes scripting difficult


    The new implementation aims to solve all these drawbacks. Talking about the implementation. There were few options for a new implementation. They were

    • Using the PWD environment variable
    • Using getcwd() function


    If PWD variable is used to get the current working directory, though it can handle symlinks, PWD needs frequent update of its value when chdir() (change directory) calls are made in the code. Besides getcwd() needs no update. It takes care of itself. There is also a danger if $PWD variable is set or unset by some application. Also getcwd() function works in all unix, mac and windows systems as there is a similar function on all platforms. Hence I went for getcwd().

    The new implementation will consider the currentWorkingDirectory as the directory from where the image has been opened. The new implementation using FFI call to get the working directory. Using the C function getcwd() the working directory is captured and it is also cached to a class variable DefaultWorkingDirectory using Alistair`s caching approach.

    Now, with the new implementation, it is easier to write scripts and save files corresponding to the actual current working directory. Currently, this has not been merged yet, as FFI is not in the kernel and needs some core modifications in bootstrap.

  2. Pharo integration of working directory

    Since there is a lot of code which considers image directory as working directory, there may be a few cases where it can break interoperability between Pharo and other Smalltalk dialects like squeak etc. This means all of such code should be reviewed. In fact, some of these problems can be however bypassed by running image from its own directory itself or by using the method imageDirectory in FileLocator class explicitly when necessary. But overall a good thing is this will ensure the system will behave as in other languages.

    Few of the changes I did after review are creation of pharo-local directory and local iceberg repo. The new implementation creates pharo-local wherever the image is opened from. The creation of pharo-local should be restricted to the image directory.

    With this new implementation, FileOut will work relative to the working directory. With the new current working directory, saving and opening files will be corresponding to the ‘Actual’ working directory. So, the file outs now will save the file from where you have opened the image.

  3. Writing a clap command line handler for clap-st

    Clap-st is a command line argument parser for Pharo just like clap-rs. In fact it is inspired from clap-rs. The core part of clap has been developed by Damien Pollet and Clement Mastin. Clap takes arguments as input, parses it and makes it easy to run different things depending on the clap output. Initially I started with writing basic examples of clap-st  and later on I developed a ClapCommandLineHandler. This is like an interface between the clap-st and the command line. And clap is really green and lacks tests. So it needs a revisit of a parser of the general architecture to integrate it to the system and give way to test.

    By using clap-st it is easier to use flags, positionals, subcommands and commands. The handler takes input from command line, uses the clap-st to parse it and will print out the output back onto the commandline. Every new handler should be a child class of the ClapCommandLineHandler class. This way, the developer can be isolated and makes it easy to write his own handler. And to isolate the subclasses for production and testing, I implemented a strategy pattern, in such a way that the user can maintain his own collection of subclasses for testing. Check out the tutorial I made on how to create your handler.

A screencast video I made illustrating all the work I have done over the last few months.


Videos or Tutorials Made
:


Blog Posts
:

I have written a total of 12 blogposts (including this) over the last three months. The link to all the blogposts is https://vineetreddy.wordpress.com . Though it was compulsory in my Org to write a blog post everyweek, I always enjoyed writing this. Instead of only writing about my progress, as my mentor Guille suggested I took on a topic every week to write on, through which I had to research and understand about the topic and I learned a lot in the progress.

  1. https://vineetreddy.wordpress.com/2017/05/17/pwd-vs-getcwd/
  2. https://vineetreddy.wordpress.com/2017/05/24/current-working-directory-implementation-initial-steps/
  3. https://vineetreddy.wordpress.com/2017/05/29/cross-platform-with-pharo/
  4. https://vineetreddy.wordpress.com/2017/06/08/filesystem-and-its-internals/
  5. https://vineetreddy.wordpress.com/2017/06/13/submitting-a-pr-to-pharo-git-repository-using-iceberg/
  6. https://vineetreddy.wordpress.com/2017/06/21/clap-command-line-argument-parsing-in-pharo/
  7. https://vineetreddy.wordpress.com/2017/06/28/session-manager-in-pharo/
  8. https://vineetreddy.wordpress.com/2017/07/09/setting-up-pharo-on-my-new-system/
  9. https://vineetreddy.wordpress.com/2017/07/12/clap-st-features-examples-part-1/
  10. https://vineetreddy.wordpress.com/2017/07/19/the-time-when-i-broke-the-pharo-image/
  11. https://vineetreddy.wordpress.com/2017/08/03/clapcommandlinehandler-and-its-architecture/
  12. https://vineetreddy.wordpress.com/2017/08/28/google-summer-of-code-2017-final-report-pharo-consortium-rajula-vineet-reddy/

Repositories worked on:


Pull Requests Made
:

As my work is more of implementing new things, rather than adding features to existing projects, do not expect a lot of PRs. JK. I have two PR`s for the work I have done. Most of my work was writing methods and classes from scratch so lot of time went into brainstorming how to implement.

  1. Current Working Directory – https://github.com/pharo-project/pharo/pull/92/Not yet merged
    The new implementation I wrote uses ‘FFI’. And FFI is not in the current kernel of Pharo, so due to this dependency issue the PR is yet to merged. My mentor is looking for a solution to solve this problem. Hopefully soon this will be merged.
  2. ClapCommandLineHandler – https://github.com/pharo-project/pharo/pull/92/Under Review
    This PR has been made a week ago. The collaborators of this repo and my mentor are currently on vacation. So, it takes some time to receive review and merge this pull request.

Learning and Experiences:

The journey of the last four months are the best in my life. May be the word I am looking for is ‘fantastic’. The Open source exposure I got from the programme is the best part. This is my ever open source contribution I did. And I am happy the contribution is for ‘Pharo’. This is a really great organization to work with. And I don`t think I can say anything about the community. Any questions at any point of the day will be answered some or the other contributor from some place in the world. In case you are reading this on thoughts of contributing to Pharo, please do not even give a second thought. You will fall in love with Pharo. Trust me. You will be in love with Pharo once you understand what it is and what the community are doing.

Acknowledgements:

I am actually not even a little bit hesitant or ashamed of thanking my mentor and my org again and again ;). Guille, Thanks for supporting and guiding me over the last three months. The concepts you taught at times, criticism you gave, code reviews you gave and help you did are the best parts of my GSoC project. Thank you so much. You have been more like a friend to me rather than a mentor. I learnt a lot of things from you. You will be my inspiration. Besides, I would also like to thank my other mentor Philippe, org admins Serge, Jigyasa, Yuriy, Ben and other contributors especially Stephane Ducasee who in the first place suggested me to take this project when I made initial contact. Thank you all for helping me, guiding me and creating a great working environment. And Good luck to you Clement. It was nice working with you. Thank you all. You guys have made my last few months memorable.

Adios to you all. Till next time ;).

Rajula

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s