freenode/lisp - IRC Chatlog
Search
9:02:33
loke
it saves a conditional jump instruction (and perhaps a CMP, depending on how you lay things out in memory) per allocation. That adds up.
9:03:28
beach
I would think that cost would be swamped by the necessity of allocating memory in order to initialize the object allocated. Plus, the branch-prediction logic will guess the right thing almost all the time.
9:04:38
trittweiler
Posterdati, Might want to add a short section in the beginning what this is about. I didn't know what Prometheus.io is, and because the name of the library is essentially the same as that service, I didn't quite get it at first. (Usually, the convention used to be to call this thing cl-prometheus rather than prometheus.cl, but that's just names.)
9:04:47
loke
beach: I'm sure it's possible to avoid page table hackery, but how much you gain I don't know.
9:05:05
loke
The benefot of not doing it would be that you can easily link in the Java VM in the same process, which would be useful.
9:05:05
schweers`
it seems to me that low level languages like C have done so much optimization, that this way of handling memory and optimizing it is completely lost to them.
9:05:15
trittweiler
Posterdati, I find the numbers in the tables confusing too. Is it really N (operations) per second? In that case, the implementation via mutex wins?
9:05:43
beach
schweers`: They can't do better if they assume that objects won't move once allocated.
9:06:27
schweers`
Is moving objects not at least somewhat expensive? It seems so to me, but then again, I don’t know much about GC.
9:06:46
beach
schweers`: In my opinion, this is the reason for the complexity of C++. They made the decision from day 1 to use manual memory management.
9:08:36
schweers`
not to bash on Stroustroup, but it seems to me like C++ is a quick hack gone too far.
9:09:12
beach
Posterdati: Here is how I see it. Common Lisp and other modern languages enforce uniform reference semantics. That is impractical without GC. Without it, you must distinguish between objects and pointers to them and you must be very careful when counting references and/or copying objects. That is a large part of the complexity of C++.
9:10:01
schweers`
nah, I disagree with him on language design, but I can kind of see how this can happen. Also, he did a remarkable job, in a way. I couldn’t have done what he has. Also, it was a different time.
9:10:41
schweers`
well, maybe for some really weird niche platform. But I guess there are better languages today for any purpose.
9:12:50
trittweiler
beach: C++ tries really hard to make it possible to use the stack for allocations because allocating on the stack is cheap (it's just a pointer increment! - oh the irony)
9:15:41
schweers`
shka: I’m afraid I don’t recall any details, but I remembering thinking that some things in CL seemed weird and somewhat arbitrary, until I got how they work together. Then it just seemed (and seems) amazing.
9:16:00
Posterdati
well every languages has got its own purpose, I still don't catch the c++ purpose, I mean it is not for system programming, nor for AI, databases? Who knows...
9:16:27
aeth
trittweiler: CL has (declare (dynamic-extent foo)) for possible stack allocations. http://www.lispworks.com/documentation/HyperSpec/Body/d_dynami.htm
9:17:01
schweers`
Posterdati: it is sometimes used for embedded devices, as it has some features which make it a little more pleasant to use than C. Which says more about C than C++, if you ask me.
9:17:36
Posterdati
schweers: on Arduino is nice, but not desiderable, I use to program them using c...
9:18:32
aeth
C++ seems to be very popular in high performance and/or real-time programs, e.g. game engines.
9:19:11
schweers`
aeth: I wonder how much of this is just history, and how other languages (CL in particular) would fare in this domain
9:19:25
aeth
Pretty much every game engine is C++, even if they let you use a different language for the part you write (like Unity's C#)
9:20:12
aeth
schweers`: Well, as far as history goes, in the 1980s games were written mostly in asm, and portable games were written that way until probably 2004 or so. In the 1990s, games got to use C and about 15 years ago they switched to C++.
9:25:16
schweers`
But even if CL were not a good candidate for AAA games, I guess that other languages might. Rust maybe?
9:34:08
shka
schweers`: needlessly to say, currently you can simply grab unreal engine or unity engine and stick to it
9:34:42
aeth
schweers`: The big problem with writing a game engine in Common Lisp (or, really, anything that's not C++) is that you have to do everything yourself instead of using existing solutions.
9:35:00
_death
did you realy suggest a language created less than a decade ago and constantly changing for a huge codebase?
9:35:19
schweers`
I didn’t realize that there were so many libraries that game engine developers could use.
9:35:55
schweers`
_death: in case you meant me suggesting rust, it was just a wild idea. I’m not seriously suggesting it, no.
9:37:33
aeth
shka: Interfacing CL with Unity or Unreal? It may or may not be impossible, but it's probably a bad idea.
9:39:46
aeth
As for Rust: https://www.reddit.com/r/rust/comments/78bowa/hey_this_is_kyren_from_chucklefish_we_make_and/
9:44:47
_death
aeth: skimming it I did not see any indication of the code base size.. anyway, to me Rust is one of the most distasteful languages in use.. so I may be biased ;)
11:01:50
figurelisp
where did you guys learn dataq structures in lisp? Not the data structures implemented in lisp but to try to implement them.In a functional way
11:03:34
eminhi
Finally figured out, that the warning i got was due to defining test-system to run tests in test-op, not on load-op.
11:10:15
hajovonta
unfortunately sometimes I had to look up functions like append and such in the beginning
11:12:32
figurelisp
there are books that teach to implement data structures like trees, graphs in imperative programming languages like java,c++ and others adn there is also data structures books for haskell, ML. Are there no books like these for Common lisp?
11:16:22
LdBeth
figurelisp: if you have already read those books i think the only additional thing you have to do is learning CLOS, which gives you the ability to implement complex data structures in CL
11:25:14
beach
figurelisp: An implementation in Common Lisp of some data structure would use exactly the same elements as are used in other languages. Common Lisp has vectors, lists, and standard objects which provide those elements.
11:26:07
hajovonta
it's not really harder or easier to implement complex data structures in CL than in other languages
11:28:43
beach
figurelisp: Now, what do you mean by "In a functional way"? Do you mean that the data structure is persistent (in the sense that applying an operation to it generates a new instance and leaves the original one intact), or do you mean that you want to implement traditional data structures that can be mutated but you want to use a functional style for the implementation?
11:30:16
beach
figurelisp: If it is the former, then you just follow the literature on how such data structures are implemented. If it is the latter, then you are looking in the wrong direction, because Common Lisp is not a particularly "functional" language in that respect. You would rather use standard objects and generic functions in an imperative style.
11:33:58
beach
figurelisp: I am asking whether you are referring to the property of the data structure you want to implement, or to the programming style to do it.
11:35:08
figurelisp
like the basic dataq structures are implemented in haskell but they are functional
11:35:09
beach
figurelisp: You can do that in Common Lisp, but that's not the typical Common Lisp style.
11:36:01
figurelisp
I don't know much about functional programming so i am not certain how they are implemented. I was thinking to learn functional paradigm through CL
11:37:08
beach
figurelisp: What antoszka says. Common Lisp shines with its object system, its condition system, etc. Not for its support for functional programming.
11:37:34
antoszka
figurelisp: It doesn't force you into functional thinking (like Clojure/Haskell do), nor does it really provide any strictly functional facilities.
11:37:38
beach
But you can definitely use a functional style in Common Lisp. It is often done to implement macros for instance.
11:39:17
figurelisp
My main objective is to learn CL. Now i am reading CL:gentle introduction but after that i thought the next path would be to learn how to implement basic data strucutes. that's all what i want to achieve right now
11:40:06
beach
figurelisp: You would have simpler data structures and a more natural Common Lisp programming style.
11:41:42
figurelisp
so what you are saying is I should try to implement it on my own and then ask for help and code review here?
11:41:52
edgar-rft
figurelisp, there'a ton of builtin data structures you can use, we would need to know more details what you need exactly
11:42:43
beach
figurelisp: The stack is particularly simple for the very simple case, but I can show you situations where the simple case is inadequate.
11:43:44
beach
figurelisp: (defgeneric push (item stack)) (defgeneric pop (stack)) (defgeneric emptyp (stack))
11:44:42
figurelisp
beach: sorry to interrupt but i will not be abel to understand it right now. I'll complete the introdution book and then i'll learn from you
11:45:57
hajovonta
beach: oh come on. (defparameter stack nil) (push 1 stack) (push 2 stack) (pop stack):)
11:46:36
beach
hajovonta: That won't respect the most elementary restriction on an imperative data structure, namely that it has its own first-class identity.
11:47:51
beach
hajovonta: Try (defparameter stack2 stack1) then (push 234 stack1). For it to be moodular, stack2 must change as well. Otherwise, your implementation is showing in the interface which is unacceptable.
11:49:04
beach
hajovonta: The Common Lisp list is not an abstract data type. I call it a "concrete" one. So it can be used to implement an abstract data type, but it can't be used as such by itself.
11:53:50
beach
LdBeth: The array with a fill pointer has the problem that you can not guarantee, nor even come close to, O(1) complexity for the operations.
11:54:27
beach
LdBeth: The list version has the problem that if you want a stack of (say) DNA letters, then storing 2 bits costs you 126 bits overhead.
11:55:50
beach
LdBeth: So it is not a simple question of preferring one to the other. It has to do with conforming to specifications. In the case of a stack, I can eliminate both problems with a slightly more complicated implementation.
11:57:11
hajovonta
it would be interesting to create a closure-based implementation and see comparisons.
11:58:02
beach
hajovonta: That would be essentially the same as the one that uses a standard class above, except it would be less flexible.
11:58:17
beach
hajovonta: The closure would play the same role as the instance of the standard class.
12:20:09
LdBeth
beach: why array with fill pointer can’t guarantee O(1) complexity, except you mean when the stack is full and needs to be resized
12:24:48
hajovonta
beach: I would think, after reading let over lambda, that closures are more flexible than using objects.
13:18:46
pfdietz
Vectors with fill pointers can implement stacks in O(1) amortized time per operation.
13:20:02
pfdietz
This is fine unless you have real time constraints, or if you're trying to make the stack "fully persistent" (where updates can be done on past versions in a branching model of time.)
13:21:25
beach
pfdietz: Correct. I was referring to the worst-case complexity of one single operation.
13:22:21
pfdietz
It's possible to get to O(1) worst case time by a more clever approach, where the copying to the new larger vector is spread out over O(n) updates. This still doesn't help with full persistence though.
13:22:29
beach
hajovonta: You can't stick an auxiliary method that specialized according to the particular type of the closure.
13:23:06
pfdietz
Another lispy example of this is implementation of a queue with stacks. Using two stacks you can do queue ops in O(1) amortized time, but you can also do it in O(1) worst case time with some effort.
13:23:18
beach
pfdietz: The better solution that solves both problems is to use a list of constant-size vectors.
13:25:33
beach
pfdietz: Interestingly, when I came up with that solution, I checked it with the algorithms and data structures expert in the lab (I do not consider myself an expert, though I may have to rethink that), and he had never heard of it, nor had he ever contemplated the problems with the list or the vector solution (space vs real-time).
13:29:59
beach
pfdietz: Using a list to implement a stack has the problem that each element takes 2 words. So if you want a stack of bits or of DNA letters, you wast a lot of space.
13:30:47
beach
pfdietz: If you use a vector instead, you are sacrificing real-time behavior, so you can't propose it to gamers for instance. Occasionally an operation may take linear time.
13:31:28
beach
If you use a list of constant-size vectors, you can have vectors of bits, and provided the vector is big enough, you can make the 2 words waste arbitrarily small.
13:31:52
Zhivago
Gamers don't really care about real-time -- they just care about latency spikes. In practice they just make things excessively fast enough that the spikes they do get are acceptable.
13:31:56
pfdietz
There's a theme in data structure design where you layer two different kinds of data structures, using a different one for small chunks. This looks like an example of that.
13:32:10
beach
pfdietz: Furthermore, you only ever need to allocate a constant-size vector and you never need to move more than that many objects, so you have constant time operations.
13:33:10
pfdietz
And the overhead of the links can be spread over the length of the vectors, and so can be made as small as desired.
13:33:56
Zhivago
I think you'll find that gamers are happy with the terrible things that STL does to extensible vectors in most cases. :)
13:34:30
pfdietz
Where I was not clear was that you were reducing the space overhead, minimizing the constant.
13:34:54
beach
Zhivago: I actually don't care much about that particular use case. I chose the wrong example. Again, I'm sorry.
13:36:22
shka
anyway, it you can have hard real time behavior as a component in system that is supposed to have soft real time characteristics without drawback, you potentially can save yourself headache when optimizing
13:47:45
beach
pjb: Clearly, for the side-effect-free version of the stack, the vector solution is totally out. The list of constant-size vectors might still be acceptable.
13:49:02
beach
pjb: If you have very small objects, like bits or DNA letters, you can copy the entire thing very efficiently, so you are no worse off than with a pure list.
13:49:21
beach
pjb: And if you have large objects, you converge toward the pure list solution anyway.
13:51:02
pjb
This is why we have programmers: there are always special circumstances that require specific data structures and algorithms.
14:34:35
flip214
would it be too much to ask that "Beta" gets removed from the documentation pages, eg. https://www.quicklisp.org/beta/releases.html (URL and text)?
14:48:01
JuanDaugherty
so the problem I was having with mcclim demo was due to trying to run under vnc
14:56:45
Bike
somewhat to my surprise, you can pass any input stream to LOAD, as far as i can tell. but if you do, and the stream has no associated file, i'm not sure what *load-truename* and *load-pathname* ought to be bound to. anyone know?
15:01:43
Bike
I mean, for example, in (with-input-from-string (s ("print *load-pathname*)") (load s)), what is printed.
15:02:50
beach
Bike: Good question. I don't see the answer to it anywhere. Something for WSCL to specify, it seems.
15:23:40
beach
figurelisp: I am a researcher and I have chosen Common Lisp both as my research project and as a vehicle to accomplish it.
15:24:30
beach
It's because where I work, we don't have the pressure they have in some countries to get grants, etc. So I can choose what I do.
15:39:52
LdBeth
Basically I learned Lisp because I’m not required to learn any particular PL and out of mania on retro computing
15:45:23
LdBeth
Actually CLtL2 is written before I was born. So I consider it as retro. Plz forgive me if that annoys you
15:51:49
LdBeth
Just because it’s strong typed. In untyped lambda calculus even Y combinator can be applied to an int
17:40:27
flip214
https://github.com/pcostanza/closer-mop says "This page is taking way too long to load."
20:23:00
HighMemoryDaemon
Can Lisp be compiled to machine code that can be ran on computers without [insert common lisp implementation] installed?
20:24:36
random-nick
HighMemoryDaemon: does that disqualify implementations that bundle themselves with your executable?
20:25:32
random-nick
even if you somehow don't use any standard functions and macros you still have the garbage collector
20:26:02
trittweiler
HighMemoryDaemon, ECL can get you binaries that simply depend on a libecl.so dynlib.
20:27:11
sjl_
depends on what you mean by "installed". If you s-l-a-d on sbcl, it can produce a single binary that doesn't need anything else on the target machine to run.
20:27:25
random-nick
HighMemoryDaemon: SBCL can save a full image of the running system as an executable
20:27:46
sjl_
That binary will happen to include SBCL itself, so whether you consider that to be "installing" SBCL on the target machine depends on your definition of installing, I guess.
20:27:55
aeth
As far as standalone binaries, SBCL wil be the fastest, but the largest, so it depends on what you want. Probably unsuitable for a tiny script, but probably most suitable for a game or large application.
20:30:58
earl-ducaine
HighMemoryDaemon: For the sake of completeness: the degree of local support needed for compiled code is unspecified, i.e. implementation dependant and can be , and for modern common ilsp often is, zero
20:31:47
HighMemoryDaemon
Just compiled a console hello world program in SBCL. 42 megabytes in total.
20:33:31
aeth
On the other hand, even graphical applications are much larger than 42 MB these days. Bloat.
20:33:51
pjb
HighMemoryDaemon: with ecl, you can also generate a static library libecl.a, and link your program statically, so the executable doesn't rely on a shared library to be pre-installed.
20:34:35
sjl_
HighMemoryDaemon: Right, that includes SBCL itself. e.g. if your hello world app crashes you'll get the full debugger and Lisp environment.
20:36:20
marvin4
is there a way to avoid packing sbcl together with every executable? or do language spec require full enivornment available at runtime
20:37:49
pjb
marvin4: yes, instead of using sbcl, use another CL implementation. Then sbcl won't include itself with the executable.
20:38:36
HighMemoryDaemon
What are the most common uses of Lisp in the modern day? GUI applications, web servers, AI, ..? I have a feeling that with a lot of uses you don't need to worry about compiling to native machine code.
20:39:27
Bike
compiling to native code is usually useful. compiling gives you static error checks, and machine code is generally faster than interpretation.
20:39:52
Bike
it is a general purpose programming language. do people ask what java is "for"? it's such a weird question to me
20:40:02
aeth
HighMemoryDaemon: Two uses are common enough for their own channels: #lispgames and #lispweb
20:40:34
aeth
Lisp was also traditionally very large in AI, but it was mainly used for old school AI, not machine learning, so relatively speaking it's probably much smaller there than it was.
20:42:04
earl-ducaine
HighMemoryDaemon: If you're concerned about the size there are various compression schemes you could lookat.
20:42:23
Bike
i think sbcl already incorporates several, so it might be hard to squeeze it much more
20:42:46
earl-ducaine
HighMemoryDaemon: A quick export shows that gzip will compress it into a 12M file.
20:43:59
earl-ducaine
HighMemoryDaemon: (sbcl) Presumably the executable has various sparse memorry areas that are simply read into their location when the executable is loaded.
20:48:41
HighMemoryDaemon
earl-ducaine: That's cool. With Gzip are you just talking about reducing the download size for the end user or is their a way to actually zip an executable that unzips on launch?
20:49:19
aeth
HighMemoryDaemon: here's a bunch of them: https://dto.itch.io/ https://itch.io/jam/lisp-game-jam-2018/results
20:58:14
earl-ducaine
HighMemoryDaemon: Launch plain SBCL from bash shell and past this lisp code https://gist.github.com/earl-ducaine/c1a59ab3d9384d318fbe715abbff0eb6 into the terminal