6 ms·
This is really the same as saying, "I won't work for company X because I don't think the brackets in the C++ code should be on the following line[1]!" [1] E.g.
by pyre 14y ago
This is really the same as saying, "I won't work for company X because I don't think the brackets in the C++ code should be on the following line[1]!"
[1] E.g.:
int main() {
}
vs.
int main()
{
}
This is an apt analogy because most companies will have some sort of code style guide that you have to follow, which doesn't make "coding at company X where bracket placement is enforced" much different from "coding in Python where whitespace is enforced."
I've yet to come across someone that had a severe hatred of Python due to the significant whitespace that was a programmer I respected. The last person that I knew (who had a visceral hatred of Python whitespace) wrote Perl code like this:
sub func1 { shift->func2(shift)->func3(@_) }
or
sub func1 { grep { $_[0]->func2($_) } $_[0]->func3() }
Note: These are literally code samples with the function names changed.
I don't know any Perl programmers that would condone this sort of code. It's a maintenance nightmare, especially since these were not one-off instances. Seems to me that the people that have a hatred of Python's handling of whitespace don't like being 'constrained' by their language, and are probably happier with Ruby or Perl.
- berntb 14y agoThere are some problems with the whitespace in Python. I wrote some code with lots of nameless functions as input parameters (think JavaScript style or Ruby blocks), which of course was an ugly pain to port to Python with no multi-line lambdas. List comprehensions is another example -- a kludge coming from that the lack of multi instruction lambdas stop real map functions. (The fun part is that this necessity is touted as something good, instead of admitting that it is unnecessary complexity to learn.)
- spacemanaki 14y ago> There are some problems with the whitespace in Python. > I wrote some code with lots of nameless functions as input parameters (think JavaScript style or Ruby blocks), which of course was an ugly pain to port to Python with no multi-line lambdas. As nnq points out elsewhere in this thread, this doesn't have anything to do with significant whitespace. Python only allows you to have a single expression in the body of a lambda, and from what I've read the reason it stays this way is to discourage using a lambda as an argument to map, fold, filter & friends. The usual suggestion from Python programmers is to just use a locally defined, named function, which to be honest is often what I do anyway in languages like ML, because it's clearer. And anyway, just because it was hard to port some code from language A to language B due to something different about B doesn't really seem like a valid knock against B.
- berntb 14y agoMy argument was that a lack of real anonymous functions (> 1 instruction) is a problem in some quite common and useful scenarios. If you REALLY can give good references that show this is wrong, I'm very interested (like, I would guess, most Ruby users). (It would also be interesting with a link to a PEP or something with, as you claim, arguments that map etc should be discouraged -- and that is why no multi line lambdas exists. For instance, how would the syntax look like??)
- dangerlibrary 14y agoFor most use cases where you want map/filter/etc, you can chain list comprehensions using generators.
- berntb 14y agoYou have no relevant comment on what I wrote either, I take it? Here I asked for references about the GP's claims. Also, welcome to HN (or are the prepared troll accounts with a few hundreds of Karma running out? :-) ).
- pyre 14y ago| (or are the prepared troll accounts with | a few hundreds of Karma running out? :-) ) Keepin' it classy.
- berntb 14y agoConsidering the way Python people have been trolling most every Perl discussion for the last few years when I've been on HN, I feel like I'm in orbit compared to people in the mud... I might also note that I got two non sequitur answers in a row, so a joke like that is imho not an extreme reaction. Hardly as sarcastic as you was over a joke, at least... Edit: I might also note that this article (76 votes) is 5 places below another roughly equally old article (8 hours) with 13 votes. So it is probably flagged to Hell. I do feel classy, compared to some others.
- pyre 14y agoI've used both Perl and Python. When using Perl I use anonymous functions all the time. When writing Python, I don't. There are instances where in Perl I would use an anonymous function, but in Python I define a local function an pass the reference. Each language has it's own style. If you're trying to fight the language's style, then you will obviously run into friction. I'm sure there are plenty of people coming from C/C++/Java that think that dynamically-typed languages are unusable because type can't be enforced at 'compile time.' Defining an anonymous function vs. a one-time use local function is mostly a matter of style/preference[1]. | which of course was an ugly pain to port to Python with | no multi-line lambdas There are two things you are describing here: 1) It was a pain to name all of these anonymous blocks. 2) The idea of naming the blocks is annoying / aesthetically displeasing to you. #1 is just part of porting something between different languages. You would equally run into issues porting JS and/or Ruby code to Haskell, even with support to lambdas. #2 is just personal opinion / preference, even if it's one that shared by many. | (The fun part is that this necessity is touted as | something good, instead of admitting that it is | unnecessary complexity to learn. I could use the same argument to rail against statically-typed languages. "A type system is just unnecessary complexity to learn." [1] I welcome examples of where anonymous functions are unable to be replaced by local functions passed by reference.
- berntb 14y ago>>Ruby code to Haskell Uh... different paradigms. The scripting languages, which we are talking about here, are generally very similar. >> I welcome examples of where anonymous functions are unable to be replaced by local functions passed by reference. Where did I write "unable" -- did I disprove some Turing machine theorem and forget about it? :-) In this specific case it was a declarative data structure with some data next to code. It was well suited to have a dozen or two short functions next to the data structures. You could rethink the whole thing and do something different in Python to keep it readable. But among the normal languages (in the same paradigm), Python is the odd man out, just because of the lack of multi line lambdas. (I also gave the example of bad influences on map, etc.)
- pyre 14y ago
- alberich 14y agoActually, saying that you'll never like a given detail about a language is not the same as saying that you'll never work for company X because of that specific detail. It is not a logical conclusion, unless you are implying that for one to work for someone else you really need to like everything about the job at hand. I see no reason why you can't do something for money that you wouldn't do for your personal pleasure.