Live data from Hacker News

Why People Should Learn Python

iluxonchik.github.io

231–240 of 329 posts

Re: Why People Should Learn Python

#231
post #49

One my feeling about python is that is a great language for "reference". Probably everybody and write and read it and its already good enough for general programming. There are edges where other languages are better but still is a great language to establish communication among different types of developers

Yes, I've seen Python described as "everybody's second-favourite language". It's not the best at anything, but if your main requirement is a bunch of different people all need to be able to read and edit the same code then it's a good choice.

As a historical note, this phrase was originally applied to WordStar. Quoting Jim Mischel at http://www.mischel.com/diary/2005/08/22.htm :

> While I'm on the subject of WordStar, I've heard a story that I haven't been able to verify. When Phillipe Kahn was asked why he chose to use the WordStar command set in the first version of Sidekick, he said that he asked a lot of people for their editor preferences. Almost everybody had a different first preference (back then it could have been Emacs, vi, Word Perfect, WordStar, Brief, Leading Edge Word Processor, or who knows what else). But almost everybody he asked knew WordStar and named it as their second preference. I don't know if it's true, but it smacks of truth. Certainly every microcomputer programmer I knew back in the late 80s was proficient with WordStar.

Re: Why People Should Learn Python

#232
post #74

Earlier quoted context omitted.

At a glance, it looks like all languages are reasonably well loved except PHP and Node.js (shouldn't this just be Javascript? Does having a different standard lib make it a different language?) I think that's due to people having flash backs to terribly written code in both languages. For example, PHP apps pre-2005 rarely if ever used frontend controllers, preferring instead to twine in configuration and helper funct…

just to chime in on this, modern PHP is nothing like what people remember from the pre ROR days, i still use it to this day and the major frameworks and libs are really well written to the point i feel some are even over engineered and almost looking like Java (just take a look at the latest Guzzle PHP Library)

My day job is no longer to write code, but I have a couple of projects I work on at night, so take my opinion for what it's worth. I have one project that's mostly static content and a couple of calculator forms. On submit, I an ajax call to post to a PHP script, it returns a json object with some data, and I display it. When I see PHP getting ripped, I always wonder, what am I supposed to use if not this? I know this is relatively simple, but my choices were to do the calculations in javascript or let PHP handle it - and PHP seemed to me as the right choice because I eventually may want to capture some of the input data, send it to a db, etc.

Re: Why People Should Learn Python

#233
I have contemplated writing a "Why You Should Learn Bash" article and then maybe "Why You Should Learn Regex" followed by "When to not use Regex".

If you know bash you probably have a pretty good idea how to manage Linux and roughly how things work on Linux (you could apply this to other Bash capable OS as well).

If you know Bash fairly well you probably also know how to automate many things and you probably already know regex which is fairly useful in GSD. If you know Bash you obviously know the command line well.

You should learn Bash (or some shell but Bash is so ubiquitous).

Re: Why People Should Learn Python

#234

Earlier quoted context omitted.

Wordpress is horrible. Never going to touch that again (Senior PHP Dev myself) or anything else like it (Magento, Drupal,...). And yes there is a lot of horrible PHP code out there, writting by bad developers. I guess newer or not as accessible languages don't have as many bad devs as PHP/JS. But if you have good devs, I prefer a good PHP codebase to any other language that I have come across (I tried a lot of them).

Around 2001 I felt jaded with the industry and determined to do whatever was expedient to earn money. That meant using PHP, because that was purportedly the place to be at the time. I have never felt so uninspired by a language. My overwhelming feeling from the get-go was that it was a collection of libraries, which would be fine -- but why create a new language? PHP has the rare distinction among languages of not co…

Ten points for the reheated leftover bit.

Re: Why People Should Learn Python

#235

Is it just my feeling or are there languages which are preferred on HN? Indicators for languages which are liked by the HN community: - Positive stories get many upvotes and are instantly at the top of HN - Most comments are positive - Frequent coverage on HN about the language Indicators for languages which are not liked by the HN community: - Rants get many upvotes and are instantly at the top of HN - Most comments…

Ordering languages and frameworks by amount of 'love' (edited with small adjustments): ***** Python, Rust, Lisp ****' Go, Swift, C, PostgreSQL **** Elm, Elixir, Typescript, Haskell, OCaml, JS-ES6, Kotlin, Crystal ***' Scala, Lua, Clojure, Erlang *** C#/.NET, Java, C++, Ruby, JS-ES5, MySQL ** Node JS, RoR, Meteor, MongoDB * PHP, VBasic, Cobol, Coffeescript

I might rank the love for Elixir higher. Go has a lot of detractors, in addition to the people who are getting a lot done with it. Comments often seem to think Haskell or its community is a little ridiculous. Lua always gets positive comments, maybe a 3.5.

If we're including MySQL and PostgreSQL, SQLite should be way up there based on the universally positive comments. MongoDB might be ranked too high at 2, though people have begun to acknowledge that was because they tried to use it for the wrong task.

Re: Why People Should Learn Python

#236
post #226

Earlier quoted context omitted.

Around 2001 I felt jaded with the industry and determined to do whatever was expedient to earn money. That meant using PHP, because that was purportedly the place to be at the time. I have never felt so uninspired by a language. My overwhelming feeling from the get-go was that it was a collection of libraries, which would be fine -- but why create a new language? PHP has the rare distinction among languages of not co…

Since when did something need to have novel features or ideas in order to be productive? I'll counter that one of the main reasons PHP became such a used language (other than ease of deploy) is exactly the reasons you dislike it. There are multiple ways to do things - that coincide with the ways you do things in many other languages (which it steals from). You dont have to learn anything radically new to use it, and…

"Since when did something need to have novel features or ideas in order to be productive?"

It doesn't. But if your language ideas are admittedly no better than the next guy's, what's the point?

Re: Why People Should Learn Python

#237

Earlier quoted context omitted.

Imagine you have a list of products with prices and you want to calculate the cost of all products that are of a certain type. In ruby you can write this as products.select { |product| product.type == 'x' }.map(&:price).reduce(:+)

And in Python you can write something like: sum([p.price for p in products if p.type == "x"]) Excuse untested code from phone, but I like it better than the ruby version.

FYI, you can leave off the square brackets for a small performance boost. That turns it from a list comprehension into a generator expression, which is lazily evaluated and doesn't create a list container (which would immediately be thrown out anyway). It's like the difference between range(n) and xrange(n).

Re: Why People Should Learn Python

#238

Earlier quoted context omitted.

I'm curious as to what issue you're running into with npm? npm install pug --save , installs to your local project, and adds to package.json. Not sure how that can get any easier! Makes deployments silly simple as well, and the ecosystem is massive surrounding it.

* I sometimes had to run "npm i" twice in order to get it to work. * It would often fail randomly. * node_modules has a fixed location. * There is a ludicrous number of dependencies even for the simplest projects. ~1000 is not unusual. Reasoning about that dependency tree simply isn't possible. * There was even a package to detect if a number was negative. It had a version 2 because there was a bug! * In general even…

Certainly any dependency manager has its issues, and I've run into a lot of them with other ones as well. But yes, I will agree, the dependency hell comes from requiring duplicates for each package you install. Though NPM is working on resolving that. Not sure what you mean by age to build though? What are you building after package install?

Re: Why People Should Learn Python

#239
If only the JVM didn't have slow startup speed I would almost exclusively write Groovy scripts.

There is just something so awesome about shoving your dependencies right in the script and not worrying about pip, easyinstall, system libraries etc [1].

Maybe Java 10 will fix the startup speed (or whenever jigsaw is done correctly) but I doubt it.

[1]: http://docs.groovy-lang.org/latest/html/documentation/grape....

Re: Why People Should Learn Python

#240

Earlier quoted context omitted.

Show me an example that uses `reduce` with a function other than sum/product that makes it clearer than the equivalent loop.

Reduce doesn't have side effects, handles an empty collection, doesn't need to reference the index of the iterable, and self-documents the code as a fold. I find the last part nice because a loop or a Python comprehension would need to add a comment to explain what would otherwise be clear from the syntax. Here's an alternative example where I think it makes sense (checking if the size of all elements in a collection…

I don't think that does what you think it does:

  >>> reduce(lambda a, b: len(a) == len(b), ["a", "b", "c"])
  Traceback (most recent call last):
    File "", line 1, in 
    File "", line 1, in 
  TypeError: object of type 'bool' has no len()
It's trying to do len(len("a") == len("b")) == len("c"), which becomes len(True) == len("c"), and len(True) doesn't work.

Some variations which do work are:

  len(set(map(len, ls))) == 1
  len(set(len(x) for x in ls)) == 1
  all(len(ls[0]) == len(x) for x in ls)
  len(min(ls, key=len)) == len(max(ls, key=len))
Append "if ls else True" to handle the empty list.
Post reply on HN