Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Will I Regret Choosing Python Over Clojure?
12 points by scobar on Apr 30, 2014 | hide | past | web | favorite | 14 comments
Because I've delayed learning a high-level programming language for too long, I have not developed a strong bias toward any in particular. I will code a web app for my current project whose main function will be a search engine for a local index of profiles. From preliminary research, I'm convinced that Lisp or Python are great choices. I've begun learning and will become proficient in both (I've chosen Clojure as the dialect of Lisp). I've found a lot of very good resources to get me started with Python, and therefore I'm leaning more towards Python with Django for my web app.

Some smart hackers evangelize the power of Lisp over other languages. The main advantage, as I understand from my novice perspective, is the ability to create and use macros. Is there anything I should be aware of that may cause me to wish I hadn't chosen Python over Clojure to code the prototype? In my ignorance, I may be asking that you infer too much before answering. If you need more explicit info for my specific situation, then please ask. Thank you very much for your time.

Use the language that lets you build things fastest. Especially since you keep using the word prototype. Once you prove it is working, you can make it beautiful, use fancy languages or throw money at the problem.

Thank you for your response. I intend to use Python because I'm more familiar with object-oriented style, and already have learned more about Python than Clojure. So I assume I'll be able to build things faster with Python.

I was asking HN if anyone could see any future problems that were not obvious to me. I understand the project will change and adapt to improve, but I prefer to avoid wasting time converting to fancy languages or throwing money at the problem.

There could be several future problems that you could optimize around. Speed, usability of API, NLP aspects of the problem, integrating with off the shelf solutions and so on. It really depends on what you want. If you want to learn a language for the sake of learning it, more power to you. Go forth and pick one of those. Python is fun. I have heard amazing things about Clojure. If you want to ship, just ship!

A coworker of mine said something amazing the other day: Whilst an Architect worried about Python vs Scala vs Java, someone shipped in PHP.

It appears that my perspective is ignorant of too many possible challenges I may face. I just need to build it, and react the best I can when a problem becomes apparent. Thank you for making this clear.

That is alright, though. This is the nature of things. For everyone, really.

What's your low-level prog lang experience? When you say search-engine, do you mean the actual indexing will be written in python, or will you be integrating w/ something else?

Finally, is your current project a school project, a hobby project, or a work project?

I learned some cs theory and basic programming with Component Pascal in 2 college semesters. I played around with Basic as a kid, and became familiar with HTML and Javascript by building websites as a hobby for about 12 years. I used the scripting language AutoIt to code programs to automate tasks in the Windows environment. I'm not as familiar with Linux as I should be, but I will dive back into it.

Yes, the web app will allow the creation of profiles, and then index those profiles. The search engine will return a ranked list of profiles based on query parameters. I do not know enough yet to understand how much of it I will have to code myself, or if something already exists that I can integrate with.

My project is my startup. My income comes from side projects.

It sounds like you are not in a situation in which taking a technological dead end would be catastrophic, so I would advise following whatever path seems most interesting to you, and not worrying too much if it's the "right" thing.

That said, here's my 2ยข.

I have a background in C++, straight C, Python, and Objective-C, and have dabbled in a bunch of other languages. In Python, I have worked on a backend for real-time routing app (which wrapped a C++ routing core); a frontend (in Qt) for a scheduling application (that embedded a C++ optimizer); and am currently working on a backend for a social app.

I have no experience w/ clojure, though it seems very interesting; the most salient feature (from my outside perspective) is its encouragement of programming using immutable datastructures. I have some experience w/ macros from emacs lisp and dabbling in scheme, and I would encourage you to avoid them -- macros are basically an easy way to define a new language, which isn't something you should be doing unless you have a really good idea of why you are doing it. (But other people would disagree w/ this.)

As for Python, it's a lovely language, but beware:

(1) It's slow. This is something that doesn't matter until suddenly it does; people will just say you should "write the slow bits in C", which I have done, but I would strongly advise against because

1a. Integrating C and python is a pain-in-the-ass; imagine all the normal pain of a compiled language, and multiply it by maybe 3

1b. It's actually a very hard optimization problem to find a computational core that can be called infrequently enough that the overhead from Python->C doesn't kill you. I suspect that for many programs, this cut occurs at "the program essentially written in C".

(2) It's dynamically typed; this is an eternal flameware, but I'll just say the longer I've been programming, the more I appreciate having as many compile-time checks as possible. Think of types as an incredibly comprehensive set of tests that were written for you for free. If you do use python, I strongly recommend using something like pyflakes or pylint.

I can't speak to clojure. :)

I might also consider something like Go -- it's simple, it has a reasonable set of static guarantees, and it performs reasonably quickly. But I've only experimented w/ toy programs so far -- caveat emptor!

And good luck :)

Your first point is accurate. I will likely start with Python because that's what I'm most attracted to currently. I want to thank you for taking the time to offer your advice with such a thoroughly written explanation from your POV. I will check out Pyflakes and Pylint. I was already intrigued by Go, so I'll learn and dabble with it for fun programs. I really appreciate your help.

Clojure is less broadly marketed than Python in the sense that the supporting materials often feel like there is an implicit assumption that the reader has a background in Java or Common Lisp. Python on the other hand is marketed like Basic or maybe Pascal, and there are many many warm fuzzy introductions - they may not be very good but they are very gentle.

Which one? Well for scripting, if it's just one or the other Python. For something big and performant, Clojure. For a pure intellectual exercise, Clojure again. For broadening a resume, probably Python.

Thank you for your response. From my experience, you're very right about resources to learn Python being very beginner-friendly. I believe I can build the prototype faster in Python, so that's what I'll do.

I don't care how my resume may be affected, so that's irrelevant to my decision. The idea of a language that evolves with the project is too tantalizing to ignore. So, I'll learn Clojure by writing fun side-project programs with it. From what I've read, learning both languages well will make me a better programmer anyway.

For side projects, have you considered Racket? Like Python there's a beginner friendly ecosystem - it might be argued that it has a better one based on Racket being the product of several decades of research into the problem of teaching programming languages.

Being a Lisp, it doesn't have the backwards/forwards compatability issues of Python 2/3 and of course has the Lisp goodness of Clojure [1].

Unlike Python, the community tends to row in the same direction because the active development community is strongly rooted in academia. This also means that just about every software theory gets rolled into the ecosystem as someone's graduate thesis or a professor's publish or perish publication. Yes, I'm a fanboy (but if it's any excuse it's because I'm a Lisp fanboy).

Another option for learning FP is Scala and Functional Programming Principles in Scala by Martin Odersky just started on Coursera [Odersky designed Scala]. Like Clojure, Scala runs on the Java Platform, and is designed to address some of the same programming issues.

Racket: http://docs.racket-lang.org

A long but great presentation on Scala: https://www.youtube.com/watch?v=LH75sJAR0hc

Odersky's Course: https://www.coursera.org/course/progfun [2]

[1] And you can tell your friends that you are using the same programming stack as was used by PG for Hacker News even if it's a bit of a stretch it does have some snob appeal.

[2] Odersky's course is loosely based on SICP but using Scala.

I hadn't considered Racket nor Scala. The first I'd heard of Racket was while reading about Arc. Thank you very much for the suggestions, and for the links to get started.

It's off topic from my original question, but what's your opinion of Arc? Is it a good idea to try to learn it as my first FP/Lisp language, or learn another first and explore Arc afterward?

Many of the issues PG addresses with Arc are those he encountered as a professional programmer in Common Lisp - the project is more analogous to Clojure or Scala than Racket in that way. That's not to say that you can't use it. People have worked through SICP in Arc. The question is what makes this better than MIT Scheme or Racket?

I've read through PG's tutorial. It claims to be for anyone, but there's a lot of discussion about fairly specific Lisp idioms - I don't think it's all too beginner friendly. In fairness, introductory tutorials where the messy interwoven details of the real world are left out doesn't seem to be consistent with PG's thinking, I don't think he's a big fan of dumbing things down, but I could be wrong.

Unlike Racket, Arc is very much batteries not included. And there aren't libraries full of them. Almost anything you want, you will need to build yourself. It's the hard way that's harder than Zed Shaw. Think On Lisp sort of programming.


--- Edit ---

What the hell, I'll just go all in.

If you're serious about Functional Programming, then why not Haskell? The documentation and community is pretty strong and it forces you to think about side effects and use strong static typing.

I don't like Python. I've tried and I've tried. Parenthesis may be visually unappealing, syntactic white space is mentally unappealing. And the whole 2/3 incompatibility suggests IE 6 and Cobol [which I find Cobol actually interesting with it's focus on data and emphasis on readabiilty]. Maybe if I was doing scientific computing, I'd use Python, but only if I could not afford Mathematica.

To me, and one of the reasons I wanted to like Python is that I grew up watching Flying Circus in the 70's, turned my son on to Holy Grail when he was five [thereby giving him an excuse to blame me for his adult problems], and have the 16 Ton DVD's. But my snarky conclusion is that Python needs the gimmick to distract attention from it's warts. It just doesn't work for me, though. Spam and eggs is cute, but it the effort might have been better spent.

Python is better designed than JavaScript. But JavaScript is unapologetically kludgy as to merit respect.

I do like Ruby. It's design is elegant and for general scripting, it's going to be just as fast. Mix in mixins for objects and blocks for higher level function passing and it's got a lot going for it. One of the big things for me that it has over Python is explicit `end` statements for blocks - Python ends blocks by indentation which means that formatting errors can give GOTOfail type errors.

Coming back to Scala, it reminds me of ML. It has the same sort of light syntax. The only reason I wouldn't use it over Python is the overhead of the Java platform - if you've got Java's libraries, you probably don't need Python's.

If you're on Windows, then C# and F# and TypeScript make a lot of sense. Lot's of documentation, lots of libraries, solid IDE, and the equivalent of the JVM you get for free.

Prolog is pretty cool. I here Smalltalk changes the way people think about programming, and I've toyed with learning Drakon.


Registration is open for Startup School 2019. Classes start July 22nd.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact