4 ms·
I've been working with clojure for over a year now and I don't really understand your demo. I think the answer to your JS question (btw the example isn't js, it
by knubie 7y ago
I've been working with clojure for over a year now and I don't really understand your demo. I think the answer to your JS question (btw the example isn't js, it's JSX, but if we convert it to the js equivalent first) is "yes." You can evaluate the string "Hello, world!"; you can evaluate `document.getElementById('root')` (I do it all the time in Chrome's js console). You can even evaluate `ReactDOM.render` assuming `ReactDOM` is in scope. I don't see any difference between the js and clojure example. What am I missing?
In another comment you gave an example like:
(foo [a b] ((c a) b))
stating that you can eval any part of it, but if you try to eval ((c a) b), won't the repl raise an error stating a and b are not defined?
- iLemming 7y agoAlright, fair criticism. You're right, I should've probably chosen a different example, but it still would be somewhat difficult to prove my point via text. The REPL experience working with a homoiconic language is definitely better, compared to other languages that have REPLs, it's better than with JS, with Python and even Haskell. You see, in Lisp you think and operate in units of s-expressions, any s-expression can be send to the REPL as-is, "code is data" <=> "data is code". In Javascript it also adds some hurdles of things being out of scope. In Clojure, due to default immutability - the problem space is usually small, it encourages you to write smaller functions and it is much simpler model - most of the time you can evaluate anything without any preceding ceremony. In some cases you do need to set the context as you pointed with `((ca) b)` example, but it's so trivial to do so with s-expressions and it's so tedious when working with Javascript (trust me, the comparison not in favor of the latter, I've built JS apps for over a decade).
- knubie 7y agoThanks for the reply. I'm not try to disparage clojure, BTW. I've chosen it to use for my start up, and am only pressing this point because I want to get the most out of it I can and I'm afraid I might be missing something with the REPL workflow. I think I agree with everything you've written here based on my experience.
- iLemming 7y ago> I'm not try to disparage clojure, BTW Even if you were, who am I to judge you? I myself had a chance to learn Clojure back in 2013, and then a few months later, and then once again next year, but I kept saying: "no, thanks". My thoughts were: - JVM, yikes. JVM means Java, everyone hates Java, am I smarter than everyone else? I hate it too; - Dynamic typing is so stupid. I've had enough with Javascript, Python and Ruby, I'm not doing that shit again; - Parentheses. Lots of them. Too many of them. I can't see anything else. I'm drowning in the sea of parentheses. If only I knew that: - JVM is actually really robust and extremely good piece of tech; Try managing Nodejs clusters or deal with dependency conflicts in Python's pip. Honestly, JVM is so much nicer. - That dynamic typing in certain context can be your friend and not the enemy. And REPL driven is much better than "save&recompile" workflow. Besides, there's Spec and it's absolutely dope; - Parentheses bring structure, simplicity and consistency, and there are not too many of them. Javascript for example has more, and also semicolons and other shit. Clojure like any Lisp, sadly doesn't do a well job of "introducing itself" to complete newbies. It doesn't look sexy when you're trying it out for the first time. It requires a bit of patience and the leap of faith. And those who are ready to pay that small price, soon may discover an amazing world of possibilities.