freenode/#lisp - IRC Chatlog
Search
2:23:36
verisimilitude
An issue with Lisp is that it can be odd moving to a new language. I've been learning Ada for a while now and it's not always easy to plan a program out in the detail required, down to the types, and I'm inclined to believe being so accustomed to Common Lisp is part of the reason.
2:27:05
aeth
verisimilitude: give nearly everything its own type and if you change what its type is later on, you just change one line instead of many
2:29:22
aeth
Also, pick a domain that fits the language, if you're just learning it on your own. CL is much better than most languages at the sort of text generation that I was talking about earlier with my HTML example. But if you're doing something that is mostly double floats or something, then that solves most of the type issues in a static language.
2:29:23
verisimilitude
In particular, I've strangled myself with the flexibility of Common Lisp for one program; it works in Common Lisp and I wanted to rewrite it in Ada, yet I find the idea lacks the structure necessary, so I'm going to need to rewrite the Common Lisp before I can get a good idea of how to write it in Ada.
2:30:04
aeth
Oh, and generally, try to avoid linked lists and trees and graphs etc. in such languages. So much harder. Not sure about the details of Ada, though
2:30:41
verisimilitude
Ada 2012 has standard doubly-linked lists, trees, sets, and other such things in its container library.
2:31:20
verisimilitude
Where one may use a hash-table in CL, one can usually use a simple array in Ada, though.
2:31:36
minion
The URL https://gitlab.common-lisp.net/users/sign_in?secret=d20b6b3c will be valid until 02:45 UTC.
2:32:42
aeth
verisimilitude: Yes, but it's not GCed (by default) afaik, which makes such allocation-heavy stuff way harder imo.
2:33:07
aeth
(Well, allocation-heavy in that sense, vs. an adjustable vector that just keeps allocating to the end but keeps it as one thing)
2:33:19
verisimilitude
It can use GC, but it doesn't. There's not much dynamic allocation, actually, as most things can be allocated on the stack.
2:34:37
verisimilitude
Another nicety of Ada are the pragmas which permit specifying certain things never occur along with banning implementation-specific functionality, etc.
2:48:40
aeth
verisimilitude: Have you ever tried (declare (dynamic-extent foo)) in CL? You can get surprisingly far in SBCL.
2:50:38
verisimilitude
I've written some macros that generate such declarations, but I don't tend to use it manually.
2:51:21
verisimilitude
I should probably go through some of my programs and start adding declarations where they can't cause issues.
2:59:35
sukaeto
aeth: the thing about HTML templating engines is that they're not designed for programmers, they're designed for UX/design people
3:02:45
aeth
sukaeto: The thing about representing something like HTML in s-expressions is that once you get that initial representation that goes from a direct mapping to a string (with all of the relevant escaping) you can do whatever you want with it as prior steps in a process. For instance, I'm not going to write my HTML documents directly in the style of the Gitlab snippit I linked to earlier.
3:03:00
aeth
I'm going to parse Markdown into s-expressions, and then transform them into those HTML s-expressions.
3:03:50
aeth
sukaeto: You're allowed a level of polish in tooling that most people (even most people in the CL community) never get to. CL is really a language for writing declarative languages (which is also probably why SQL-in-s-expressions doesn't really seem like it needs many more layers)
5:13:20
pjb
In lesser languages such as C or Ada, managing types is easy: just use pointers to structures for everything.
5:36:32
aeth
Well, C and C++ and similar languages add an extra level of complexity in API choice that you don't see in CL. Basically, pass by reference vs value. i.e. (at least C-style pass by value) your choice is a pointer vs. copying-everything.
5:42:10
pjb
generally, it's optional. Pascal has it, with var parameters. Modula-2 with INOUT parameters, etc.
5:42:15
aeth
beach: No, what I meant is that for every function you make, you have this mental overhead of whether or not to do foo or &foo and there's probably even a line in object size where it's more efficient to do one or the other, and it's a lot of thinking
5:47:54
aeth
It gets pretty bad in C++ more than C because you want to do OOP like everyone else, so you're doing a lot of Foo *foo that you call with &foo (except when you don't) and that means that in a lot of places you're having to do (*foo)[whatever] or (*foo)(whatever) or whatever << (*foo) and it quickly turns into a mess
5:49:06
aeth
At least compilers are pretty good at telling you (in the first of 200 lines, which you then have to scroll up to read) when you should have used foo instead of &foo to call the function that wants Foo *foo.
5:54:20
aeth
(I'm not sure about Ada and if it addresses this. I wouldn't be surprised if Pascal is similar.)
6:00:51
beach
In metamodular.com/modular-c.pdf I recommend programming with pointers only and using something like the Boehm-Weiser automatic memory manager. Uniform reference semantics is the only sane way of programming.
6:02:43
aeth
I wonder if there's a way to get something like CL semantics... basically, pointers except when it fits in a machine word? I guess not that simple.
6:04:26
pjb
aeth: it wouldn't be safe C. It's better to write pure C code, (C code that is defined by the standard).
6:05:44
aeth
pjb: Wouldn't it be even better to compile a C ABI-compatible binary, but with much Lispier semantics where possible? Technically, only the interop would matter.
6:15:02
aeth
pjb: I don't think that counts because of the runtime. So I guess this is necessarily off-topic except for the obvious choice of the compiler language
6:15:51
aeth
pjb: If such a language existed, you could potentially rewrite ECL in it, though. Then ECL wouldn't need a C compiler, too, since it could just do ECL->this-hypothetical-language->ECL
6:16:34
pjb
aeth: the point is that when you adopt a stereotyped programming style, you necessarily use a run-time.
7:40:22
verisimilitude
With Ada, it's not defined whether copying or referencing occurs with in out parameters, sans some special cases such as limited objects.
7:42:14
beach
The fact that SBCL no longer complains when there is a DEFMETHOD but no associated DEFGENERIC does not suit me at all. My worsening dyslexia results in numerous spelling errors that are not caught.
8:00:19
saturn2
beach: (shadow 'defmethod) (defmacro defmethod (name &rest rest) `(if (typep (symbol-function ',name) 'generic-function) (cl:defmethod ,name ,@rest) (error "~A is not a generic function" ',name)))
8:15:11
Shinmera
ACTION wonders if a general utility to check all symbols for a close Levenshtein distance would be useful
8:20:51
pjb
Here I have a tool to check for "duplicate" symbols, ie. symbols with the same name interned in different packages. https://github.com/informatimago/lisp/blob/master/tools/symbol.lisp#L133
11:50:16
Shinmera
no-defun-allowed: Shoulda watched my streams ;) https://github.com/Shinmera/flow/blob/master/graph.lisp#L131
12:40:43
jonatack
Just realised how good the logs are for this channel. Thank you to the kind people who maintain them!