
Run code inline in Atom using Jupyter kernels - dkharrat
https://github.com/nteract/hydrogen
======
pjmlp
> Hydrogen was inspired by Bret Victor's ideas about the power of
> instantaneous feedback and the design of Light Table.

Good work.

Although Bret Victor deserves lots of appreciation for his work, most of his
ideas are actually how Xerox PARC workstations and Lisp Machines used to
enable developers to program more productively.

So if anything the best part of his work is making young generations aware of
what the industry lost when those systems failed to gain wide market
acceptance.

~~~
ZenoArrow
If you try hard enough, you could tie any new development to the past.

Lisp may have been the first language with a REPL (as far as I'm aware it was
either Lisp or Forth), but REPLs have evolved over the years, and plenty of
modern programmers were familiar with REPLs before Bret Victor's views on
instant feedback became popular.

~~~
pjmlp
The way one interacts with the Xerox PARC and Lisp Machines environments is
much richer experience than a plain REPL.

It was a graphical REPL that could embedd live objects, which were still
active to further interactive changes.

Also the ability to have the whole OS exposed via the REPLs is hardly
available in modern systems.

Not alk REPLs are made alike.

~~~
ZenoArrow
My point is that REPLs (and other dynamic programming tools) have been in
constant use since they were invented, and although respect can be paid to the
originators of the approach, we're not really experiencing a rediscovery of
those first ideas, but rather we're experiencing an evolution of the ideas
they started. In other words, there's been plenty of activity in this area
between when they were invented and now, let's not discount that activity.

As for modern systems not allowing the whole OS to be exposed via a REPL,
there is at least one actively developed OS that allows this, and that's
Oberon. The most recent revision of the Oberon OS was from 2013.

[https://en.wikipedia.org/wiki/Oberon_(operating_system)](https://en.wikipedia.org/wiki/Oberon_\(operating_system\))

~~~
pjmlp
I was an Oberon user for a while, back when it was still being developed.

The version 3 with the Gadgets framework was quite cool.

The only modern OS environments that come close to these experiences are
Windows with .NET/VS/Powershell and OS X with Playgrounds, the OS X Frameworks
and Applescript.

Don't get me wrong, it is great what they are doing and I for one enjoy
Notebooks, Playgrounds, modern IDEs, tooling that allows for both for JIT and
AOT, while offering safety.

Just a bit nostalgic how things could have been different.

For example, when Google brought out ChromeOS and Dart, I thought there was a
perfect opportunity to have a similar experience, but that is not how it
turned out to be.

------
cheez
This is really cool and I think over time, Atom is going to become really
compelling once their org mode implementation or its moral equivalent gets
some legs.

I've used the Jupyter emacs integration ([https://github.com/millejoh/emacs-
ipython-notebook](https://github.com/millejoh/emacs-ipython-notebook)) but in
the end, I stuck with org mode.

For an example of what you can do in org mode (in emacs), here is part of a
"dashboard" I created for one of my products:
[https://i.imgur.com/QUFbIBk.png](https://i.imgur.com/QUFbIBk.png)

And an example of how I design:
[https://i.imgur.com/MeRYn1L.png](https://i.imgur.com/MeRYn1L.png)

You can essentially use org-babel to recreate an approximation to the notebook
environment which si cool

~~~
duerrp
Org mode rocks! And with ob-ipython you basically get same functionality as
the notebook...

[https://github.com/gregsexton/ob-ipython](https://github.com/gregsexton/ob-
ipython)

~~~
cheez
Ah yes, that's the one I tried.

------
ced
I haven't tried either, but atom-notebook ([https://github.com/jupyter/atom-
notebook](https://github.com/jupyter/atom-notebook)) looks more promising to
me. I hope they can integrate it well.

With hydrogen, are there cells? What happens if I want to rerun everything?
Will I get no output except the output of the last line?

~~~
robinson-wall
I think they both have a place - atom-notebook (like the web version) for more
structured use with cells, and hydrogen for ad-hoc ("Will this work?")
anonymous execution while you're editing.

> Will I get no output except the output of the last line?

If the return value is one line, it prints neatly after the executed block. If
it's more than one it inserts a little pane with the results, with options to
copy the data or open it in a new buffer.

~~~
ced
I agree, it looks like Hydrogen is a nice replacement for the REPL, whereas
notebooks are a completely different workflow.

------
glogla
Many times I wanted to switch from Sublime Text to Atom, but I always went
back for some reason (slowness, not remembering open files upon restart, etc).
Maybe this will make me swich for good.

~~~
eivarv
FYI: Sublime Text's plugin API has recently (v. 3118) been updated with some
cool new features relating to inline minihtml, which makes something like this
more feasible.

While it doesn't currently exist, someone might implement something like this
for Sublime Text in the future.

~~~
jbrooksuk
Also, Sublime now has a Phantoms API which lets you insert content after (or
blocked) the line.

~~~
eivarv
Yeah, that's what I'm talking about.

------
machbio
Jupyter released a cool computational environment(basically an IDE like
Rstudio Web) -
[https://github.com/jupyter/jupyterlab](https://github.com/jupyter/jupyterlab)

There is already discussion about Jupyter lab here on the front page -
[https://news.ycombinator.com/item?id=12098180](https://news.ycombinator.com/item?id=12098180)

------
olsgaard
What Jupyter Notebook is missing is a good text/code editor and what good
text/code editors are missing is Jupyter Notebook like write and execute.

This is the first example I've seen of the power that using Electron in Atom
can give, and it makes me super exited!

~~~
denfromufa
Have you tried PyCharm with jupyter notebook?

~~~
olsgaard
No, I didn't know they worked together. I'll have a look!

------
leetrout
If you're spending a lot of time doing data science and if you might be
missing R studio for Python I work for Yhat and we make a product called Rodeo
[http://rodeo.yhat.com/](http://rodeo.yhat.com/)

~~~
olsgaard
What are the major benefits of Rodeo compared to Spyder?

------
mbm
For any of those who may be doing Elixir development,
[https://github.com/pprzetacznik/IElixir](https://github.com/pprzetacznik/IElixir)
works perfectly with this.

------
kabdib
The MPW Shell (the Macintosh Programmer's Workshop) had a feature like this;
every editor window was also a shell command window. You could select some
text and run it as a shell command.

I regularly included build steps as comments in the first few lines of C and
Pascal sources. No makefile necessary.

You could also arrange for code to run on actions like 'cd' (to set up
environments, for instance; your editor window could become a context of
readily selectable commands based on the directory you were in).

Oh, and 1987.

------
Wonnk13
Advantages of this over running a repl in an Emacs buffer and evaluating code
that way? I've never tried Atom.

~~~
throwanem
Same question, but s/running repl in an Emacs buffer/authoring in org-babel/
\- I have a hard time seeing Jupyter and friends as anything other than a
subset of what people have been using org-babel to do for years, and I'm not
really sure whether that's an accurate perception or not.

~~~
ced
Thank you for the babel reference, it looks interesting. From what I can tell,
it's pretty similar. In a notebook I'm directly editing the code and seeing
the results immediately, instead of switching back and forth between emacs and
a browser window. That looks like a pretty big win for interactive
development. Is there any babel feature that you think is missing in Jupyter?

~~~
throwanem
Babel does the same thing; you just press Control-C twice while the cursor is
in a code block, and it's evaluated and the results inserted immediately below
the code block. (If there are already results there, they're replaced by
default, but you can opt to have new ones appended instead.) It's no less
interactive than Jupyter; it's just interactive in the paradigm of an Emacs
buffer instead of a browser window.

A major feature Babel offers, which Jupyter doesn't seem to, is passing data
among code blocks in different languages. Any language Babel supports [1] can
receive results from any other in the receiving language's native idiom, so
there's no need to marshal temporary files or what-have-you in order to
exchange data among blocks - Babel takes care of that for you. In a case where
multiple transformations are necessary to get from source data to results,
this makes it very easy to express each in a language well suited to it,
without having to spend a bunch of time and mental energy on menial file
shuffling.

The same is true for most other representations of data that Org mode
supports. In particular, Org tables, which themselves have many features of
spreadsheets, can be sourced in code blocks in the same way as the results of
other code blocks, and a code block can generate an Org table as a result.
These tables can be imported and exported as CSV, too. My work is professional
rather than academic, but I can imagine a lot of cases in which this
capability would be useful in the latter context, and Jupyter doesn't seem to
offer it. (It's hard to tell, because Jupyter's documentation seems pretty
thin overall - not something which can be said of Org mode.)

On the whole, Jupyter looks like a pretty nifty tool, and one which would be
accessible to people who don't already use Emacs. I'm not sure how I would
feel about recommending Emacs to someone just for Org mode, although I've
heard several people say they picked up Emacs for precisely that reason and
have stuck with it. But, if you already use Emacs and don't have contextual
reasons (such as everyone else around you using Jupyter) to choose one tool
over another, I wouldn't hesitate to recommend investigating Org mode first,
because it is very nearly a strict superset of Jupyter. (It'll be a few years
before you can easily embed a video in an Emacs buffer; right now you'd need
to use a pre-release version with some extra compile options.)

[1] [http://orgmode.org/worg/org-
contrib/babel/languages.html](http://orgmode.org/worg/org-
contrib/babel/languages.html)

~~~
ced
That sounds really nice, thank you for taking the time to write all this. I do
use Emacs for editing, and I miss all the features SLIME offered for Common
Lisp. Unfortunately, I'm using Julia now, and while the language is really
getting there, tooling support is minimal outside of Jupyter and Atom, so I
wouldn't bet on Babel.

I should learn org-mode though. I've heard so much praise for it!

~~~
optimali
I have been using Julia in emacs, primarily using ESS [1] and ob-julia [2]
(org babel julia package). It is relatively well integrated with some basic
auto-complete features and nice org-babel integration (as good as python or
r).

[1] [https://github.com/emacs-ess/ESS/wiki/Julia](https://github.com/emacs-
ess/ESS/wiki/Julia)

[2] [https://github.com/gjkerns/ob-julia](https://github.com/gjkerns/ob-julia)

------
Chris2048
I could never get this to work in Ubuntu 14.1 :/

There are issues with Jupyter in that distro too, But hydrogen had some nps js
error regarding a missing lib or something. So many stacks in these things...

------
kdtg
For vim people living in terminal, I suggest cellmode plugin for vim
([https://github.com/julienr/vim-cellmode](https://github.com/julienr/vim-
cellmode)). You can split tmux window into vim + ipython panes, and trigger
the evaluation of selected vim lines by pressing Ctrl-C.

------
mungoid
Suuure, now this gets posted after I JUST found out about it yesterday in a
comment about the JupyterLab link.. Go ahead, rub it in more.. Seriously
though, I never thought to look for something like this so I'm happy more
people are finding out about it too. Even if there may be better alternatives,
more people now know to look.

------
projectramo
Is there any way you could have this running on the cloud (in Digital Ocean or
AWS)?

Suppose you had Jupyter installed using the following process:

[https://www.dataquest.io/blog/digitalocean-docker-data-
scien...](https://www.dataquest.io/blog/digitalocean-docker-data-science/)

------
vanous
I have been enjoying Python (or any other external command) execution on whole
file or on selected text block in Vim and it has been great, even for some
specialized mini applications and custom docbook/markup formatting. The
ability to have graphics is intriguing, will give atom a try.

------
babo
Works fine after adding a minimal config {"magicpython": "Python 3"} at the
Kernel Mappings setting and setting PYTHONPATH at the command line when
running atom. It's kinda cool to manage your kernels from the editor!

------
mungoid
So I know Sage is quite a bit more hefty than the standard Jupyter kernel, but
I wonder if this could work with the Sage kernel? I quickly attempted it with
no luck but assume with the right setup it could. Maybe?

------
nickjj
This looks cool but how does this translate to being beneficial in real world
web applications?

Often times the result of running some bit of code is to see the end result in
a browser because the code resulted in sending a bunch of HTML or JSON as a
response.

Also in the above case your code isn't self contained to a block of code.
Chances are you have a web server, along with a database and cache server.
Most of my projects are also encapsulated in half a dozen Docker containers.
How is this plugin going to know what to do with that?

Starting up an entire stack of programs to live preview a few lines of code
would end up being slower than just saving the file and reloading the browser
to see feedback.

~~~
minimaxir
Jupyter Notebooks are more for statistical, iterative coding, not running an
application.

~~~
nickjj
Thanks. I wasn't aware of what Jupyter was.

I only glanced the top of the README which compares the project to what Light
Table was trying to solve and then showed an animated gif of inline code
evaluation examples.

------
Dawny33
Super awesome! The gif can do with a better Atom theme, though!

The dark one isn't really ideal for a cell-by-cell Jupyter-like implementation

~~~
herrvogel-
Is there a specific theme you had in mind? Just curious.

------
blahi
VS Code?

~~~
baldfat
I can't see why this wouldn't work just as well.

I certainly would be interested. I started using VS Code more and more and VIM
less and less :(

