#clojure log - Jun 23 2017

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

1:26 mercwithamouth: not a clojure question but i've just added swagger to my project. has anyone changed the color theme for swagger? i'm not able to find the location to change the css files

3:57 nivag: curious, why does Clojure use the archaic this-variable format (which reminds me of my COBOL days, back in the 1970's) rather than the more modern succinct & easily readable thisVariable format?

3:58 dysfun: it's not archaic, it's what lisp did. i don't consider camelcase to be more readable

3:59 of course nothing stops you from using camelcase if you want to

3:59 metellus: readability is entirely subjective, and if you're calling camelCase modern you're ignoring the tons of modern languages that use this_format_for_names

3:59 nivag: my first 3 languages were BASIC, FORTRAN, and COBOL - I think I'm liking Clojure better than Python

4:00 dysfun: i think i'm liking anything better than basic, fortran and cobol

4:01 amalloy: ifCamelCaseIsSoGoodWhyDoesntEnglishUseIt

4:01 metellus: variable-names-arent-supposed-to-be-sentences

4:01 nivag: metellus, I written code in over 2 languages, I've found camelCase to be the best - I'm forced to use the older form in databases, and I find that a pain

4:01 Para`: amalloy: It used to, capitalization rules of ye olde English were kind of wonky.

4:01 nivag: over 20

4:02 Para`: which is also over 2

4:02 larsen: nivag: as they said, it's derived from Lisp. I think one of the reasons Lisp settled on this convention was that in the early days, when first Lisps were developed, lowercase were not available on the systems they were working on

4:02 metellus: nivag: right, it's subjective and you prefer camelCase. I do too. That doesn't make it inherently better, and it's a mistake to call it more modern

4:03 nivag: initially printers only had digits (fortunately, before my time), when I started programming all language keywords had to be upper case

4:05 metellus, well you couldn't use camelCase when cheap printers only had upper case! so it is more modern - unless you are a lot younger than me! :-)

4:05 camelCase is leads to shorter variables names than only using one case for letters

4:08 the convention for lower case user names for Linux, dates back to when you indicated to a Unix system that your terminal could handle lower case by typing your user name in lowercase!

4:09 dysfun: if you really think saving one character matters, i don't want to read your code

4:12 nivag: the first versions of BASIC & FORTRAN only allowed very short variable names - COBOL allowed up to 30 characters (when I used it)

4:13 I tend to use long variables names when appropriate, like pFullyQualifiedClassName (p prefix as it is a parameter)

4:14 dysfun, people tell me that my code is very readable! :-)

4:15 dysfun: that's a form of hungarian notation i suppose. i dislike hungarian notation

4:15 (i used to program vb which is full of it)

4:16 nivag: dysfun, you would have had fun with the first version of BASIC I programmed in, variables were up 2 characters long: a letter followed by a digit AFAICR

4:16 dysfun: i only see those as generated names these days

4:16 anyway, back then there was a reason. there isn't now

4:16 nivag: dysfun, I only prefix parameters, I don't both with other types og variables

4:18 Visual Basic is the only language I've ever written a program in and not been able to get it to run! VB should NEVER have been called a BASIC!!!!!!

4:18 dysfun: it may have been a shitty language, but the toolkit for building apps was brilliant

4:20 nivag: the first computer I programmed in had 4KB core memory, now I have 32GB & sometimes I find that not enough....

4:20 dysfun: i suspect the extra bytes taken up by dashes are not a large contributor

4:21 * nivag chuckles

4:21 dysfun: but you know if you care about memory efficiency, clojure's a terrible choice

4:21 the jvm readily trades memory for throughput

4:22 nivag: its the extra libraries and crap that is included into loadable programs 'just in case' - leading to HalloWorld programs of half a MB or more!!!

4:23 dysfun: clojure.jar is ~4MB

4:24 nivag: variable naming conventions are more about readability & line length than RAM - besides, in a compiled language, variable name length is somewhat irrelevant!

4:24 dysfun: oh yes, line length. because we're all limited to 80x24 these days...

4:25 nivag: well in an IDE I want want several columns and space for browser pointing to documentation next to it

4:26 even on my 3840 * 2160 screen

4:26 dysfun: most of us don't care about your particular choice of IDE setup

4:27 nivag: more I was just pointing out that limiting line length allows better use of precious screen real estate

4:28 and when I'm forced to use my laptop, it becomes even more important

4:29 dysfun: *shrug* i've got an emacs pane on about 2/3 of my horizontal screenspace with two splits. lines are wrapping and emacs is clever enough to handle it. i'm sure your fancy IDE can too

4:29 charleshd: Hi

4:29 dysfun: hello

4:30 charleshd: I've an another issue in 1.9.0-alpha17

4:30 nivag: both my IDE's can handle such (Eclipse & AndropidStudio) - I used love Emacs when I used it at university!

4:31 charleshd: when I do something like (defn [& {:keys [b] :or {:b 0}}] b) the defn spec isn't happy and don't let me do it. It was a form that worked in 1.8.0

4:31 That's the :or part it does not like

4:31 * nivag is very glad he no longer has to punch code onto 80 chr punch cards!!!

4:32 dysfun: charleshd: hrm, have you checked jira?

4:33 charleshd: yeah, I'm on it right now. I'll came back if I find nothing

4:33 nivag: is there somewhere that explains why there is 'def' and 'defn'? I know where they are used, but not why 'def' couldn't have been used in both situations!

4:35 dysfun: defn expands to (def (fn ...))

4:35 charleshd: defn is just a macro that expands in a def call

4:38 nivag: dysfun, charleshd: thanks!

4:42 charleshd: Okay, was wrong about the defn was writing (fn [& {:keys [b] :or {:b 0}] …) instead of (fn [& {:keys [b] :or {b 0}] …)

4:43 in the :or parameters aren't keyworded, though they were.

4:45 dysfun: aha!

4:45 yes, i remember now

4:48 charleshd: So I see that core function are instrumented, is there a way to instrument functions from a library ?

4:49 ah yeah, they are findable using instrumentable-syms

6:48 seorigjsgre: Hi! I'm using Postgres to store data from Clojure. In clojure the keys are :keywords-with-kebab-case, while postgres stores things with_underscores. Is there some way to tell JDBC to convert between the two cases when doing I/O, or do I need to wrap every DB call in a function that will do the conversion?

6:52 dysfun: if there is, i haven't found a way

7:02 does anyone else wish spec had :req-any , which would accept the value with or without the keyword

7:23 phillord: is there any easy way to get to Java operators in clojure? I need to do arithmetic over integers and clojure keeps on pushing into longs

7:24 dysfun: https://github.com/ztellman/primitive-math

7:25 phillord: ah, thats helpful

7:26 is there any way of doing it without adding a dependency. I have "bit-shift-left" working, but am now stuck with "+"

7:26 dysfun: probably, but i'll leave it to someone who knows to answer

7:27 phillord: ah, never mind, "clojure.lang.Numbers/unchecked-int-add"

7:28 well, now my code is totally unreadable, but hey it works!

8:35 puredanger: charleshd: the keys of the :or have to be symbols

8:40 phillord: why not just call unchecked-add-int?

8:41 phillord: puredanger: because I didn't know about that one

8:42 what about bit-shift-left (am using clojure.lang.Numbers/shiftLeftInt), unsigned-bit-shift-right , and bit-and?

8:42 do they have pure int equivalents?

8:44 puredanger: I think if you have int inputs those may produce int bytecodes

8:44 But I don't know off

8:44 the top of my head

8:45 phillord: (type (bit-shift-left (int 0) (int 0)))

8:45 ,(type (bit-shift-left (int 0) (int 0)))

8:45 clojurebot: java.lang.Long

8:46 phillord: Numbers.java has a static method "and" doing x & y over ints

8:47 but alas it's commented out

8:50 puredanger: In general Clojure believes in just using prim longs for math stuff

8:50 The -int functions are mostly there to give you the correct overflow answer for algs where that's important, like hashing

8:55 phillord: puredanger: Yes,I understand. I'm writing a function for something like hashing where the overflow is important for the correct answer:-)

8:59 puredanger: But don't the bit ops give you the same answer either way? My 2s complement math is rusty

9:00 I would expect the jit and cpu to optimize all that anyways.

9:01 * phillord shrugs

9:02 phillord: god knows -- I think bit-shift-left does (because it's smaller) but right obvious depends on size and sign

9:03 after that, I guess, it's just worries about passing ints to longs and back. My algorithm is giving the right answer now, but I think part of it is still doing long arithmetic

12:58 justin_smith: ,(let [everything-is-a-lie (number? Double/NaN)] everything-is-a-lie)

12:58 clojurebot: true

13:06 Para`: justin_smith: Why wouldn't NaN be a number? It's defined in IEEE754

13:07 TimMc: Says it on the box: Not a number :-)

13:07 Para`: No, the value does not represent a number bit is still a number :)

13:08 IEEE754 spec is a real "fun" to read through.

13:08 luma: somebody needs to fix their funny radar

13:08 Para`: Bah!

13:10 technomancy: call me old-fashioned, but I would say that even RFCs don't get to redefine what "not" means

13:12 ridcully_: ,(double? Double/NaN)

13:12 clojurebot: true

13:12 ridcully_: a false would have been really funny

13:15 xemdetia: request for not

13:16 northcode: is there a way I can implement IFn on something? Like a regex Pattern for example?

13:17 dysfun: no, IFn is an interface, so you can only implement it for new classes

13:17 northcode: is there a way I can "wrap" a regex in a new class or something so I can implement it though?

13:18 dysfun: you can instantiate a new object that contains the regex

13:18 amalloy: yes, you can create a function that closes over the regex

13:18 northcode: essentially what I want is to be able to do: (#"some regex" "some string to match")

13:18 and have it do the same as re-matches

13:18 dysfun: well no, you'll never be able to do that

13:18 northcode: aha.. well ok

13:19 amalloy: set a keyboard macro in emacs binding # to insert instead the string "re-matches #"

13:19 technomancy: I have been wishing for that for years =\

13:19 IMO making #"" read as an actual java.util.Pattern was a mistake, but it's too late now

13:20 northcode: unless someone manages to change it

13:20 amalloy: i don't agree

13:20 northcode: is java.util.Pattern final?

13:21 amalloy: for one thing it means you have to be explicit about whether you want re-find, re-matches, or some kind of replace

13:21 dysfun: even if it wasn't, you can't tell the reader to instantiate your subclass

13:21 amalloy: and subclassing it would be very poor form even if it weren't

13:21 northcode: yeah I guess

13:22 amalloy: but maps works that way? I can do ({:a "hello" :b "world} :a)

13:23 dysfun: maps are clojure objects

13:23 rich implemented IFn on them because he wrote them

13:24 they also have a fairly obvious "natural operation"

13:24 technomancy: I have never passed a regex to a java API, so it seems like a weird thing to insist on being "pure java"

13:25 dysfun: oh, i have

13:25 technomancy: yeah but you're like a kotlin user or something

13:25 (i kid, i kid)

13:25 dysfun: i did this before i discovered kotlin even

13:26 and in any case, i've written way more clojure this week than kotlin

13:39 patchwork: I have discovered I have a pet peeve against intentionally misspelled words in software library names (and company names)

13:40 northcode: Like every single "hipstr" site where they have a name ending in er but drop the e?

13:40 patchwork: northcode: Much like that! yes

13:40 northcode: same man, same

13:41 technomancy: intentionally misspelled words like "clojure"?

13:41 TimMc: northcode: To expand on amalloy's point, *quite a few* security vulnerabilities are due to someone forgetting to re-matches instead of re-find. I don't want an API that glosses over the difference.

13:41 dysfun: clojr!

13:41 patchwork: Ha, maybe! It is not the greatest selling point of the language I'm not going to lie

13:41 Also, right now trying to show people Clojure and having them type "clojurewerkz" is embarrassing

13:41 TimMc: dysfun: "clojure"

13:41 it's a misspelling of closure

13:41 patchwork: dysfun: I like it!

13:41 dysfun: TimMc: no shit

13:41 TimMc: aw, sniped by technomancy

13:42 I was reading the log in reverse like a good lispr.

13:42 dysfun: patchwork: i run a github org called 'irresponsible'...

13:43 patchwork: dysfun: But that is spelled correctly?

13:43 dysfun: maybe?

13:43 ridcully_: irresponzibl

13:43 dysfun: 1rr35p0n51bl3

13:44 patchwork: Stop you are actually hurting me

13:44 dysfun: i won't lie: it hurt to type

13:44 patchwork: I feel it like knives in my brain

13:44 TimMc: irresponsable

13:44 patchwork: TimMc: I hate you

13:45 TimMc: sorry, that was

13:45 iresponsible of me

13:45 justin_smith: things I love that are intentional misspeelings include but are not limited to unix, ocaml, clojure, linux

13:45 xemdetia: my favourite is when I am on a remote hands session of the customer and I have to tell them that no, I did spell it right

13:45 patchwork: (cries)

13:45 xemdetia: and that critical data

13:45 has a really dumb column name

13:45 technomancy: justin_smith: "conkeror"

13:45 justin_smith: not fond of that one, but good example

13:45 patchwork: technomancy: Oh man! totally forgot about that one

13:46 technomancy: that one's even better because it's a misspelling of a misspelling

13:46 patchwork: why did I ever use that again? I remember a distant memory....

13:46 technomancy: because it's great?

13:46 patchwork: No I am just trying to remember what the hell it did

13:46 TimMc: Macintosh

13:46 dysfun: browser

13:46 technomancy: oh, it's a web browser with emacs keybindings

13:46 patchwork: was it some kind of UI library?

13:46 Ah that's it

13:47 dysfun: huh i thought it had vim keybindings

13:47 justin_smith: of course the vi version is called vimperator

13:47 amalloy: justin_smith: not sure about "misspeelings"...

13:47 dysfun: mispeelings!

13:47 TimMc: (McIntosh is the original spelling)

13:47 patchwork: I thought that was intentinoal

13:47 justin_smith: amalloy: was that over the top? I could have tried to be more subtle

13:47 amalloy: no, i think it instilled the right amount of self-doubt in us all

13:47 "did he mean to do that? i'm just not sure about anything"

13:48 patchwork: It's true, all of my convictions are shaken now

13:48 This has been a devastating morning

13:49 justin_smith: also there are no good bands that intentionally misspell their names

13:49 dysfun: so i'm about to implement a defrecord that implements s/Spec , is there anything in particular i should know before i start tearing hear?

13:50 justin_smith: what about staind?

13:50 justin_smith: dysfun: even the beatles are better than staind

13:50 * dysfun quite likes the beatles

14:02 ridcully_: motley crue

14:58 jeaye: Is it possible, in a macro, to detect if I'm compiling for Clojurescript using the reader?

14:58 Typical reader macros just think it's Clojure, since, well, it is. My Clojure macros for Clojurescript need to act a bit differently though, and I'd prefer not to duplicate them.

15:00 dysfun: compiling *for* clojurescript, as in macros?

15:00 justin_smith: jeaye: cljc reader conditionals don't detect this I guess?

15:00 jeaye: justin_smith: Correct. They treat it as though I'm in Clojure.

15:00 dysfun: you can check &env

15:01 (if (:ns &env) ... ...)

15:02 (:ns &env) will be nil in clojure

15:03 jeaye: Why's that?

15:03 dysfun: implementation detail that's quite handy

15:37 jeaye: Well, that seems to do the tricky, though it's super hacky.

15:37 Thanks, dysfun.

15:37 s/ky/k/

16:11 dysfun: jeaye: that's the least offensive hack i'm aware of, there are worse :)

16:29 {blake}: I think "Beatles" is a misspelling of "Beetles", tho'.

16:30 amalloy: no, they were founded to beat les paul

16:39 ridcully_: i get there is a harrison les paul signature edition

16:39 s/get/bet/

16:54 jeaye: dysfun: heh

17:51 technomancy: my understanding with namespaced keywords is that they are important when you have maps that can contain keys from various sources, but unnecessary otherwise. agree? [Y/n]

17:53 justin_smith: I don't know if this counts as "important" but I often use them to differentiate data that is only interesting in a specific context, so that when I see the dumped data I have a better idea of where it came from or what that key is for

17:54 eg. a key like ::auth if other code might want to carry the data and pass it back, but only the namespace that creates it would know what to do with it

17:55 and a coworker would be like "oh, that key must be specific to the foo.bar namespace, and I bet the code in that namespace would show me what it is for"

17:55 technomancy: hm; yeah that makes sense

17:55 we have an API where we just namespace everything in a normal CRUD rpc call and I don't understand whi

17:55 why

17:55 justin_smith: yeah, namespaces on everything seems weird

18:00 TimMc: I also get twitchy about namespaced keywords because if you rename a namespace your map keys can change.

18:01 I get over it by making sure to include the expanded keyword names in at least one test, but... bleh.

18:03 hiredman: don't use ::

18:03 northcode: why not?

18:04 hiredman: your problem isn't namespaced keywords, it is making the namespace implicit in the context in which the keywords are read instead of explcit

18:05 TimMc: Yeah. But if I don't use ::, there's a chance someone will later change things to be more compact. So the tests are still important.

18:06 hiredman: I have no idea what that means

18:06 I have no idea what tests you are talking about

18:06 TimMc: "I get over it by making sure to include the expanded keyword names in at least one test, but... bleh."

18:06 hiredman: I am just saying, stop using :: and you will enjoy the benefits of namespaced keywords more freely

18:07 TimMc: I haven't done stuff with namespaced keywords in a while, so it's slowly coming back to me... I guess what I actually do is use :: with ns aliases

18:08 hiredman: don't do that either

18:08 TimMc: I understand.

18:09 Anyway, what do you end up doing, if you even use namespaced keywords?

18:09 hiredman: I use namespaced keywords without ::

18:10 :some.namepsace/whatever

18:12 :: is really the only bit that ties clojure code namespaces to keyword namespaces, otherwise they are entirely disjunct things, so if you stop using :: you will likely find yourself using namespaces for your data that are different than namespaces for your code

18:34 peterpp: 안녕

Logging service provided by n01se.net