freenode/#lisp - IRC Chatlog
Search
11:12:47
scymtym_
TMA: it would produce the correct result. efficiency would depend on whether the untagged representation was used for the arithmetic, i think
11:14:08
lieven
if you want to assure the compiler that that wont happen you can do (the fixnum (* <fixnum> 2))
11:17:52
lieven
kuribas: in optimising settings, a CL compiler will not check your type declarations but will take your word for it. If you lie to the compiler, it will have its revenge.
11:23:25
jmercouris
I'm just trying to dispel the myth ath CPU cycles are ALWAYS cheap, there is of course times when they are cheap, like during one-off tasks
11:25:11
kuribas
you can count the cost of requiring more computers - the cost of the programmer optimizing it.
11:26:54
jackdaniel
can I buy 20 CPU cycles from aws? that's really fine-grained :) what if I have a program which is composed only of operations where each takes 3 cycles?
11:27:23
kuribas
having to choose between safety and efficiency is also something you get when you bargain for using a dynamic language
11:28:48
jackdaniel
I don't think the major efficiency and safety gain comes from the language you write in – you can create unsafe and inefficient algorithms in a safe and efficient language
11:30:08
jackdaniel
kuribas: you simply write safe and efficient code ;-) what lisp gives you is a decent optimizing compiler and runtime safety guarantees
11:31:50
jdz
kuribas: make sure you use the takeWhile, etc. version (i.e., tho generic programmer-cycles saving one).
11:35:16
jdz
_death: c'mon bruh, we only care about toy examples, not practical real world scenarios.
11:44:28
jackdaniel
if the type is inferred, then redundant type checks may be safely removed (unless there is a bug in type inference algorithm)
11:45:26
White_Flame
in other words, type checks internal to a function body migh tbe elided. Those at the interface should remain intact
11:48:29
kuribas
what I mean, is that if you have a function using fixnum, calling another function with fixnum, the typecheck is redundant
11:51:49
jdz
It looks like you're wasting programmer-cycles with unimportant details instead of concentrating on a task at hand.
11:53:10
jdz
I trust my programs to be efficient enough if I don't write intentionally inefficient code.
11:53:22
_death
think about program evolution.. starting a lisp brings up a world at a particular stage of evolution, and you further evolve it by evaluating code.. static languages result in a dead world that's incapable of evolution
11:55:23
kuribas
so the lisp code took 0.069 (with no optimizations as recommended), the haskell code 0.009sec
11:55:32
_death
jmercouris: perhaps a better way to distinguish is system thinking vs. language thinking
11:56:19
jackdaniel
kuribas: then stick to haskell if you plan to write these kind of programs and you really care about efficiency on such level, lisp clearly fails to meet your standards
11:58:53
_death
jmercouris: http://dreamsongs.com/Files/Incommensurability.pdf contains some good discussion about systems vs. languages.. it takes a while to get there though, because the author wrote one essay where he should've written two
11:59:07
jdz
Right, and write another article titled "Why Common Lisp is not my favourite programming language and why I'm sticking with Haskell".
12:01:27
jackdaniel
protip: you may put x as a third argument in dotimes, it will be returned by that block
12:03:54
jackdaniel
kuribas: may I ask a question: do you plan to learn lisp, or your goal is to compare it to haskell?
12:04:42
jmercouris
jackdaniel: may I ask a question: why do people preface questions with questions in this manner?
12:05:13
jackdaniel
imo you can't do both *at the same time*, because these are two different languages with different promises
12:05:38
jdz
kuribas: you might as well think what you're doing. Why not set -O0 -g for haskell version?
12:05:38
jackdaniel
for instance (I don't know haskell, so I may be wrong here) – if haskell is functional, then it can memoize function call results
12:05:55
jackdaniel
in Common Lisp you'd have to create your own defmemo macro for that to achieve similar result
12:06:40
jackdaniel
jmercouris: how can I answer? that's how I speak sometimes? should I really explain myself on this matter?
12:07:14
jmercouris
jackdaniel: I was making an observation that I thought you might be interested in reflecting on
12:08:23
kuribas
jdz: I am getting the same performance with speed 3, but maybe i am doing something wrong.
12:09:04
jmercouris
jackdaniel: https://en.wikipedia.org/wiki/Socratic_questioning - last post on the matter, as it is off,topic
12:12:00
shrdlu68
kuribas: The biggest optimization, in my experience, is usually in type declarations.
12:15:18
jdz
Also, this exercise is really silly, nothing to do with the ADD-TEXT-PADDING we discussed earlier.
12:19:38
jdz
I thought the point of the exercise was not to try and optimize a trivial piece of code, but to compare the speed of idiomatically written code...
12:23:52
jdz
Considering you've translated the code correctly, and Int in Haskell is 32-bit signed integer.
12:29:12
jdz
Next step of the exercise is to measure the time it takes to compute a value that exceeds Haskells Int type.
12:37:49
jdz
kuribas: I'd still like to know what the result with my proposed change for the Haskell version is.
12:39:19
shrdlu68
kuribas: Indeed. But you don't have to, until speed really matters. It won't get in your way screaming for declarations and types.
12:39:58
kuribas
shrdlu68: I am going to work on a codebase involving lots of data, were performance does matter.
12:40:49
shrdlu68
kuribas: Good, write the code as you would naturally, with optimal data structures and algorithms, _then_ add declarations.
12:43:05
jmercouris
jdz: If you reframe any problem enough times, I belive you'll always end up where you started: rewrite it in rust
12:43:38
kuribas
White_Flame: for example, simple averaging numbers is faster on the CPU, because you don't have the latency of transferring to the GPU.
12:44:24
jackdaniel
xificurC: I have my doubts, but not sure who should take a kick, it seems like a rebellion ;-)
12:44:57
jdz
We just proved the superiority of Common Lisp over Haskell, surely we can have a little afterparty, right?
12:45:48
shrdlu68
There has been a renewed interest in comparing languages recently, what with all the new languages being invented, and all the propaganda being thrown around.
12:45:57
jmercouris
we can only compare the specific implementation of a problem in language A and language B
12:46:29
jackdaniel
there is no such thing as language speed. quality of produced code may be measured, or at the very last – language "optimization"-friendliness
12:47:39
jmercouris
I was even having a conversation with beach at the time where I could not explain it to him
12:47:55
jdz
This what it was all about: <kuribas> the thing is, I don't find giving up safety for performance a good option.
12:48:36
jmercouris
it wasn't for a lack of his comprehension or anything, I just couldn't put the thoughts into words, in that context
12:53:29
_death
typical development in lisp is working with a living system.. you define stuff, test in the repl, redefine, inspect objects, etc. typical development in haskell is write, compile, rinse, repeat.. each time setup the whole thing from scratch
12:56:06
White_Flame
and lisp refactoring teaches you to keep your abstractions well-defined so you can adjust things later. I wonder how difficult it is to refactor the types in a haskell program
13:08:59
runixy
Can I specify some constraints on the type of the parameters for a function, such as informing the compiler that the parameters are NUMBER? See lines 75 to 113 (including error message) on https://paste.ofcode.org/yzZkqCsTshQZtJ5gKwKddM as I would like to avoid having to use the macro for defining the function.
13:14:42
beach
runixy: I am not sure I understand what you are trying to do and I am not sure I understand why wall-builder-not-working is not working.
13:19:16
xificurC
I'm pretty sure runixy is going through this https://chriskohlhepp.wordpress.com/reasoning-systems/specification-driven-programming-in-common-lisp/
13:20:44
runixy
yes, and then I don't understand why I/we would have to make a macro to build the wall-builder function
13:23:23
beach
runixy: If you declared it to be a number you would lie to the compiler, because you are passing a symbol, not a number.
13:26:13
beach
runixy: Can you please tell us whether build-constraints is supposed to have any side effects. It looks to me like it is just supposed to return some code. Right?
13:29:19
beach
So if BUILD-CONSTRAINTS returns something useful without having any side effects, in this context, the useful thing is thrown away.
13:29:34
xificurC
beach: build-constraints returns (progn (setf ...) (setf ...)) as seen from his paste
13:31:01
runixy
ye, and then I don't understand why he had to wrap the wall-builder function in a macro
13:31:48
runixy
the macros are used to provide forms that are being evaluated in wall-builder-builder
13:33:18
xificurC
runixy: this is explained in the blog post. The guy writes out a function for 2x2 and one for 3x3. Then he proceeds to write a macro which takes the dimensions as parameters and produces the boilerplate code automatically
13:34:50
xificurC
runixy: what might be tripping you is that the macro always generates (defun wall-builder ...) which isn't really correct. It should generate a different function for each input, e.g. wall-builder-2x2, wall-builder-4x20, ... The author just didn't bother to write this out explicitly
13:34:53
runixy
ye, but couldn't wall-builder be a function taking in the parameters directly (if I could specify types)
13:35:31
beach
runixy: I think you will understand if you macroexpand the call to wall-builder-builder.
13:35:32
xificurC
runixy: it's not about types, forget types. It's about having a solver for a 2x2 grid, a solver for a 20x20 grid, whatever one wants
13:36:34
xificurC
runixy: he wrote out the 3x3 case, did you see how much more boilerplate code that was? Now he wrote a macro so if he needs a 4x4 solver the macro will generate a solver for it. It should be named wall-builder-4x4 though, not overwriting any previous wall-builder
13:37:14
runixy
I have to redefine wall-builder (by using wall-builder-builder) for different parameters, but I was curious if that can be circumvented and just define a function that then evaluates the other macros at run-time.
13:38:16
beach
runixy: If you did that, you would see that the BUILD-CONSTRAINTS form has numbers in it.
13:39:05
runixy
I don't get why doing a macro to define a function is able to look past type issues, when just defining the function is not? I guess that is my real question
13:40:33
beach
If you declare the type to be number, then you will like to the compiler because you are passing it symbols, not numbers.
13:44:39
xificurC
(defmacro add-one (x) `(+ ,x 1)) (let ((n 1)) (add-one n)) . this is a simplified version of his issue, correct beach?
13:46:38
beach
makomo: When the compiler sees the call to build-constraints, it will macroexpand it.
13:48:14
beach
makomo: Macros don't evaluate their parameters, so you can't pass it a symbol expecting its value to be used.
13:48:45
makomo
beach: yes, of course. which means that the macro expects to work with constants, correct?
13:51:31
specbot
Congruent Lambda-lists for all Methods of a Generic Function: http://www.lispworks.com/reference/HyperSpec/Body/07_fd.htm
13:51:57
beach
xificurC: More like (defmacro add-one (x) (1+ x)) and then the difference between (add-one 234) and (let ((n 234)) (add-one n))
13:53:24
makomo
yup, same. so then what would be the reason for the method accept invalid keyword arguments?
13:54:24
makomo
i mean, i don't know whether to interpret that last sentence in case 4 as something that's applicable only when case 4 applies, or as a general fact (with or without case 4)
13:55:04
makomo
so i have (defgeneric hello (a b &rest c)) and (defmethod hello (a b &key c)). then i call (hello 1 2 :d 100)
13:55:08
beach
I think case 4 is all about &key being mentioned in the generic function lambda list.
13:55:47
xificurC
runixy: try (defmacro what-am-i-at-compile-time (x) (format t "type ~a with value ~a~%" (type-of x) x)) and then (what-am-i-at-compile-time 100) and (let ((x 100)) (what-am-i-at-compile-time x))
13:56:38
beach
makomo: Do we know that an implementation is obliged to signal an error in such a situation?
13:57:40
specbot
Unrecognized Keyword Arguments: http://www.lispworks.com/reference/HyperSpec/Body/03_ead.htm
14:26:31
beach
_death: Can you point to the relevant Common Lisp HyperSpec section that supports that claim?
14:28:57
beach
That if the generic function lambda list mentions &rest but not &key, then there is never any argument mismatch, even when a key is passed to a method that does not accept it.
14:31:00
makomo
if the answer is "because only the generic function checks the argument list, not the methods", then where is this said in the standard?
14:31:58
makomo
this is valid, why? the method clearly takes only the keyword argument :c. why is :d allowed?
14:33:55
makomo
i.e. you're calling the generic function, and only it does the validation of the arguments
14:35:00
_death
if it took &key, then there'd be validation.. perhaps also when the method is called
14:35:50
beach
_death: Like makomo, I don't buy your argument. You may be right, of course, but I don't see it.
14:37:45
Inline
beach: i have an offline question related to wxmaxima, maxima therein is loosing it's socket somehow, when i start maxima from the console everything works as expected....
15:04:42
jackdaniel
I don't remember details, but we were troubleshooting this problem with someone using maxima
15:51:09
puchacz
hi, how to correctly read an unknown XML from file pls? the first problem is that it can have unknown encoding, and I think usually the header says something like: <?xml version="1.0" encoding="UTF-8" standalone="no"?>
15:52:29
puchacz
maybe this one handles nuances like this: (cxml:parse-file "example.xml" (cxml-dom:make-dom-builder))
16:40:20
pjb
Ukari: actually, the way to write local constants, is to write literals. Ie. anything that's quoted or self-evaluating is for all intents and purposes the same as a constant variable defined with defconstant.
16:41:24
pjb
Ukari: the only meaning of defconstant is that the compiler is allowed to inline (possibly multiple copies) of the value. It doesn't mean that the object is immutable per se (but it should be considered immutable, because if you try to mutate it, you can get starnge results, such as crashes, nasal daemons, or only one copy being mutated!
16:49:36
pjb
Ukari: also, notice how in (let ((zero 48)) (+ zero 4)) it doesn't matter whether zero is a constant variable or not: we can see it LEXICALLY that we are not mutating the bingin, and the compiler knows it too, so it can eliminate the variable and inline the value.
16:50:45
pjb
Try it: (declaim (optimize (space 3) (speed 3))) (disassemble (compile nil (lambda (d) (let ((zero 48)) (+ zero d)))))
16:50:46
Ukari
if use a (funcall return-48) instead of 48, literals way can't use (funcall return-48)'s value twice if I don't wan't funcall return-48 twice
16:52:01
pjb
Constant variable values must be known at compilation time, so they may be inlined by the compiler.
16:52:29
pjb
Ukari: Look, the point is that defconstant is a very strange and very specific operator that just doesn't do what you think it does.
16:52:55
pjb
Already, the name "constant VARIABLES" should give you a hint you're in Alice Wonderland territory.
16:53:48
pjb
Ukari: so lexically, things are know at compilation time, or they don't qualify for "lexical".
16:54:06
pjb
the value returned by (function return-42) is not a lexical value, because it cannot be known by the compiler.
16:54:49
pjb
(unless some very specific cases, but few CL compilers implement the global analysis that would allow them to know).
16:55:42
pjb
Ukari: perhaps you would want to consider a macro or a compiler-macro to deal with those forms, instead of just a binding?
16:57:34
Ukari
maybe it is a mistake for me to use defconstant as a compare target to what i need, what i need is not literal constant because it can't assign to some stuff in runtime
16:58:30
Ukari
what i need is a immutable let, it could assign once, assign to some stuff in the runtime, then it couldn't change anymore
17:01:09
Bike
i don't think it's hard to imagine a let binding that would have setqs of the variable to be a compiler warning or error, regardless of one's understanding of physics.
17:01:45
pjb
Either you write a assignment inside the scope, or you don't. And this is written textually, in space, so it is known of all eternity whether you did it or not.
17:02:29
pjb
Bike: sure, but then you want to change the compiler. As a user, you can do that with writing your own IMMUTABLE-LET macro and do the code walking to check.
17:04:50
Ukari
though let is analysis by compile in space, but the assignment between stuff to it is actually happens in runtime
17:16:40
Ukari
the compiler knows the reference or address or pointer, but not know the value store in address
17:16:41
pjb
This gives you a run-time check. Perhaps sbcl could also validate it at compilation time.
17:20:23
beach
Ukari: There is, for example, a compiler optimization technique called "constant propagation" that takes this information and replaces all references to the variable by the literal.
17:21:23
beach
Speaking of which, I have always claimed that even application programmers should know about compiler design. I have seen so many application programmers write silly code because they have an incorrect model of what the compiler does.
17:22:43
Bike
though "the compiler never knows about or does any optimizations ever" is a new attitude for me
17:25:19
Ukari
If i remember correctly, in python, if there is a array a = [1, 2, 3, 3]. use id(a[2]) and id(a[3]), you could find it returns a same address where stores the only one 3
17:25:45
makomo
beach: i agree. in general, regarding usage of any interface, i think that programmers should be aware of how the underlying implementation works, or at least have an idea how it works
17:27:01
makomo
beach: for me, using an abstraction shouldn't mean that you're ignorant about the details. it should mean that you half-know how it works, but don't assume anything, i.e. you're intentionally avoiding relying on anything that's implementation-defined
17:28:10
Bike
fuck, id is an address-of function. that's a weird builtin for a language like python to have
17:28:20
beach
makomo: I think I understand. The "silly code" I was referring to typically avoided abstractions because of some idea that the compiler would generate slower code then.
17:28:58
makomo
beach: ah i see. i guess it's not directly related, but i think it's an interesting thought/approach anyway
17:30:24
Ukari
in let example, complier gives address and no need to know what stores in address because what stores in address is not sure in runtime
17:30:57
Bike
Ukari: Lisp doesn't have some weird semantics where you can redefine what 3 is at runtime. if you write (let ((x 3)) ...) x will be 3, as is intuitively obvious.
17:33:09
mfiano
I'm sorry for spreading misinformation...I was completely wrong. It's lists that are implemented as arrays, rather than linked lists.
17:33:10
beach
I am intrigued by this idea that the compiler should not optimize code even if it can because it is not its "duty".
17:33:21
Ukari
well, Bike, but the optimization technique trick only happens in some case can't prove that all stuff's value which assign by let are certein in compile time
17:36:05
jackdaniel
it could be certainly useful for testing (being able to disable certain optimizations, so you can for instance examine output with only one optimization being active), but it is a different story
17:37:46
makomo
half of everything in this world would be much easier if people just used consistent and proper terminology
17:39:04
jackdaniel
new ideas emerge from chaos, made-up terminology may spawn new ideas (by triggering metaphores) etc, don't discard the brilliance of mistakes
17:42:29
makomo
in fact, alex stepanov, the designer of C++'s STL, named std::vector after CL's vector
17:45:04
jackdaniel
non-optimizing compilers may be also useful for producing result code which is meant to be read by a human - as a first draft (and tweaked after that manually), but that's very rare I suppose
17:51:00
makomo
beach: "When a generic function or any of its methods mentions &key in a lambda list, the specific set of keyword arguments accepted by the generic function varies according to the applicable methods."
17:51:04
specbot
Keyword Arguments in Generic Functions and Methods: http://www.lispworks.com/reference/HyperSpec/Body/07_fe.htm
17:51:35
makomo
"The set of keyword arguments accepted by the generic function for a particular call is the union of the keyword arguments accepted by all applicable methods and the keyword arguments mentioned after &key in the generic function definition"
17:54:41
makomo
or would that whole section of the standard only apply in the case when we have a &key in our GF
18:10:35
littlelisper
i want to get the modification time of a file. is there any library for it? i googled but no help
18:21:28
makomo
if i'm writing a DSL and want my macros to be indented nicely, what are some general tricks or ways to structure these macros to make this happen
18:22:14
makomo
"here" is where is how i want the process code to be aligned, "not-here" is what i don't want
18:24:47
_death
I assume you're asking about the editor (emacs+slime) indenting it.. there's trivial-indent, but for more complicated macros you could patch cl-indent or otherwise write elisp code to do it
18:42:11
_death
you can import specific _symbols_ from a _package_ using :import-from in your defpackage form
18:46:02
pjb
(defparameter *my-fun-package-foo* (list (function sin) (function car) (function cos)))
18:46:29
pjb
(defparameter *my-fun-package-bar* (list (elt *my-fun-package-foo* 0) (elt *my-fun-package-foo* 2)))
18:46:48
pjb
So you have "imported" the first and third function from *my-fun-package-foo* into *my-fun-package-bar*.
18:47:15
pjb
CL packages only deal with symbols, not with functions or variables or types or whatever the symbol is used to name.
18:49:09
pjb
littlelisper: on the other hand, you may not care if the symbols used to name your function also name types or slots or variables or whatever.
18:49:56
pjb
It also helps that global variables are special, therefore they are named with *stars-around*, and functions usually no. (even if some functions may be named with one or two postfix stars, like, f, f* and f**).
18:50:44
pjb
On the other hand, it occurs often that you have both a type and a function using the same name: (typep (vector 1 2) 'vector) (typep (list 1 2) 'list) etc.
18:56:13
_death
(defpackage "AI" (:use "COMMON-LISP") (:export "THINK")) (defpackage "PERSONALITIES" (:use "COMMON-LISP") (:import-from "AI" "THINK") (:export "THINKER")) (in-package "PERSONALITIES") (defun thinker () (loop (think)))
19:00:25
warweasle
_death: I was hoping the singularity would hit today. I don't trust people to run things anymore.
19:03:10
_death
warweasle: the last time I hoped for a singularity event was when I waited at some hospital queue (for a routine check) while the secretaries went superslow
19:04:07
MichaelRaskin
_death: let me assure you that it is in fact possible to intentionally program AI to maintain unacceptably slow speed of the queue
19:08:14
aeth
If I compile a random program, I can tell you without looking at anything but htop if it's C++ or not.
19:16:08
aeth
I'm not sure why people say SBCL takes a long time to compile or otherwise list its compile time as a disadvantage. (1) you only ever see that when you update QL and (2) it doesn't take very long, and this is even with only one core being used
19:16:50
aeth
Well it's generally either very quick or an infinite loop bug, but, yes, you can put anything in compile-time
19:18:09
aeth
Bike: you generally only see everything being compiled when you ql:update-all-dists afaik.
19:20:48
aeth
Bike: The only thing that seems to be noticably slow in the entire compilation process is cl-sdl2 and that's probably because it uses autowrap
19:22:04
Bike
the level of confidence you put into your assertions really doesn't match the evidence behind them
19:27:08
aeth
Just under 3 seconds to build the largest thing that I've written in CL, which is about 7k lines of code, and it has one slow file because of an elaborate data structure.
19:30:59
aeth
Let's say 2.8 and let's say it's directly related to LoC. 7k in 2.8 seconds is 2.5k a second. (/ 60d3 2.5d3) would then be 24 seconds. Actually sounds fairly plausible.
19:31:48
aeth
My computer could be twice as fast as yours and/or your files could be more elaborate at compile time.
19:36:49
scymtym_
i halved SBCL's ironclad compile time some time ago. and this weekend, stassats halved it again
19:39:19
aeth
Of course, kloc/s probably isn't the best measurement when you can do so much at compile time.
21:38:47
pjb
varjagg: (setf (sexp-file-contents "user-token.db") '(("pjb" . "DEADFACE") ("varjagg" . "12345678")))
21:43:52
pjb
Again, depending on the number of processing acessing the data, the size of the data etc.
21:45:44
aeth
When CL is popular enough, it might even add s-expressions to its storage next to JSON and XML and whatever else.
21:48:58
aeth
PostgreSQL is definitely the way to go, though. Perhaps via postmodern. https://github.com/marijnh/Postmodern
21:50:28
aeth
mySQL is for performance or ubiquity, SQLite is if you want to embed a SQL database, and noSQLs (including random CL-based storage systems) aren't a good fit for the problem.
22:16:16
aeth
It's possible that they make it require nickname registration to prevent being hit by the spambot that floods freenode from time to time
22:34:18
edgar-rft
noobly: #emacs was locked for users with non-registered nicks a while ago because too much spam.