Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> CL still got symbols, the reader (and its macros), gradual typing and user available runtime compilation (compile and compile-file).

TypeScript has all of these, too.




JS Symbols are like CL gensym and CL symbols (interned strings) don't exist in JS.

Normal TS doesn't expose normal macros or reader macros to the user.

JS runtimes don't have the image introspection ability of CL.

TS types are removed before the JIT and don't actually impact performance (not to mention they encourage polymorphism which is actively BAD for JS performance). CL type hints are use by the compiler to actually speed up the output code (quite dramatically I'd add).


Really? You can `(compile nil my-lambda)` without having to write a JIT yourself?

I meant reader macros, by the way: can it do that?

  ; A comment
  (set-macro-character #\% (get-macro-character #\;))
  % Also a comment


Sure.

    new Function(“…”)
There’s no guarantee that it will be JITed, but then the CL standard is also pretty loose about the semantics of ‘compile’.


I must admit, I don't know what this is doing, and why.


The semi-colon symbol is the single-line comment symbol in Lisp, but the percent symbol means nothing special in Lisp.

SET-MACRO-CHARACTER is used to modify what happens when certain characters are found while reading code. In this case, SET-MACRO-CHARACTER is being used to instruct Lisp to start treating % as if it were a semi-colon (i.e. the third line is a comment), thus extending the syntax of Lisp on-the-fly.

The (GET-MACRO-CHARACTER #\;) portion could have been any code at all; GP could have defined % to do anything, such as "treat the remainder of this line as if it were a line of Python code", using calls to a Python implementation, such as cl-python [0].

[0] = <https://github.com/metawilm/cl-python>


who is using macros in ts ?




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: