Earlier quoted context omitted.
Clojure is concise, expressive, not noisy, opinionated (with generally appreciated opinions), dynamically typed, a Lisp, functional with some escape hatches (but not confused with being FP and OOP), and built to solve real problems. Scala is either the opposite of these, or at least not as much of these. IMO, less code is better. Clojure is about as terse as you can get and still be readable (by my opinion). Scala is…
Though Clojure jobs tend to be the highest paying. https://insights.stackoverflow.com/survey/2019#top-paying-te...
Why I like Clojure
131–140 of 155 posts
Re: Why I like Clojure
#132as i was talking to a friend about clojure i came up with an analogy i cant shake: clojure is what happens when you just make your programmer directly write an AST. a bit reductionist, but anyone care to debate this?
Isn't that the point of lisp and homoiconicity in general? That you're writing an AST that you can also treat as a data structure?
Re: Why I like Clojure
#133as i was talking to a friend about clojure i came up with an analogy i cant shake: clojure is what happens when you just make your programmer directly write an AST. a bit reductionist, but anyone care to debate this?
That’s a fair description of the syntax, but Clojure is more than just syntax.
Re: Why I like Clojure
#134Earlier quoted context omitted.
Isn't that the point of lisp and homoiconicity in general? That you're writing an AST that you can also treat as a data structure?
ok so... why is writing an AST more ergonomic than having some syntax?
Also part of the reason Babel exists is to take the place of a macro system. Instead of transpiling array spread into a function polyfill, macros would just output the pollyfill into the AST. What’s nice about this is that since it’s userland, people can test drive new features. Rust did that for async/await. And the pattern matching proposal in JS is based off a SweetJS macro.
(Obviously not all language features can be implemented as macros but you get my point, right)
Re: Why I like Clojure
#135Need someone to explain why I should use clojure over scala because typelevel seems pretty well developed
1) Clojure is more fun, more interactive and interesting.
2) You learn a lot more, more quickly. In Scala it's easy to just fallback to writing classic OOP with a nicer syntax. Clojure forces you to learn FP, meta, logic, etc. much sooner.
3) I'm more productive in it.
4) The interop is way better.
5) Compile times are instantaneous.
6) The community is friendlier.
7) New versions are always backwards compatible, Scala often breaks compatibility and updating is annoying.Re: Why I like Clojure
#136Earlier quoted context omitted.
> get the AST (a data structure AFAIK), manipulate it in a sane fashion in Python, compile it, return the result. No string munching eval require I use both Lisps and Python, and especially after learning to use Lisps I've wanted to do this in Python, so I looked for the ability to do what you describe here. While it is technically possible to do this (like most things) in Python, it is quite the effort and nowhere n…
This is true, but I wanted to correct factual errors in the article. If you or your team are Lisp users then Hy or Clojure would be good choices, but if you are just trying to create a transformation for existing Python codebases, the decorator approach is a good shoehorn. On the other hand, you can also interpret the difficulty of AST transforms as a signal from the language designers (had van Rossum really never he…
> if you are just trying to create a transformation for existing Python codebases, the decorator approach is a good shoehorn.
For transformations that need to modify the code, decorators are insufficient. Decorators have their value, and I have built good interfaces using decorators, which would have been rather difficult without them, but all of that was because decorators help _wrap_, not _transform_ code.
When I had a need to transform code, I looked for the right tool, and the takeaways of my searches are mentioned in my original comment.
> you can also interpret the difficulty of AST transforms as a signal from the language designers (had van Rossum really never heard of Lisp?) that they hurt readability and their use should require a little ceremony.
Nobody's claiming Guido had never heard of Lisp, or any non-lispy-language designer for that matter. Language designers make languages for varied reasons. Guido's reasons actually happen to be documented, and the only reason Python isn't homoiconic is because Guido didn't have a need for it, not because he explicitly wanted AST transforms to "require a little ceremony".
In fact, Python AST transforms do not merely "require a little ceremony". They are actually quite cumbersome. The standard library actually provides no help at all in transforms, making it necessary for libraries like Rope, RedBaron, and Astor to be written.
Re: Why I like Clojure
#137Need someone to explain why I should use clojure over scala because typelevel seems pretty well developed
Clojure: live repl into running code Scala: Clojure: Explore the problem you are facing with quick prototyping in the repl and see the blind spots, the unknowns, the shape of data received from flaky integrations. Mold and shape your functions as the problem becomes clearer. Scala: Best it can do is write unit tests and the debugger to look at what exactly is happening, devise a bunch of classes to handle them, rinse…
Firstly Scala does have a couple of REPL's, the best being Ammonite which is mentioned below. It can be embedded in code to provide a live repl just as your Clojure program. I often work in Scala in a similar way to I work in Clojure; creating and testing new types and functions in the repl before moving them back to a source file.
The way you build programs sounds quite horrible, but I know people do it that way and it works well enough. Your complaints about long compile times are largely irrelevant. Incremental compilation means it's usually 2-3 seconds at the most before I can test a change. We don't build programs as a bunch of classes by the way, that would be OOP. Scala is more commonly written in a functional and/or streaming/reactive stle. Also I'm glad you brought up refactoring. It's a breeze in Scala because of the strong type system. Poorly defined data can be expressed just well in Scala with types as it can in your blob of maps of maps, and it's much easier to work with.
Finally you may finish your program first; it appears to do the thing you want but you can't really be sure. There will be more runtime errors such as NPE's and type errors because you don't have mechanisms to remove them from possibility. I'd much rather maintain and evolve a Scala program.
Re: Why I like Clojure
#138Earlier quoted context omitted.
Hiccup has functionality to perform escaping with `h`. It doesn't do it by default though, for performance reasons and nesting of Hiccup in Hiccup. Normally, you'd just want to sanitize right before returning your response. Doing it that way you can also perform more selective sanitation if needed. Hiccup2 does sanitation by default, still in beta though. The common SQL lib is java.jdbc or next.jdbc and they use prep…
> Hiccup has functionality to perform escaping with `h`. It doesn't do it by default though, for performance reasons and nesting of Hiccup in Hiccup. Normally, you'd just want to sanitize right before returning your response. One of the things that Rails' templates gets completely right is that it knows when something is nested and when it's going to be returned immediately. It is thus able to do its automatic escapi…
That's actually what hiccup2 does as well by the way. I admit, it is a nicer behavior, and I'm not sure why hiccup2 hasn't gained more traction since it released, but you are free to use it, it's part of the normal hiccup release, just require hiccup2 instead of hiccup.
But hiccup is not the only popular Clojure HTML templating lib. Selmer, Clostache and Stencil which are much more ERB or Django like, both HTML escape by default.
Re: Why I like Clojure
#139Earlier quoted context omitted.
> The developer didn't think about what might be in what they were logging, the package assumed that the developer did, and the result could have been avoided by a more integrated whole Umm, is there any all in one web framework that protects against this to any level of guarantee?
It's been my experience that Rails logging can and will do things like censor password fields when passed objects. So, yes, it is possible for logging (and serialization) systems to defend against this kind of thing.
Re: Why I like Clojure
#140I love the idea of Clojure. I find the ecosystem immature and full of ideas about "libraries, not frameworks" that leave developers incredibly vulnerable to their own ignorance and second-order ignorance. The number of developers I know - or even know of - that can be trusted to develop a useful and secure web application from the ground up with this kind of tooling approaches zero. Clojure is a cool language. I can…
http://flyingmachinestudios.com/programming/why-programmers-...