Live data from Hacker News

Homogenization of scientific computing – Python is eating other languages’ lunch

r-bloggers.com

181–184 of 184 posts

Re: Homogenization of scientific computing – Python is eating other languages’ lunch

#181
post #128
post #95

Earlier quoted context omitted.

Deliberately-straightforward -- agreed. But "highly proficient" after writing one or two scripts? That's quite a stretch. For instance, one of the questions I give in phone screens is for the candidate to write a program to count the number of occurrences of unique words in a text file. The "after writing one or two Python scripts" approach is something like this: counts = {} f = open('test.txt') lines = f.read().spl…

My solution: lines = [line for line in open("bible.txt")] words = [word for line in lines for word in line.split()] counts = {word:0 for word in words} for word in words: counts[word] += 1 No imports needed. Linear time. A bit inefficient in the dictionary comprehension, but easy to read. The "lines=" and "words=" can be compressed into one line, but I figure this is a bit easier to read for people who aren't familia…

I'm not too familiar with Python, but this is case sensitive unlike benhoyt's examples. Would this be case insensitive?

    lines = [line for line in open("bible.txt")]
    words = [word.lower() for line in lines for word in line.split()]
    counts = {word:0 for word in words}
    for word in words:
        counts[word] += 1

Re: Homogenization of scientific computing – Python is eating other languages’ lunch

#182

Earlier quoted context omitted.

I agree with collyw; Lisp is too much for most scientists, who just care about getting their research done and can't be bother to learn all this weird FP/paren stuff [1]. Supplying an obvious, familiar syntax that looks like math written on paper for, e.g., matrix operations, is critical. This is actually one of the core tensions in Julia development imho: balancing having a sane, well designed language (from a progr…

Just relaying the response you will get from most practicing scientists who are not trained as programmers. Is it that hard of a gap to cross? I was a math major who took a couple CS courses, and wouldn't say I was "trained as a programmer". I found Scheme pretty easy to get from the go. I tend to think that anyone who can get a PhD in the physical sciences can become a half-decent programmer-- if the desire is there…

It's less a matter of ability and more a matter of having the time/motivation. If you took a bunch of practicing natural scientists and/or engineers and forced them somehow to enroll in a course teaching Scheme/Clojure/etc., would many of them do well? Almost certainly. If you gave them the choice between a Lisp and something like Julia or MATLAB to use in their everyday work when they need to do some computation? They'll probably choose the later because it's easy and familiar and doesn't have a huge up-front time investment; scientists tend to be very busy people.

Re: Homogenization of scientific computing – Python is eating other languages’ lunch

#183
post #128

Earlier quoted context omitted.

My solution: lines = [line for line in open("bible.txt")] words = [word for line in lines for word in line.split()] counts = {word:0 for word in words} for word in words: counts[word] += 1 No imports needed. Linear time. A bit inefficient in the dictionary comprehension, but easy to read. The "lines=" and "words=" can be compressed into one line, but I figure this is a bit easier to read for people who aren't familia…

I'm not too familiar with Python, but this is case sensitive unlike benhoyt's examples. Would this be case insensitive? lines = [line for line in open("bible.txt")] words = [word.lower() for line in lines for word in line.split()] counts = {word:0 for word in words} for word in words: counts[word] += 1

yes!

Re: Homogenization of scientific computing – Python is eating other languages’ lunch

#184

Earlier quoted context omitted.

Oops, you're right. words = open("test.txt").read().split() [(k, len(list(g))) for k, g in groupby(words, lambda x: x)]

Doesn't that require an "import itertools"?

Yup. Sorry.
Post reply on HN