Fork me on GitHub
#beginners
<
2022-03-19
>
Michael Agres01:03:10

I'm still struggling with setting up my environment properly, which is probably why I still can't get my first program up and running.

John Bradens03:03:04

Hey here's a tutorial for setting up the environment with vs code (I tried emacs at first and I much prefer vs code): https://www.clojurehub.com/post/10. Sorry if this isn't the help you're looking for - hopefully someone who is experienced with emacs will respond as well.

John Bradens03:03:37

Briefly looking at your post, it looks like when you switch namespaces, you might still need to require the namespace first? And that might be why the compiler doesn't know what "train" function is. That's something I had an issue with a lot when I first started.

pavlosmelissinos08:03:27

@U037SG1L9PV YMMV of course but as a rule of thumb don't try to learn multiple things at once. Just use the editor/IDE/whatever you're already most familiar with. emacs is really powerful and has an amazing ecosystem. I love it so much that I can't imagine using anything else today but when I started with Clojure I hadn't used emacs before and didn't dare to touch it until after about a year. The learning curve was too steep then. Clojure for the Brave and True has helped a lot of people learn Clojure (myself included) but much has changed since it was written. Assuming no familiarity with any editors at all I think the most beginner-friendly approach today is https://calva.io/getting-started/. #calva is a VSCode extension for Clojure. @U0ETXRFEW has done an excellent job there and is always eager to help 🙂

calva 1
pez10:03:15

Yes, we have spent a lot of effort in Calva to make it easy for beginners. Lots of work still to do there, but anyway. However, Emacs is nice, and if you know your way around it, prefer it, I think it is the best choice. I added an answer to your http://ask.clojure.org question, @U037SG1L9PV.

🙏 1
practicalli-johnny09:03:03

The Emacs chapter in the Brave Clojure book is quite dated. If using Emacs, I would recommend either Spacemacs, Doom or Prelude. It is also useful to know the basics in a command line UI to the REPL, to test if there is an issue with the editor setup for Clojure or something wrong with a Clojure project. As your follow Brave Clojure, Leiningen should be installed. Open a terminal in the root of your project (where project.clj is), then run the command

lein repl
Require a namespace to load the code into the REPL
(require '[my.namespace])
The code in that namespace can the be called with its full name (fully qualified name)
(my.namespace/function-name)
Switch to the specific namespace to use the short name
(in-ns 'my.namespace)
(function-name)
There is an example here https://practical.li/clojure/clojure-cli/repl/coding-in-the-repl.html

pez10:03:12

The prompt was actually used here, instead of the editor, as the guide instructed.

Michael Agres00:03:44

Thanks everyone.

Michael Agres00:03:34

I'm going to try Calva for now, because Emacs and the Terminal are frustrating me.

pez05:03:21

Welcome to Calva, @U037SG1L9PV. And welcome to ask for help in #calva. I recommend reading about getting started on http://calva.io and also to use the Getting Started REPL to prepare. That should make it easier to follow along the Brave and True book.

Filip Strajnar14:03:52

what's the recommended REST API library for clojure, and most mainstream Text editor choices?

Ferdinand Beyer14:03:12

REST API: Client or server? Editor: Oh god, do you really want to start this flame war? 🙂 (Many LISP users like Emacs. There are great extensions for VS-Code, Atom, IntelliJ to choose from).

Filip Strajnar15:03:01

REST API is a server thing

Filip Strajnar15:03:12

so I'm looking to make endpoints on a server yes

Filip Strajnar15:03:39

as for editor, I have no interest in flame war, i just want information

nate15:03:04

People like and use emacs, vim, vscode, intellij. All are good and will work well. I suggest using the editor you're most familiar with, mostly so you're not learning two big things at once. There are helpful channels here for each editor.

dorab17:03:57

For REST API server libraries, I'd recommend either http://pedestal.io/index or https://github.com/juxt/yada. Yada is the one I've used. Both have a bit of a learning curve depending on your background.

dharrigan17:03:27

Reitit is really good. I have an example here:

Michaël Salihi03:03:44

Yes +1 for Reitit. Here is the classic Todo app example with Reitit + Swagger.js configured: https://github.com/prestancedesign/todo-backend-reitit

practicalli-johnny09:03:21

I built a REST API for work using Reitit and found it really simple to work with, all the routes are defined as a data structure. Ring is the most common request/response library, decoding and encoding http to/from Clojure data structures. Reitit has a ring handler and ring middleware.

practicalli-johnny09:03:42

https://practical.li/clojure/clojure-editors/ is a quick guide to many of the Clojure aware editors. I use Emacs myself, but also have used neovim (conjure) and VS Code (VSpaceCode+ Calva) for the Live Code feature.

Dustin Paluch15:03:16

clojurescript doesn’t hoist function definitions, right?

sova-soars-the-sora15:03:58

like override stuff?

Dustin Paluch15:03:23

In JS, you can do

function foo() {
	bar();
}

foo();

function bar() {
	console.log('hello');
}
and bar will be defined before foo is called.

sova-soars-the-sora15:03:46

Clojure and ClojureScript are single-pass

sova-soars-the-sora16:03:03

but you can do (declare bar) and later implement it with (defn bar)

👍 2
wow 1
Prithvi Hv19:03:24

Execution error (FileNotFoundException) at app.core/eval2041 (form-init15186151634269250230.clj:1).
Could not locate cheshire__init.class, cheshire.clj or cheshire.cljc on classpath.
does anyone know why i would get this error?

Cora (she/her)19:03:15

I'm betting you're requiring cheshire instead of cheshire.core

🙌 1
👏 1
Prithvi Hv19:03:07

thanks facepalm i spent at-least 30 mins at this point.

Cora (she/her)20:03:59

I've been there with this exact library, unfortunately