freenode/#lisp - IRC Chatlog
Search
20:31:53
minion
emaczen, memo from jasom: you don't need to know the size of anything for searching a B-Tree; you only need to know the position of the child nodes.
20:35:23
phoe
emaczen: for very implementation-specific stuff, implementations have their own channels.
20:38:45
Bike
sizeof is implementation specific in C (which is why it exists), and C has a lot more restrictions on memory than lisp does
20:40:31
emaczen
Bike: Is it completely unreasonable for language designers to enforce memory restrictions in their standards?
20:42:57
Bike
it's not completely unreasonable, but imposing perfect restrictions of "this object takes up N bytes" wouldn't be very reasonable either, for almost all applications.
20:44:28
Bike
first off it's usually pointless, and secondly the language would be obsolete as soon as a new system with differently aligned loads or something appears.
20:45:08
Shinmera
Plus forcing memory constraints eliminates a good class of potential optimisations an implementation could do.
20:46:04
Bike
like what, "a word is some implementation defined number of bytes, and a cons is two words"?
20:46:55
emaczen
Bike: nvm, I'm just going to experiment, call (room) use :space 3 and see how much memory I am using up
20:48:00
Bike
reasons to need an exact memory layout include understanding resource usage of a program and communicating with systems that are that exact, and... that's all i got off the top of my head
21:07:18
jasom
emaczen: also for a database like b-tree usually you store your index separately from your data, so your values are just offsets into the data file. In any event, you should create your own fixed-sized layout for your tree nodes, since the whole point of a B-Tree is to use disk-friendly node sizes
21:08:19
jasom
emaczen: if the underlying file system uses fixed logical block sizes, that makes sense, since logical blocks will be contiguous in LBA space (which usually means fast reads)
21:16:43
pjb
emaczen: In general the O(.) in space of each object is not implementation specific, but the constant factors are.
22:22:03
pillton
tjb Bike: I'm not sure I follow. Jasom's interpretation of that part the CLHS makes it possible for a compiler to inline a function or use a different entry point to the function.
22:25:11
pillton
I'm fine with performing optimizations on one function given an analysis of the operators it calls.
22:26:31
jasom
pillton: it's a compromise betweeb efficiency and dynamicsm; by default require people to recompile a single file (i.e. C-c C-k in slime), which is pretty quick when making changes while developing, but give people a way to make functions freely redfinable (via the declare)
22:28:07
jasom
recompiling a single file has been a typical way of making changes going back to the 70s at least, so they don't want to break that, but they do want to leave room for the compiler to optimize.
22:29:35
Bike
pillton: you can't do any analysis of the operators it calls if they can be redefined arbitrarily
22:36:20
jasom
pillton: the compiler will also do dead code elimination without being requested to... in general most optimizations are not explicitly requested by the user
22:39:33
pjb
jasom: I think it's more linked to the way separate compilation generates independently linkable modules. So internal references are resolved by the compiler (by direct jumps or inlining), while external references go thru the linker symbolic tables, the equivalent of lisp symbols.
22:40:16
jasom
pjb: I don't think so since traditional lisp systems didn't work that way, and function definitions can be moved around in memory
22:40:22
pjb
Bike: in any case, analysis requires global knowledge of the program: it could as well redefine all the functions in a file!
22:41:12
pjb
jasom: were there files on lisp machines? just kidding, but I mean unix may have strongly influenced this part of the design of the language.
22:42:05
pjb
As soon as you have a linker, you have this distinction between internal references compiled in directly, and the references across modules, resolved by the linker.
22:42:47
Bike
if it redefines all the functions in the compilation unit, any optimizations in the previous versions are gone with the functions, so no big
22:42:51
jasom
pjb: I maintain that it is unrelated to unix style linking, but am willing to be proven wrong. There should be notes somwhere on why this was decided upon.
22:45:36
pillton
I assumed you could only eliminate code in that example according to an ftype declaration present in the environment.
22:47:34
Bike
i guess an explicit "this form is wild" annotation could be nice, but in practice it seems okay
22:51:43
Bike
i think that might technically allow dead code elimination of the kind you imply. dunno
22:59:26
jasom
I just always use C-c C-k, but you can use notinline as well. Also no sane implementation would do these optimizations when you set (debug 3) (speed 0), so that's another option
3:06:22
didi
You know... I miss having a COND clause that I could use the result of `test-form', e.g. (cond ((test-form) => (use test-form-result)))
3:19:34
stylewarning
At which people were amazed that a few carefully chosen optimizations made code 50x faster without sacrificing code quality.
3:20:34
stylewarning
Mostly techniques in Common Lisp for identifying areas ripe for optimization, and how to do that
3:28:32
stylewarning
The answer is "probably yes". Working out some details now since I came back from vacation
3:34:30
stylewarning
Yes of course. I'd argue things are a little more nuanced than what he presented (in my opinion, IIRC)
3:38:58
stylewarning
For instance, consider extending his pixel problem to be an array of structs of RGB values
3:40:39
stylewarning
Idiomatic Lisp would be a simple array of structs. You could write special accessors into a specialized array of floats that emulates a flat array of structs. You could even construct a struct when you pull the array out.
3:41:16
stylewarning
You could even remember a pointer to the array the struct came out of so you could setf the struct to transparently setf the array
3:42:34
stylewarning
I would guess that even with all of that involvement, none of it will likely beat some SIMD craziness if a flat array of structs in C.
3:43:26
stylewarning
(One of my long term goals is to think about CL extensions to give you some of that additional power.)
3:45:33
stylewarning
(Franz did some stuff like this and has a YouTube presentation about it. https://youtu.be/S7nEZ3TuFpA Not quite what I want. I want primitives for pinning objects and getting pointers basically.)
3:59:51
mfiano
I would not say that aeth. We've told you time and again, most of a game is not even on the CPU. SIMD is nice, but unless you are doing some crazy physics simulations, a typical game will be using a very small percentage of your processing power.
4:04:42
aeth
mfiano: And I've said repeatedly that that common wisdom only applies to graphics-heavy, AAA games that no one here is making and that simulation-heavy CPU games (not even necessarily physics simulations) can still definitely live on the CPU.
4:05:51
mfiano
Which puts you in the domain of your statement, not the lispgames community. You are the only one I know of that spends years optimizing low level game math rather than making anything remotely like a game.
4:06:12
aeth
RTSes and building games (especially the subgenre of building games with stockpiles) can still fill the CPU.
4:08:13
aeth
Bike: the problem with building games is you can have hundreds or thousands of units doing things at once, on the CPU
4:10:48
Bike
stylewarning: anyway, i'm probably going to try to add arrays of structs to clasp at some point. we need it for chemistry stuff.
4:11:57
stylewarning
The semantics of that reference, it's out-of-line modification, storage, identification on the heap
4:13:37
aeth
stylewarning: What I've been doing is retrieving and setting multiple values in 2D arrays, and covering up that messiness with macros.
4:16:23
stylewarning
Aeth, the most reasonable way I've found to hack it is to just internally allocate as a struct of arrays
4:23:39
stylewarning
Just a macro DEFSTRUCT-ARRAY that's like DEFSTRUCT but the accessor takes an integer N
4:26:05
Bike
yeah, maybe something i should prioritize... dealing with gc might be annoying, but so it goes
4:34:46
vtomole
So anytime a variable is created, that symbol is stored in the environment along with it's value? Are function names also "variables"?
4:47:58
Bike
if you do (second (read-from-string "(defparameter a 2)")), you'll get A, even though the defparameter is not actually executed
4:53:36
vtomole
So read creates the symbols. If I do (Defun square (x) (* x x)). Is square a variable or a symbol? What is the difference?
4:57:20
vtomole
But "square" and "a" are both symbols, it's just that one points to a variable and another points to a lambda expression. Is that the correct type of thinking?
5:00:22
beach
vtomole: Check the glossary entry for "lambda expression" in the Common Lisp HyperSpec.
5:01:26
White_Flame
it's the pairing of a symbol and a function object, in the case of a named function
5:02:41
beach
function n. 1. an object representing code, which can be called with zero or more arguments, and which produces zero or more values. 2. an object of type function.
5:05:22
White_Flame
and it's technically not "the function SQUARE", but "the function named by SQUARE"
5:33:56
jmercouris
hello everyone, let's say given the string "hcpr", and the other string "helicopter" what kind of mechanism could I use in lisp to identify that the sequence of characters "hcpr" appear in order in the string "helicopter"?
5:34:25
jmercouris
i was thinking about using regex something like h*c*p*r where * represents one or more arbitrary chars
5:37:18
jmercouris
ppcre seems really good for regex, but this cl-string-match also has some cool features i could just drop in for more sophisticated matching
6:11:08
jmercouris
so basically what i wanted to do was iterate char by char and make a string appending the regex to do matching
6:12:20
beach
When the reader sees #\ it creates such an object, and when the printer sees such an object, it prints #\.
6:13:19
jmercouris
I'm thinking of what the best way to build up the string is without doing a ton of concactenation
6:14:01
beach
You can build a string either by using an adjustable string and adding characters to the end, or you can use a string stream.
6:14:30
beach
If you use make-array with a fill pointer and with element-type 'character, you get such a string.
6:47:36
jmercouris
so I have written the following code to try to do re matching: https://pastebin.com/0xFRmcRP
6:47:48
jmercouris
unfortunately, I am getting "#<string-output stream 00000001091361e0> is not of type SEQUENCE."
6:50:27
jmercouris
i've already read it a few times, i can't seem to understand the documentation style yet
6:51:02
beach
with-output-to-string returns the resulting string. That's what you need to use for the match.
6:54:01
beach
With DOLIST, you first have to convert the string to a list of characters, which involves consiing.
6:55:32
beach
It may not matter in your case, of course. But it is also more idiomatic to do it that way.
6:56:31
jmercouris
i come from a python background where there are very clear "pythonic" guidelines, and since there is nothing like pep8 for lisp, it has left me a bit lacking
6:58:00
pjb
It's not as formally documented as in the PEP. In lisp, a lot is encoded into the editors and IDEs.
6:58:21
jmercouris
that's what I was saying, like that's just one guys opinion, i mean a very respected guy, but it's not like an "official" organization
6:58:57
pjb
jmercouris: there's no official organization, until you create a startup named "Official", and then you will only be able to impose your rules to your employees.
6:59:22
jmercouris
well, even if it was something like ansi publishing a list of guidelines, i'd consider that more official
6:59:57
pjb
jmercouris: the assumption with lisp is that lisp programmers are intelligent. They're able to not shoot themselves in their foot, and they're free to use their own rules.
7:01:03
jmercouris
all valid points, I'm just saying it would be nice if there was a "standard set of guidelines" or however the semantically correct way of saying that is, to guide lisp programmers to create code that is consistent
7:01:10
beach
jmercouris: A standard for a programming language is an official document that determines exactly what an implementation must or is allowed to do in order to call it an implementation of that language.
7:01:34
jmercouris
in this sense, there exists a standard for lisp, but i'm looking for something like pep8, whatever you'd call that
7:02:16
beach
jmercouris: No guideline would tell you not to convert a vector to a list before iterating of the elements. That's just standard programmer knowledge.
7:03:08
pjb
jmercouris: there's the CDR as document repostory. https://common-lisp.net/project/cdr/ You can write PEP-like documents and publish them there.
7:03:53
beach
jmercouris: The LUV slides that I gave you a URL to is as close to an ANSI guide you can get, given that Kent Pitman is one of the main authors of the standard.
7:06:00
beach
jmercouris: Well, you are out of luck, because Common Lisp is a language with an independent published standard, and there is no official organization deciding what you should or should not do with it. The advantage of that is, of course, that there is no organization that can arbitrarily decide to change what it means for a program to be valid Common Lisp by arbitrarily changing the language definition.
7:07:39
beach
jmercouris: And, as I often say in my talks to industry people, a project leader to decides to use a programming language without an independent standard, i.e. a language that can evolve arbitrarily at the whim of some official organization, should be fired.
7:07:49
jmercouris
beach: I'm not trying to start a war :D I'm just saying a little more guidance would be nice, most likely my opinion will change as I become more experienced with common lisp, I've only been seriously working with it for about a month
7:08:47
jmercouris
beach: I can definitely see the advantages of a completely free language, it's like an "open source" language in a way
7:08:59
beach
jmercouris: You are getting hints here. But the one about converting a vector to a list before iterating over the elements is not a guideline item. It is common sense, and will be obvious to you when you know more about how the language works.
7:09:05
jmercouris
not in a literal open-source sense, but in the fact that it gives you some power as the user
7:09:58
beach
jmercouris: I don't even know what an "open-source language" could possibly mean. One where each person is free to change its definition at any point in time?
7:11:32
beach
Not to talk about the proliferation of IRC channels #lisp-according-to-bob, #lisp-according-to-bill. There would be a single person in each channel.
7:12:12
beach
jmercouris: We are very lucky here in #lisp in that there is a well-defined basis for what we are discussing.
7:15:11
jack_rabbit
Common lisp, in some ways, was constructed in order to solve the problems caused by exactly what you describe: many different and incompatible lisps.
7:15:15
beach
jmercouris: The current trend is to confuse "programming language" and "programming system". If you add to that a single organization (or worse, a single person) with the power of changing the language/system at a whim, you get what ought to be a no-no for any serious programming project.
7:16:44
jmercouris
beach: I'm saying that if the language definition is not controlled by anybody, you are free therefore to adopt it or not adopt it, and you won't have to bend to the will of some random corporation
7:16:52
beach
jmercouris: So, unless you are just doing hobby programming that you don't mind throwing away at regular intervals as a result of the decisions of some "official organization", I strongly suggest you stay away from such languages/systems, and go for a language with an independent standard, and multiple suppliers of implementations.
7:17:11
jmercouris
it's true that there are many possible derivatives that will emerge, but at least a couple of them are bound to be popular enough to have a community to support them
7:17:58
beach
jmercouris: You are contradicting yourself. On the one hand, you want everyone to be able to change the language definition. On the other hand, you want the "official guidelines".
7:18:21
jmercouris
beach: I would agree with that for extremely long term projects, or mission critical things, I think it is okay sometimes to use controlled languages when you are locked in. Let's say you are on windows, it would be very advantageous to use C# despite all of the problems you described
7:19:01
jmercouris
beach: i'm not contradicting myself, in the python organization, it is an official org, but anyone can join and change the definition through the submission of pep guidelines
7:19:02
beach
jmercouris: Plus, it is not forbidden to change the Common Lisp language, even though it has an independent standard. You just can't claim that the result is a conforming implementation. I see no restrictions here.
7:20:20
phoe
Lisp is a very different language compared to Python because a) you don't need to submit any pep guidelines to *drastically* change how the language works, b) there is a standard from 1994 that describes what an unmodified language should look like - and that has given Lisp an insane lot of stability since then.
7:21:33
jack_rabbit
It is amazing to find libraries from decades ago that still load fine today. I don't see that in any other language I've used. Even ones with solid standards.
7:21:39
beach
jmercouris: The existence of an independent standard is not a constraint. It is the other way around. I mean, if you don't like it, just pretend it doesn't exist and do whatever the Python people do. But if you want to have a precise definition of the language that you can be sure will not be altered, then accept the independent standard.
7:22:30
phoe
on the other hand that standard from 1994 gives you enough power to completely change how the language reads, expands, compiles, runs
7:24:16
beach
jmercouris: One that is published by an organization that is not the supplier of an implementation, or at least not of the only permitted implementation. It is also required that this standard be given a unique document number, so that it can be referred to uniquely.
7:24:52
Shinmera
phoe: Considering CLtL1 was published in 1984 and a good bunch of programs were written against that and still work, it's actually even longer.
7:24:55
jmercouris
I don't see what the issue therefore is with this SOMEBODY being an organization that publishes guidelines
7:25:43
Shinmera
jmercouris: Because a standard without implementations following them is pointless. See CDR.
7:26:35
phoe
3) some people have thrown ideas of how Lisp *could* look like, but these have not been widely adopted
7:28:07
beach
jmercouris: The ANSI standard is an excellent basis. Any additional functionality can be (and is) handled by additional libraries.
7:28:34
beach
jmercouris: Because Common Lisp has Common Lisp macros, libraries can also supply new syntax, which is impossible in most other languages.
7:29:43
phoe
but what beach said, you don't need to change the standard to modify the language - you don't publish new standards, you publish new libs, which is a drastic difference compared elsewhere. Lisp isn't changed, Lisp is grown.
7:29:45
jmercouris
I mean, I get that, I just don't see what the issue would be there was a comittee responsible for evolving the language over time
7:30:24
Shinmera
They paid a lot of money to get the standard made, in hopes that it'll save them from future monetary losses.
7:30:54
phoe
I guess, Lisp is still alive and kicking, both in the commercial and non-commercial world
7:31:56
beach
jmercouris: Many people here are very happy that there is not an arbitrary committee, company, or organization deciding to make their programs non-conforming at a whim.
7:33:11
jmercouris
basically the secret sauce is the defmacro, because no need to invent new forms or syntax that are adopted by an implementation, you can just make a lib that supports it
7:33:26
jmercouris
this also allows you to change how you use the language, and allow you to use code from as far back into the past as you like
7:34:04
Shinmera
There are some things that genuinely need implementation changes to do in a way that's not horrendous, and you'll find people lamenting those things in here if you stick around long enough.
7:34:36
jmercouris
phoe: interesting, i'll have to read about those, for now, i'm just struggling to learn the basics
7:34:49
phoe
so you can do crazy stuff like (with-c-syntax:with-c-syntax () #{ format (t, "Hello World!"); }#)
7:34:56
phoe
or (with-c-syntax:with-c-syntax () #{ int i, sum = 0; for (i = 0; i <= 100; ++ i ) sum += i; return sum; }#)
7:41:26
beach
jmercouris: "beach" is just a literal translation into English of "Strand" (the `h' is added for kicks).
7:44:57
phoe
this is McCLIM that's been used to recreate environment like the ones of ye olde Lisp Machines
7:45:18
jmercouris
beach: yeah, i saw that link on reddit, you'll see i also commented with my project i'm working on
7:49:12
phoe
jmercouris: it's a part of programmer enlightenment. if your ego prevents you from acknowledging how much you don't know, then it'll be a very successful ego indeed
7:49:46
jmercouris
phoe: nah, I'm 100% joking, I've been programming ~10 years now, the computer has taught me how dumb I am :P
7:57:31
beach
jmercouris: In case you are interested in McCLIM, some of us hang out in the #clim channel.
8:03:54
Shinmera
hjudt: I've made some changes to the tutorial to address the concerns you had. Thanks again for the feedback!