Timeline for What are the practical benefits of LISP like syntax which Clojure uses over Java like syntax of Scala?
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 18, 2013 at 20:16 | comment | added | Giorgio | @mike30: I also use this trick: I look at the indentation and forget about the parens. BTW, isn't this the same trick we use to read C code (C++, Java, C#, ...)? | |
Jun 18, 2013 at 17:19 | comment | added | Evicatos | I've also found it easier to read Lisp style syntax from the "inside out". You're probably use to imperative style programming where you just read from top to bottom and get an idea of what's going on. Lisp tends to be easier to understand if you start from the "innermost" set of parenthesis and work your way out, at least for me anyway. | |
Apr 22, 2013 at 16:10 | comment | added | mike30 | @AmoghTalpallikar. Your eyes use the indentation to tell what is what, rather than jumping back and forth matching parens. | |
Apr 22, 2013 at 14:33 | history | edited | user39685 | CC BY-SA 3.0 |
i can haz spelin' skillz
|
Apr 4, 2013 at 21:12 | comment | added | Amogh Talpallikar | wrote a function tat returns a vector containing fibonacci numbers with n elements. feel much better now :) | |
Apr 4, 2013 at 21:10 | vote | accept | Amogh Talpallikar | ||
Apr 4, 2013 at 13:40 | comment | added | Michael Shaw | @AmoghTalpallikar: Dry-running code is just a matter of running it in the REPL (read-evaluate-print loop (an interactive command-line-like environment, like irb for ruby)). You can copy-paste from the editor to the REPL, and it doesn't have to be a whole function, it can be a subexpression that you're testing. Modularity helps with testing, so if you feel that the function is too big and needs to be broken into subfunctions, you're probably right. Using "let" also helps avoid too much nesting, since you can define helper functions. | |
Apr 4, 2013 at 13:03 | comment | added | user39685 | @AmoghTalpallikar the only way to get good at it is to do it and look at how other top coders do it. There's no magic trick. Parentheses matching isn't a problem if you have any kind of code-aware text editor at all. | |
Apr 4, 2013 at 12:57 | comment | added | KChaloux | @Amogh In my limited experience with Clojure, yes, you want to use a newline and indent for nested functions. This is a Y-Combinator example I adapted from a tutorial in Scheme to Clojure that shows how I'd lay it out: pasteall.org/41052/lisp | |
Apr 4, 2013 at 12:34 | comment | added | Amogh Talpallikar | How do people dry run such code? I mean expression inside expression inside expression. by the time you solve inner expression you forget what the other one was ? and if remember as well it's difficult to identify which close paren si for which open paren? Should every new '(' be in a new level of indentation ? Any tips ? | |
Apr 4, 2013 at 11:27 | history | answered | user39685 | CC BY-SA 3.0 |