5 ms·
I know Norvig uses both Lisp and Python, but it seems like he is all Python these days. Nothing wrong with that, but a little depressing for Lisp.
by throwaway7645 10y ago
I know Norvig uses both Lisp and Python, but it seems like he is all Python these days. Nothing wrong with that, but a little depressing for Lisp.
- js8 10y agoIt's not a shame for a language to lose against Python. Python has by far the best focus on usability of the standard libraries of all the languages I have ever seen (which includes major ones). As they say, "practicality beats purity". Let me compare for example Lisp lists with Python lists. Lisp lists are in a way more low-level, lacking useful things as slices. Sure you can always write a function to do a slice, but the point is many useful functions are missing from the standard libraries. I tried to learn Common Lisp and Clojure (I like the language more than Python) but I was never more productive in it than in Python for this reason. This year, I have actually done some AoC in Haskell, and it's a similar deal as with Lisp. There are plenty libraries, but they just don't work as well together. An example: I needed a queue. So I used Data.Seq, but, there is no pop() function. No big deal, for sure, but annoying. Another example: I wanted to put list or set into a hash table, but unfortunately, these are not defined as instances of Data.Hashable. It's actually debatable whether list should be Hashable by default. Sure it would be practical, but someone could complain about the hashing implementation. And that's why Python is going to beat Haskell on these problems, where you simply don't want to worry about thousands of those little things. I was actually thinking about building myself a "pythonic" Haskell prelude which would have similar design to Python standard libraries and the same attention to consistency.
- lispm 10y ago> Sure you can always write a function to do a slice Common Lisp provides the function SUBSEQ for primitive slices. CL-USER 66 > (subseq '((a 1 x0) (b 2 x1) (c 3 x2)) 1 2) ((B 2 X1)) For some more slice functionality you could use the CL-SLICE lib. It's also not too difficult to write. I wrote a multi-dimensional slice like Take in Mathematica: CL-USER 58 > (take '((a 1 x0) (b 2 x1) (c 3 x2)) '(1 3) '(1 3)) ((2 X1) (3 X2)) CL-USER 59 > (take '((a 1 x0) (b 2 x1) (c 3 x2)) -2) ((B 2 X1) (C 3 X2)) CL-USER 61 > (take '((a 1 x0) (b 2 x1) (c 3 x2)) :all '(1 2)) ((1) (2) (3)) CL-USER 62 > (take '((a 1 x0) (b 2 x1) (c 3 x2)) '(1 2) :all) ((B 2 X1)) CL-USER 65 > (take '((a 1 x0) (b 2 x1) (c 3 x2)) -2 -2) ((2 X1) (3 X2)) with steps: CL-USER 71 > (take '((a 1 x0 y0) (b 2 x1 y1) (c 3 x2 y2)) :all '(1 4 2)) ((1 Y0) (2 Y1) (3 Y2))
- js8 10y agoAs I said, I am sure I can do it or find it in some library. But the integration of the APIs that Python has is missing. For example, I doubt your subseq works on strings (or bytestrings). But as I said, Python is IMHO the state of the art when it comes to PL usability (people have spent a lot of time thinking about use cases, sometimes at the expense of elegance or versatility), so no shame here.
- ScottBurson 10y ago> I doubt your subseq works on strings (or bytestrings) Actually, it does.
- lispm 10y ago> For example, I doubt your subseq works on strings (or bytestrings) Your view of Common Lisp seems to be created more by assumptions and not so by actual real limitations. Strings: CL-USER 10 > (subseq "xxfoobarxx" 2 8) "foobar" Any vector: CL-USER 11 > (subseq #(10 30 20 100 50 30 20 20) 2 8) #(20 100 50 30 20 20) Bitvector: CL-USER 12 > (subseq #*10101010010101001010101 2 8) #*101010
- hellofunk 10y agoI would expect Clojure's standard library to be just as useful as Python. I did last years contest in Clojure and it was quite straightforward and fairly little code. Clojure is much much more usable than CL.
- js8 10y agoThe way I understood the Clojure's standard library is that for many things (such as string manipulation) you have to fall back on Java libraries. And Java standard string libraries are AFAIK terrible compared to Python (again, no shame here).
- hellofunk 10y agoThat's certainly not true at all. Clojure has a rich string library where you can do all sorts of manipulation. Clojure's strings are also native data sequences so you can use the entire Clojure standard library's tools for manipulating data right on strings naturally. I wrote full-time Clojure for two years, and did all of last year's Advent of Code in Clojure. In my entire life, I have never once written a line of Java and I have no idea the details of its standard library. That's how well-encapsulated Clojure is.
- throwaway7645 10y agoThanks for the reply. I'm actually in the same boat as you. I'd like to use CL and Clojure as they are definitely faster than Python (I don't think Jython or PyPy are actual solutions if you want all your code to run 10x faster). I've read several Lisp books and you never seem to get to the power of what you get in 3 chapters of Python or Perl. Granted, Lisp has super powers, but not sure if worth it. Damien Conway got interviewed by a Linux magazine awhile back (years) and goes over some of this. I keep waiting for someone to release a Lisp that takes off, but they all have big problems that make getting started a huge pain. Clojure needs you to understand Java, Emacs, Leinegein...etc.
- danidiaz 10y ago> So I used Data.Seq, but, there is no pop() function Perhaps "viewl :: Seq a -> ViewL" a could be used as pop. > I wanted to put list or set into a hash table, but unfortunately, these are not defined as instances of Data.Hashable. Are you using the "hashable" package? There does seem to be an instance for lists (when the elements of the list are themselves hashable): > Hashable a => Hashable [a]
- js8 10y agoI am not even sure from the documentation what the ViewL abstraction is supposed to be good for. OK, I stand corrected on Hashable, apparently what I said is not true for neither lists or sets.
- topkekz 10y agohttps://news.ycombinator.com/item?id=1803815 https://news.ycombinator.com/item?id=1803815