4 ms·
This. Most schools are moving away from C or Java being their primary language. Most comp sci professors acknowledge the usefulness of a scripting language and
by schneems 9y ago
This. Most schools are moving away from C or Java being their primary language. Most comp sci professors acknowledge the usefulness of a scripting language and so when they need to pick one, they pick one they have the most familiarity with. Due to numpy and scipy this tends to be Python over Ruby.
Also many things about python that I don't like such as `len` being a function rather than a method on a list are very trivial when coming from a language like C which has hordes of tiny inconsistencies.
The whitespace thing in python is pretty gimmicky but does also hold a certain amount of pedantic appeal.
- xapata 9y agoThe Python design FAQ explains why Len is a built-in function instead of a method. Guido wanted a guarantee that whenever he called it, it'd return a whole number. As just another method, you might find a new type that defines a length in fractional terms, which would break any code wanting to use that as a list index, etc.
- goatlover 9y agoBut that would be on your for misusing the length method. All the built-in and popular libraries would still define length properly.
- xapata 9y agoPerhaps, but "your" mistake might impede the popularity of the language. A wide range of well-designed community libraries are a major reason to choose Python. Take a look at the design rationale for the new __matmul__ magic method. It's not for the standard library, it's for the community.
- antonvs 9y agoThe need to do that reveals a couple of weaknesses (or more charitably, tradeoffs) of Python: lack of type constraints, and (related) lack of well-defined, invariant interfaces on objects.
- xapata 9y agoTrade-offs indeed. Magic methods indicate the use of interfaces defined by traits rather than formal types. Duck Typing. It's flexible. But you can also see that Guido has been into types lately. He's been pushing the development of mypy and the new optional type system.
- dom0 9y agoRuby is just used rarely outside RoR, realistically speaking.
- trcollinson 9y agoActually, you should qualify that a bit more. Ruby is rarely used outside of Ruby on Rails in North America. In Japan, it is widely used and Ruby on Rails is fair less common.
- ksec 9y agoWhat were Ruby used for in japan?
- goatlover 9y agoProbably anything that Perl and Python are used for.
- trcollinson 9y agoRuby is a very versatile language in its own right. While the other poster is correct that it is used for anything that perl and python are used for it's also taking a large chunk from the Java and C# crowd in Japan. Everything from server side applications to command line tools and even GUI based desktop applications can be written in Ruby. Using FFI I have made some quite amazing applications with Ruby. Rails is amazing and I personally love it. But it's not the only thing Ruby is good for.
- rpazyaquian 9y agoWell, true, you have a point. Ruby is rarely used outside of Rails. Which is a shame, really.
- schneems 9y agoGo to Japan.
- submeta 9y agoWhitespace is no issue with a good editor (Sublime, vim, emacs...). I dislike the many inconsistencies in Python. You mentioned one. Others: sort vs sorted (destructive vs non destructive). Also: not being able to chain methods because many don't return a value. (Scheme, Elixir or even Ruby are imho much more elegant.) But all in all Python is a very useful programming language with a rich eco system.
- xapata 9y agoThe Python design FAQ explains that .append and .sort return None to remind you they are mutation methods. I find this more elegant than Ruby, etc., where many things look like pure functions but aren't. https://docs.python.org/2/faq/design.html#why-doesn-t-list-sort-return-the-sorted-list https://docs.python.org/2/faq/design.html#why-doesn-t-list-s...
- submeta 9y agoI know the reasons why and how mutating methods work in Python. Nevertheless I find this here much more elegant: data.sort.tail.first # or this data.append(7).append(3) More elegant than this: sorted(data)[1:][0] data.append(7) # and then data.append(3) I love method chaining in Elixir or Javascript. In Python I have to create temp variables here and there to capture / further process intermediate results. Having said that: Python has it's strengths. I use it more than any other programming language.
- xapata 9y agoI understand the preference and the difficulty created by methods and operators that are essentially statements instead of expressions. However, when making that criticism we should also acknowledge the benefit of requiring or encouraging multiple lines for those actions. if (x=42) {} Has burned many people. Append having a useful return is comparable, though probably not as much of a trap. > sorted(data)[1:][0] I don't want to get into the weeds, but shouldn't that just be sorted(data)[1] Or if you like unpacking for clarity first, second = sorted(data)[:2] ?