freenode/#lisp - IRC Chatlog
Search
22:54:50
pjb
How the parameters are passed, and what is pushed on the stack in addition to them and the return PC.
22:55:16
pjb
Usually, there's a FP link saved on the stack. You seem to have two more slots since it adds 4.
22:55:39
pjb
This is probably described in the documentation/specification of the VM and/or the compiler.
23:05:38
aeth
It doesn't look like particularly well-written Lisp in the first place. Unless the style got messed up in the cut and paste.
23:06:09
aeth
It violates every style guide I know of, which makes it harder to read that it should be.
23:08:54
Shinmera
I've seen enough mind boggingly awful template code from university lectures that I'm entirely ready to believe someone wrote this who just doesn't know lisp either.
23:09:41
megachombas
tried to wrote my own. but at arrrived at a point where i didnt understand lisp at all. found this one that was functional, so i tried to understand it to do mine
23:10:06
megachombas
but i arrived at a point where im still trying to understand this one, and bassicly doing small modifications
23:10:33
aeth
megachombas: If you need to pick up functional Lisp-style programming in a short amount of time, work through The Little Schemer (formerly The Little Lisper). It's in Scheme, but most of the lessons would carry over imo.
23:12:10
aeth
Do not put assignments off to the last minute. I tried doing this in college, and it ruined my health, possibly permanently.
23:12:42
|3b|
ACTION just put things off until past the last minute, much better for health (bad for grades though)
23:13:09
aeth
|3b|: If there are grace periods, and you're good enough to consistently be able to get an A even with the -10% penalty or whatever, it can still work
23:13:29
Shinmera
I try to do things as early as possible, but then I just get stressed out to all hell towards the end anyway.
23:14:02
megachombas
found this http://www.lirmm.fr/~lafourcade/ML-enseign/Compilation/compil-GenCode.HTML
23:15:38
aeth
megachombas: My recommendation to you would be to pick up processing things with cond. It's fast enough that you could pick it up quickly enough. A lot of functional-style Scheme and Lisp uses that basic style. (There's no time for fancier techniques.)
23:16:36
megachombas
yes, just i discovered those instructions today ,and he NEVER EVER give it to us
23:20:11
aeth
megachombas: COND is basically an if/elseif/elseif/.../else block, except that it is a form that also returns values so you can use it just like a very elaborate ternary operator if you wanted
23:20:21
aeth
This is its documentation: http://www.lispworks.com/documentation/HyperSpec/Body/m_cond.htm
23:21:10
aeth
megachombas: You should make sure you understand COND first, because you're probably going to need it in your program if is going to have any elaborate conditionals in it. It's simpler than fancier alternatives.
23:26:13
aeth
I would personally try to build something useful from the very simple basics of Lisp rather than trying to dissect an existing Lisp program. Build up from a toy program and gradually add the features you need.
23:27:08
aeth
It's very important, at least the way I program, to have a completely working program at every step of the way.
23:27:57
aeth
If your teacher actually didn't explain things properly, then don't panic. If it's a large class, lots of people will probably do worse than you, and the grades might be adjusted upward.
23:30:31
pjb
(get-newFP 2) returns the frame pointer of the caller of the caller of the current function.
23:30:59
pjb
This is why there's this loop and it updates the LOCAL variable newFP. But it doesn't modify (get vm :FP) the actual frame pointer!
23:31:06
aeth
megachombas: Is the assignment to build a register machine like on the website you linked to?
23:33:23
aeth
Well, if there's more freedom of choice, then choose a stack machine. They're (afaik) simpler, especially in languages that have stacks (CL has two built-in stacks). That might not be an option, though.
23:39:20
pjb
(get-loc-src vm expr) reads the memory containing the value of the local variable number EXPR in the current frame.
23:39:59
aeth
megachombas: Is the assignment something like this? Given the instructions, do the operations.
23:41:14
megachombas
the asignment is 'make a VM in lisp that use 4 registerys and a lisp compiler "
23:50:36
aeth
(And if your requirement is to compile a standard Lisp or Scheme, then you're doomed.)
23:58:32
aeth
I'm not sure any Lisp resources will be helpful. The assignment itself, even to those who know Lisp, will probably take more than one day to write.
0:01:05
aeth
(And no one is going to do your homework for you, so you'd have to add the time it would take to learn Lisp.)
0:03:05
pjb
aeth: for a student, yes. I would do it in a day, I already done it several times, including an assembler, a disassembler, etc.
0:03:33
aeth
pjb: I would estimate 3 days for someone doing it the first time, student or not. Obviously doing something more than once makes you write it a lot faster. Sorry, I could have been clearer.
0:04:15
aeth
A minimum of two calendar days because sometimes you get to a point where you get stuck and only sleep can solve things.
0:09:32
whoman
i am sorry to hear,i hope your health and quality of life returns to normal and/or improves
0:17:25
drmeister
Is there a lisp function that waits for the user to hit enter or a key - something that will work in slime.
1:26:22
pransninja
True to form, the Chapter 13 of PCL took me as long as every other chapter before it, the chapter title: Beyond Lists: Other Uses for Cons Cells
1:27:43
aeth
Lisp has multidimensional arrays, hash-tables, and other things that aren't cons cells.
1:30:39
aeth
Syntactically, everything's cons cells. The actual data structures that you create are not, though.
1:31:37
aeth
closures, hash tables, multidimensional arrays, structs, standard-objects, etc., couldn't be efficiently implemented with cons cells.
1:37:36
aeth
vectors (including strings) will have an O(1) length and an O(1) elt (or aref). lists will have an O(n) length and an O(n) elt (or nth)
1:38:05
aeth
Vectors have different performance characteristics. And even if they're expressed as lists in source code, they will (usually) be turned into vectors at compile time.
1:39:48
aeth
CL's hash-tables have a different performance trade-off than plists or alists. In theory, plists might be faster for very short things, but hash-tables will win for large data sets.
1:43:18
pjb
Last time I benchmarked, for implementations compiling to native code the break-even point was about 5 entries (<= 5 entries, a-list or p-list are faster; >5 entries, hash-tables are faster), and for byte-interpreted implementations such as clisp, the break-even point is more like 35 entires!
1:44:09
pjb
If you can bound the number of elements, to a small number, it may be even better to use a vector than a hash-table.
1:45:58
aeth
pransninja: You can't expect all implementations to behave exactly the same because maybe one day someone will finish JSCL or write a popular JIT bytecode CL.
1:46:21
aeth
pransninja: But hash tables are in the standard, as are vectors. And a lot of the same optimizations apply to all of the current major implementations.
1:46:49
aeth
e.g. unless you're using clisp, you can pretty much assume that you can make single-float and double-float specialized arrays.
1:47:22
aeth
That's what the standard says about hash tables (or at least one entry point into what it says)
1:48:28
aeth
Vectors will win more often than you think when numbers are involved because they can be specialized
1:49:26
aeth
There aren't any typed lists or typed hash tables (well, they all store type T), so vectors often give more information to the compiler
1:51:25
aeth
Most information is probably specific to SBCL (and/or CMUCL), but a good deal of that will also apply to CCL and possibly even ECL.
1:54:33
aeth
Most optimizations are imo a waste of time. Generally you want to (declare (optimize (speed 3))) and declare any types that are numeric or arrays (if you can provide length information for the array type, that can really help because the compiler may replace repeated bounds checking with one type check at the beginning of the function)
1:56:11
aeth
If everything is of the same numeric type, you can use :element-type in make-array, e.g. (make-array 3 :element-type 'single-float :initial-element 0f0) or (make-array '(2 2) :element-type 'double-float :initial-contents '((0d0 0d0) (0d0 0d0)))
1:56:41
aeth
If things aren't of the same type but are numbers or arrays, typed slots in a struct (defined with defstruct) might work
1:57:32
aeth
If something is trivial and probably never going to change, inlining can help the compiler. Above the function you can do this: (declaim (inline the-function-name-goes-here))
1:59:07
aeth
Not every implementation will use all of the optimization information you give it, e.g. CLISP doens't have single-float or double-float specialized arrays, and just makes them T arrays. I think almost every implementation does accept single-float, double-float and a large number of integer types (e.g. (unsigned-byte 8) and (unsigned-byte 32))
1:59:24
aeth
Only character and bit are required by the specification, but (unsigned-byte 8) is heavily assumed by many libraries.
2:00:52
pjb
aeth: on the other hand, clisp has short-float that will fit immedately into arrays of T!
2:01:27
aeth
pjb: The arbitrary-precision long float is the one reason to use CLISP for code that deals with numbers, afaik.
2:02:31
pjb
pransninja: you can reason with clisp, you just need to know what CL functions are implemented in C and what are implemented in lisp!
2:02:52
pjb
If you write your function to process your data with CL functions implemented in C, then it'll be fast. If you do it in lisp, it'll be slower.
2:03:56
pjb
So what's funny is that basically you must adopt a style opposite to what you'd do in sbcl to write efficient code in clisp :-)
2:04:32
aeth
pransninja: For advanced optimizations, you might be interested in specialization-store. https://github.com/markcox80/specialization-store/
2:05:27
pransninja
at this point, I would like to learn the basics of how you go about optimizations in lisp
2:06:03
pransninja
Though, the fact that optimizations depends on the compiler, which is fair, but still, makes it hard.
2:06:55
pjb
pransninja: it goes like this: you write code that works, without having to deal with memory management or array overflow, because this is controled by the implementation. Once you have something that works, since you've spent 1/10 the time you'd have spent in C, you are left with 9/10 of the time to think about better algorithms. So you can implement them and obtain faster results.
2:13:00
shrdlu68
pransninja: When compiling with slime you get optimization tips (at least using SBCL)
2:13:54
aeth
pransninja: The list I gave is pretty much all you need, except perhaps with the added advice to preallocate things before large loops. Consing (heap allocation) in large loops might hurt performance.
2:14:17
aeth
CL is not a pure functional programming language. People are fine with using things like setf when it helps performance
2:15:45
Pixel_Outlaw
I think it's less /functional/ to mandate a single style at the expense of the programmer's style.
2:15:54
aeth
Most of the advice is about providing array or number type information to the compiler. That's because functions like + and map are type-generic, but can be inlined by the compiler if the type is known. A lot of type information will be given to the compiler just by the function call. e.g. you can only use car on a cons cell
2:19:09
aeth
(Providing the array types can potentially also do two other things: remove bounds checks and tell the compiler the type of the thing that it gets with aref)
2:33:20
aeth
pransninja: What are you interested in optimizing, btw? If it's a program that essentially uses no numbers anywhere, almost all of the advice I just gave is worthless.
2:36:05
aeth
Generally, I optimize on SBCL and hope it works on the other CLs because they just don't expose as much useful information. An almost-complete implementation called Clasp (a C++ and LLVM CL) might, though. And SICL (not anywhere near complete afaik) is designed to be very easy to debug.
2:37:24
aeth
Only optimize the parts that matter, though. You can spend literally forever getting an extra few percent, and the more specific the optimizations are, the less likely they are to be portable away from SBCL.
2:41:14
aeth
(I think the point where you've gone way too far is probably if your code has implementation-specific optimizations all over the place. And if you're inlining assembly...)
2:50:51
aeth
Afaik, for anything that can be expressed as a specialized array, vectors will win unless you construct those benchmarks carefully to have lists win. Lots of inserting in the middle, maybe?
2:52:35
aeth
For the best performance with arrays, though, you'll want known length and you'll want an :element-type that actually gets used (not just a T array).
2:55:03
aeth
So the most dramatic wins for vectors over lists would probably be something like 4x4 matrix multiplication.
2:56:32
aeth
(especially when the matrix has the :element-type defined as single-float or double-float)
3:01:10
aeth
So, afaik, Common Lisp is almost an acceptable FORTRAN now. It looks like it's good enough for Maxima (a CAS program) to use f2cl to compile Fortran to CL. https://github.com/andrejv/maxima/blob/fc2d2c3d0cc532275ac060d46924c26afc667c50/src/numerical/f2cl-lib.lisp
3:02:02
ebzzry_
aeth: searching for the existence of an element is generally faster with vectors, right?
3:03:03
aeth
That sounds like something that should (theoretically) work equally well with either sequence type, so benchmark it!
4:50:12
jmercouris
whoman: "forests are contained in seeds", I feel like there is some profound meaning to this, but I'm not seeing the connection here
4:51:05
whoman
if morning is the seed for night, how we nurture and water this, will bloom into the night. and vice versa, how night fertilizes the next morning
4:51:25
whoman
so you may be having good nights because of bad mornings, but having bad morning times because of good night times ...
4:53:26
defaultxr
has anyone noticed weird behavior when using quoted lists in tests in fiveam? i.e. if i use '(1 2 3 4 5) in two different tests, and one of the tests modifies its list, it affects the other test. doesn't happen if i use (list 1 2 3 4 5) instead. but it seems like it shouldn't happen at all. didn't happen when i was using prove.
4:56:43
defaultxr
i'll try installing another and installing quicklisp on it, etc, if you think that will make a difference
4:57:33
jmercouris
I'm just asking general troubleshooting questions, it sounds a very strange error beacause the quoted list should not share context with another test, and I am thinking it may be some strange bug
4:57:59
defaultxr
the tests seem to be running concurrently based on some print statements i added to my code while i was testing
4:58:20
jmercouris
I also don't know what the difference between '(1 2 3 4 5) and (list 1 2 3 4 5) on an implementation level is
4:58:53
jmercouris
maybe there is some strange compiler optimization behavior going on with contexts, that's my best guess
4:59:05
whoman
there shouldnt be any real difference, not like how its affecting the situation there
5:00:27
defaultxr
it doesn't, if the two lists are different. i'm guessing it has something to do with this: https://stackoverflow.com/a/578365 "DO NOT USE QUOTE TO CREATE LISTS THAT YOU WILL LATER MODIFY. The spec allows the compiler to treat quoted lists as constants"
5:03:26
|3b|
PUSH doesn't modify the list stored at that place when called correctly though, it just changes the contents of the place to point to a list whose CDR is the previous list
5:04:35
|3b|
if that previous list was a literal, you are allowed to modify the car/cdr of the new value, since that cons was created by PUSH, but you are not allowed to modify any car/cdr past that, since they are from the literal list
5:05:39
jmercouris
I assume pop does actually modify the list instead of returning a copy of the list with the element missing
5:07:06
|3b|
(theoretically it still remains unchanged even if you don't, but GC will may affect in ways you can no longer detect, but which wont affect the behavior of your program)
5:10:30
|3b|
right, nreverse may modify the structure of its arguments, so shouldn't be called on literals
5:11:01
jmercouris
So basically if you are manipulating a piece of data over and over again to avoid gc you might use a recycling function instead
5:11:46
|3b|
note that not all of them are /required/ to work in-place, so probably should check the spec (and/or rethink the algorithm) if that matters a lot
5:13:19
|3b|
expense of GC depends on your data to some extent, lots of conses is more expensive to GC than same amount of storage for vectors specialized for things like fixnums or characters that can be known not to contain other objects
5:14:37
|3b|
when it is invoked depends on the implementation, usually in some way related to amount of allocations
5:14:37
aeth
|3b|: Does that mean one big 2D array is better than a vector of specialized vectors because the latter has a T vector that has to be walked through?
5:16:00
jmercouris
|3b|: What is the expensive part based upon the number of cons' is each cons cell it's own object that must be free'd?
5:16:11
|3b|
right, though small effect on GC time might be outweighed by increased costs in the actual code if the abstraction is worse
5:17:11
jmercouris
basically on a system level here, when we run a GC in lisp, are we actually freeing the memory, or is it just now available within our loaded lisp image as "free" memory?
5:17:31
|3b|
jmercouris: speaking very generally, GC tends to involve walking through all objects on the heap starting at for example a register or other known starting point to see what is still 'alive'
5:17:57
jmercouris
furthermore, is this memory every coalesced or just exists neubulously within the lisp image, and then has to be coalesced to reduce the size of the image?
5:18:26
|3b|
if you have a 1 million element list of numbers, it has to look at 1 million conses. and at each number to verify it is just a fixnum/single-float/etc that doesn't need further processing (and if not, walk whatever is there)
5:18:55
|3b|
if you replace that with an untyped array, it skips the million conses, but still has to look at the million values
5:19:34
|3b|
if you switch to a specialized array, it can say "this 1 array only holds fixnums, so it can't hold anything else i need to look at" and the whole array is 1 check
5:19:40
jmercouris
what is the garbage collection strategy in lisp? is it different across implementations?
5:20:04
jmercouris
So there exist some optimizations for the compiler to be more efficient, makes sense
5:20:30
jmercouris
|3b|: I guess one could use any of many strategies, but I'm asking in a general sense, what to expect
5:20:33
|3b|
and differs between implementations (or even options/architectures within an implementation)
5:21:06
jmercouris
Okay, so it is all over the place, and I shouldn't worry too much about it except for when I can use recycling or somehow let the compiler/system know to optimize something
5:22:06
|3b|
ACTION doesn't even usually bother with using the destructive functions (and then only on obvious things like a list i just created, like in the push + nreverse idiom)
5:22:47
jmercouris
do you know of any lisp implementations that use reference counting to facilitate gc in an efficient manner?
5:23:25
jmercouris
I remember back in the early days of dalvik, good times, GC would freeze the phone for several frames
5:24:02
jmercouris
and there was no easy way to 1. limit when it runs, 2. control what it garbage collects (technically you could, but it was an abuse of java)
5:26:06
aeth
I have a game loop that essentially doesn't cons at all (a tiny bit of cl-sdl2 it uses conses a little; I'll have to replace cl-sdl2 eventually)
5:26:40
aeth
You have to pre-allocate everything and write a ton of macros to make complicated things seem natural
5:27:48
aeth
jmercouris: No language is good for game programming, then. C++ engines literally never get completed because C++ is is hard to do right when you're writing a large application
5:28:29
jmercouris
I don't even like C#, but I can't pretend it isn't good for game programming, MS put a lot of work into it
5:28:53
|3b|
jmercouris: people made plenty of games in flash with bad GC, lots of games in JS with bad GC, failure to make games in CL can't be blamed on GC :/
5:29:23
aeth
jmercouris: Most C# game programming (by an overwhelming amount) uses an engine (Unity) written in C++
5:29:37
|3b|
and even if it were horrible, i'd still argue for prototyping in CL even if parts of final thing had to be reimplemented in C or whatever
5:30:19
jmercouris
Java also has terrible GC indeed, thats why I mentioned Dalvik, when I was doing some very very early android games, what a nightmare
5:30:36
jmercouris
there's perhaps just not a good platform for CL, so maybe that's why nobody writes games in CL
5:31:47
|3b|
(java actually has some good GCs from what i hear, no idea if the defaults on consumer java stuff are any good though)
5:33:03
loke
|3b|: Java probably has the best CG's available in any system. It's not focused as much on low/zero latency though, and tuning for near-realtime can be a hassle, which is what I suspect jmercouris was referring to.
5:33:23
|3b|
doesn't help that there are lots of ways to rate a GC, some tasks might think a high-throughput GC is great (batch jobs that run over night for example), while some things might care about latency (games, sort of), or maximum pauses (games)
5:33:35
aeth
jmercouris: Anyway, I would argue that CL is the only language suitable for game programming. No matter how badly you have to abuse the language (and literally every large enough game engine will run into limitations with the language unless the engine authors also wrote the language) you can cover it up with metaprogramming. And not the kind of painful metaprogramming you'd see in a language like C++.
5:34:19
aeth
jmercouris: Sure, maybe the CL implementations haven't really caught up yet, but optimizations follow use, they don't precede it.
5:34:44
aeth
You're wasting time as a language implementor if you optimize for things that no one is writing.
5:35:09
loke
|3b|: Java comes with several GC's that you can choose between. And on top of that you can tune them in about a million ways. The default GC is great for long-running server applications, which is kinda the opposite of games. So yeah, for games stuff you have some tuning to do.
5:36:03
jmercouris
loke: The implementation on Dalvik was a nigthmare, go ahead and spin up some old android vms and you'll see what I mean
5:36:08
aeth
loke: and Minecraft was poorly optimized Java, which gave Java gamedev a bad reputation
5:37:13
loke
Also, Android now has multiple implementations as well, so one has to be specific when talking about Dalvik, or ART, or the thing that ART has become in Android 8.
5:37:35
jmercouris
it is only recently in my mind that I've begun to distnguish between language and implementation
5:37:54
loke
As far as I can tell, the VM in Android 8 seems a lot better, but I haven't pushed it very hard. :-)
5:38:03
aeth
jmercouris: And my non-consing style is actually unnecessary, I roughly lowered 4%-5% CPU usage to 2%-4% CPU usage
5:38:39
aeth
(Although that reduction in CPU usage included replacing efficient SIMD linear algebra that consed with naive not-SIMD linear algebra that didn't cons)
5:38:47
jmercouris
loke: The VM in Android can get as good as it likes, it's still a VM and, bare metal is always best
5:39:10
jmercouris
as much as I like the java "code once, run everywhere", the experience is still a pipe dream, and it is 2018 now
5:39:27
aeth
jmercouris: I'm writing a game engine because it prioritizes CPU performance without having any real RAM limitations. That's a fun combination for me.
5:39:42
jmercouris
|3b|: I remember when NDK was so terribly documented, there wasn't even ANY documentation
5:39:54
loke
jmercouris: The question is how close to Java the VM is... The problem with the JVM is that a lot of its features are designed to make Java very efficient, but makes it hard to implement some features of other languages (efficiently).
5:39:55
jmercouris
I also remember having to edit special strings in eclipse to load your APK onto different phones
5:40:55
jmercouris
loke: I have no problem with the JVM speficically, I have problem with VMs in general
5:41:18
DevilsDulcimer
anyone have any experience working with outsourcing? preferably an American company working with Indians over Telecommuting solution such as skype...are they a viable lot when it comes to going forward with a tech company?
5:41:24
loke
jmercouris: THat is fortunately no the case now. OWEVER, it's worse in another way. Now the entire ecosystem is based on Gradle, which is probably the worst piece of shit build system I ever had the misfortune to be force to work with.
5:42:07
jmercouris
loke: Gradle is a war crime, I'm not sure why they pushed that and the Intellij train so hard
5:42:27
loke
jmercouris: IntelliJ is great, but what they did to it when thet made AS was a disaster
5:42:50
loke
jmercouris: I used to do ANdroid development in IDEA, and clicking on "run" compiled an, built, and deployed on the emulator in about 5 seconds.
5:42:59
aeth
If there's a quality outsourcing firm with Common Lisp experience, maybe we could crowdfund some patches to key CL projects.
5:43:20
loke
jmercouris: With Gradle and AS, that increased to about a minute. It's better now, if you're lucky enough that the damn thing doesn't roll over and die on you.
5:44:09
loke
Oh, and if you _DARE_ to try to load load an old project after 3 weeks of not using it, it won't beuild anymore because Gradle decides to upgrade half your dependencies and nothign will work anymore, and you are force to cargo-cult random changes in your Gradle project file to get it to run again... MAYBVE
5:44:56
jmercouris
loke: Lol I love those stack overflow "I changed x to y" in these lines for upgrades which are basically breaking against user will, and undocumented
5:44:58
loke
The funny thing is that I listen to the Android Developers podcast (by the Android team at Google themselves), and they'
5:45:27
jmercouris
What's wrong with maven? what's wrong with manually coyping some jars when you need them?
5:45:56
loke
jmercouris: I absolutely abhor maven, and it's quiote telling that I'd gladly commit to Maven 100% just to be able to get rid of Gradle.
5:47:15
loke
The worst par tis that Gradle is just a script, with a horrific syntax hack to make Groovy look like a DSL. That means that every single line is executable and then AS attempts to actually parse this thing to make sense of it.
5:48:06
jmercouris
I didn't even know that, but it doesn't exactly shock me, that's some next level stuff... in a bad way
5:48:14
loke
Damn it... Just thinking about that crap makes me angry. I need to go have lunch now and cool down.
5:48:40
beach
jmercouris: Reference counting is way more expensive than tracing collectors, and on top of that, it doesn't work for cycles.
5:49:05
loke
jmercouris: Try it next time, pluck some Groovy code in there (it's essentially Java with a more scripty syntax, but most Java constructs still work) and see the... erm... beauty
5:49:48
jmercouris
beach: of course reference counting will also fail for cycles, it's just made for lightweight applications, but I see your point
5:50:27
jmercouris
How so? reference counting is MOST DEFINITELY lighter, you simply maintain a hash table of counts, in fact, you could even maintain a sorted hash table
5:50:45
beach
jmercouris: By reference counting, we mean that when a variable is assigned to, the object previously contained in it has its reference count decremented and tested for 0.
5:51:31
beach
jmercouris: Yes, so every time you do an assignment, you have to go to memory and update a reference counter. On modern processors that kills performance.
5:52:13
loke
jmercouris: The issue with refcounting is that you have to access this refcount variable all the time, and in a multithreaded environment you also need some way of dealing with data races
5:52:17
jmercouris
Perhaps assignment will be slightly slower, eg. intialization code, but garbage collection will definitely be faster
5:52:31
beach
jmercouris: And C# uses garbage collection as well, so there is nothing related to garbage collection that makes C# better suited for anything than Common Lisp.
5:52:58
rme
reference counting spreads out the pain. with a tracing gc, you suffer the pain all at once, but you get a bulk discount.
5:54:32
jmercouris
not some form of automatic reference counting, not some form of marking relations, but literally incrementing referencing counts manually as a user
5:55:14
jmercouris
it's just BARELY different than manually alloc and freeing memory, but can mean a performance boost in some cases where you know you don't need to actually now mark something during a transient operation (for example)
5:56:23
loke
jmercouris: There is also the issue of bookeeping. In C, for example, both allocating and freeing memory requires the malloc implementation manage a tree of free memory structures which can be quite expensive. In a compating GC language, a malloc() is essentially a single instruction (an ADD, moving the free memory pointer), and a free() takes zero cycles, since you simply drop the pointer.
5:56:56
loke
Of counrse the GC intself takes some reasoucres, but it's not clear-cut which one wins.
5:57:01
beach
jmercouris: Earlier you asked about CONS cells being freed. Did you think that some version of free() was being called in order to free those cells?
5:58:33
jmercouris
I don't believe so, I literally just this past year studied GC, within the context of distributed systems even
6:00:23
jmercouris
loke: Yeah, that was more or less my question about what common lisp implementation is likely doing when freeing a cons cell
6:00:53
jmercouris
CL has surprised me in so many ways so I keep asking questions that I know the answer to in other languages, but I'm never sure
6:01:05
loke
jmercouris: I presume you are referring to the work neede by the GC to release the memory used by CONS cells that have been released?
6:01:44
beach
As loke says, a modern GC does not touch unreferenced objects, so it does not "free" any cells. And this is not specific to Common Lisp. It has to do with modern GC algorithms.
6:02:33
loke
jmercouris: By the time the GC frees the unused memory, that memory dones not consist of CONS cells any more. It's just a blob of memory that no one cares about :_)
6:02:48
aeth
I heard before in this channel that SBCL doesn't have a good GC and that CCL's GC is better.
6:03:16
loke
aeth: There are certainly problems with the SBCL GC. It could be a lot better. But it's not terrible.
6:04:27
loke
aeth: well, of example, there are cases where it needs to fill a structure with zeroes instead of just dropping the reference in order for the GC not to mistake random values with a pointer. It was disucced on the SBCL devel mailing list last week in fact.
6:09:01
jmercouris
beach: here's where I was asking that question: "basically on a system level here, when we run a GC in lisp, are we actually freeing the memory, or is it just now available within our loaded lisp image as "free" memory?"
6:10:01
beach
jmercouris: But most GC algorithms, just like malloc() and free() do not give memory back to the operating system.
6:15:00
fouric
"By the time the GC frees the unused memory, that memory dones not consist of CONS cells any more. It's just a blob of memory that no one cares about"
6:15:04
jmercouris
aeth: Presumably always one would know more than they do because knowledge always precedes action
6:15:34
fouric
...or do we not consider them "cons cells" because for our intents and purposes they aren't?
6:20:09
beach
fouric: Because all information about the exact contents of that memory has been lost. At some level, there are still Common Lisp objects there, of course, but as far as the system knows, it is just random garbage.
6:24:22
fouric
...and one more question since we're talking about GC anyway: can SBCL's garbage collector run concurrently with running programs?
6:24:42
fouric
i poked around in the manual, which says that it's a "generational" garbage collector
6:25:09
fouric
...but i haven't been able to determine if that says anything about its ability to run in parallel with the program it is managing
6:26:52
krwq
soes anyone know how to write strings to in-memry-stream with flexi-streams? I've tried with-output-to-sequence + setf flexi-stream-external-format and also wrapping that stream with another flexi stream with :external-format set
6:28:41
fouric
(...would you happen to have any suggested resources for reading up on garbage collection and memory management?)
6:29:51
krwq
actually bummer - it worked correctly but I misread the error (it was on file-length call)
6:30:14
rme
https://ccl.clozure.com/docs/ccl.html#understanding-and-configuring-the-garbage-collector might be worth a look, too.
6:32:15
aeth
Looks like I just learned that the magic words that a game would need are "real-time concurrent garbage collection"
6:34:36
rme
sometimes use the phrase "stop the world" to describe collectors which are sort of the opposite (and which are more tractable to implement and thus more common)
6:40:12
fouric
ACTION is not very good at search-engine bingo, which is why he asks for recommendations from humans whenever possible
7:52:11
jmercouris
what's the best way to create a config file that can be loaded by a standalone lisp program?
7:52:33
jmercouris
I've forked "site-generator" and I want to be able to pass it a series of commands to execute in the form of a config file
7:53:00
jmercouris
e.g. if I launch "site-generator" in a dir with a config file, it should pick up that config file
7:53:26
jmercouris
I guess the real question I am asking is, how can my program know from where it was launched in order to load the appropriate lisp file?
7:58:41
Shinmera
If it's a source file, the usual trick is #.(make-pathname :name NIL :type NIL :defaults (or *compile-file-pathname* *load-pathname* (error "Welp"))
8:31:09
jackdaniel
what's more, *default-pathname-defaults* and current working directory may be inconsistent (because one or another may be adjusted at runtime independently)
8:46:48
p_l
at least it's rare these days to write lisp for OS that doesn't have the concept of CWD ;)
10:20:04
hjudt
is there an easy way to read a whole text file into a string instead of reading it line by line and concatenating?