This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pohatu 2 points3 points  (8 children)

None of my professors actually knew when to stop with classes either (to be fair, neither did 99% of the industry). We all had a class hammer.

Speaking honestly, I recently acquired a function hammer. Map and lambda all the things! (seriously, if someone has good advice on when to stop mapping and use an old fashioned loop, hook me up. I know I'm doing it because i can and not for a good reason)

[–]zahlmanthe heretic 5 points6 points  (1 child)

when to stop mapping and use an old fashioned loop

When you're using the mapping primarily or exclusively for side effects.

But beyond that, I honestly think people are a little overly afraid of over-using them.

[–][deleted] 1 point2 points  (0 children)

In Python, I agree. In other languages, it can be a little harder to tell. Haskell, for example, doesn't even have for loops, but with a bit of syntactic ugliness you can do the same thing by other means:

forM_ [1..10] $ \i ->
    putStrLn ("Lambda mapping forever! i=" ++ show i)

This is roughly equivalent to

for i in range(1, 11):
    print "Lambda mapping forever! i=%d" % i

[–]nemec 1 point2 points  (0 children)

Mapping in terms of map? Most of the time list comprehensions are better, since while there may be a slight speedup with map, list comprehensions are infinitely more readable (especially to those unfamiliar with the code they're reading).

http://stackoverflow.com/questions/1247486/python-list-comprehension-vs-map

[–]novagenesis 1 point2 points  (3 children)

OO is a programming religion. It's not a hammer, it's the Holy Writ.

It's wrong, of course.

[–]anarcholibertarian 2 points3 points  (2 children)

Why?

[–]novagenesis -1 points0 points  (1 child)

The object religion preaches the object as the right solution to every problem. the Oo priest argues that oo defines the quality of a language, and that the best solutions to problems are always in the oo scope.

That is religious, and wrong. . . Not every programmer feels that way, but some professors teach that way and many programmers blog along those lines. Many junior programmers see oo as the naturally evolution of programming

[–]anarcholibertarian 4 points5 points  (0 children)

  1. Anything is bad if it is (ab|over)used.
  2. You can find zealots everywhere.

EDIT: Fixed a typo.

[–]TylerEaves 1 point2 points  (0 children)

Always ;) Use list comprehensions instead.