Hacker News new | past | comments | ask | show | jobs | submit login

I love them. Lisp can use lists for everything, and PHP arrays ;)

Thanks to their mixed nature they're very versatile. People even make small DSLs out of them. And they're order-preserving, so they won't inject non-determinism just to smugly teach you a lesson about real hash tables.




Almost anything can be simulated in any other data type, often with poor performance and easy bugs.

If a programmer use lists in lisps where vectors or hash tables are more appropriate, he is doing something wrong.

Likewise, simulating arrays in hash tables, which is what PHP expects one to do, is a very bad idea.

Bash lacks multidimensional arrays, but it does have hash tables, so some programmers resort to simulating multidimensional arrays by using keys such as `"3,4"` as a string in hash tables, this would be a very bad idea if Bash had true multidimensional arrays. In it's lack thereof, it is only a bad idea where no better idea is possible.


The reality of most of programming I've done is that in 98% of cases you deal with data structures that are sufficiently small for performance not to matter much on modern hardware.

If you do need to deal with data structures that are quite large (i.e., take GBs of memory), perhaps PHP is not the right language.


The performance is hardly the biggest issue, the ease of bugs is.


The problem is that lisp APIs tend to treat paired sequences as equal citizens, whereas PHP treats paired arrays as a special case and they're effectively a different data type. This is the same problem with how Erlang/BEAM languages treat strings as a list of character data. It's the same until it's not, and then it's decidedly not.


  This is the TXR Lisp interactive listener of TXR 249.
  Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet.
  Poke a few holes in TXR with a fork before heating in the microwave.
  1> [mapcar succ "abc"]
  "bcd"
  2> (car "abc")
  #\a
  3> (cdr "abc")
  "bc"
  4> (cadr "abc")
  #\b
  5> (cddr "abc")
  "c"
  6> (cdddr "abc")
  nil
  7> (rplaca (copy "abc") #\x)
  "xbc"
  8> (rplacd (copy "abc") "yz")
  "ayz"
  9> (ldiff "abcd" "cd")
  "ab"


Shots fired at Golang




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

Search: