#clojure logs

2017-06-23

01:26mercwithamouthnot 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
03:57nivagcurious, 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?
03:58dysfunit's not archaic, it's what lisp did. i don't consider camelcase to be more readable
03:59dysfunof course nothing stops you from using camelcase if you want to
03:59metellusreadability is entirely subjective, and if you're calling camelCase modern you're ignoring the tons of modern languages that use this_format_for_names
03:59nivagmy first 3 languages were BASIC, FORTRAN, and COBOL - I think I'm liking Clojure better than Python
04:00dysfuni think i'm liking anything better than basic, fortran and cobol
04:01amalloyifCamelCaseIsSoGoodWhyDoesntEnglishUseIt
04:01metellusvariable-names-arent-supposed-to-be-sentences
04:01nivagmetellus, 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
04:01Para`amalloy: It used to, capitalization rules of ye olde English were kind of wonky.
04:01nivagover 20
04:02Para`which is also over 2
04:02larsennivag: 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
04:02metellusnivag: 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
04:03nivaginitially printers only had digits (fortunately, before my time), when I started programming all language keywords had to be upper case
04:05nivagmetellus, 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! :-)
04:05nivagcamelCase is leads to shorter variables names than only using one case for letters
04:08nivagthe 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!
04:09dysfunif you really think saving one character matters, i don't want to read your code
04:12nivagthe first versions of BASIC & FORTRAN only allowed very short variable names - COBOL allowed up to 30 characters (when I used it)
04:13nivagI tend to use long variables names when appropriate, like pFullyQualifiedClassName (p prefix as it is a parameter)
04:14nivagdysfun, people tell me that my code is very readable! :-)
04:15dysfunthat's a form of hungarian notation i suppose. i dislike hungarian notation
04:15dysfun(i used to program vb which is full of it)
04:16nivagdysfun, 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
04:16dysfuni only see those as generated names these days
04:16dysfunanyway, back then there was a reason. there isn't now
04:16nivagdysfun, I only prefix parameters, I don't both with other types og variables
04:18nivagVisual 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!!!!!!
04:18dysfunit may have been a shitty language, but the toolkit for building apps was brilliant
04:20nivagthe first computer I programmed in had 4KB core memory, now I have 32GB & sometimes I find that not enough....
04:20dysfuni suspect the extra bytes taken up by dashes are not a large contributor
04:21dysfunbut you know if you care about memory efficiency, clojure's a terrible choice
04:21dysfunthe jvm readily trades memory for throughput
04:22nivagits the extra libraries and crap that is included into loadable programs 'just in case' - leading to HalloWorld programs of half a MB or more!!!
04:23dysfunclojure.jar is ~4MB
04:24nivagvariable naming conventions are more about readability & line length than RAM - besides, in a compiled language, variable name length is somewhat irrelevant!
04:24dysfunoh yes, line length. because we're all limited to 80x24 these days...
04:25nivagwell in an IDE I want want several columns and space for browser pointing to documentation next to it
04:26nivageven on my 3840 * 2160 screen
04:26dysfunmost of us don't care about your particular choice of IDE setup
04:27nivagmore I was just pointing out that limiting line length allows better use of precious screen real estate
04:28nivagand when I'm forced to use my laptop, it becomes even more important
04:29dysfun*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
04:29charleshdHi
04:29dysfunhello
04:30charleshdI've an another issue in 1.9.0-alpha17
04:30nivagboth my IDE's can handle such (Eclipse & AndropidStudio) - I used love Emacs when I used it at university!
04:31charleshdwhen 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
04:31charleshdThat's the :or part it does not like
04:32dysfuncharleshd: hrm, have you checked jira?
04:33charleshdyeah, I'm on it right now. I'll came back if I find nothing
04:33nivagis 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!
04:35dysfundefn expands to (def (fn ...))
04:35charleshddefn is just a macro that expands in a def call
04:38nivagdysfun, charleshd: thanks!
04:42charleshdOkay, was wrong about the defn was writing (fn [& {:keys [b] :or {:b 0}] …) instead of (fn [& {:keys [b] :or {b 0}] …)
04:43charleshdin the :or parameters aren't keyworded, though they were.
04:45dysfunaha!
04:45dysfunyes, i remember now
04:48charleshdSo I see that core function are instrumented, is there a way to instrument functions from a library ?
04:49charleshdah yeah, they are findable using instrumentable-syms
06:48seorigjsgreHi! 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?
06:52dysfunif there is, i haven't found a way
07:02dysfundoes anyone else wish spec had :req-any , which would accept the value with or without the keyword
07:23phillordis 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
07:24dysfunhttps://github.com/ztellman/primitive-math
07:25phillordah, thats helpful
07:26phillordis there any way of doing it without adding a dependency. I have "bit-shift-left" working, but am now stuck with "+"
07:26dysfunprobably, but i'll leave it to someone who knows to answer
07:27phillordah, never mind, "clojure.lang.Numbers/unchecked-int-add"
07:28phillordwell, now my code is totally unreadable, but hey it works!
08:35puredangercharleshd: the keys of the :or have to be symbols
08:40puredangerphillord: why not just call unchecked-add-int?
08:41phillordpuredanger: because I didn't know about that one
08:42phillordwhat about bit-shift-left (am using clojure.lang.Numbers/shiftLeftInt), unsigned-bit-shift-right , and bit-and?
08:42phillorddo they have pure int equivalents?
08:44puredangerI think if you have int inputs those may produce int bytecodes
08:44puredangerBut I don't know off
08:44puredangerthe top of my head
08:45phillord(type (bit-shift-left (int 0) (int 0)))
08:45phillord,(type (bit-shift-left (int 0) (int 0)))
08:45clojurebotjava.lang.Long
08:46phillordNumbers.java has a static method "and" doing x & y over ints
08:47phillordbut alas it's commented out
08:50puredangerIn general Clojure believes in just using prim longs for math stuff
08:50puredangerThe -int functions are mostly there to give you the correct overflow answer for algs where that's important, like hashing
08:55phillordpuredanger: Yes,I understand. I'm writing a function for something like hashing where the overflow is important for the correct answer:-)
08:59puredangerBut don't the bit ops give you the same answer either way? My 2s complement math is rusty
09:00puredangerI would expect the jit and cpu to optimize all that anyways.
09:02phillordgod knows -- I think bit-shift-left does (because it's smaller) but right obvious depends on size and sign
09:03phillordafter 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:58justin_smith,(let [everything-is-a-lie (number? Double/NaN)] everything-is-a-lie)
12:58clojurebottrue
13:06Para`justin_smith: Why wouldn't NaN be a number? It's defined in IEEE754
13:07TimMcSays it on the box: Not a number :-)
13:07Para`No, the value does not represent a number bit is still a number :)
13:08Para`IEEE754 spec is a real "fun" to read through.
13:08lumasomebody needs to fix their funny radar
13:08Para`Bah!
13:10technomancycall me old-fashioned, but I would say that even RFCs don't get to redefine what "not" means
13:12ridcully_,(double? Double/NaN)
13:12clojurebottrue
13:12ridcully_a false would have been really funny
13:15xemdetiarequest for not
13:16northcodeis there a way I can implement IFn on something? Like a regex Pattern for example?
13:17dysfunno, IFn is an interface, so you can only implement it for new classes
13:17northcodeis there a way I can "wrap" a regex in a new class or something so I can implement it though?
13:18dysfunyou can instantiate a new object that contains the regex
13:18amalloyyes, you can create a function that closes over the regex
13:18northcodeessentially what I want is to be able to do: (#"some regex" "some string to match")
13:18northcodeand have it do the same as re-matches
13:18dysfunwell no, you'll never be able to do that
13:18northcodeaha.. well ok
13:19amalloyset a keyboard macro in emacs binding # to insert instead the string "re-matches #"
13:19technomancyI have been wishing for that for years =\
13:19technomancyIMO making #"" read as an actual java.util.Pattern was a mistake, but it's too late now
13:20northcodeunless someone manages to change it
13:20amalloyi don't agree
13:20northcodeis java.util.Pattern final?
13:21amalloyfor one thing it means you have to be explicit about whether you want re-find, re-matches, or some kind of replace
13:21dysfuneven if it wasn't, you can't tell the reader to instantiate your subclass
13:21amalloyand subclassing it would be very poor form even if it weren't
13:21northcodeyeah I guess
13:22northcodeamalloy: but maps works that way? I can do ({:a "hello" :b "world} :a)
13:23dysfunmaps are clojure objects
13:23dysfunrich implemented IFn on them because he wrote them
13:24dysfunthey also have a fairly obvious "natural operation"
13:24technomancyI have never passed a regex to a java API, so it seems like a weird thing to insist on being "pure java"
13:25dysfunoh, i have
13:25technomancyyeah but you're like a kotlin user or something
13:25technomancy(i kid, i kid)
13:25dysfuni did this before i discovered kotlin even
13:26dysfunand in any case, i've written way more clojure this week than kotlin
13:39patchworkI have discovered I have a pet peeve against intentionally misspelled words in software library names (and company names)
13:40northcodeLike every single "hipstr" site where they have a name ending in er but drop the e?
13:40patchworknorthcode: Much like that! yes
13:40northcodesame man, same
13:41technomancyintentionally misspelled words like "clojure"?
13:41TimMcnorthcode: 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:41dysfunclojr!
13:41patchworkHa, maybe! It is not the greatest selling point of the language I'm not going to lie
13:41patchworkAlso, right now trying to show people Clojure and having them type "clojurewerkz" is embarrassing
13:41TimMcdysfun: "clojure"
13:41TimMcit's a misspelling of closure
13:41patchworkdysfun: I like it!
13:41dysfunTimMc: no shit
13:41TimMcaw, sniped by technomancy
13:42TimMcI was reading the log in reverse like a good lispr.
13:42dysfunpatchwork: i run a github org called 'irresponsible'...
13:43patchworkdysfun: But that is spelled correctly?
13:43dysfunmaybe?
13:43ridcully_irresponzibl
13:43dysfun1rr35p0n51bl3
13:44patchworkStop you are actually hurting me
13:44dysfuni won't lie: it hurt to type
13:44patchworkI feel it like knives in my brain
13:44TimMcirresponsable
13:44patchworkTimMc: I hate you
13:45TimMcsorry, that was
13:45TimMciresponsible of me
13:45justin_smiththings I love that are intentional misspeelings include but are not limited to unix, ocaml, clojure, linux
13:45xemdetiamy 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:45patchwork(cries)
13:45xemdetiaand that critical data
13:45xemdetiahas a really dumb column name
13:45technomancyjustin_smith: "conkeror"
13:45justin_smithnot fond of that one, but good example
13:45patchworktechnomancy: Oh man! totally forgot about that one
13:46technomancythat one's even better because it's a misspelling of a misspelling
13:46patchworkwhy did I ever use that again? I remember a distant memory....
13:46technomancybecause it's great?
13:46patchworkNo I am just trying to remember what the hell it did
13:46TimMcMacintosh
13:46dysfunbrowser
13:46technomancyoh, it's a web browser with emacs keybindings
13:46patchworkwas it some kind of UI library?
13:46patchworkAh that's it
13:47dysfunhuh i thought it had vim keybindings
13:47justin_smithof course the vi version is called vimperator
13:47amalloyjustin_smith: not sure about "misspeelings"...
13:47dysfunmispeelings!
13:47TimMc(McIntosh is the original spelling)
13:47patchworkI thought that was intentinoal
13:47justin_smithamalloy: was that over the top? I could have tried to be more subtle
13:47amalloyno, i think it instilled the right amount of self-doubt in us all
13:47amalloy"did he mean to do that? i'm just not sure about anything"
13:48patchworkIt's true, all of my convictions are shaken now
13:48patchworkThis has been a devastating morning
13:49justin_smithalso there are no good bands that intentionally misspell their names
13:49dysfunso 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:50dysfunjustin_smith: what about staind?
13:50justin_smithdysfun: even the beatles are better than staind
14:02ridcully_motley crue
14:58jeayeIs it possible, in a macro, to detect if I'm compiling for Clojurescript using the reader?
14:58jeayeTypical 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:00dysfuncompiling *for* clojurescript, as in macros?
15:00justin_smithjeaye: cljc reader conditionals don't detect this I guess?
15:00jeayejustin_smith: Correct. They treat it as though I'm in Clojure.
15:00dysfunyou can check &env
15:01dysfun(if (:ns &env) ... ...)
15:02dysfun(:ns &env) will be nil in clojure
15:03jeayeWhy's that?
15:03dysfunimplementation detail that's quite handy
15:37jeayeWell, that seems to do the tricky, though it's super hacky.
15:37jeayeThanks, dysfun.
15:37jeayes/ky/k/
16:11dysfunjeaye: 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:30amalloyno, they were founded to beat les paul
16:39ridcully_i get there is a harrison les paul signature edition
16:39ridcully_s/get/bet/
16:54jeayedysfun: heh
17:51technomancymy 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:53justin_smithI 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:54justin_smitheg. 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:55justin_smithand 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:55technomancyhm; yeah that makes sense
17:55technomancywe have an API where we just namespace everything in a normal CRUD rpc call and I don't understand whi
17:55technomancywhy
17:55justin_smithyeah, namespaces on everything seems weird
18:00TimMcI also get twitchy about namespaced keywords because if you rename a namespace your map keys can change.
18:01TimMcI get over it by making sure to include the expanded keyword names in at least one test, but... bleh.
18:03hiredmandon't use ::
18:03northcodewhy not?
18:04hiredmanyour problem isn't namespaced keywords, it is making the namespace implicit in the context in which the keywords are read instead of explcit
18:05TimMcYeah. 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:06hiredmanI have no idea what that means
18:06hiredmanI have no idea what tests you are talking about
18:06TimMc"I get over it by making sure to include the expanded keyword names in at least one test, but... bleh."
18:06hiredmanI am just saying, stop using :: and you will enjoy the benefits of namespaced keywords more freely
18:07TimMcI 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:08hiredmandon't do that either
18:08TimMcI understand.
18:09TimMcAnyway, what do you end up doing, if you even use namespaced keywords?
18:09hiredmanI use namespaced keywords without ::
18:10hiredman:some.namepsace/whatever
18:12hiredman:: 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:34peterpp안녕