Python Forum
Reasons to choose Python over C++? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Reasons to choose Python over C++? (/thread-3047.html)

Pages: 1 2 3 4 5 6 7


RE: Reasons to choose Python over C++? - micseydel - May-03-2017

RE: Java / Scala / FP - I feel embarrassed to say this but Java's lambdas put Python's to shame, and Scala wins FP hands-down. I had to write something where I applied a map, filter, map, filter and nested comprehensions are gnarly. Python's FP support is alright unless you want to really embrace FP.

I think FP and procedural have their places. But Scala has better multi-paradigm support, at least in the FP realm. Python is still my go-to language and I didn't know what I was missing FP-wise until the last year or so, but Python could stand to learn a thing or two (maybe pattern matching? definitely better lambdas).


RE: Reasons to choose Python over C++? - nilamo - May-03-2017

(May-03-2017, 04:51 AM)micseydel Wrote: I feel embarrassed to say this but Java's lambdas put Python's to shame

You shouldn't be embarrassed about that, it's pretty common knowledge that python has some of the worst lambda support.  Every time someone tries different syntax for it, gvr shoots it down.  And for good reason, because they all look pretty ugly (similar to what I'm running into here: https://python-forum.io/Thread-How-do-you-do-method-chaining).

Which kind of just kills fp, since naming all the little functions you pass around loses a lot of meaning, since you end up giving the functions stupid names like "temp" or "item_filter" just so you can have two line functions in a few places.

Even for single line functions, lambda is a heck of a lot of characters.  I think I'd just prefer parenthases personally, maybe like: items = filter( (item): len(item)>2, items).

But these are all minor arguments.  Really, I'm not sure what a good answer would look like while still having whitespace matter.


RE: Reasons to choose Python over C++? - micseydel - May-03-2017

(May-03-2017, 04:26 PM)nilamo Wrote: You shouldn't be embarrassed about that, it's pretty common knowledge that python has some of the worst lambda support.
Sorry, meant to say I'm embarrassed for Python, especially at this point in time. Like it should have been figured out by now. And Java isn't known as a great or progressive language.

I almost cited your method chaining thread as a FP deficiency of Python. I also prefer Scala (and Java for that matter) making map, reduce, filter, etc. be methods rather than functions. There's gotta be a way for whitespace and lambdas to work.