Live data from Hacker News

Why I Switched from Python to Clojure (2016)

bradcypert.com

51–60 of 200 posts

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

#51
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 have considered Python many times, but I cannot work with a language that considers whitespaces as required syntax. I just cannot work with it.

the downvotes are funny because this was exactly the criticism Python got before it became popular. Probably still gets it.

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

#52
post #36
post #32

Earlier quoted context omitted.

Only if you don't consider a forest of parens to be noise. I do. I'm sure I could get used to it after a while, but at first glance, Python code is definitely cleaner than Lisp.

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.

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

#53
post #33

Earlier quoted context omitted.

I always thought this made sense: a method, considered as a property of a class isn’t yet bound to any particular instance while, considered as a property of an instance has an implicit parameter of the instance you’re currently operating on: languages like Java hide this “this” parameter from you by passing it automatically while python makes it explicit so you can form a better mental model of what’s going on

The problem is that Python is the exception here. Those of us that learnt other languages first already have a mental model and find this explicit self parameter weird. And it's more typing. Yegge thinks that "self" is a wart and I agree. The article is a fun read but it's showing its age. I suspect Python might just have beaten Perl by now. https://sites.google.com/site/steveyegge2/tour-de-babel#TOC-... I suppose Py…

I also like how you can call the method on the class and pass self in explicitly. e.g.:

    class Foo:
      b = 4
      def foo(self, a):
        return a + self.b

    inst = Foo()
    inst.foo(3)
    Foo.foo(inst, 3)
I haven't written python in a while, but I really like that python makes this possible and obvious and I've found this behavior pretty handy when working in a more functional style.

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

#54

Earlier quoted context omitted.

I always thought this made sense: a method, considered as a property of a class isn’t yet bound to any particular instance while, considered as a property of an instance has an implicit parameter of the instance you’re currently operating on: languages like Java hide this “this” parameter from you by passing it automatically while python makes it explicit so you can form a better mental model of what’s going on

I think the way Lua handles it is much better. If you have object foo of class Foo with method bar, accessing it like foo.bar does no magic on it. You would have to call it as foo.bar(foo, ...) if you wanted to access the method with a dot. Only foo:bar will do the magic on it. If you call it as foo:bar(...) then the object will be passed to the first parameter. This follows "explicit is better than implicit" much be…

I'm no Lua expert, but isn't this because Lua's object model is more prototypical inheritance than a standard class-based model like python has?

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

#55
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 agree. Within the data science community I often see the question of "R versus Python" and it always makes me think of the Old El Paso commercial: ¿por qué no los dos?

I know choosing the right tools for the task can have serious long-term implications on the project, team, or organization level, but individually I get the impression that people worry too much about which language is best when, in reality, many of them are perfectly suitable and appropriate.

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

#56
post #33

Earlier quoted context omitted.

The problem is that Python is the exception here. Those of us that learnt other languages first already have a mental model and find this explicit self parameter weird. And it's more typing. Yegge thinks that "self" is a wart and I agree. The article is a fun read but it's showing its age. I suspect Python might just have beaten Perl by now. https://sites.google.com/site/steveyegge2/tour-de-babel#TOC-... I suppose Py…

I also like how you can call the method on the class and pass self in explicitly. e.g.: class Foo: b = 4 def foo(self, a): return a + self.b inst = Foo() inst.foo(3) Foo.foo(inst, 3) I haven't written python in a while, but I really like that python makes this possible and obvious and I've found this behavior pretty handy when working in a more functional style.

Also, I find writing languages with an implicit self like Java, Kotlin and Scala really irritating because there's nothing to distinguish access to a locally-scoped variable or function from access to a class member. I've always appreciated how, in Python, `x` always refers to something bound according to Python's pseudo-lexical scoping rules while class members always have a `self.` to make them stand out.

These days, however, I mostly write Common Lisp and Clojure which, each in their own way, have explicit selfs: Common Lisp because it uses multiple dispatch and, consequently, there isn't one "self" and Clojure's protocols are designed to dispatch on the first argument, which is always passed explicitly.

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

#57
post #29

Earlier quoted context omitted.

I haven't got much experience with Lisp, but I can imagine that, similarly to Python's significant indentation, it's a shallow weirdness that can be overcome easily after a little while. In both cases a little help from the editor will probably be needed.

You will shoot yourself in the foot less often with Lisp parens than you might with Python whitespace. Most modern editors handle the closing parens anyway. Plus, many editors without any plugins can jump between matching braces; so moving around the code is very quick compared to Python (unless you have a Python plugin that has block movement shortcuts).

> You will shoot yourself in the foot less often with Lisp parens than you might with Python whitespace.

I'm not letting that stand ;-)

In my experience Python's whitespace generally removes sources of scope/block errors compared to parenthesis and curly-based languages

> unless you have a Python plugin that has block movement shortcuts

Not sure what this means. The only support I need in an editor is the ability to use tab and shift tab on blocks of text to change the indentation level. It's visually obvious when code is correctly indented.

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

#58
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…

rails/Django -> luminous

Flask -> pedestal/clojupture

Relay -> fulcro

Pandas -> clojure.core, specter

Keras -> mxnext/neanderthal

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

#59
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 generally has pretty good library support: the JVM has several high-quality web application servers: Jetty, Netty, Tomcat, Glassfish, etc. And, being a Lisp, Clojure can wrap these with a nice interface. The same is true in other areas: you have very nice access to the entire JVM ecosystem and really-well designed interop with the host language's concepts so, to a large degree, you never run into a situation where you can't do something because there isn't a good library for it: at work, we regularly use Kafka, Avro, Elasticsearch and several other major data systems and we mostly just use thin wrappers around the official Java implementations of the clients for these systems.

Similarly, when connecting to a database like Oracle, it's trivial to just use JDBC/etc. while, for example, my coworkers who are using Haskell generally have to write a Java gateway because there aren't well-tested clients for Haskell.

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

#60
post #34
post #31

Earlier quoted context omitted.

This is just blaming people for using Clojure's features though. If deep JVM integration wasn't a selling point, you'd use a vastly more mature Lisp, right?

A lot of us use Clojure despite the JVM, not because of it. Closure has a lot of (other) compelling features.

I mostly write Clojure because, unfortunately, it's nearly impossible to sell management on Common Lisp: ime, Clojure is a nice language, but it's very uneven because it's well-designed for the sorts of things the core team cares about and everything else is barely passed the MVP stage.
Post reply on HN