5 ms·
> Beside python has pretty awful support for functional programming That seems counter to my experience and understanding of things. Python has adequate suppor
by optimuspaul 8y ago
> Beside python has pretty awful support for functional programming
That seems counter to my experience and understanding of things. Python has adequate support for functional programming. And bonus you can mix in some object oriented things as well.
- sevensor 8y agoWhat Python has, is really good support for procedural programming. You can write pure functions when it makes sense, and you can write side-effecting procedures wherever you want. You have a bag full of useful data structures, and an extensive standard library to hand. Python's biggest drawback for me is that it's what I'd call a "surprisingly typed" language. Values in Python are strongly typed, but we pretend they're not. Until, surprise! AttributeError! That thing isn't what you thought it was. Optional typing has started to help with that.
- pmoriarty 8y ago"Values in Python are strongly typed, but we pretend they're not. Until, surprise! AttributeError! That thing isn't what you thought it was." Strongly typed? Maybe you mean statically typed? From "What To Know Before Debating Type Systems"[1]: "Probably the most common way type systems are classified is "strong" or "weak." This is unfortunate, since these words have nearly no meaning at all..." [1] - http://blog.steveklabnik.com/posts/2010-07-17-what-to-know-before-debating-type-systems http://blog.steveklabnik.com/posts/2010-07-17-what-to-know-b...
- sevensor 8y agoNo, I don't mean statically typed. Python is dynamically typed. But it's typed nonetheless, and types in Python matter way more than it appears at first glance. There's no such thing as an untyped value in Python. This is the opposite of C, which is statically typed, but where void* opens the door to doing great and terrible things. I guess you could also call C's type system "surprising", except the surprises aren't cute and annoying like Python's. C's type system is surprising like being defrauded by an accountant is surprising -- everything seems fine for years, and then it all falls apart.
- bunderbunder 8y ago"surprisingly typed" is a good term. It sounds, though, like you're using it to mean "dynamically typed", which is maybe overly harsh. What I think it captures well, though, is an unfortunate habit among many dynamic languages' communities to pretend that types don't matter. Python is getting better, but it used to be really bad about this. The standard library's documentation, for example, would give only the names of a function's parameters, and leave it to you to figure out, presumably by guess and check (and prayer), what kind of input it was prepared to accept. It's still really common for the documentation to force you to go to the REPL to ask a function's return value what its type is.
- sevensor 8y agoI work in Python day to day and have done for several years, so I think I'm entitled to describe Python's type system as "surprising." I generally think duck typing is great, and I always appreciate the flexibility it gives me. But the flip side of that is -- surprise! -- you can't use me as an index! -- surprise! -- I'm not hashable! -- surprise! -- you can't pickle me!. I've been looking at how other languages handle this, and I think typeclass / trait systems seem to strike a good balance, allowing flexibility without surprises.
- bunderbunder 8y agoThe typeclass approach can be just as surprising. Possibly more so, because it means that a type's implementation of a class can come from literally anywhere. So the universe of surprises still includes "Surprise! It's not hashable!", but now also includes, "Surprise! It was hashable, but now isn't, because you stopped importing this seemingly unrelated package." If you do get surprised that X doesn't support Y, though, you have ability to provide your own implementation without resorting to monkey patching.
- sevensor 8y agoThat's a good point! I suppose the grass is always greener...