4 ms·
I use Python every day and I like it. However, functional semantics are not elegant at all IMO. Using list() and map() all over the place is not cool, and like
by arcturus17 4y ago
I use Python every day and I like it. However, functional semantics are not elegant at all IMO. Using list() and map() all over the place is not cool, and like many others say, list comprehensions, though concise, are not always that readable (and I say this as someone who reads and writes plenty of them). Lambdas are not great, either.
In Django in particular, async feels like an afterthought, compared to other frameworks where it's first class.
- empthought 4y agoPython lambdas are not great but Ruby not having first-class functions is also not great. Neither are perfect and there is no syntactic reason outside of variations of personal taste to choose one language over the other. There are a boatload of compelling reasons to choose Python for its libraries and documentation and adoption level, though.
- arcturus17 4y agoI didn't know Ruby didn't have first-class functions but that's already a massive no for me. You don't need to convince me regarding Python though - it's too convenient to pass up. And despite its shortcomings it's certainly not a language devoid of elegance like some in this thread are painting... Like the old adage goes, there's the languages nobody uses, and there's the languages people talk shit about. Or in simpler terms, as seen in this thread: "everything I don't use is utter shit".
- djur 4y agoI have no idea what they mean by Ruby not having first-class functions. Of course it does. It's a fundamental feature of the language.
- empthought 4y agoNo it does not. Ruby has first-class procs. They are not the same thing. It's a fundamental flaw of the language. It's in the Wikipedia page. https://en.wikipedia.org/wiki/First-class_function https://en.wikipedia.org/wiki/First-class_function "The identifier of a regular "function" in Ruby (which is really a method) cannot be used as a value or passed. It must first be retrieved into a Method or Proc object to be used as first-class data. The syntax for calling such a function object differs from calling regular methods." Why do people like you insist on talking about things you don't actually know about?
- djur 4y agoThe Wikipedia article is wrong. A proc is a function. The misunderstanding here is confusing methods with functions. "def foo" defines a method, not a function. That same article claims that Java has first class functions on the basis of anonymous inner classes, that C# has them because of lambda expressions, etc. OCaml has different syntax for functions and methods. Does that mean it doesn't have first-class functions? You should really consider whether this is an important enough topic to be worth personally insulting people over.
- empthought 4y agoRuby doesn't have first-class methods, either. Python has both first-class methods and first-class functions. > In computer science, a programming language is said to have first-class functions if it treats functions as first-class citizens. This means the language supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data structures.[1] OCaml has first-class functions, the names can be passed around as parameters and returned as values. Ruby functions and methods cannot; only Proc objects and Method objects proxying for them can be. You should really consider whether pointing out your incorrectness constitutes an insult and why you think this is so.
- djur 4y agoEverything is an object in Ruby. Proc objects and Method objects _are_ functions. The same is true in Python -- functions are instances of the 'function' class. What's the difference between a proc and a function? Nothing. "[P]eople like you insist on talking about things you don't actually know about" is insulting language. Consider discussing this with some people you know in real life to see what they think.
- empthought 4y agoYou can’t use a Proc or Method value directly to call a method with the Ruby method invocation syntax! In Python and JavaScript and Scheme and OCaml you can! This is the whole idea behind “first-class.” Whether “everything is an object” or not is irrelevant.
- arcturus17 4y agoNoted. I've read the rest of the conversation and it's very interesting.
- jonnytran 4y ago> Ruby not having first-class functions This is simply false. Ruby has first-class functions. Not only that, it has blocks, which few other languages have. Ruby optimizes for the common use-case of a method that takes a single callback/piece of code, and I miss it in most other languages, including Python. In Python, the "with" statement is super special. But in Ruby, it's just a method that takes a block. And any method can take a block, not just one per class. https://yehudakatz.com/2010/02/07/the-building-blocks-of-ruby/ https://yehudakatz.com/2010/02/07/the-building-blocks-of-rub...
- empthought 4y agoRuby does not have first-class functions. Why do you insist on sounding so sure about something you are so wrong about? https://blog.appsignal.com/2018/09/04/ruby-magic-closures-in-ruby-blocks-procs-and-lambdas.html https://blog.appsignal.com/2018/09/04/ruby-magic-closures-in...