r/functionalprogramming • • Sep 06 '17

Python Using Python... Struggling with inconsistency...

I'm mainly working with Python at the moment. Most people in my company are using oop, which is kinda "natural" given the choice of the language. In general, I don't like oop. I prefer simple solutions to complex ones when they can solve the same thing and oop adds one layer of abstraction to functions. I value consistency and explicity. I hate it that in Python sometimes you call by reference and sometimes by value and there's no apparent model behind it. Most people are using oop coz they dont care as much about which paradigm to use and it's always easier to argue for oop since "everything is an object anyway" (which is not entirely true and how is that a valid argument..). Is there a way to be more "functional" with Python? Are there good argument against using oop? Or maybe I should just give up and go with the flow...

7 Upvotes

28 comments sorted by

View all comments

Show parent comment

1

u/graemep Sep 08 '17

Yes, I get it, and I am very interested in other languages, especially functional ones. I keep studying them (doing an Erlang MOOC right now) but I always end up using Python - I have clients with Python code bases, and I do stuff that has Python libraries, ad I can get Python work because I have Python experience.

I found Pike's attitude very off-putting too. What sort of people are Google recruiting? At the other extreme, I find Haskell very hard to get to grips with, and that is a problem too.

a programming language for people that hate to program

I disagree with that (its the only thing I do disagree with) - a lot of people who like programming like Python too. Of course there is a big element of fit and personal preference.

Though, oddly, I didn't mind Ruby's OOP for some reason; maybe due to its Smalltalk influence?

Have you tried Smalltalk itself? Pharo is nice implementation, although, again, for various reasons it does not fit what I do (although some recent changes may make me look again).

1

u/ws-ilazki Sep 09 '17

I always end up using Python - I have clients with Python code bases, and I do stuff that has Python libraries, ad I can get Python work because I have Python experience.

You might like Coconut (I linked to it in another comment) then. Python superset with some ML-ish functional leanings, so you can use all the libraries and fall back to normal Python code whenever it's convenient, but with nicer FP as well.

I found Pike's attitude very off-putting too. What sort of people are Google recruiting? At the other extreme, I find Haskell very hard to get to grips with, and that is a problem too

I get why they're making a language like that, but it's just not for me, and Pike's a terrible spokesperson for anything. If you think that stuff's bad, you should look into his opinions on syntax highlighting, where he compares people using it to children that need to grow up. I'm not joking, or even exaggerating, with this. :/

As for Haskell, I agree. It's a nice language, but a bit too academic for my taste. I get along better with other ML-family languages like F# or OCaml, if I go that route, though I still tend to prefer lisps, like Racket and Clojure.

I disagree with that (its the only thing I do disagree with) - a lot of people who like programming like Python too

Oh, of course. I didn't mean that you have to dislike programming to want to use Python; I meant that it's a language that's well-suited to people that just need to get a result and don't care at all about the programming required to do it. They're the types that need enforced indentation rules and other aspects of Python's rigidity, because they're non-programmers that occasionally need a program, rather than programmers.

Have you tried Smalltalk itself? Pharo is nice implementation, although, again, for various reasons it does not fit what I do (although some recent changes may make me look again).

I actually have Pharo installed, spent a little time experimenting with it. I didn't go into enough depth to have a strong opinion, but its OOP seemed fine as well. As with Ruby, the focus on the message passing instead of the objects makes more of a difference than one might initially think.

Another cool thing is how the whole thing is image-based. You can see sort of what Java was trying to emulate with its classpath- and object- based (rather than filesystem and file based) JVM design, and it's honestly quite interesting. Sort of related, there's a Clojurescript IDE called Nightlight that is somewhat like the Smalltalk design. It's an IDE that runs as part of the CLJS project itself, for that extra bit of interactivity with the project.