Fork me on GitHub
#beginners
<
2017-09-11
>
Zor13:09:40

greetings! Something looks terribly wrong to me with my environment. I ran lein new compojure-app httpbis and I can't seem to get anything worthy out of the REPL. By that I mean, when I (in-ns 'httpbis.repl) then (start-server), I get a CompilerException java.lang.RuntimeException: Unable to resolve symbol: start-server in this context, compiling:(/tmp/form-init9088880558428708437.clj:1:1)

noisesmith17:09:20

the common issue here is that you have no :init-ns defined, or there was a startup compilation error you missed. when in-ns is run, it doesn’t require the namespace or ensure it’s valid, if the ns specified doesn’t exist (for any reason) it creates a new one but makes none of the default bindings (eg. putting clojure.core into scope with refer-clojure which ns does implicitly)

noisesmith17:09:10

the solution is two part: you can use (clojure.core/in-ns 'user) to get back to a sane place, then (require 'httpbis.repl :reload) and then switch to the ns but only if there are no errors on the require

Zor21:09:46

Thank you for your detailed reply 🙂 Much appreciated

Zor13:09:30

I also tried with the Cursive NREPL - same results. Also tried with Emacs' CIDER (jacked in, moved to NS using a fancy elisp fn, didnt work either)

Zor13:09:06

I can see the code. I can cat it. It is there. How to troubleshoot this ?

Lucas Barbosa13:09:24

I’m also experiencing that… can’t use docs, for instance, on my proto-repl on Atom

noisesmith17:09:14

if by docs you mean doc AKA clojure.repl/doc this is only available if you use clojure.repl which is done by default by clojure for your first namespace, but can be done by hand in other namespaces later (use 'clojure.repl)

Lucas Barbosa17:09:45

Got it! Thanks

Zor13:09:09

@lvbarbosa is your project using ring as well ?

Lucas Barbosa13:09:01

Yes, same thing

Zor13:09:17

mmh. I suspect this has to do with either the generated project.clj being wonky or it's the lein-ring plugin's fault

Zor13:09:36

so you are making do without a REPL ? do you run lein ring server and hope it reloads code correctly ?

Lucas Barbosa13:09:17

Well, the only thing I can’t access is those handy functions like docs

Lucas Barbosa13:09:33

I can load my namespace and test the functions I am writting

Lucas Barbosa13:09:42

Let me show you

Zor13:09:33

with pleasure

Zor13:09:24

apparently you editor sent your (defn ..) form to the REPL

Zor13:09:42

but there's no evidence your file was loaded before that

Zor13:09:16

when you lein repl, can you just invoke code from your project ? I can't believe this is not working for me 😒

Lucas Barbosa13:09:26

I can’t but it works if I require the .clj module

Lucas Barbosa13:09:36

like (require 'tasks-api.core)

Lucas Barbosa13:09:48

should this be automagic?

Zor13:09:35

I would think so, was hoping so, what was I thinking

Lucas Barbosa13:09:54

maybe there’s a quicker way to setup the project.clj

Zor13:09:54

for your case, have you tried (use 'clojure.repl) ?

Lucas Barbosa13:09:32

I mean, maybe there’s a way to setup the project.clj file in order to make it automatically import our namespaces

Lucas Barbosa13:09:46

I didn’t try that yet. Giving it a try soon

Zor14:09:18

ok I got it

Zor14:09:30

when editing my files, I introduced some errors, compilation errors

Zor14:09:52

so my 'httpbis.repl namespace couldn't be required correctly

Zor14:09:18

but they wouldn't show up until I did the (require ... - which is why I wasn't suspecting this at all

Zor14:09:42

now with regards to my project fiels being magically required when I start the REPL ... well I probably got spoiled

Zor14:09:12

or ... in my previous clojure endeavors there was a main

Zor14:09:25

that was eventually requiring most of my code, one way or another

Zor14:09:43

in this case I notice the repl starts in home NS, where presumably nothing is loaded by default

Zor14:09:34

gotta leave for ~20mn, feel free to either PM me or use slack threads

Zor14:09:08

@lvbarbosa I found :repl-options {:init-ns httpbis.repl} in project.clj - that helps a lot with regards to requiring my stuff when REPL starts

Zor14:09:55

An alternative is providing a :main namespace, which the REPL should home in

vinnyataide16:09:11

Hello there. Anyone using spectrum?

vinnyataide16:09:50

I was hooked by it after using ocaml for awhile. Only need to know how to use it automatically without having to type 'check ns fn everytime

noisesmith16:09:01

https://github.com/arohner/spectrum - I hadn’t heard of it, but it looks very promising - I think I’ll use it when I start using spec

itaied19:09:41

where can I discuss and ask questions about datomic?

seancorfield19:09:42

There's a #datomic channel

itaied19:09:02

Great thanks

rcustodio19:09:06

Hi... is netty better than java socket?

seancorfield19:09:43

I suspect that's one of those "It Depends" questions... better for what? Better in which way?

rcustodio19:09:12

I'm playing with clojure.. making online games (backend).. and to comunicate between client <-> server I will use TCP/UDP of course, but I'm not sure which should I use

rcustodio19:09:47

Or a backend server like "mainframe", all connect to it...

seancorfield19:09:47

So you're going to be communicating server to server, rather than web browser client to server @rcustodio ?

rcustodio19:09:05

I'm new in clojure and java libs..

rcustodio19:09:40

There is server to server (the mainframe like)... and there is client to server (game like)

Ben Redden19:09:50

Howdy ClojureFolks. Ive been inspired to check out Clojure from a blog article about Functional Programming in JavaScript being an anti-pattern.. they recommended ClojureScript.. and then someone recommended Clojure instead of that, to begin with. Any good “hello world” resources I have to check out?

seancorfield19:09:52

Not sure what I'd suggest for that. If you were building a web app game, the obvious answer would be "use web sockets" and I'd probably point you at Sente which uses core.async to provide channels that communicate back and forth between web client and server in a really nice way.

seancorfield19:09:36

I'd probably avoid direct server-to-server comms if possible -- and use a message queue instead...

bfabry19:09:50

@bengineer the most popular introductory clojure book is free online, it's called "Clojure for the Brave and True"

rcustodio19:09:09

I see... but I dunno if the game will be browser.. The "front" developer says he prefer to use scala to make for mobile

rcustodio19:09:20

Like RabbitMQ?

bfabry19:09:32

clojure vs clojurescript is really a "what do you want to do?" question

seancorfield19:09:35

@bengineer Getting up and running with Clojure on the JVM is a lot easier than ClojureScript in the browser -- so I'd "learn Clojure" on the back end first, so you can avoid a lot of the tooling complexity.

Ben Redden19:09:29

i’m already liking it :+1:

rcustodio19:09:40

@bengineer I agree with @seancorfield, I think you should get used with clojure before, FP

seancorfield19:09:18

@rcustodio Ah... so he'll be writing Scala for the client and connecting to your Clojure backend over the Internet. Hmm, not sure what I'd recommend then, sorry.

rcustodio19:09:54

That is the reason I'm choosing TCP/UDP

seancorfield19:09:26

@bengineer Brave/True is a good place to start. I hear really good things about Carin Meier's "Living Clojure" book too. The http://4clojure.com website is a great way to practice your understanding of Clojure/FP once you're through Brave/True, if you like programming puzzles.