
Show HN: Nightlight, an editor that runs inside Clojure projects - gw
https://github.com/oakes/Nightlight
======
qwertyuiop924
I don't really see how the integration would be any better than what I'm
getting already from Emacs: I can already patch the code live, etc, through a
REPL, and run the code as I develop it.

Nightlight is asking me to give up the comfort of Emacs: so what does it get
me?

~~~
tunaoftheland
I am ignorant of SLIME/CIDER (though I think I've used the latter with
Clojure). Do they have access to the same memory space as the running
application and the ability to interact with live application state? It seem
that Nightlight has that as a goal. My (limited) understanding is that
SLIME/CIDER run in a separate process from the application, thus requiring IPC
back and forth between Emacs and the application runtime.

~~~
qwertyuiop924
That's true, but the practical effect (having access to application internals,
interacting with live program state, the ability to connect to a live program
and hotpatch it, even if it's running on a remote server (but you'll really
want the source files if you're doing that, and you should be sure to upload
the new sources/binary to the server you just hotpatched, or you'll be in for
a shock when it reboots), and so on) is exactly the same, and they mostly
share the same capabilities (AFAICT, Nightlight might have better autocomplete
than SLIME/Geiser, but other than that, I can't think of anything).

------
fedess
Wish it credited Light Table as inspiration
([http://lighttable.com/](http://lighttable.com/)) :/ Even the term
"instarepl" is taken from LT's creator, Chris Granger. Of course LT's
inspiration is Smalltalk's IDE.

~~~
azeirah
"Of course ..." is that really true though? From the very beginning, the very
first demo, Chris Granger mentions that he got inspired by Bret Victor's
Inventing on Principle demo. He mentions it in the first blog post as well :p
No mentions of smalltalk

Chris Granger's first video on LightTable:
[https://www.youtube.com/watch?v=7XUWpze_A_s](https://www.youtube.com/watch?v=7XUWpze_A_s)
Chris Granger's first blog post on LightTable: [http://www.chris-
granger.com/2012/04/12/light-table-a-new-id...](http://www.chris-
granger.com/2012/04/12/light-table-a-new-ide-concept/)

~~~
e12e
Ah, but Bet Victor draws inspiration from Smalltalk, Logo and Hypercard :

[http://worrydream.com/LearnableProgramming/](http://worrydream.com/LearnableProgramming/)

------
gravypod
I like the idea of a browser based IDE. I like the idea of an IDE for a lisp-
like language that actually offers first-class auto-completion.

I don't like the idea of embedding it into a project. That doesn't make sense
from a dependency tree way of looking at it.

~~~
tunaoftheland
Maybe a Clojure equivalent to NPM's "devDependencies" can manage something
like this, so that it gets excluded from the final deployment JAR. It's been a
while since I'd done Java/JVM development, but the dev-time vs. deploy-time
dependencies configuration should be possible, I would think.

~~~
gravypod
I wouldn't want to risk something this critical being in my project. I'm
stupid so I try and limit my own attack surface against myself.

~~~
tunaoftheland
A very humble approach, and one that I try to subscribe to, as well. :)

I think the embedding part is certainly a tradeoff. Once the development
community settles on a best-practice for things like this, it becomes less of
a danger of forgetting. For example, once this sort of config shows up by
default in archetypes and boilerplate projects, I feel that the danger is
reduced to the level of being manageable. And hopefully the port that the
editor uses is blocked by default in the production environment. :)

~~~
gravypod
Yea it seems like a great project but I don't really like to think of my IDE
as a dependency of my code but rather my code as a dependency of my IDE.

------
swalsh
The possibilities of this thing blow my mind. Very cool idea.

~~~
S4M
Can you give some examples of what you have in mind? I find this very
intriguing but I can't think of anything it could do that would be impossible
with hot reloading code.

~~~
JamesLeonis
1\. Cloud based development/debugging.

One of the harder issues when I'm building microservices is stringing each
service and dependency together and debugging. With this I could put together
a full staging environment and log into each service to monitor and tweak
problems I've found.

2\. Limited hardware or access.

This is important because it's talking with Java Clojure not Clojurescript.
Because it's entirely browser based, I could spin up an EC2 instance and load
the editor on my phone. I can't do that with a regular Clojure environment in
my phone.

~~~
qwertyuiop924
...But can't you do that already with CIDR? (or SLIME/Geiser, for some of the
other lisps).

IIRC, it does support connecting to a remote REPL like this.

------
samatman
Very cool. Looks like a spiritual successor to Catnip[0], which I made heavy
use of when I was newer to Clojure.

Bodil's moved on to other things, I'm glad someone is moving forward with this
kind of environment.

[0]: [https://github.com/bodil/catnip](https://github.com/bodil/catnip)

------
runeblaze
Something more advanced yet similar to Nightcode is something I am definitely
excited to try as an alternative to Emacs and Cursive. Also gotta try this
with play-clj to see how the workflow plays out.

Edit: Tried the REPL but it felt quite buggy:
[http://recordit.co/ziDH1PrJvm](http://recordit.co/ziDH1PrJvm).

~~~
yojex
It's the same author, so I'm assuming that this is his spiritual continuation
of Nightcode with a huge update.

EDIT: They are going to remain separate, here's what he wrote on the project
site:

> _Nightcode remains easier for beginners, because it 's a standalone
> application with Leiningen and Boot built in, so they don't need to use the
> command line. Nightlight must be added to your project, but provides more
> power, so it may be more suitable for intermediate and advanced users._

------
sdegutis
This is actually _really_ creative and clever! In fact it's the first project
of it's kind that I've _ever_ heard of!

Basically it's a library that runs a web server that serves a page which
displays the contents of your source files in an editable text field, and
saves/loads them by reading/writing directly to disk. This also means it
should be _much_ easier to implement the advanced IDE features of CIDER, since
you don't need a plugin system and have full access both to the raw source
code files and the project's very own JVM (which the IDE shares). Neat!

Although, I once again have to completely disagree with Oakes' choice of
buttons in the toolbar (just like in Nightcode): I don't know any programmers
who don't know the shortcuts for Save, Undo, and Redo by heart.

~~~
e12e
You might want to have a look at LivelyKernel too:

[https://www.lively-kernel.org/](https://www.lively-kernel.org/)

------
sdegutis
> _" More powerful editors like Cider and Cursive manage to do this with some
> very complex machinery that I could never duplicate. Instead, I decided to
> rethink the problem. Since Nightlight runs inside the same process as your
> project, code completion and other advanced features are trivial to
> implement."_

How? What makes it easier to implement code completion when the IDE is running
inside your project's JVM? Clojure is still a _dynamic_ language, which means
you'll never fully know what vars make _actual sense_ in a given context. For
example what vars in the current context make sense as arguments to the
function you're about to call, when you have no idea what the type signature
of that function is (which may even be a variable). Unless, do you mean very
simple context-less code completion? That's what CIDER does, and presumably
Cursive too, but they just do it by asking the process on the other end of the
nREPL server for more details, and the plugins for these have access to the
same JVM.

~~~
gw
The reason code completion is easier with this design is that I don't need to
deal with any nREPL server; Nightlight can just go to the relevant namespace
and ask for the available symbols.

You are wrong that it is context-less code completion. In fact, I use the same
library that CIDER does: [https://github.com/alexander-
yakushev/compliment](https://github.com/alexander-yakushev/compliment) I pass
the entire top-level form to the library so it can make intelligent choices
about what to complete. Here's how it works: [https://github.com/alexander-
yakushev/compliment/wiki/Exampl...](https://github.com/alexander-
yakushev/compliment/wiki/Examples)

~~~
tunaoftheland
Just wanted to repeat my sentiment in another thread, that I love this
approach to problem solving. The outcome appears to be a tradeoff, but one
that simplifies the hard part beautifully, leaving a simple(r) solution. I
look forward to how this goes!

------
xg15
"The ambition is to create something that follows the Lisp and Smalltalk
tradition, _blurring the line between your tools and your code_ to provide
unprecedented interactivity."

(emphasis mine)

I don't come from a Lisp background, but I don't see why that would be
something desirable at all. Does anyone know more about this?

~~~
nextos
Reflection, for example, was heavily used by Smalltalk tools to build and
debug objects alive.

Growing programs without the need to stop them is also very much in the Lisp
tradition. See, e.g. the JPL remote bug in spaceship story [1].

[1] [https://ti.arc.nasa.gov/m/pub-
archive/176h/0176%20(Havelund)...](https://ti.arc.nasa.gov/m/pub-
archive/176h/0176%20\(Havelund\).pdf)

------
Jeaye
I would love to see if this works on Google App Engine. GAE has some strict
requirements, as far as what its apps are allowed to do, but, up until now,
it's been a pretty closed box when it comes to debugging. Something like this
would be superb; official support for GAE would be even better.

~~~
nothrabannosir
GAE is rolling out their next gen which is container based. No more restricted
jvm, and debugging is much better (live ssh access). Just a heads up :)

~~~
Jeaye
Thanks for the heads up. Do you know when?

~~~
nuschk
It's in beta currently [1].

Last time i checked (4 months ago, with a hobby project) it felt already
pretty mature.

[1]
[https://cloud.google.com/appengine/docs/flexible/](https://cloud.google.com/appengine/docs/flexible/)

------
wmichelin
Something is wrong with the SSL cert on
[https://sekao.net/nightlight/](https://sekao.net/nightlight/)

~~~
gw
I'm using let's encrypt, which seems to not work on chrome for android.

~~~
kim0
My let's encrypt sites work just fine on Android

------
slim
This is amazing. Could you provide a "starter image" in the form of, say, an
android .apk ? That would get me started on clojure very quickly

(that would be the smalltalk way)

~~~
sova
So you can code on a mobile device?

~~~
slim
yes, I would code by connecting to my mobile device from my laptop

------
agumonkey
Very metacircular of you. I bet 5$ that jmc is applauding.

------
meira
Interesting project. but I don't feel I'd use other editor than Emacs for
clojure.

~~~
qwertyuiop924
CIDER allow for many of the same features, IIRC. But you likely already knew
that, and I'm primarily working in Scheme with Geiser, so what do I know?

