Help in thinking about how to save a "program"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Help in thinking about how to save a "program"

ghoetker
Hi all.  I’m new to Pharo and loving it.  As I transition from a text-file based mindset, I’m a little stuck and would appreciate help in how to think about a situation in a Pharonic (Pharo-ish, Pharoc?) way.

I”m crafting a short program to help me process a large text file (specifically: extract, sorting, and regularizing the “keyword” fields of a large BibTex file). Especially since I don’t really know what I’m doing, working in a Playground has been a great development environment.  Now that the program is complete (under 30 lines, wonderful), I want to be able to save it for future reference (and perhaps for future use).  If I’d written a shell script, I’d just save “fixBibDeskKeyWords.sh” to a directory. I’m not sure what to do in the Pharo environment, thought.

At the moment, it just lives in the Playground I’ve developed it on.  I could save the image and leave that Playground open, but I’m just positive that’s not a best practice. I also worry about what happens if I closed/cleared that Playground by accident.

I think I understand that, if I created a new package, I could use Monticello to save it to a local cache and load it into a new image whenever I needed it.  But, given that it’s short, highly specialized and fairly linear, the idea of creating a “GHBibDeskStuff” package with one class (“GBibDeskKeywordFixer” containing a single “FixFile” method seems really heavy and awkward.

Can one save the contents of a Playground in a Pharonic way?  Is there a better approach?

Thank you to all involved in this wonderful programming ecosystem. I appreciate any advice.

Glenn
Glenn Hoetker
ghoetker@me.com
http://hoetker.faculty.asu.edu
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help in thinking about how to save a "program"

philippeback

If you have a playground script maybe just having it as a .st file and running it with Pharo is good enough.


Like
pharo Pharo60.image myscript.st

Check

Or get into Iceberg (Git) or Monticello to save your code as a package.

Check deep into pharo, there is a chapter on these things.

Gofer may also be a solution.

Are you on Discord?

Phil

Le 12 juin 2017 01:22, "Glenn Hoetker" <[hidden email]> a écrit :
Hi all.  I’m new to Pharo and loving it.  As I transition from a text-file based mindset, I’m a little stuck and would appreciate help in how to think about a situation in a Pharonic (Pharo-ish, Pharoc?) way.

I”m crafting a short program to help me process a large text file (specifically: extract, sorting, and regularizing the “keyword” fields of a large BibTex file). Especially since I don’t really know what I’m doing, working in a Playground has been a great development environment.  Now that the program is complete (under 30 lines, wonderful), I want to be able to save it for future reference (and perhaps for future use).  If I’d written a shell script, I’d just save “fixBibDeskKeyWords.sh” to a directory. I’m not sure what to do in the Pharo environment, thought.

At the moment, it just lives in the Playground I’ve developed it on.  I could save the image and leave that Playground open, but I’m just positive that’s not a best practice. I also worry about what happens if I closed/cleared that Playground by accident.

I think I understand that, if I created a new package, I could use Monticello to save it to a local cache and load it into a new image whenever I needed it.  But, given that it’s short, highly specialized and fairly linear, the idea of creating a “GHBibDeskStuff” package with one class (“GBibDeskKeywordFixer” containing a single “FixFile” method seems really heavy and awkward.

Can one save the contents of a Playground in a Pharonic way?  Is there a better approach?

Thank you to all involved in this wonderful programming ecosystem. I appreciate any advice.

Glenn
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help in thinking about how to save a "program"

K K Subbu
In reply to this post by ghoetker
On Monday 12 June 2017 04:52 AM, Glenn Hoetker wrote:
> I”m crafting a short program to help me process a large text file
> (specifically: extract, sorting, and regularizing the “keyword” fields
> of a large BibTex file). Especially since I don’t really know what I’m
> doing, working in a Playground has been a great development environment.
>  Now that the program is complete (under 30 lines, wonderful), I want to
> be able to save it for future reference (and perhaps for future use).
>  If I’d written a shell script, I’d just save “fixBibDeskKeyWords.sh” to
> a directory. I’m not sure what to do in the Pharo environment, thought.

Playground saves your scripts in pharo-local/play-cache folder. Use
Tools->File Browser to look in play-cache/ or pharo-local/play-cache/
folder. You will find all your playground scripts saved in *.ph files.
Note down this name (or rename it to something easy to remember) and
make a copy. Pass this file as an argument:

$ ./pharo Pharo myscript.st

BTW, Playground is just that and a file is for unstructured stream of
bytes. You may want to start using System Browser to create classes and
methods, tests etc. for code worth preserving. Pharo offers you a lot of
services like live debug, cross-refs, tracking changes, packaging etc.
It is a lot easier than you think ;-).

HTH .. Subbu

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help in thinking about how to save a "program"

Pharo Smalltalk Users mailing list
In reply to this post by ghoetker
Hi Glenn,

Another very useful tool you can use to save/manipulate/store Smalltalk scripts is ScriptManager (http://catalog.pharo.org/catalog/project/ScriptManager).  There are plenty of similar tools but this one is very easy to use and simple and has been doing the job for years for me.


hth
 
-----------------
Benoît St-Jean
Yahoo! Messenger: bstjean
Twitter: @BenLeChialeux
Pinterest: benoitstjean
Instagram: Chef_Benito
IRC: lamneth
Blogue: endormitoire.wordpress.com
"A standpoint is an intellectual horizon of radius zero".  (A. Einstein)



From: Glenn Hoetker <[hidden email]>
To: [hidden email]
Sent: Sunday, June 11, 2017 7:23 PM
Subject: [Pharo-users] Help in thinking about how to save a "program"

Hi all.  I’m new to Pharo and loving it.  As I transition from a text-file based mindset, I’m a little stuck and would appreciate help in how to think about a situation in a Pharonic (Pharo-ish, Pharoc?) way.

I”m crafting a short program to help me process a large text file (specifically: extract, sorting, and regularizing the “keyword” fields of a large BibTex file). Especially since I don’t really know what I’m doing, working in a Playground has been a great development environment.  Now that the program is complete (under 30 lines, wonderful), I want to be able to save it for future reference (and perhaps for future use).  If I’d written a shell script, I’d just save “fixBibDeskKeyWords.sh” to a directory. I’m not sure what to do in the Pharo environment, thought.

At the moment, it just lives in the Playground I’ve developed it on.  I could save the image and leave that Playground open, but I’m just positive that’s not a best practice. I also worry about what happens if I closed/cleared that Playground by accident.

I think I understand that, if I created a new package, I could use Monticello to save it to a local cache and load it into a new image whenever I needed it.  But, given that it’s short, highly specialized and fairly linear, the idea of creating a “GHBibDeskStuff” package with one class (“GBibDeskKeywordFixer” containing a single “FixFile” method seems really heavy and awkward.

Can one save the contents of a Playground in a Pharonic way?  Is there a better approach?

Thank you to all involved in this wonderful programming ecosystem. I appreciate any advice.

Glenn


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help in thinking about how to save a "program"

Ben Coman
In reply to this post by ghoetker


On Mon, Jun 12, 2017 at 7:22 AM, Glenn Hoetker <[hidden email]> wrote:
Hi all.  I’m new to Pharo and loving it.  As I transition from a text-file based mindset, I’m a little stuck and would appreciate help in how to think about a situation in a Pharonic (Pharo-ish, Pharoc?) way.

I”m crafting a short program to help me process a large text file (specifically: extract, sorting, and regularizing the “keyword” fields of a large BibTex file). Especially since I don’t really know what I’m doing, working in a Playground has been a great development environment.  Now that the program is complete (under 30 lines, wonderful), I want to be able to save it for future reference (and perhaps for future use).  If I’d written a shell script, I’d just save “fixBibDeskKeyWords.sh” to a directory. I’m not sure what to do in the Pharo environment, thought.

At the moment, it just lives in the Playground I’ve developed it on.  I could save the image and leave that Playground open, but I’m just positive that’s not a best practice. I also worry about what happens if I closed/cleared that Playground by accident.

I think I understand that, if I created a new package, I could use Monticello to save it to a local cache and load it into a new image whenever I needed it.  But, given that it’s short, highly specialized and fairly linear, the idea of creating a “GHBibDeskStuff” package with one class (“GBibDeskKeywordFixer” containing a single “FixFile” method seems really heavy and awkward.

Can one save the contents of a Playground in a Pharonic way?  Is there a better approach?

Thank you to all involved in this wonderful programming ecosystem. I appreciate any advice.

Great to hear you are enjoying Pharo.

The heavy part of saving to disk as a Monticello package is an optional secondary step, but to make you code "permanent" in the image you do need a class to hang it on, and a package to hold that.  Doing this only in-Image is quite light and quick to do, and makes it easy to find later.  In a System Browser create package "GHBibDeskStuff", class GBibDeskKeywordFixer.  Create your method so you can use it from playground like this...

     GBibDeskKeywordFixer new fixFile.

Then to the class side of GBibDeskKeywordFixer also add a method #fixFile like this...
    GBibDeskKeywordFixer class >> fixFile
          self new fixFile.

so that from playground you can drop the "new" and use it like this...

    GBibDeskKeywordFixer fixFile

  
Feels like you've added a new command to Pharo?

Note that "GBibDeskKeywordFixer class >>" is just a documentation convention indicating you should click the <Class> button to add a method to the class-side.

cheers -ben
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help in thinking about how to save a "program"

Stephane Ducasse-3
In reply to this post by ghoetker
Hi glenn

Do you use Citezen to parse?
I create a class and put the script as methods and save. You should
kill script as fast as possible
up the give birth to nice method.

GHBibDesk new loadFrom: ''
GHBibDesk new analysis

should be your scripts :)
:)


On Mon, Jun 12, 2017 at 1:22 AM, Glenn Hoetker <[hidden email]> wrote:

> Hi all.  I’m new to Pharo and loving it.  As I transition from a text-file
> based mindset, I’m a little stuck and would appreciate help in how to think
> about a situation in a Pharonic (Pharo-ish, Pharoc?) way.
>
> I”m crafting a short program to help me process a large text file
> (specifically: extract, sorting, and regularizing the “keyword” fields of a
> large BibTex file). Especially since I don’t really know what I’m doing,
> working in a Playground has been a great development environment.  Now that
> the program is complete (under 30 lines, wonderful), I want to be able to
> save it for future reference (and perhaps for future use).  If I’d written a
> shell script, I’d just save “fixBibDeskKeyWords.sh” to a directory. I’m not
> sure what to do in the Pharo environment, thought.
>
> At the moment, it just lives in the Playground I’ve developed it on.  I
> could save the image and leave that Playground open, but I’m just positive
> that’s not a best practice. I also worry about what happens if I
> closed/cleared that Playground by accident.
>
> I think I understand that, if I created a new package, I could use
> Monticello to save it to a local cache and load it into a new image whenever
> I needed it.  But, given that it’s short, highly specialized and fairly
> linear, the idea of creating a “GHBibDeskStuff” package with one class
> (“GBibDeskKeywordFixer” containing a single “FixFile” method seems really
> heavy and awkward.
>
> Can one save the contents of a Playground in a Pharonic way?  Is there a
> better approach?
>
> Thank you to all involved in this wonderful programming ecosystem. I
> appreciate any advice.
>
> Glenn
>
> Glenn Hoetker
> [hidden email]
> http://hoetker.faculty.asu.edu
>
>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help in thinking about how to save a "program"

Offray Vladimir Luna Cárdenas-2
In reply to this post by ghoetker

Hi Glenn,

I made also the transition for the plain "dead" text-files based mindset to live objects. My approach to bridge these two words was to create Grafoscopio [1], where I can save my scripts and put them inside a broader context/narrative. This environment let's me go from scripting/files to objects / code browser and back and I have found this is useful for non programmers (researchers, hacktivists, journalist), because they can have a notebook for their explorations. For example, recently we started a pretty specific project at [2] using this interactive notebook + code browser approach (see screenshot attached below).

[1] http://mutabit.com/grafoscopio/index.en.html
[2] http://smalltalkhub.com/#!/~Offray/DPYA



If you're interested in Grafoscopio, please follow the manual and take into account that now we're trying to migrate to Pharo 6.

Cheers,

Offray

On 11/06/17 18:22, Glenn Hoetker wrote:
Hi all.  I’m new to Pharo and loving it.  As I transition from a text-file based mindset, I’m a little stuck and would appreciate help in how to think about a situation in a Pharonic (Pharo-ish, Pharoc?) way.

I”m crafting a short program to help me process a large text file (specifically: extract, sorting, and regularizing the “keyword” fields of a large BibTex file). Especially since I don’t really know what I’m doing, working in a Playground has been a great development environment.  Now that the program is complete (under 30 lines, wonderful), I want to be able to save it for future reference (and perhaps for future use).  If I’d written a shell script, I’d just save “fixBibDeskKeyWords.sh” to a directory. I’m not sure what to do in the Pharo environment, thought.

At the moment, it just lives in the Playground I’ve developed it on.  I could save the image and leave that Playground open, but I’m just positive that’s not a best practice. I also worry about what happens if I closed/cleared that Playground by accident.

I think I understand that, if I created a new package, I could use Monticello to save it to a local cache and load it into a new image whenever I needed it.  But, given that it’s short, highly specialized and fairly linear, the idea of creating a “GHBibDeskStuff” package with one class (“GBibDeskKeywordFixer” containing a single “FixFile” method seems really heavy and awkward.

Can one save the contents of a Playground in a Pharonic way?  Is there a better approach?

Thank you to all involved in this wonderful programming ecosystem. I appreciate any advice.

Glenn

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help in thinking about how to save a "program"

ghoetker
H Offray,

Thanks for the helpful reply and nice welcome to the Pharo community. Grafoscopio looks wonderful and the Panama Papers application of it, in particular, is really impressive.  I look forward to experimenting with it.

Best wishes,

Glenn

p.s. Previously, I had actually Googled my way Grafoscopio’s Spanish language site and wasn’t aware it had a corresponding English site. Perhaps a link between the English/Spanish sites would be helpful for some?  If I just overlooked such a link, sorry to mention it.


On Jun 14, 2017, at 2:10 PM, Offray Vladimir Luna Cárdenas <[hidden email]> wrote:

Hi Glenn,

I made also the transition for the plain "dead" text-files based mindset to live objects. My approach to bridge these two words was to create Grafoscopio [1], where I can save my scripts and put them inside a broader context/narrative. This environment let's me go from scripting/files to objects / code browser and back and I have found this is useful for non programmers (researchers, hacktivists, journalist), because they can have a notebook for their explorations. For example, recently we started a pretty specific project at [2] using this interactive notebook + code browser approach (see screenshot attached below).

[1] http://mutabit.com/grafoscopio/index.en.html
[2] http://smalltalkhub.com/#!/~Offray/DPYA

<hmnillffiajnlhpp.png>

If you're interested in Grafoscopio, please follow the manual and take into account that now we're trying to migrate to Pharo 6.

Cheers,

Offray

On 11/06/17 18:22, Glenn Hoetker wrote:
Hi all.  I’m new to Pharo and loving it.  As I transition from a text-file based mindset, I’m a little stuck and would appreciate help in how to think about a situation in a Pharonic (Pharo-ish, Pharoc?) way.

I”m crafting a short program to help me process a large text file (specifically: extract, sorting, and regularizing the “keyword” fields of a large BibTex file). Especially since I don’t really know what I’m doing, working in a Playground has been a great development environment.  Now that the program is complete (under 30 lines, wonderful), I want to be able to save it for future reference (and perhaps for future use).  If I’d written a shell script, I’d just save “fixBibDeskKeyWords.sh” to a directory. I’m not sure what to do in the Pharo environment, thought.

At the moment, it just lives in the Playground I’ve developed it on.  I could save the image and leave that Playground open, but I’m just positive that’s not a best practice. I also worry about what happens if I closed/cleared that Playground by accident.

I think I understand that, if I created a new package, I could use Monticello to save it to a local cache and load it into a new image whenever I needed it.  But, given that it’s short, highly specialized and fairly linear, the idea of creating a “GHBibDeskStuff” package with one class (“GBibDeskKeywordFixer” containing a single “FixFile” method seems really heavy and awkward.

Can one save the contents of a Playground in a Pharonic way?  Is there a better approach?

Thank you to all involved in this wonderful programming ecosystem. I appreciate any advice.

Glenn


Glenn Hoetker
ghoetker@me.com
http://hoetker.faculty.asu.edu
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help in thinking about how to save a "program"

ghoetker
In reply to this post by Stephane Ducasse-3
Hi Stephan,

Thank you for the helpful info and nice welcome to the Pharo community.  I’d not been using Citezen.  Since your email, I’ve found the Smalltalkhub site for it and had two quick questions. 1. Is it compatible with Pharo 6? 2. Is there a manual or getting started document you could point me to? (I love the ability in Pharo to peruse well-documented classes and methods in a package, but for a new user and big package, it’s hard to get started!).

I’ve made the jump to creating a class with methods for my small script.  Less work than I thought—it’s really just a change of thinking.

Again, thank you.

Glenn


On Jun 13, 2017, at 10:53 PM, Stephane Ducasse <[hidden email]> wrote:

Hi glenn

Do you use Citezen to parse?
I create a class and put the script as methods and save. You should
kill script as fast as possible
up the give birth to nice method.

GHBibDesk new loadFrom: ''
GHBibDesk new analysis

should be your scripts :)
:)


On Mon, Jun 12, 2017 at 1:22 AM, Glenn Hoetker <[hidden email]> wrote:
Hi all.  I’m new to Pharo and loving it.  As I transition from a text-file
based mindset, I’m a little stuck and would appreciate help in how to think
about a situation in a Pharonic (Pharo-ish, Pharoc?) way.

I”m crafting a short program to help me process a large text file
(specifically: extract, sorting, and regularizing the “keyword” fields of a
large BibTex file). Especially since I don’t really know what I’m doing,
working in a Playground has been a great development environment.  Now that
the program is complete (under 30 lines, wonderful), I want to be able to
save it for future reference (and perhaps for future use).  If I’d written a
shell script, I’d just save “fixBibDeskKeyWords.sh” to a directory. I’m not
sure what to do in the Pharo environment, thought.

At the moment, it just lives in the Playground I’ve developed it on.  I
could save the image and leave that Playground open, but I’m just positive
that’s not a best practice. I also worry about what happens if I
closed/cleared that Playground by accident.

I think I understand that, if I created a new package, I could use
Monticello to save it to a local cache and load it into a new image whenever
I needed it.  But, given that it’s short, highly specialized and fairly
linear, the idea of creating a “GHBibDeskStuff” package with one class
(“GBibDeskKeywordFixer” containing a single “FixFile” method seems really
heavy and awkward.

Can one save the contents of a Playground in a Pharonic way?  Is there a
better approach?

Thank you to all involved in this wonderful programming ecosystem. I
appreciate any advice.

Glenn

Glenn Hoetker
[hidden email]
http://hoetker.faculty.asu.edu





Glenn Hoetker
ghoetker@me.com
http://hoetker.faculty.asu.edu
Loading...