Live data from Hacker News

Try Clojure

tryclojure.org

361–370 of 404 posts

Re: Try Clojure

#361
I love Clojure. My dream is to be a clojure developer, but there aren't a lot of jobs available and everyone wants 87 years experience.

Re: Try Clojure

#362

Earlier 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?

No, that's defiantly true in other non-native runtimes.

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

#363

Isn'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?

Re: Try Clojure

#364

There 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?

No. That in itself shouldn't be a cause for concern. Local users can do anything to their own machines already. It would be a concern if you persist this to then later be loaded by someono else's machine.

Re: Try Clojure

#365

Isn'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?

I think it's tiring because before every expression I have to type a (. It's not tiring to type semi-colors and commas because they are very well positioned on the keyboard and I don't have to reach out in the same way as I need to for the parenthesis.

Plus, there are not a lot of semi-colons and commas in JS and Python.

Re: Try Clojure

#366

Isn'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 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

#367
post #263

Earlier 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

There’s no needle back and forth. Everything in parentheses is a complete expression, like a formula. You have the operator (function) and the operands (args). Think of it as add instead of + and multiply instead of *. You get used to it very quicly and then it does not matter.

Re: Try Clojure

#368

Isn'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…

You're right about the order part and I didn't consider it initially. This is what Fizzbuzz looks like in Clojure:

  (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

#369
post #211

Earlier 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…

> I implemented the small website you were talking about

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

#370
post #164

Earlier 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).

No object is kinda mind blowing since it has java interop. I guess everything just becomes maps?
Post reply on HN