3 ms·
I want to get my head wrapped around lisp but I just see code like this and my head hurts
by gigatexal 4y ago
I want to get my head wrapped around lisp but I just see code like this and my head hurts
- fredrikholm 4y agoHighly recommend Clojure(Script) as a nice introduction to Lisps. It has slightly more syntax (square and squiggly brackets) to avoid having to use an army of parens to denote destructuring, binding etc.
- medo-bear 4y agoi think common lisp has much better learning material. although it has been a while since i last looked, there isnt really anything beginner friendly for clojure beginners would do well to look at COMMON LISP: A Gentle Introduction to Symbolic Computation. it's easy going and i think everything you learn can quite easily translate to other lisps
- coutego 4y agoI'd say that Racket makes for an easier introduction to Lisps, at least for people not familiar with the functional paradigm. The reason for this is that Clojure intentionally discourages many common imperative idioms by not making any effort to support them. That forces you to learn how to do things "the Clojure way". Once you know it, you realise it makes sense and it's a better way to do thing in that context, but when you are coming from outside, it can be very hard to get things. At least it was for me, after some 20 years of programming experience. Racket? Sure, I was able to do (simple) programs without too many problems in a matter of hours. Clojure? Lots of "huh?" moments for months until the "aha" moment when things makes complete sense. I'm quite a big fan of Clojure, for full context.
- agumonkey 4y agoit's mostly just induction over trees with a few old idioms for matching
- jdale27 4y agoI wouldn't call this everyday Lisp code for beginners. Try Practical Common Lisp: https://gigamonkeys.com/book/ https://gigamonkeys.com/book/.
- Archelaos 4y agoI would like to give Common Lisp a try. What setup/frameworks are best for a beginner targeting Win10 GUI apps (ideally self-contained in a single exe) that need to access a MariaDB server over the Internet?
- mark_l_watson 4y agoI don’t use Windows, but LispWorks is well supported on Windows, macOS, and Linux. I bought the macOS version and pay the yearly maintenance fee. It has a good portable GUI library called CAPI and creates small standalone executables. LispWorks is expensive so try the free version for a long time to make sure it is right for you. For macOS and Linux, the open source SBCL is excellent and there are libraries to use TK or web apps as GUI interfaces.
- dwringer 4y agoI'll second that Tk works well with SBCL, and add that I have also used it in a Windows 10 environment without much hassle (although a web app GUI is a great route), the libraries may not all be up to date with the latest features but it's relatively straightforward to implement them looking at the source code as a template. With CFFI one can get into the windows API pretty readily as well, so the sky's really the limit. As far as being self-contained it's at least easy enough to get everything within a single project directory, and one should be able to load pretty much everything (other than if you rely on tcl or something external like that) into the image and save it as an .exe with sb-ext:save-lisp-and-die.
- tmtvl 4y agoProbably LTK and CLSQL. Accessing a MySQL (well, MariaDB is a drop-in replacement) DB over the internet is no different from accessing it locally. If you don't like Tk, there's a few alternatives like IUP or Qtools. Of course if you'd prefer you could grab Armed Bear, use Java libraries, and export a JAR. In that case you can use Swing and JDBC.
- tetris11 4y agoI think there's an inherent beauty to Lisp, but when I see backquote/comma expansion commas it upsets this idea for me. I wish they chose other symbols for this
- abecedarius 4y agoDo you have an alternative design you like? (Not a gotcha. I have my own Lisp dialect and I'm willing to mess with the syntax.)
- tetris11 4y agomaybe using triangle brackets instead on statements that need to be immediately evaluated
- lispm 4y agoIt's unfamiliar to the beginner and could take also some "unlearning" of expectations how a program looks like and how to program. But there are reasons for the syntax: it allows relatively easy language extensions. The mentioned PCASE macro extends the language with a pattern matching construct. Every user can write theses things. Directly in Lisp, without modifying the language itself - because it is already extensible. The source for PCASE is here: https://github.com/emacs-mirror/emacs/blob/master/lisp/emacs-lisp/pcase.el https://github.com/emacs-mirror/emacs/blob/master/lisp/emacs... Emacs Lisp has some well written extensions. I find the coding style of something like the PCASE extension to be quite readable, for me as a Lisp user. ;-)
- medo-bear 4y agothis is not beginner code, lisp or otherwise. you are looking at macros. macros are a very powerful programming feature, and no other programming language excells at writing macros to lisp level. moreover writing macros might not be very elegant compared to other code. however writing macros in lisp certainly is much more elegant compared to what you need to do to achieve the same result in other languages. the point of writing macros is to make calling them elegant
- neilv 4y agoDon't get intimidated. This article doesn't much get into explanation. Understanding `match`-like syntax takes some explanation, and then the syntax can sometimes still look intimidating, especially if they added in lots of conveniences. But once you read through the docs, it's usually trivial, and can eliminate a lot of bulky and error-prone code. Named-`let` in Scheme (which is what I suspect inspired this Emacs `named-let`) looks confusing until you know it. As you try to write Scheme code without mutating variables (setting variables to new values after they already had one) as a stylistic choice, named-`let` and properly-implemented tail calls get very useful. And once you've used it a little, it's simple, and tail recursion will usually be easy to follow (easier than trying to follow code setting flag variables, having premature exits, etc.). These are actually two very-very different kinds of constructs. `match` ends up being a kind of mini-language with some syntactic sugar thrown in, but named-`let` is more a fundamental construct.
- hddqsb 4y agoAs others have said, this article is not beginner-friendly. The book "Structure and Interpretation of Computer Programs" (SICP) is a classic introduction to Lisp (specifically Scheme), the full text is available online: https://mitp-content-server.mit.edu/books/content/sectbyfn/books_pres_0/6515/sicp.zip/index.html https://mitp-content-server.mit.edu/books/content/sectbyfn/b...
- deleted 4y ago[deleted]