5 ms·
Anyone got an ELI5 on the goal of this language, or the pros and cons? I'm not a dev, but, a Python user with a background in data/info science - so I'm a bit
by AdamSC1 7y ago
Anyone got an ELI5 on the goal of this language, or the pros and cons?
I'm not a dev, but, a Python user with a background in data/info science - so I'm a bit unclear on what Wikipedia means by things like "a dialect language of Lisp", and using it to write "domain specific languages."
Is this just a way to use Python libraries in Lisp (which seems to be a low level programming language?)
- pixelmonkey 7y agoDo you love Common Lisp, Racket, Scheme, and/or Clojure, but wish you had a language like that, but with full interop support for Python libraries (in much the same way Clojure has full interop for Java libraries)? If so, you might like Hy. It's not as mature as those other projects, but its support for Python interop is impressive, and by letting you write Lisp-style code, you can make more functional-feeling code and also do things like macros and metaprogramming more easily.
- jnbiche 7y agoLisp is not typically a low-level programming language, but rather extremely high-level (high level of abstraction)[0]. The "dialect language of Lisp" quote just means that it's a variation of Lisp, but running in a Python environment. The term "domain-specific languages" refers to programming languages created for a specific, often one-of, task. If you look at this repo, you'll see various languages used to create diagrams and graphs in this library. These are all examples of DSLs (note, they're in many places, this is just an example): https://github.com/francoislaberge/diagrams https://github.com/francoislaberge/diagrams Regarding Hy specifically, it's basically Python that uses a different syntax, or skin, of sorts. Instead of white-spaces and colons, you get parentheses and...parentheses. It's more complex than that, but it's basically just a way to write Python for people that like Lisps. 0. Yes, there are some examples of low-level lisps without features like memory management, but they're pretty unusual.
- alexanderdmitri 7y agoHow does Hy manage recursion given the limitations there in Python?
- gilch 7y agoIt doesn't. Or does the same way as Python: imperative loops. TCO is a key feature of Scheme, but not of Lisps in general. Clojure doesn't have it. You can always trampoline like Clojure's loop does.
- alexanderdmitri 7y ago10-4, thank you!
- jedimastert 7y agoWhat kind of limitations are you referring to?
- alexanderdmitri 7y agoPython limits the stack to a 1000 and a series of recursive calls hitting that ceiling will throw a `RecursionError`.
- gilch 7y agoYou can actually set this to a higher number in the sys module. Maybe not too high if you don't like segfaults.
- AdamSC1 7y agoSo, if I was to boil it down, its like "Hey, use Python, but with a different writing style you are used to."?
- stan_rogers 7y agoSort of. It's more a case of having all of the flexibility of a Lisp - the ability to program with wishful thinking and fill in the details later - and all of the "batteries included" of Python. It would genuinely be worth your while to watch the SICP lectures with Gerry Sussman and Hal Abelson [1] to get an inkling of an idea of what "your program is just more data" can mean. Lisp is more about brining the language up to the level of the problem than bringing the problem down to the level of the language, and it's difficult to appreciate what that means until you've seen it. By the time you get to the end of lecture 3B, it should click. [1] https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video-lectures/ https://ocw.mit.edu/courses/electrical-engineering-and-compu...
- jhbadger 7y agoThere's also the Common Lisp package "burgled batteries"[1] which allows you to call Python from Lisp. Unfortunately, the original author no longer maintains it and it hasn't been updated to Python 3. [1] https://github.com/pinterface/burgled-batteries https://github.com/pinterface/burgled-batteries
- ruricolist 7y agoThere is a fork that supports Python 3: https://github.com/snmsts/burgled-batteries3 https://github.com/snmsts/burgled-batteries3
- AdamSC1 7y agoThanks - appreciate that and I'll double check the link. Because I'm still a bit confused at what Lisp is!
- zaro 7y ago> Lisp is not typically a low-level programming language, For most practical reasons is pretty low level. You don't really write in a language you write in AST directly, which while powerful IMO is not very high level.
- lispm 7y agoOne writes in a hierarchical data structure: s-expressions. Since Lisp has built-in macro expressions, on top of s-expressions, one can represent code independent from 'ASTs' and make it executable: For example the LOOP macro introduces a non-prefix syntax: (loop for i below 100 for j = (random 100) sum j into s while (< s 1000) finally (return i)) This is actually pretty powerful and high-level (the user being able to extend or change the syntax in complex ways in portions of a program). The LOOP implementation as a macro is actually an integrated sublanguage and the user can add arbitrary (and even extensible) complex macros like that... Generally Lisp is low to mid level as a programming language, with a bunch of features which can be considered high-level: extensive macro system, Common Lisp Object System, extensive error handling, ...
- jnbiche 7y ago> Generally Lisp is low to mid level as a programming language, I believe that no programming language with automatic memory management can be considered "low-level". That aside, why would you call Lisp "low- to mid-level"? Commonly-used implementations are at about the same level of abstraction as Ruby or Python.
- lispm 7y ago> I believe that no programming language with automatic memory management can be considered "low-level". That's a view of a whole language and its implementation. Still it may have a range of features which are low level. Lisp for example has Foreign Function Interfaces (FFI) with low-level interfaces and manual memory management. Example: http://www.sbcl.org/manual/#Foreign-Function-Interface http://www.sbcl.org/manual/#Foreign-Function-Interface Basic Lisp stuff like CAR and CDR were (almost) instructions on a CPU ( https://en.wikipedia.org/wiki/CAR_and_CDR https://en.wikipedia.org/wiki/CAR_and_CDR ). Something like a cons cell (the building block for lists) is basically a two-element vector. Lists were made by chaining them together via a CONS operator, which creates such a two-element vector. Such a linked list data structure is pretty low-level and the typical mark&sweep GC of the early days is also relatively basic. There is not much magic to it. Many other programming languages have much more complex basic data structures (see object-oriented programming in Java with classes and instances, inheritance, interfaces, namespaces, ...). Compared to that the basic linked list in Lisp is primitive. > I believe that no programming language with automatic memory management can be considered "low-level". See the standards for Scheme or Common Lisp. There is not a word about automatic memory management in the specifications. Automatic memory management is a feature of an implementation, just like foreign function interfaces. Most implementations have a kind of garbage collector. But most implementations also have manual memory management. People even write operating systems in Lisp sometimes: https://github.com/froggey/Mezzano https://github.com/froggey/Mezzano