Open practicalli-johnny opened 4 years ago
Recorded the video. Some editing required to remove the bloopers.
Re-recorded video with new OBS setup, with full HD and 450,000kbps bitrate.
Edited the video to remove gaps and bloopers. Now waiting for YouTube to process the new video.
Hmm, there is a limit to how many edits you can make via the YouTube dashboard :disappointed:
Welcome to Practicalli, thank you for joining me.
I'm John and i'll introduce you to the Clojure CLI tools, the simplest way of running and working with a Clojure REPL and projects.
This video assumes you have installed the Clojure CLI tools and the Practicalli deps.edn configuration. See the video on installing the Clojure CLI tools if you havent done so already.
I will show you how to run a single Clojure expression so you can quickly try a little Clojure. How to run a feature rich REPL for a simple development environment.. How to create and run Clojure projects
Finally we will see how to run a REPL, which is a live Clojure environment in which you can immediately evaluate your code, so you get feedback as you write your code.
** Running Clojure code
Using the
-e
option with theclojure
command you can evaluate a Clojure expression, an expression being any single piece of correct Clojure code.For example clojure -e "(+ 1 2 3)"
This command prints out the value returned from evaluating the Clojure code.
You can run an existing Clojure project using the
-m
option. The-m
option sets the main namespace, the entry point into your applicationThe project does need to have a
-main
ormain
function defined and have (:gen-class) in the namespace.clojure -m simple.core
This is a very simple project and prints out "Hello World!"
** Running a Clojure REPL
Clojure development is done with a REPL. This is your live Clojure environment, where you can run your code as you write it and get immediate feedback.
There is no external compilation of code, it all happens as soon as you evaluate the expression.
Typing
clojure
into a command line terminal will start a Clojure REPL Although better REPL experience is provided via theclj
command.clj
adds therlwrap
command, providing a readline for the Clojure REPL.A readline library provides line-editing and history capabilities, essential for interactive command line tools such as the Clojure REPL.
[run clj in a terminal]
** Extending Clojure CLI tool with Aliases <Review the ~/.clojure/deps.edn> file from practicalli and discuss aliases.
clojure
andclj
commands can use aliase with the-A
option, for exampleclojure -A:new
uses the alias called:new
, which in this case creates a project.To create a Clojure project that we can run as an application, use the app template. clojure -A:new app domain/main-namespace
The domain is the top level grouping for your project, like google, cognitect, clojure.org. It could be the company you work at, the business area, application suite the project is part of or your GitHub account or organisation name for a personal or open source project.
The main-namespace is usually the name of the specific application or service you are building.
This creates a project with a standard structure
[tree of project]
Other templates can be used such as
lib
when building a library of functions. There are many other templates defined by the community [provide a link / create a website with a curated list of templates]** Rebel Readline Alias Rebel Readline provides function signature information, documentation, editing styles and tools to manage the REPL, including a quit function.
Using an alias, the rebel readline library is added as a dependency and its main namespace specified so it will run when calling the
clojure
command.Including an alias for rebel readline in $HOME/.clojure/deps.edn makes it available to all projects.
There are many useful aliases defined in the Practicalli deps.edn configuration.
** In summary This has covered the basics of evaluating Clojure code, running a REPL and working with projects so you have a good foundation on which to learn how to write Clojure code.
Thank you for listening and see you in the next video.