Smalltalk, Haskell and Lisp

https://news.ycombinator.com/rss Hits: 15
Summary

To assist with job interviews at the NRAO we recently wrote a small “contest” program. Without giving away the details, the crux of the problem is to read a file with a list of scans and calculate the amount of time it takes to move the dishes and perform the scans, and report it. Candidates are required to write this in Java, but that restriction does not apply to me, so I of course had to write it in three languages that are not Java: Haskell, Common Lisp and Smalltalk. I expect to learn something, or at least reinforce an existing fact, by doing these sorts of language games, but this time I really wasn’t expecting what I found. I discovered that my enjoyment of Haskell is pretty much independent of Haskell’s appropriateness or usability. In fact, it is more attributable to the way I feel when using it, in contrast to everything else. Let me show you a piece of code: -- | Perform a scan and produce the scan log for it. performScan ∷ Scan → AntennaSimulator ScanLog performScan scan = wrapDuration $ do slewTime ← moveTo $ scanPosition scan -- move to the scan's position onSourceTime ← waitFor $ scanLength scan -- wait for the scan to finish return $ Log scan onSourceTime slewTime Somehow, the other languages I’ve used to implement this problem never arrived at a piece of code quite this beautiful. Compare to the Smalltalk: Scan ≫ runWith: anAntenna runWith: anAntenna "Performs this scan on the supplied antenna." | onSourceTime slewTime | slewTime := anAntenna moveTo: self position; lastActionDuration. onSourceTime := anAntenna wait: self duration; lastActionDuration. ^ ScanResult withScan: self slewTime: slewTime onSourceTime: onSourceTime And the Lisp: (defun run-scan (antenna scan) "Perform a scan on this antenna. Return a scan log." (let* ((slew-time (move-to antenna (scan-position scan))) (on-source-time (delay antenna (scan-length scan))) (total-time (+ on-source-time slew-time))) (with-slots (last-duration) antenna (setf last-duration total-time) (make-scan-l...

First seen: 2025-06-06 22:09

Last seen: 2025-06-07 12:11