2 ms·
I am a dynamic language fan but I would actually disagree. I prefer the Julia programming language and there I see a lot of benefits from working with types. I
by jernfrost 9y ago
I am a dynamic language fan but I would actually disagree. I prefer the Julia programming language and there I see a lot of benefits from working with types.
I've always had a fascination for LISP, but every time I've tried using it after learning Julia, I've found the lack of type focus limiting and in the way.
Types makes it easier to build abstractions. I can write several functions which look the same but act different depending on the type of the arguments.
The way in which types get in your way in statically typed languages is pretty much gone in Julia as you can so easily and fluidly deal with types as they are just objects at runtime which you can pass around freely.
Julia already has most of the things I like about LISP: everything is an expression, and it is really easy to write macros.
- kbp 9y ago> I've always had a fascination for LISP, but every time I've tried using it after learning Julia, I've found the lack of type focus limiting and in the way. > Types makes it easier to build abstractions. I can write several functions which look the same but act different depending on the type of the arguments. You can do this in Lisp: CL-USER> (defclass my-class () ()) #<STANDARD-CLASS COMMON-LISP-USER::MY-CLASS> CL-USER> (defmethod identify ((mc my-class)) "This is my class") #<STANDARD-METHOD COMMON-LISP-USER::IDENTIFY (MY-CLASS) {1005BDFFB3}> CL-USER> (defmethod identify ((n fixnum)) "This is a fixnum") #<STANDARD-METHOD COMMON-LISP-USER::IDENTIFY (FIXNUM) {1005C984F3}> CL-USER> (identify (make-instance 'my-class)) "This is my class" CL-USER> (identify 3) "This is a fixnum" > The way in which types get in your way in statically typed languages is pretty much gone in Julia as you can so easily and fluidly deal with types as they are just objects at runtime which you can pass around freely. Did you notice how DEFCLASS returned a class object earlier? It's a first class value in Lisp: CL-USER> (defvar *c* (find-class 'my-class)) *C* CL-USER> (type-of *c*) STANDARD-CLASS CL-USER> (make-instance *c*) #<MY-CLASS {1005E38AA3}> CL-USER> (typep (make-instance 'my-class) *c*) T CL-USER> (subtypep (defclass derived-class (my-class) ()) *c*) T