3 ms·
Every time I think of Javascript language concept, I think about Lisp, and every time I think of "javascript fatigue" I think of Lisp Curse. I think that the c
by golergka 11y ago
Every time I think of Javascript language concept, I think about Lisp, and every time I think of "javascript fatigue" I think of Lisp Curse.
I think that the core feature of JS and Lisp is the fact that there's no concept of "compile time". Declaring classes, methods, even entire language concepts like promises happens entirely in runtime, and the language is soft to touch that every programmer with a healthy dose of curiosity and love for his craft is trying to build his own OOP system on it at some time.
This softness allows for incredible freedom for a programmer, and incredible speed of development of the language. But freedom is dangerous, both when you work with code written by others (often idiots, either only in the eyes of maintainer or completely objectively) and when you just support your own codebase that you wrote several years prior. Would anyone expect anything else from language with such capabilities?
- lispm 11y ago> Lisp is the fact that there's no concept of "compile time". The first Lisp compiler was finished in 1960. Naturally Lisp has the idea of 'compile-time'. > Declaring classes, methods, even entire language concepts like promises happens entirely in runtime Let's see. I have a file with these contents: (defclass foo () (a b c)) (defmethod bar ((a foo) (b foo)) (+ (slot-value a 'a) (slot-value b 'b))) Now let's use a Lisp compiler (!), here SBCL: $ sbcl This is SBCL , an implementation of ANSI Common Lisp. More information about SBCL is available at <http://www.sbcl.org/>. SBCL is free software, provided as is, with absolutely no warranty. It is mostly in the public domain; some portions are provided under BSD-style licenses. See the CREDITS and COPYING files in the distribution for more information. compiling the file: * (compile-file "compile-test.lisp") ; compiling file "compile-test.lisp" (written 16 MAR 2016 07:34:51 PM): ; compiling (DEFCLASS FOO ...) ; compiling (DEFMETHOD BAR ...) ; compile-test.fasl written ; compilation finished in 0:00:00.020 #P"compile-test.fasl" NIL NIL Wow, the sbcl Lisp compiler just compiled the file and generated the code for a class and a method using that class. Let's see if sbcl knows about the class: * (find-class 'foo) debugger invoked on a SIMPLE-ERROR: There is no class named COMMON-LISP-USER::FOO. Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL. restarts (invokable by number or by possibly-abbreviated name): 0: [ABORT] Exit debugger, returning to top level. (SB-PCL::FIND-CLASS-FROM-CELL FOO NIL T) 0] 0 Oh, it doesn't know about the class. We are no longer in 'compile time'. The class was only known during 'compile time', a concept you said Lisp does not have. sbcl seems to have it. Funky. But we can load the generated machine code: * (load "compile-test") STYLE-WARNING: Implicitly creating new generic function COMMON-LISP-USER::BAR. T * (find-class 'foo) #<STANDARD-CLASS FOO> * Now it knows about the class. > Would anyone expect anything else from language with such capabilities? Lisp has a lot of code bases which are large and maintained for 2 or more decades. Common Lisp has especially been designed to support compilation in various forms and to support the development of complex/large systems. One gets a lot of support from compilers like sbcl for doing so.