# Command-line or notebook?
Once you've decided on the language, you next have to decide on your
programming environment: the command line as in {ref}`the basics`, or the
notebook as in {ref}`the notebook server`.
## In favor of notebooks
- They facilitate rapid code development. You fiddle inside a cell,
hit SHIFT-ENTER to execute it, get it to do what you want. Then you
move to the next cell.
- Documentation is easy, as shown {ref}`here `.
- Notebooks are easy to share. For example, a colleague of yours can
copy one of your notebooks to their own area to look at it:
%cp ~jsmith/energy-calibration/myanalysis.ipynb jsmith-analysis.ipynb
- The interface to a notebook is through a web browser. You don't need
ssh or an X-Windows emulator.
## Against notebooks
- They're relatively new in software development. It's possible your
supervisor has never heard of them. If you say you've got a .png
plot in a Jupyter notebook, they'll reply "You've got a what in a
where?"
- The `%jsroot on` magic command does not enable every X-Window
feature available from within the ROOT command line. There's no
`TBrowser`, `Treeviewer`, or `FitPanel`. You can't add new elements to a
plot and then save the ROOT commands so you can examine how to use
them in a .C file.[^f64]
- As you saw {ref}`before `, your canvases are not
automatically drawn or updated for you. You must explicitly issue
`Draw()` commands for your canvases.
## Issues with the Nevis notebook server
Most of these points involve technical sysadmin issues. You may want to
skip them, and come back later if you have a notebook problem.
- The Nevis particle-physics JupyterHub notebook server is not
something you find at most institutions, at least not for now. Only
the REU students and the particle-physics groups have access to it.
Your astrophysics or RARAF colleagues won't be able to view your
notebooks. You can install Jupyter on your laptop, but that won't
help anyone else see your work.
- You can develop software in notebooks, but you can't run multi-hour
jobs with them on our notebook server.[^f65]
- Some physics software is a "chimera", a blend of software compiled
in two languages. For example, the Neutrino Deep Learning group uses
Python to call pre-compiled C++ routines. Our notebook server may
not be able to run software that's been compiled on another
machine.[^f66]
- As you get more familiar with the UNIX shell, you may start making
changes to your standard shell setup. You do this by editing special
shell initialization files such as `.profile`.[^f67] If you add new
variables to your environment, these variables are available in our
notebook server as well.[^f68]
However, if you modify certain variables such as
`$LD_LIBRARY_PATH` or run environment-customization scripts (such
as `conda activate /usr/nevis/conda/root`) in your default
initialization, it can affect the execution of the notebook
server. The typical symptoms are a notebook kernel that refuses to
start or you get library load errors.
You can get around many of these issues by [running
Jupyter](https://twiki.nevis.columbia.edu/twiki/bin/view/Main/IPython)
on your Nevis workgroup server.
[^f64]: See {ref}`magic-command` for a minor exception to this.
[^f65]: The way to handle such tasks is with {ref}`batch-systems`.
[^f66]: I doubt this will be important to your work this summer, but so
you can look it up if necessary: As of 2024, most of the
Nevis particle-physics systems are running [AlmaLinux 9](https://almalinux.org/).
[^f67]: Here's a list of [shell initialization
files](https://twiki.nevis.columbia.edu/twiki/bin/view/Main/Shell), at
least for the systems at Nevis.
A UNIX survival tip: Never let a well-meaning friend start editing
your shell initialization scripts for you. I can't count the number
of times I've looked at someone's shell init scripts and saw they
were last edited in the 1990s. A user had either forgotten or never
knew that their friend had put any such commands there, and so never
kept them updated in the years since. These init scripts were copied
from user to user for decades.
If you edit your scripts yourself, at least you have a chance to
maintain them.
[^f68]: For reference:
If you define a variable in a shell, e.g.,
export mywork=~/analysis_work_directory
then you can access the variable within your program in ROOT C++:
TString my_location = gSystem->Getenv("mywork");
In Python:
import os
my_location = os.environ["mywork"]
:::{figure-md} mac_pc-fig
:align: center
by Randall Munroe
:::