Live data from Hacker News

Why I Switched from Python to Clojure (2016)

bradcypert.com

81–90 of 200 posts

Re: Why I Switched from Python to Clojure (2016)

#81
post #40

Earlier quoted context omitted.

"The worst injuries I've ever seen were in big factories with large, powerful tools -- not in home garages where people just use hammers and hand-saws." Powerful abstractions are... powerful. They're more difficult to use correctly, and take longer to learn. The conclusion shouldn't (always) be to avoid them entirely.

A good rule of thumb is the more powerful the language the stronger your justification needs to be for using it: https://en.m.wikipedia.org/wiki/Rule_of_least_power LISP is, of course, way more powerful than most languages so it is more susceptible to technical debt.

Simplicity matters more than power.

Re: Why I Switched from Python to Clojure (2016)

#82
post #4

I have considered multiple times switching from Python to other alternatives. However, I instantly discard any language with a Lisp-like syntax. I just cannot work with it. Being a Haskell hobbyist, I would like Python to be statically type and have better support for pure functional programming, but Python has the libraries that I need.

"I instantly discard any language with a Lisp-like syntax. I just cannot work with it." I feel the opposite. I avoid any language without a Lisp-like syntax, since its absence is a serious handicap which unnecessarily complicates code and makes it less readable. I also much prefer the Lisp idiom of using meaningful function and variable names, vs the one-letter names and crypitic operators that are so common in Haske…

I agree; once I beat the initial scariness of Lisp, I found it hard to go to any non-Lisp language.

Macros, while easy to abuse, are kind of a game-changer; the ability to add new semantics to a language make it borderline impossible for me to go to any language that doesn't have a good macro system.

I started with Clojure, which I still really enjoy, but due to how much I grew to love the `define-syntax` system in Chicken Scheme, that's become my latest weapon of choice.

Re: Why I Switched from Python to Clojure (2016)

#83
post #80

Earlier quoted context omitted.

The parent post did not say JVM, they said Java paradigms. Vastly different things. Writing Javaonic Clojure vs Clojuronic Clojure. So, trying to replicate the style/structure/paradigms of Java rather than learning and using the Clojure styles, structures and paradigms.

Yes, I understand, and I contend that being able to do this, and leverage Java libraries bidirectionally in impure Java-y ways is an explicit, deliberate and fundamentally useful feature of Clojure. Unless you're trying to say that things like protocols are fundamentally un-Clojurey because they smell of OO or something in which case I just disagree.

More widely, Clojure's pragmatism and the fact that it's not overly sniffy about what paradigm to use is one of its nicest features. If I wanted my programming language to make me feel bad about myself, then obviously I'd just use Haskell and be done with it.

Re: Why I Switched from Python to Clojure (2016)

#84

Earlier quoted context omitted.

I have considered Python many times, but I cannot work with a language that considers whitespaces as required syntax. I just cannot work with it.

Whitespace is not any more significant in Python than most languages. Indentation is significant. Just replace '(' with space/tab and ')' with "deindent". Done.

Have you done indentation with anything else other than whitespace?

I prefer to let this idea of required indentation to FORTRAN.

Re: Why I Switched from Python to Clojure (2016)

#85
post #43

I can, and do, appreciate opinions on languages themselves. But my decision to continue using Python over Clojure is much less about the language's syntax and more about the available libraries. How do Clojure web frameworks compare to Django/Flask? What would I use instead of Pandas for data analysis? Are there keras-like deep learning tools? Switching languages based on a comparison of idiosyncrasies between the tw…

Clojure lets you leverage the entire Java library ecosystem, which is flippin' huge -- bigger, even, than Python's.

Re: Why I Switched from Python to Clojure (2016)

#86
post #48

Earlier quoted context omitted.

Oh, so many things. The parallelism isn't actually that powerful, and in 2019 there's very little to set it apart. The building blocks are great, e.g. immutability everywhere, but few of the built-in primitives are actually usable (hidden unconfigurable thread pools etc). Stack traces still regularly horrible. Libraries are regularly abandoned. ClojureScript integrating with npm etc is more stress than you'd like. Co…

I had lots of pain dealing with CLJS but, since switching to http://shadow-cljs.org as my compiler, I've generally found that things "just work": instead of complicated messing with externs, you just npm install the package and then add `["vega" :as vega]` to your namespace's list of requires. As far as the stack traces go, I have a hard time understanding why tooling like Cider's stacktrace filtering isn't wider spr…

Thanks for this, shadow-cljs looks very promising.

In terms of stack traces, it's not just the location in your code that you care about, it's the nature of the error. In lieu of spec being ubiquitous or anybody really checking their arguments ever, you're still left looking at 20 lines of stack beyond your own code to realise you've passed the incorrect type or structure somewhere. And even with spec you need additional libraries to actually yield human error messages in a lot of cases.

Re: Why I Switched from Python to Clojure (2016)

#87
post #78
post #43

I can, and do, appreciate opinions on languages themselves. But my decision to continue using Python over Clojure is much less about the language's syntax and more about the available libraries. How do Clojure web frameworks compare to Django/Flask? What would I use instead of Pandas for data analysis? Are there keras-like deep learning tools? Switching languages based on a comparison of idiosyncrasies between the tw…

I will admit that there aren't as many direct Clojure libraries, but many of the core things out there; core.matrix works pretty well for elaborate matrix processing, there are several decent web frameworks, as well as parsing libraries. There's a metric ton of libraries for Java and Scala out there, and as a consequence of Clojure's ability to use Java stuff, you have access to all of it. I admit I've not done a ton…

The data science story in Clojure is good and improving fast. Neanderthal is the fastest matrix library available on the JVM. Bayadera is ridiculously fast probabilistic programming (not to mention Anglican, which has a slightly easier API in exchange for perf). There's a lot of activity around Clojure bindings for MXNet, if you want deep learning. It's not mainstream Python, but it's far from limited by community or libraries.

Re: Why I Switched from Python to Clojure (2016)

#88
post #85
post #43

I can, and do, appreciate opinions on languages themselves. But my decision to continue using Python over Clojure is much less about the language's syntax and more about the available libraries. How do Clojure web frameworks compare to Django/Flask? What would I use instead of Pandas for data analysis? Are there keras-like deep learning tools? Switching languages based on a comparison of idiosyncrasies between the tw…

Clojure lets you leverage the entire Java library ecosystem, which is flippin' huge -- bigger, even, than Python's.

Except for numerics, which is my whole world, where Java is horrific roadkill. FWIIW back 8 years ago I was ---><--- this close to trying to build out an important system with wrapped Fortran in Clojure. People (who even then looked like they didn't know what they were talking about) assured me the JVM would eventually surpass lapack, because MUH JVM, and that has failed to come to pass.

Re: Why I Switched from Python to Clojure (2016)

#90
post #36

Earlier quoted context omitted.

It's not a "forest of parens" any more than any language with C style syntax is, they're just in different places (the correct places) and there's no need to distinguish with braces (which you shouldn't need to).

That’s not true. When you’re passing functions to functions inside functions that return functions... it’s a nested mess. I studied Lisp and Scheme at university and that’s where it had to remain for me: academically entertaining mind puzzles in data structures and algorithms. It’s just not productive or easily graspable from one coder to another.

Tasteful macros can alleviate this, and Clojure's std lib has a few which are just delightful.

The following does exactly what you'd expect, and there are even cooler ones like `some->` or `as->`.

    (->> some-nums
         (map square-root)
         (filter even?)
         set
         count)
This is what lisp buys you, dead simple rules for syntax, with the option to add syntax with macros. If you made a mistake in syntax design, deprecate the lib and make a new macro, it need not be a feature of core language for all eternity.
Post reply on HN