Giter Club home page Giter Club logo

cljsh's Introduction

cljsh

A library which makes your REPL the best IDE ever and promotes totally "editorless" approach.

The ambitious goal is eliminate the code editor at all. REPL should be full autonomous: any declaration should be properly synchronized into the filesystem including proper dependency tree. The runtime is our friend. The code should be self-aware.

In the future you'll start a repl (even without a project), start hacking, compose your -main function and just have your project in the fs properly saved, ready to be compiled to jar :)

Note, this is proof of concept for now. Everything will change :)

Done

  • cljsh.repl/defnc (define-code) macro allows you preserve fn definition
  • cljsh.repl/save fn dumps the code and updates it properly
  • cljsh.namespaces/add-requires-from-var fn to patch fn's namespace with required imports
  • cljsh.deps/install! fn to add dependency dynamically and update project dependencies inside the lein's project

Usage

(ns cljsh.example)
(use 'cljsh.repl)

;; define fns using this macro instead of defn
(defnc f1 [] (println (str "Any crazy code" (or true "even macros" "(you know 'or' is a macro)"))))
(defnc f2 [] (println (str "Now use f1:" (f1))))

;; at some point just save it to the filesystem
(-> f1 var save)
(-> f2 var save) ;; no dependency management right now, sorry, note the dependency-first order

;; now hack on any fn
(defnc f1 [] "Refactored")

;; and just save the function again!
(-> f1 var save)

;; check filesystem contents:
(-> f2 var var->sym-filename slurp println)

the output and the content of src/cljsh/example.clj should be like this:

(clojure.core/ns cljsh.example)

(clojure.core/defn f1 [] "Refactored")

(clojure.core/defn f2 [] (println (str "Now use f1:" (f1))))

Of course this ns is ready to be used. Check like this:

(require 'cljsh.example :reload)
(f2)
;; This will print:
;; Now use f1:Refactored

Known limitations

Reader macros are written already expanded by repl reader (e.g. #(pr %) -> (fn* [foo#] (pr foo#)), also ' -> quote, #' -> var). Use function, not reader macros to get pretty dumped fns (expanded are saved also correctly, but look ugly)

Is this any good?

Yes. This library is being developed absolutely without any editor.

I started with clojure and com.cemerick/pomegranate adding dependencies on the fly. Nothing else. Even no shell commands (used lucid.git to commit & push)!

License

Copyright © 2017 Vlad Bokov

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

cljsh's People

Contributors

razum2um avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.