freenode/lisp - IRC Chatlog
Search
8:03:26
no-defun-allowed
Dynamic dispatch is a defining feature of object-oriented programming, and I suppose it kinda exists with typeclasses in some functional languages.
8:04:25
aeth
charlie770: most will have dynamic or static dispatch. Iirc, C++ is an example of the static kind, where the information is available at compile time. A quick search shows that it does have some dynamic dispatch, too, but it's very different from CLOS's because CLOS has multiple dispatch
8:05:52
aeth
Just one method will do, I guess. (defmethod foobar ((obj1 string) (obj2 number)) (values obj1 obj2))
8:06:34
aeth
Many hide the first argument since there's always going to be one and only one like that in a method
8:07:12
aeth
The typical example here is a collision method, and Wikipedia has it. https://en.wikipedia.org/wiki/Multiple_dispatch#Common_Lisp
8:08:24
aeth
Notice that 2 classes and 2 arguments means 4 methods... so there can be a lot of combinations if you really wanted to take advantage of multiple dispatch.
8:09:18
aeth
This chapter from PCL goes into detail... http://www.gigamonkeys.com/book/object-reorientation-generic-functions.html
8:11:33
aeth
Common Lisp rarely is the only language with a feature (maybe just the Common Lisp condition system?), but it has an interesting combination of features.
8:12:00
no-defun-allowed
Dylan has a condition system, but it's basically the Common Lisp condition system.
8:12:38
charlie770
aeth: The problem with classes, like macros is they that they can be used everywhere. You can wrap them around anything and still have a working program. People use oop as a silver bullet for every problem. They just don’t know what the problem is. Makes you wonder if there’s a method to his madness😉. If I wanted to understand oop, I think I need to know when not to use it.
8:13:36
aeth
CL just gives you a bunch of different equally-powerful tools to solve a problem and lets you decide which ones to use
8:14:08
phoe
that's the case with e.g. Java which has an "everything is a class or its subpart" approach
8:14:42
phoe
CLOS is optional do indulge in when you program in CL, since CL is a multiparadigm language and doesn't limit the programmer in choices like Java does
8:14:47
aeth
As I said a while ago, you can simultaneously entirely avoid CLOS in your code, and not even notice if other people's code that you're using is written via CLOS... mainly due to the uniform syntax and the focus on generic functions (verbs, not nouns)
8:15:17
aeth
Lots of languages give you the first option, but then if you use someone's library, you're going to have to deal with foo.bar()s
8:16:27
aeth
Okay, you'll probably notice MAKE-INSTANCE, but I like wrapping (MAKE-INSTANCE 'FOO ...) with a MAKE-FOO function, personally.
8:17:35
no-defun-allowed
Multiple inheritance and packages used to (approximately) enforce encapsulation instead of class relations.
8:18:49
aeth
With CLOS you have methods living with generic functions instead of with the classes... and the uniform syntax (generic functions are just functions) rather than the typical dot notation of method calls (which is infix and encourages noun-based APIs that focus on the object)
8:18:52
no-defun-allowed
I'm not sure if I should have expected you to know or not, given that you started this discussion with "I dislike object-oriented-programming!"
8:19:40
no-defun-allowed
Encapsulation is how you stop the external world from modifying the stuff that you don't want it to modify.
8:20:10
cl-arthur
charlie770: Would recommend you spend more time with it to the point where it's understandable and known if your main irk is confusion
8:20:17
aeth
charlie770: Encapsulation is often seen as an essential OOP feature, especially by C++/Java programmers, but in many languages it's just by convention. Really, I don't see it as an essential part of OOP because everyone does encapsulation to some extent. (At least, if it's some form of structured programming.)
8:21:44
aeth
Often, languages do just have a "private" keyword that they put in front of their methods and/or slots
8:22:43
charlie770
cl-arthur: I try to learn it. Then again, after a while, I think "I could probably do all this with macros"
8:22:44
aeth
CLOS is more in the encapsulation-by-convention camp (naming conventions, to be specific), like Python. Iirc, Python uses __foo (or is it __foo__?) while CL uses %foo
8:23:05
aeth
Arguably, the only true way to encapsulate in CL is with a closure (which is an entirely different kind of thing than OOP)
8:23:50
no-defun-allowed
You also have packages, and an agreement with the client that they can't use internal symbols and/or SLOT-VALUE.
8:24:13
aeth
no-defun-allowed: yes, but packages are a weak form of encapsulation because you can just do foo::bar and access the private thing even if foo:bar doesn't work
8:24:52
aeth
charlie770: you could implement OOP with closures... but CLOS (probably) isn't implemented via closures in any implementation
8:25:07
no-defun-allowed
aeth: Yes, then you write in the agreement that the client loses their keyboard and monitor if they do that.
8:37:13
aeth
What kind of application? There are some games, e.g. https://borodust.org/projects/trivial-gamekit/
8:37:33
phoe
there exists https://github.com/atlas-engineer/nyxt whose sources I have almost never read so I cannot say anything about the quality of the code there
8:38:28
aeth
The most popular application might be pgloader... which is apparently about migrating to PostgreSQL. https://github.com/dimitri/pgloader/
9:17:21
beach
Wow, this discussion reminds me of a student I once had, who moved to Bordeaux to avoid Ada, which was taught at the university of his home town. But after I questioned him, he admitted to knowing nothing about Ada at all. Disliking object-oriented programming while not knowing about encapsulation, polymorphism, or dynamic dispatch seems very similar to me.
9:18:11
beach
charlie770: I think you need to work on your basic programming skills and basic knowledge about software development tools before you can hope to start implementing an interpreter or a compiler.
9:18:21
phoe
it's even easier if you dislike the lack of knowledge itself and then project it onto whatever
9:20:53
charlie770
beach: I don't understand oop. Maybe that's why I dislike it. Maybe also because I could get away with it(using macros).
9:21:13
phoe
the best thing is to acknowledge it and move on with life while trying to fix the ignorance to the best of one's ability, no point in dwelling on it too much
9:22:45
charlie770
beach: do you think learning object-oriented-programming will make me a better programmer?
9:23:00
beach
charlie770: If you dislike things just because you don't understand them, you will be very limited in what you can do in the future.
9:23:08
dim
yeah pgloader can be used to move from Postgres to Postgres, the main use case is to have a alternative to ALTER TABLE foo ALTER COLUMN bar TYPE bigint USING processing_function(bar); but well we didn't solve all of the concurrency issues at the moment
9:23:31
beach
charlie770: Because you will then have an informed opinion about it, and you can make choices based on knowing what you are talking about.
9:23:47
beach
charlie770: That might be to avoid object-oriented programming, but at least you then know why.
9:25:17
beach
charlie770: I don't use traditional object-oriented programming, where encapsulation and abstraction go together. I much prefer CLOS-style programming, whatever you call it, where encapsulation is handled by the package system and the abstraction is done with generic functions.
9:25:41
beach
charlie770: But then, I understand both styles, and I have made my decision based on that knowledge.
9:26:22
dim
also when all you have is object oriented as the only architecture tool, I tend to dislike those programming languages (Java is the main example I can think of)
9:27:43
beach
dim: Right. For example, in order to create an anonymous function, some languages require (or used to require) that you actually create a class with a single method in it.
9:28:25
dim
beach: same with closures being only available within a class construct in Python, I guess?
9:28:38
no-defun-allowed
(And the inspirations for the former, Erlang and Smalltalk, to some extent, allow one to produce closures.)
9:29:47
beach
I also recently realized that, in some object-oriented languages, you defeat encapsulation entirely when you make a subclass. Then it is easy to, by accident, violate the original protocol.
9:30:07
dim
a friend of mine loved closures when he taught himself Clojure (the lisp inspired language in the JVM) but always though he wasn't smart enough for OOP, I showed him a class in Python is the same thing as a closure in Clojure and he was like “wow”, I hope he know realises he's smart enough ;-)
9:31:01
no-defun-allowed
charlie770: Message passing is what most people think of when they think of object-oriented programming, where objects collaborate by sending "messages" to each other.
9:34:21
no-defun-allowed
That's not quite the same as objects calling methods on each other, as messages can also be passed around as objects, allowing one to do a few things that would be tricky otherwise, such as selectively passing on messages to another object.
10:15:22
TMA
speaking of message-passing and OOP, I want to point out the power of reification. reification is an enabler for neat things. in the same vein is reification of computation environments as invented by beach here -- enabler for nifty things
10:44:35
TMA
in a sense it enables the programmer to do something that would otherwise be restricted to the compiler/system
14:56:08
edgar-rft
SICP teaches programming in general using Scheme examples, but it's not necessarily only for Scheme or Lisp
14:57:33
jackdaniel
while they belong loosely to the same family of programming languages, they are very different (both design- and community- wise)
14:57:44
edgar-rft
clockboi: no worries, there's lots of historical quirks in Lisp, don't be afraid to ask :-)
15:02:15
phoe
if you want to, you can do all of SICP in Common Lisp; the most important difference you will encounter is FUNCALL which does not exist in Scheme but is necessary in Common Lisp
15:12:46
beach
clockboi: There are books specifically for Common Lisp, in case you already know the basics of programming in general.
15:20:25
p_l
clockboi: also, consider that the amount of scheme you're supposed to know to finish SICP is quite small
15:39:20
docl
I just did SICP 1.1 in CL, one thing I noticed was define doesn't exist, instead you have to do defun for functions. and the paren structure for that is slightly different.
15:40:15
beach
Also, using DEFUN inside a function means something different from using DEFINE to define a function inside another one in Scheme.
17:21:31
gothnbass
Tracking down a bug relating to `html-template:fill-and-print-template`. Does anybody know of a non-obvious dependency on `pwd`? It works just fine if I'm running from the parent directory of `/templates`, but breaks with a `format` error otherwise.
17:21:32
dim
I like PAIP intro chapter about Common Lisp for people who already know how to write some code
17:31:15
gothnbass
Never mind; I found it. I'm an idiot, and I hard-coded that path into TMPL_INCLUDE statements in the templates.