5 ms·
Programming language readability: Python vs Haskell
- willvarfar 15y agoAnyone who missed it: the link in there to TDD Sudoku is well worth a visit: http://devgrind.com/2007/04/25/how-to-not-solve-a-sudoku/ http://devgrind.com/2007/04/25/how-to-not-solve-a-sudoku/
- gatlin 15y agoEverything I know about Haskell leads me to believe its purpose is to be a research bed for functional programming concepts. Correctness is first; speed is a nice thing that happened later. And readability is even less important. This is like comparing granite to glass regarding translucence. And, actually, if you do it right you can end up with readable, imperative Haskell.
- willvarfar 15y agoHaskell is often put forward as a learning language. I have myself worked through "how to program" books for people with no prior programming experience that used haskell, in the same way that lisp (scheme) is used in sicp.
- tincholio 15y agoI'm not familiar with the author and his expertise, but he might benefit from this: http://blog.ezyang.com/2011/11/how-to-read-haskell/ http://blog.ezyang.com/2011/11/how-to-read-haskell/ And maybe also this: http://www.haskell.org/haskellwiki/How_to_read_Haskell http://www.haskell.org/haskellwiki/How_to_read_Haskell I consider myself a newb in Haskell (and functional programming in general), and didn't see anything too mystifying in the code, other than it takes a declarative approach (well, Control.Arrow.first is maybe the only 'exotic' thing, but it otherwise looks rather straightforward).
- justncase80 15y agoWhile I think it's possible to compare language readability I don't think you can simply place them side by side and expect most programmers to fairly compare them. Python is much more "C-like" and as a result I'm able to read it a little better. I don't think that makes it inherently more readable, it just means that I don't know how to read Haskell at all. It's like if you put some English dialect next to German and asked me about the readability of both... I can't speak or read German at all so I really have no idea. If you can speak both Haskell and Python than by all means compare the readability of the two and I would be interested to hear your opinion but I want to make sure we're not judging Haskell because we haven't taken the time to learn it and it happens to be more divergent than whatever language we happen to already know.
- willvarfar 15y agoI've added a bit to the blog about why I think Python is more readable. I lament that more languages aren't trying to be readable. To my mind, it ought to be goal number 0.
- vorg 15y ago> Why is Python more readable? [...] Second is the use of short words instead of symbols. Perhaps the Haskell is trying a little to hard to feel like algebra? [...] Python goes further than most to use short concise words; COBOL used long words To make words even shorter than in Python without resorting to Haskell-like symbols, try ChinesePython (http://www.chinesepython.org/english/english.html http://www.chinesepython.org/english/english.html). Here's some examples from their site: 寫 ..(print) 刪除 ..(del) 定義/函數 (def) 忽略 (pass) 中斷 (break) 下一個 (continue) 傳回 (return) 示警 (raise) 載入 ... 名 ... (import ... as ...) 從 ... 載入 ... 共用 (global) 執行 (exec) 斷言 (assert) 如 .. 不然 .. 否則 .. (if .. elif .. else ..) 只要 .. 否則 .. (while .. else ..) 取 .. 自 .. 然後 .. (for .. in .. else ..) 試 .. 失敗 .. 否則 .. 然後 .. (try .. except .. else .. finally .. ) 概念/類別 (class) 來自/不來自 (in / not in) 是/不是 (is / is not) 或 or 且 and 不是 not