2016-03-16
| 00:11 | rhg135 | maybe deep down you knew |
| 00:38 | sdegutis | Perhaps. |
| 00:38 | sdegutis | Why is all the code I've ever written in my past terrible? |
| 00:39 | rhg135 | has anyone else besides you said that? We're our worst critics. |
| 00:39 | sdegutis | It's almost as if (is-code-good? code) is implemented as (.before (:date-written code) (java.util.Date.)) |
| 00:39 | sdegutis | Or perhaps (constantly false). |
| 00:40 | sdegutis | Hmm. Nobody has seen my code, so nobody can say that. |
| 00:40 | sdegutis | Oops that should be .after not .before |
| 00:40 | sdegutis | Also it's cleaner looking this way (. (:date-written code) after (java.util.Date.)) but I don't know if that's valid syntax. |
| 00:40 | sdegutis | ,(. (java.util.Date.) before (java.util.Date.)) |
| 00:41 | rhg135 | (constantly false) sounds right |
| 00:41 | clojurebot | false |
| 00:42 | rhg135 | ,(. (java.util.Date.) (before (java.util.Date))) |
| 00:42 | clojurebot | #error {\n :cause "java.lang.Class cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Class cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval49 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval49 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval49 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 692... |
| 00:42 | rhg135 | ,(.. (java.util.Date.) (before (java.util.Date))) ; yay |
| 00:42 | clojurebot | #error {\n :cause "java.lang.Class cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Class cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval73 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval73 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval73 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 692... |
| 00:42 | rhg135 | aww |
| 00:43 | rhg135 | ,(.. (java.util.Date.) (before (java.util.Date.))) ; heh |
| 00:43 | clojurebot | false |
| 00:44 | rhg135 | you just need to squint a bit at that exception |
| 01:04 | sdegutis | wait, what? |
| 01:04 | sdegutis | Oh, missing period. |
| 01:04 | sdegutis | Heh. |
| 01:04 | sdegutis | ,(. (java.util.Date.) (before (java.util.Date.))) |
| 01:04 | clojurebot | false |
| 01:04 | sdegutis | clojurebot: YOU SUCK |
| 01:04 | clojurebot | It's greek to me. |
| 01:04 | sdegutis | exactly. |
| 01:06 | rhg135 | Don't be mean to her! |
| 01:20 | sdegutis | You.. you gave it a /name/ ??? |
| 01:23 | sdegutis | Goodnight rhg135 |
| 01:24 | rhg135 | You must be in Europe |
| 01:24 | rhg135 | Those timezones |
| 01:25 | sdegutis | Haha. |
| 01:26 | sdegutis | ,(java.util.Date.) |
| 01:26 | clojurebot | #inst "2016-03-16T05:26:17.092-00:00" |
| 01:26 | sdegutis | Hmm, yeah that's about 5 hours off. |
| 01:26 | sdegutis | Good night. |
| 04:59 | zipper | How can I find out how to identify the library I want from clojars? For example all I know is that I want to use `Thread/sleep` |
| 05:01 | ben_vulpes | that'd be a java call, zipper |
| 05:01 | ben_vulpes | ,(.sleep Thread 50) |
| 05:01 | clojurebot | #error {\n :cause "No matching method found: sleep for class java.lang.Class"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching method found: sleep for class java.lang.Class"\n :at [clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 53]}]\n :trace\n [[clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 53]\n [clojure.lang.Reflector invokeInstanceMe... |
| 05:01 | ben_vulpes | or something like that |
| 05:02 | ben_vulpes | ,(sleep Thread. 50) |
| 05:02 | clojurebot | #error {\n :cause "Unable to resolve symbol: sleep in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: sleep in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: sleep in this... |
| 05:02 | zipper | ben_vulpes: Let me google how to make a java call from clojure |
| 05:02 | qsys | '(Thread/sleep 50) |
| 05:02 | qsys | ,(Thread/sleep 50) |
| 05:02 | clojurebot | nil |
| 05:02 | qsys | sleep is a static of class 'Thread' |
| 05:03 | qsys | so you call it with (Thread/sleep xx) |
| 05:03 | qsys | http://clojure.org/reference/java_interop |
| 05:07 | zipper | I get a null pointer exception on `((Thread/sleep 1000) (println "hi"))` |
| 05:07 | zipper | Even though it does delay and prints as expected. |
| 05:07 | zipper | Then the exception comes later. |
| 05:08 | qsys | Thread/sleep returns nil |
| 05:09 | luma | you're calling the return value of Thread/sleep as a function |
| 05:09 | qsys | so your expression evaluates, if I'm right, to (nil (println "hi")) |
| 05:09 | luma | it returns nil (and so does println), so you're actually calling (nil nil) |
| 05:09 | luma | ,(nil nil) |
| 05:09 | clojurebot | #error {\n :cause "Can't call nil, form: (nil nil)"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: Can't call nil, form: (nil nil), compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6875]}\n {:type java.lang.IllegalArgumentException\n :message "Can't call nil, form: (nil nil)"\n :at [clojure.la... |
| 05:09 | qsys | and than 'nil' is a 'function call' |
| 05:09 | qsys | thx luma :p |
| 05:09 | zipper | I see |
| 05:10 | i-blis | qsys: wrap in a do |
| 05:10 | luma | ,(do (Thread/sleep 1000) (println "hi")) |
| 05:10 | clojurebot | hi\n |
| 05:10 | i-blis | ,(do (Thread/sleep 3000) :value) |
| 05:10 | clojurebot | :value |
| 05:41 | zipper | Hey why would this require be failing on me https://www.refheap.com/4ecaf595303df887e0cad70e5 |
| 05:42 | hiredman | there is no namespace core.async |
| 05:43 | ridcully_ | is :gen-class a thing in cljs? |
| 05:43 | hiredman | nope |
| 05:43 | ridcully_ | guessed so |
| 05:44 | zipper | I'm not using cljs |
| 05:45 | zipper | It seems that I am though. I am currently just simulating uploads. |
| 05:45 | ridcully_ | but require-macro/include-macros is cljs only (right?) |
| 05:45 | zipper | Here's a better one then https://www.refheap.com/2bb002a66f61f1c2641410321 |
| 05:46 | zipper | Improved and the error has reduced. |
| 05:46 | zipper | ridcully_: I am learning so much in parallel it's confusing. |
| 05:47 | zipper | FilenotFoundException hmmm maybe it hasn't downloaded the lib |
| 05:52 | zipper | How can I see the return values of `ret-num` in the repl? |
| 05:54 | AndreasO | Draw multiple objects on seesaw canvas, not knowing amount or places beforehand? |
| 07:24 | aurelian | hi there... I need to collect some data by doing some api calls, but now I have to add another data source, another service that will basically return same kind of data. |
| 07:24 | aurelian | now, I've been trying to figure out what's the best way to do that, should I use defprotocol or definterface or just stick with simple fn and not overthink this thing? |
| 08:31 | adam2 | Hi there ! |
| 08:34 | adam2 | I have a bit of a hard time finding good doc about macros in clojurescript |
| 09:15 | iMadper | Hi. I have following code to read logs into list from a file. (println "loading file done in: " (time (def lines (str/split-lines (slurp "log2"))))) However it runs extermely slow. (~3000ms) (compare to golang or Crystal-lang in 100ms) May I know what's the correct way? :-) |
| 09:16 | iMadper | The log2 is about 300MB |
| 09:18 | iMadper | oops, it should be read as "(~13000ms)" |
| 09:20 | opqdonut | you could write your own loop that uses BufferedReader.readLine |
| 09:20 | opqdonut | and you could also profile slurp and split-lines separately |
| 09:20 | dysfun | slurp is really meant for reading small files |
| 09:21 | iMadper | opqdonut: Thanks a lot. I will give it a try. |
| 09:21 | dysfun | and split-lines is probably not horrifically efficient |
| 09:21 | iMadper | opqdonut: slurp is slow as well.. |
| 09:21 | opqdonut | it seems split-lines just calls java's String.split |
| 09:21 | dysfun | if you need high performance IO, the java reader stuff is worth looking into |
| 09:21 | opqdonut | but still, if you have lots of lines it doesn't make sese to read the file into a huge string and then split |
| 09:22 | iMadper | dysfun: Yeah you are right. Slurp is slow for a big file. |
| 09:22 | opqdonut | https://clojure.github.io/clojure/clojure.java.io-api.html lots of useful stuff here |
| 09:22 | dysfun | slurp is more a convenience for when you're in the repl and want to play with some data |
| 09:22 | iMadper | I see. Thanks you all. |
| 09:22 | opqdonut | e.g. (input-stream "filename") should give you something you can call .readLine on |
| 09:22 | iMadper | I'll try some other api. :-) |
| 09:23 | opqdonut | sorry, (reader "filename") |
| 09:26 | dysfun | bufferedreader is good because it will read in large chunks |
| 09:27 | dysfun | so you're trying to parse a logfile? |
| 09:27 | iMadper | dysfun: yes. |
| 09:27 | dysfun | is it a widely used format? |
| 09:27 | iMadper | dysfun: No. |
| 09:27 | dysfun | ah |
| 09:28 | dysfun | do you have to read a lot of them? |
| 09:28 | dysfun | as in is performance a hard requirement here? |
| 09:28 | iMadper | dysfun: not a hard requirement. I just want to know why my program is so slow... |
| 09:29 | dysfun | ah right. well if you don't have strong performance requirements, you might find something like parse-ez quite helpful |
| 09:29 | dysfun | but you'll have to google it because i don't have a browser installed yet on this machine :) |
| 09:30 | iMadper | dysfun: Yeah, I can google it even if I'm in China. lol |
| 09:30 | dysfun | oh is google forbidden at the minute? |
| 09:30 | iMadper | yes. |
| 09:30 | dysfun | and baidu has been serving malware in its ads |
| 09:30 | dysfun | quality |
| 09:31 | iMadper | Sometimes you just won't get the correct answer by using Baidu... |
| 09:32 | dysfun | i remember at my college (a top 20 college in britain, thus very attractive for rich chinese parents to send their kids off to get educated) |
| 09:33 | dysfun | we were having an 'everyone in the year' presentation sort of thing and the woman on the stage said "be sure to google tiananmen square while you're here" |
| 09:33 | iMadper | lol~ |
| 09:34 | rks | lol |
| 09:35 | rks | did anyone heard about shenlanguage |
| 09:35 | rks | ? |
| 09:35 | rks | i just visited their website |
| 09:35 | dysfun | no, what's their USP? |
| 09:36 | rks | you can visit their website http://shenlanguage.org/ |
| 09:37 | wink | was that the one with the license kerfuffle? |
| 09:37 | rks | a lisp dialect that have types, pattermatching like prolog |
| 09:37 | dysfun | hrm, interesting |
| 09:37 | dysfun | probably not interesting enough for me to bother learning, but interesting enough to look at |
| 09:38 | rks | it grew some interest on me |
| 09:38 | dysfun | i'm sceptical that lisps with type systems work terribly well |
| 09:39 | rks | i see |
| 09:39 | dysfun | i like haskell's type system, i like clojure, but the intersection of them is a bit weird |
| 09:39 | rks | in clojure in have schema / typeclojure |
| 09:39 | dysfun | and syntax for type annotations is universally awful |
| 09:39 | rks | *it |
| 09:40 | rks | i agree |
| 09:40 | rks | made in china :) |
| 10:10 | sdegutis | Is there some nifty way to replace nils with zero when adding? |
| 10:10 | sdegutis | fnil comes to mind, but I don't remember why it's there |
| 10:11 | sdegutis | ,(+ ((fnil + 0) nil)) |
| 10:11 | clojurebot | 0 |
| 10:21 | sdegutis | Never mind. |
| 10:27 | pyr | hola |
| 10:38 | faxmodem | que tal? |
| 10:38 | oracle123 | I have some code as data in a file, but how to read it out as code? |
| 10:38 | oracle123 | (read-string (slurp "my.ini" :encoding "utf-8")) |
| 10:39 | oracle123 | I use that code, but it doesn't work |
| 10:39 | oracle123 | The content of the file is {:accounts 1 :bidding? false :start-webdriver? true} |
| 10:39 | oracle123 | But the result of read-string is empty |
| 10:40 | opqdonut | does the slurp work on its own? |
| 10:40 | opqdonut | because that does look correct |
| 10:40 | oracle123 | it works for (slurp "my.ini" :encoding "utf-8") |
| 10:40 | opqdonut | what's the result of that? |
| 10:40 | oracle123 | it should show the good result |
| 10:41 | wink | (:accounts (read-string (slurp "my.ini" :encoding "utf-8"))) -> 1 |
| 10:41 | wink | works for me |
| 10:41 | oracle123 | If I println , then the result of slurp is {:accounts 1 :bidding? false :start-webdriver? true} |
| 10:41 | oracle123 | |
| 10:41 | wink | maybe your file contents is different from what you pasted |
| 10:41 | oracle123 | not sure whether the encoding is the problem |
| 10:42 | oracle123 | Original it works on my linux, but when I share it with my friend who are on windows, then it failed |
| 10:42 | oracle123 | So I save it in UTF-8 in notepad on windows and copy to linux |
| 10:43 | opqdonut | you could use (seq (slurp "my.ini" :encoding "utf-8")) to see what characters the file contains |
| 10:43 | opqdonut | in case there is something weird there |
| 10:44 | wink | maybe try a clojure.string/trim around slurp as well |
| 10:46 | oracle123 | I tried trim, still doesn't work |
| 10:46 | opqdonut | what did seq give? |
| 10:46 | oracle123 | if use seq, I could see \return \newline |
| 10:47 | oracle123 | is that the problem? |
| 10:47 | wink | should not if you use trim |
| 10:47 | opqdonut | that's not a problem anwyay |
| 10:47 | oracle123 | |
| 10:47 | oracle123 | (println (seq (load-config "/home/oracle/clojure/lein/page_scan_controller/config_test_no_chinese.ini"))) |
| 10:47 | opqdonut | ,(read-string "{:hello 1}\r\n") |
| 10:47 | clojurebot | {:hello 1} |
| 10:47 | oracle123 | ( { : a c c o u n t s 1 : b i d d i n g ? f a l s e : s t a r t - w e b d r i v e r ? t r u e } |
| 10:47 | oracle123 | |
| 10:48 | opqdonut | no don't println it |
| 10:48 | opqdonut | just run it and show what you see in the repl |
| 10:48 | opqdonut | or if you're not in a repl use prn |
| 10:49 | opqdonut | prn is what you should use when debugging, it doesn't hide stuff |
| 10:49 | oracle123 | (\ \{ \: \a \c \c \o \u \n \t \s \space \1 \space \: \b \i \d \d \i \n \g \? \space \f \a \l \s \e \space \: \s \t \a \r \t \- \w \e \b \d \r \i \v \e \r \? \space \t \r \u \e \} \return \newline) |
| 10:49 | oracle123 | |
| 10:49 | oracle123 | that's the prn |
| 10:49 | opqdonut | yeah that looks ok |
| 10:50 | oracle123 | then why read-string return nothing? |
| 10:51 | opqdonut | are you certain it returns nothing? does nothing mean it returns nil? |
| 10:52 | prohobo | NOTHING |
| 10:52 | oracle123 | in cider, it shows nothing, but when check it's type, it's clojure.lang.Symbol |
| 10:53 | opqdonut | hmm |
| 10:53 | oracle123 | I can't see anything if run the read-string |
| 10:53 | oracle123 | but if use (type (read-string (load-config "/home/oracle/clojure/lein/page_scan_controller/config_test_no_chinese.ini"))) |
| 10:54 | opqdonut | maybe the first empty character in that string is some sort of weird non-breaking whitespace |
| 10:54 | opqdonut | which gets read as a symbol |
| 10:54 | oracle123 | ok, let me delete the leading invisible char |
| 10:55 | opqdonut | ,(read-string "\u00A0{:hello 1}") |
| 10:55 | clojurebot | |
| 10:55 | opqdonut | something like that |
| 10:55 | opqdonut | my repl shows a ? character instead of an empty line |
| 10:56 | opqdonut | it might be the utf-8 byte order mark, created by notepad |
| 10:56 | opqdonut | ,(read-string "\uFEFF{:hello 1}") |
| 10:56 | clojurebot | |
| 10:56 | opqdonut | no idea why it shows up as "\ " and not \uFEFF or something |
| 10:57 | oracle123 | yes, must because of the notepad, since when I work on linux native file, it works well |
| 10:58 | oracle123 | but faield when work on the file coped from window notepad |
| 10:58 | oracle123 | any workaround? |
| 10:59 | oracle123 | In windows the repl show ?, in linux it show nothing |
| 10:59 | opqdonut | don't have BOMs in files |
| 10:59 | opqdonut | is the best solution |
| 11:00 | oracle123 | so don't use notepad? |
| 11:00 | opqdonut | yeah |
| 11:00 | oracle123 | then use what editor? the custome is not IT guys |
| 11:00 | oracle123 | and I need to give them a tool to edit the file |
| 11:00 | oracle123 | I have put the configuratoin in the file, |
| 11:01 | opqdonut | well you can ask them to save as ascii |
| 11:01 | opqdonut | or perhaps you can remove the BOM when reading |
| 11:01 | oracle123 | But I have Chinese in the data |
| 11:01 | opqdonut | oh ok |
| 11:01 | oracle123 | then how to remove BOM? |
| 11:02 | opqdonut | clojure.string/replace |
| 11:02 | opqdonut | for instance |
| 11:02 | opqdonut | ,(clojure.string/replace "\uFEFF{:hello 1}" #"\uFEFF" "") |
| 11:02 | clojurebot | "{:hello 1}" |
| 11:02 | oracle123 | great, let me try :) |
| 11:05 | opqdonut | googling reveals lots of problems with BOMs in clojure, it's kinda dumb that the reader doesn't support it |
| 11:08 | oracle123 | yeap, it works, thanks very much |
| 11:08 | dysfun | opqdonut: that should probably be anchored to the start of string. the string is otherwise invalid |
| 11:08 | opqdonut | I don't think the BOM can occur anywhere else |
| 11:08 | dysfun | not and be valid, yes |
| 11:08 | opqdonut | but sure, why not |
| 11:09 | opqdonut | oracle123: you can use #"^\uFEFF" as the replacement regex for added safety |
| 11:09 | dysfun | if you can't trust a tool not to put a BOM except at the beginning of the string, you can't trust it to spit out unicode, period |
| 11:09 | opqdonut | would also give performance in case the string is long |
| 11:09 | dysfun | that was the main reason i suggested it, yeah :) |
| 11:09 | opqdonut | "if you can't trust a programming language to hand BOM you can't trust it to handle unicode, period"? |
| 11:09 | opqdonut | *handle |
| 11:10 | dysfun | clojure handles utf-8 absolutely fine |
| 11:10 | oracle123 | should it be a bug? of just as design? |
| 11:10 | dysfun | well, i do think it is a bug, but i don't know whether reporting it would result in it being fixed |
| 11:10 | opqdonut | I think it's a bug, but opinions may vary |
| 11:11 | dysfun | there is an argument that you should be decoding the string, for example |
| 12:57 | amalloy | the BOM should be handled when reading the file, not when processing the string |
| 12:57 | amalloy | whatever file-reading mechanism load-config is using |
| 12:58 | amalloy | it should already be gone by the time you call read-string |
| 12:59 | dysfun | it should, but also clojure should be quite capable of skipping over a BOM |
| 13:46 | adam1 | Hey there, any expert to generously give me a hint about macros in clojurescript ? |
| 13:48 | rhg135 | They have to be in. .clj files that you require-macros in |
| 13:48 | adam1 | Yes, but i get a "Could not locate pro/macro__init.class or pro/macro.clj on classpath" error and I'm not sure why |
| 13:49 | adam1 | I've got a macro.clj file in the same directory as my *.cljs file, have specified the right namespace... |
| 13:50 | rhg135 | Does that file actually load? Look at the cause there |
| 13:51 | rhg135 | Squint at it |
| 13:53 | adam1 | Hmmm |
| 13:54 | rhg135 | You can probably get better information trying to require it in a clj repl. Keep in mind the expansions will not work |
| 13:55 | adam1 | Not quite sure what you mean by "squint", my english is pretty decent nonetheless :p |
| 13:57 | adam1 | But I can require the macro file from the repl |
| 13:57 | rhg135 | I mean those traces sometimes require you to look at them differently |
| 13:58 | rhg135 | That's strange, maybe there's more people that actually use cljs |
| 13:59 | adam1 | I'll try to figure it out, quite weird indeed |
| 14:16 | adam1 | Well, kinda works now |
| 14:19 | justin_smith | ben_vulpes: do you want Thread/currentThread ? |
| 14:19 | justin_smith | ugh, n/m, scrollback, sorry |
| 14:52 | sdegutis | My muscle memory suddenly went blank, I can't remember how to jump to the definition of a symbol, or what that's even called in Cider. Anyone remember? |
| 14:53 | amalloy | M-. |
| 14:53 | sdegutis | Oh right, C-u M-. |
| 14:53 | sdegutis | Thanks amalloy. |
| 14:54 | sdegutis | amalloy: we may not see eye to eye on everything, but you're a swell chap and a mighty fine Clojurian at that |
| 14:54 | amalloy | C-u? what does it do without that prefix? |
| 14:54 | sdegutis | amalloy: I think it asks you to specify what symbol without the prefix. |
| 14:54 | sdegutis | amalloy: with the prefix, it just jumps to the symbol under your cursor. |
| 14:54 | amalloy | lame. it should be the opposite imo |
| 14:54 | sdegutis | For sure. |
| 14:55 | amalloy | it's the opposite in slime |
| 14:55 | sdegutis | Isn't that a predecessor of Cider? I vaguely remember that name. |
| 14:56 | sdegutis | Oh right, it's the CL thing. |
| 14:56 | sdegutis | Haha, "Common Lisp". |
| 14:56 | justin_smith | and alos a cider precessor |
| 14:56 | amalloy | "precessor": it was a cesspool before cider was? |
| 14:56 | sdegutis | Haha. "Cesspool." |
| 14:56 | justin_smith | oops, heh |
| 14:57 | amalloy | ps i don't feel that strongly about cider. just an opportune pun |
| 14:57 | justin_smith | amalloy: https://en.wiktionary.org/wiki/precessor |
| 14:57 | justin_smith | :P |
| 14:57 | justin_smith | amalloy: I read a novel from the 18th century recently, I think it did damage |
| 14:57 | sdegutis | Good day, gentlemen. |
| 14:57 | amalloy | "obsolete" in 1913. rip |
| 14:57 | justin_smith | like I said, it's all 18th century literature's fault |
| 14:58 | amalloy | almost as outdated as slime |
| 15:01 | sdegutis | Hmm, seems the chatter died down in here. Welp, back to being productive for me I guess. |
| 15:38 | rhg135 | justin_smith: that's not a unfortunate thing. now we have things like anyways, ain't, and bad meaning good |
| 15:39 | RedNifre | Heya. I first installed Clojure from the Ubuntu repository and got an outdated version but I could start .clj files with "clojure bla.clj". I got rid of that version and used leiningen instead. Does the leiningen repl only work for projects or can I start a single file with it? |
| 15:39 | RedNifre | When I try "lein run somefile.clj" it looks for a namespace in a missing project file. |
| 15:40 | RedNifre | Also, is it possible to write a shebang and execute clj files like "./somefile.clj"? |
| 15:40 | rhg135 | I want to say yes, but that will only help if you have no deps |
| 15:40 | justin_smith | RedNifre: on linux a jar file is executable, so you can do ./clojure-1.8.jar somefile.clj |
| 15:40 | rhg135 | and yes to shebang |
| 15:41 | justin_smith | oh, yeah #!/path/to/clojure.jar on the first line of the file |
| 15:41 | hiredman | it is |
| 15:42 | hiredman | how to do that is kind of complicated, because it turns out that how the shebang line is handled isn't entirely standard on different unix like systems |
| 15:42 | rhg135 | if you have deps, just make a project |
| 15:42 | hiredman | osx is kind of the easiest to make work, linux takes more work |
| 15:42 | rhg135 | or inlein I guess |
| 15:42 | justin_smith | there's that new thing hyPiRion did, is that inlein? |
| 15:42 | hiredman | osx is easy to make work because it handles multiple arguments to the program in the shebang line like you would expect |
| 15:43 | rhg135 | yeah that thing |
| 15:43 | rhg135 | I've never used it, but it should work here |
| 15:44 | RedNifre | Hm, sounds like I couldn't just hand a .clj script to somebody else though. I guess making a jar is more reliable, huh? |
| 15:44 | rhg135 | yeah |
| 15:44 | hiredman | yeah |
| 15:44 | rhg135 | windows... |
| 15:45 | rhg135 | also, deps |
| 15:46 | hiredman | https://gist.github.com/hiredman/a8fb63ec64704ecb967f this style shebang works on osx |
| 15:48 | hiredman | on linux I've done stuff like https://gist.github.com/hiredman/0ecf33119a470339c89e so the file ends up valid shell and valid clojure |
| 15:48 | rhg135 | yay for hardwiring paths, but I didn't know linux didn't habdle arguments |
| 15:48 | hiredman | (with the actually clojure code following that) |
| 15:50 | hiredman | you can actually avoid all that, by putting the java -jar clojure.jar bits in a shell script, and using that as the shebang line, but there is no standard way to do that |
| 15:52 | rhg135 | maybe I only dreamt it worked |
| 15:52 | RedNifre | Hm, could I just put #!clojure at the beginning of the file and tell people to make sure they alias clojure="path/to/the/clojure.jar" ? |
| 15:52 | rhg135 | I could have sworn I tried the former and it ran fine |
| 15:52 | justin_smith | I don't think a shebang will check aliases for the first line |
| 15:52 | hiredman | I am not sure aliases work for that, and you need the whole java bit, not just the clojure jar |
| 15:52 | RedNifre | jar it is then. |
| 15:53 | hiredman | the jar is easier to deal with dependencies too |
| 15:53 | rhg135 | plus it's pretty easy to run still |
| 15:54 | rhg135 | java -jar ... |
| 15:54 | RedNifre | Different topic, I have a problem about namespaces. I think I might kinda understand namespaces, not sure. To learn clojure I thought it might be fun to write a tiny text adventure. What I have right now is a dictionary from commands to functions, i.e. { "look" (fn [gamestate] ...) "take" (fn [gamestate] ...)} etc. Would it be a good idea to somehow turn that into a command namespace and replace it with (defn look [gamestate] ...) (defn t |
| 15:54 | RedNifre | ake [gamestate] ...) etc.? |
| 15:55 | justin_smith | RedNifre: having an explicit map from string to action is a nice way to isolate your implementation from the text UI |
| 15:56 | rhg135 | I think either would work, but being explicit is nice |
| 15:56 | justin_smith | rather than some scheme which ends up being essentially "take user input, automated transform, then eval", which is much messier |
| 15:56 | justin_smith | rhg135: my concern is the code that ends up mapping from the user input to the functions - if you don't have a hash-map with the mapping, you end up just giving the user a weird repl |
| 15:57 | justin_smith | which I mean hey, a repl is a UI too I guess, but might as well give them a real one if that's what it is |
| 15:57 | rhg135 | not really if you limit it to just ns-resolve |
| 15:58 | RedNifre | But if I had the commands in a namespace I could have language based mappings so it would still be clean i.e. (def EN {"look" look}) (def DE {"schau" look}) etc. Or would that be (def EN {"look" command/look})? Hm. |
| 15:58 | justin_smith | ,(ns-resolve *ns* 'eval) rhg135: nope |
| 15:58 | clojurebot | #'clojure.core/eval |
| 15:58 | justin_smith | it's jut a weird repl, even with ns-resolve |
| 15:59 | rhg135 | you could tag your vars, but it is messy as you say |
| 15:59 | RedNifre | Okay, so I'll keep the {"string" (fn..)} thing. What would be a good use for namespaces then? |
| 15:59 | justin_smith | now you could make an explicit hash-map lookup in the definitions of that ns alone, but the real hash-map in the file has the advantage of being more explicit |
| 15:59 | rhg135 | look it up in ns-publics too |
| 16:00 | rhg135 | indeed |
| 16:01 | justin_smith | RedNifre: namespaces are for making collections of functions that combine to provide some kind of domain of functionality, where your project is easier to understand, maintain, and use if the functions are grouped in that way |
| 16:01 | justin_smith | functions plus a few constant values too I guess |
| 16:01 | RedNifre | But doesn't that sound EXACTLY like "bunch of game commands"? |
| 16:01 | justin_smith | RedNifre: absolutely not |
| 16:02 | justin_smith | RedNifre: I would make that hash map from command names to functions in one ns, and define the individual functions in namespaces separated by theme or type of action |
| 16:02 | justin_smith | start with oen or two, split them as they become messy |
| 16:03 | RedNifre | Alright, I'll keep it as is and see where I'll end up. |
| 16:03 | RedNifre | Thanks for the feedback. |
| 16:48 | ben_vulpes | anyone ever get "NoClassDefFoundError org/apache/http/conn/ManagedHttpClientConnection com.amazonaws.http.protocol.SdkHttpRequestExecutor.doSendRequest " when using amazonica? |
| 16:49 | amalloy | probably a dependency-version conflict |
| 16:49 | hiredman | ^- |
| 17:03 | ben_vulpes | exciting! |
| 17:05 | ben_vulpes | amalloy: shall i just start snipping libs out until i find the conflicting one? |
| 17:06 | amalloy | see what `lein deps :tree` thinks |
| 17:06 | amalloy | it'll point out conflicts |
| 17:06 | amalloy | (you probably have a lot of conflicts that are just lurking, and then this one that's actually doing damage) |
| 17:09 | ben_vulpes | amalloy: good grief |
| 17:09 | ben_vulpes | been doing this long? :P |
| 17:09 | amalloy | doing what long? |
| 17:11 | ben_vulpes | working with clojure, answering questions in irc |
| 17:13 | amalloy | yes |
| 17:14 | ben_vulpes | it shows |
| 17:14 | ben_vulpes | (thank you) |
| 18:18 | kellytk | Is there a channel for lisp web dev? I found noone in #om |
| 18:19 | rhg135 | I don't think there is any I know of |
| 18:20 | kellytk | Oh, thank you rhg135 |
| 18:21 | rhg135 | here is usually pretty useful |
| 18:21 | TEttinger | yep |
| 18:25 | rhg135 | #clojurescript can be nice too, but dnolen is also here ;) |
| 19:34 | gfredericks | is there a clojure-flavored lisp somewhere that aims at purity & simplicity and a formal spec? |
| 19:35 | amalloy | dang gfredericks, you are complecting '&' and 'and' |
| 19:35 | rhg135 | purity? as in haskell with () |
| 19:35 | amalloy | you are forbidden from participating in this simple lisp |
| 19:35 | amalloy | rhg135: what does () have to do with it? |
| 19:36 | rhg135 | it doesn't really |
| 19:36 | rhg135 | you can have lists without () |
| 19:36 | gfredericks | oh I also forgot to say that I was imagining not a full general-purpose language |
| 19:36 | gfredericks | so IO not strictly necessary |
| 19:37 | amalloy | gfredericks: lambda calculus |
| 19:37 | gfredericks | you could say what I'm imagining is more of an edn-processing subset of clojure |
| 19:38 | gfredericks | but that isn't afraid to break compatibility to eradicate edge cases |
| 19:38 | gfredericks | or to simplify things |
| 19:38 | gfredericks | e.g., only one integer type |
| 19:39 | gfredericks | no vars |
| 19:39 | hiredman | have you heard of klambda? |
| 19:39 | rhg135 | lambda calculus has only one type |
| 19:39 | gfredericks | nope |
| 19:41 | gfredericks | something to do with shen? |
| 19:41 | hiredman | it is the langauge for bootstrapping shen, I guess |
| 19:41 | gfredericks | aah |
| 19:42 | hiredman | I tend to think of those sorts of things as urlisps |
| 19:43 | hiredman | they are sort of like ir languages in compilers, or bytecodes in runtimes |
| 19:43 | gfredericks | I think I keep imagining it as a language that could be used to describe business logic in a sterile and easy-to-analyze environment |
| 19:43 | gfredericks | and especially could be implemented in any clojure dialect fairly easily, following a spec so as to give identical behavior |
| 19:43 | hiredman | clojure without '.' |
| 19:44 | gfredericks | '.' meaning interop? |
| 19:44 | hiredman | yeah |
| 19:44 | gfredericks | yeah that'd be a big part of it |
| 19:44 | gilch | Maybe implement edn in Scheme? |
| 19:44 | rhg135 | specs, pfft. C has done fine so far without those |
| 19:45 | hiredman | there is so overlap with this with sandboxing |
| 19:45 | gfredericks | yes absolutely |
| 19:45 | hiredman | which I have spent time thinking about re clojurebot |
| 19:45 | gfredericks | executing untrusted code is another use case |
| 19:46 | gfredericks | AWS lambda etc |
| 19:46 | gilch | WISP is Clojure-like. |
| 19:47 | gfredericks | looks JS oriented? |
| 19:47 | hiredman | for sandboxing at various times I have looked at adding hooks to the compiler so you could take control over how it compiles special forms and writing an interpreter for clojure |
| 19:49 | hiredman | but it sounds like the difference is, while for sandboxing I largely wanted clojure semantics, with some extra control points |
| 19:50 | gfredericks | yeah definitely |
| 19:50 | hiredman | while you want a total subset of clojure |
| 19:50 | gfredericks | except the parts I don't like :) |
| 19:50 | gfredericks | I figured a first pass impl could either be an interpreter or naive compile to clojure forms |
| 19:51 | hiredman | you would like to be able to specify transforms over datastructures |
| 19:51 | gfredericks | for the spec part you mean? |
| 19:51 | gfredericks | or the compiler? |
| 19:52 | hiredman | I am restating what I think your goal is, so you can tell me I am wrong |
| 19:52 | hiredman | :) |
| 19:53 | gfredericks | oh you mean the purpose of the language then? |
| 19:53 | hiredman | yeah |
| 19:54 | gfredericks | yeah that's totally fair |
| 19:54 | gfredericks | another use case would be implementing something like jq but for edn |
| 19:54 | gfredericks | on that note if I took this seriously I might have to fork edn |
| 19:54 | hiredman | have you seen specter? |
| 19:54 | gfredericks | the marz thing? |
| 19:54 | hiredman | I haven't used it, but it seems like that |
| 19:54 | hiredman | yeah |
| 19:54 | gfredericks | not in detail |
| 19:54 | gfredericks | presumably I'll see it a month from now |
| 19:54 | gilch | pixie is also Clojure-like |
| 19:54 | hiredman | indeed |
| 19:55 | gfredericks | if I could get away with a subset of edn I could name it ed |
| 19:58 | TEttinger | then someone forks that, ned |
| 19:58 | TEttinger | nicely extensible data |
| 19:59 | rhg135 | then someon forks that, yay oss |
| 19:59 | hiredman | so specter has you specify a path (sort of like update-in, but more powerful) then you can either select out whatever is there or transform whatever is there |
| 19:59 | hiredman | so sort of like a more powerful version of get-in or update-in |
| 20:00 | hiredman | the transform of course can be an arbitrary clojure function, which may not be what you want |
| 20:00 | hiredman | but I dunno, I am not sure some restricted form of clojure is the best way to express a restricted set of changes |
| 20:01 | gfredericks | portability and exactness and simplicity are a big motivation for me |
| 20:01 | hiredman | there are lots of dsls for this kind of (jq, xslt, sql, etc) |
| 20:02 | gfredericks | sure |
| 20:02 | hiredman | (specter) |
| 20:03 | hiredman | there are, I think, regexes style libraries for clojure datastructures, that you could use to build some kind of sed for clojure data structures |
| 20:04 | hiredman | also hello haskell and lens and prisms and traversals oh my |
| 20:07 | hiredman | given lenses, I think you can model something like jq as pushing and popping lenses on a stack, which is actually kind of similar to zippers |
| 20:09 | hiredman | https://gist.github.com/hiredman/acf9d25ec013d694e2bb |
| 20:09 | hiredman | very zipper like |
| 20:12 | gfredericks | I'm still fixated on something that smells like a general purpose language |
| 20:12 | hiredman | well, so clojure is a general purpose language, why not use that? |
| 20:14 | hiredman | (this is like the fourth or fifth macro I've written named flense that does something relective on a class, but the end result is entirely different) |
| 20:14 | gfredericks | because I also want something a lot less messy than clojure |
| 20:15 | gfredericks | both w.r.t. platform stuff, other weird edge cases, and impurity |
| 20:16 | hiredman | is this subset going to ship with its own std library? |
| 20:18 | gfredericks | hiredman: yeah, though maybe heavily backed by clojure where appropriate; I'd want it to be logically untied to clojure |
| 20:21 | hiredman | so you are thinking a real language, that you would write a program in (as opposed to a fragment of a program I guess?) where you would define functions that could be reused in other parts of the program? |
| 20:23 | gfredericks | hiredman: yeah I think that and the related question of libs are the biggest thing I'm not sure about |
| 20:24 | gfredericks | and probably like 20 other thorny issues I haven't even thought of yet |
| 20:26 | hiredman | there is a design space between clojure and more declarative data dsls (like sql, specter, etc), but I have a heard time imagining something in that design space being particular useful |
| 20:26 | gfredericks | yeah :/ |
| 20:28 | rhg135 | specter itself leans on clojure to actually manipulate data |
| 20:33 | gfredericks | I've just got this soft spot for perfect ideal abstractions without messy host/perf-based edge cases |
| 20:35 | gfredericks | ugh and I'd have to have opinions about exception handling too, this would be the biggest yak... |
| 20:36 | amalloy | just declare your language unexceptional |
| 20:36 | gfredericks | nothing can crash |
| 20:37 | gfredericks | you could take the haskell approach and say you can throw errors but not catch them |
| 20:37 | gfredericks | oh geez and what about laziness I hate everything |
| 20:38 | amalloy | you can catch them in haskell though |
| 20:38 | amalloy | it's just discouraged |
| 20:38 | gfredericks | only in IO right? |
| 20:38 | amalloy | well, in the monad that your errors live in. so you can catch IO exceptions in IO, or Either exceptions in Either... |
| 20:39 | gfredericks | I was talking about (head []) in particular |
| 20:40 | rhg135 | division by zero too |
| 20:40 | gfredericks | right |
| 20:43 | amalloy | right, those are IO exceptions |
| 20:44 | gfredericks | and the others don't apply because gfrlang doesn't have monads |
| 20:44 | rhg135 | I guess technically moving electrons qualifies as io |