Try Clojure
361–370 of 404 posts
Re: Try Clojure
#362Earlier quoted context omitted.
It's not the JVM. It's how much code you load.
I mean... That's not an issue in other runtimes, so it's kind of a JVM quirk no?
E.g. any Python project has to deal with this, like Mercurial.
Java projects tend to (insert stereotype) have a lot of code.
Re: Try Clojure
#363Isn't it tiring to type so many parenthesis all the time? This is probably my first time encountering a Lispy language, other than Logo.
Re: Try Clojure
#364There is XSS in the (my-name) part :) (my-name " ")
Nice catch. Is it an issue though when the script injection only runs within your own browser session?
Re: Try Clojure
#365Isn't it tiring to type so many parenthesis all the time? This is probably my first time encountering a Lispy language, other than Logo.
The number of parentheses is the same, they're just in a different place. Isn't it tiring to type so many semi-colons and commas all the time?
Plus, there are not a lot of semi-colons and commas in JS and Python.
Re: Try Clojure
#366Isn't it tiring to type so many parenthesis all the time? This is probably my first time encountering a Lispy language, other than Logo.
Of course, there are constructs such as `let` and `cond` that are more parenthetically noisy (not so much in Clojure though), but on the flip side you don’t have to remember a lot of special syntax like in non-lisp languages.
Most Lisp-people also use structural editing tools like paredit[1], which make it really easy to write and edit s-expressions. I found that after some time I didn’t really think that much about parentheses anymore.
[1]: https://paredit.org
Re: Try Clojure
#367Earlier quoted context omitted.
The parenthesis highlight in any decent editor. So it always very obvious which operators apply to the operands.
This reduces the friction, but doesn't eliminate the needles back and forth. Breaking context locality is just bad The threads example in another comment is way better
Re: Try Clojure
#368Isn't it tiring to type so many parenthesis all the time? This is probably my first time encountering a Lispy language, other than Logo.
I know a lot of people think that you write more parentheses in Lispy languages, but actually in most cases you just type them in a different order, e.g. instead of `foo(x, y)` to call a function, you type `(foo x y)` and you even save a comma. Of course, there are constructs such as `let` and `cond` that are more parenthetically noisy (not so much in Clojure though), but on the flip side you don’t have to remember a…
(defn fizzbuzz [n]
(cond
(zero? (rem n 15)) "FizzBuzz"
(zero? (rem n 3)) "Fizz"
(zero? (rem n 5)) "Buzz"
:else (str n)))
(defn print-fizzbuzz [n]
(doseq [i (range 1 (inc n))]
(println (fizzbuzz i))))
This looks overwhelming for someone who hasn't written any Lisp. My thought looking at this code was that I have to type a parenthesis before formulating any thought. Which is crazy because it's not some huge thing. It's like saying I have to press Enter before writing a line of Python.Re: Try Clojure
#369Earlier quoted context omitted.
In Django I would just do Posts.objects.filter(title=x) I don't need to define driver boilerplate for every query (or ever have to write it... at all).
In Clojure you'll have to write the queries yourself unfortunately. People always ask, where is the fully fledged web framework in Clojure? There isn't one. Why there isn't one is hard to answer, but it's partially because the people who could write one, don't find they need one themselves. There's definitely a preference in Clojure for not relying on frameworks, because the current people in the community like to be…
Thanks, that's neat.
I'm not even talking about the framework part. Just db access. Let's say I have a Posts with a managed_by property that points to a list of User which have a ManagedProfile. In Django's ORM (or any good ORM), I could do:
if post.managed_by.contains(user.managedProfile)...
or I could do:
post.managed_by.add(user.managedProfile)
also all these tables and join tables are generated by just a few lines of model definitions.
I'm still in control. I am writing the code. I get to choose when I do slow and fast stuff. Not having these features isn't "more control" it's less features. :P
I still see the benefits of Clojure, though!
Re: Try Clojure
#370Earlier quoted context omitted.
Biff looks neat, thanks! I mainly just don't want to write raw sql/mappers to structures for simple queries. Looks like most sql libraries with clojure can just return maps so that's neat.
There's no object in Clojure, so there's no need for an Object Relational Mapper. You just work directly of the query result sets, which the SQL library itself can conveniently turn into rows of maps if you prefer (over rows of lists).