
How the fuck is trim in Python? - inerte
http://www.inerciasensorial.com.br/2009/01/22/perils-of-software-development/how-the-fuck-is-trim-in-python/
======
gojomo
"How the fuck is..." is the wrong wording, at least in idiomatic American
English.

"What the fuck" (aka "WTF?") connotes more "this is wrong/surprising" than
"could you please tell me the answer?". "WTF?" is often a rhetorical question,
but even when it demands a response, the response is a situational
explanation, not a mere bit of trivia (such as "trim is called strip").

"What the fuck is trim _doing_ in Python?" is more idiomatic in its use of
'fuck', but would express surprise that Python has a trim() function, as if it
were against the spirit of the language. Because your "How the fuck..." sounds
a little like that in its use of 'fuck', it gives the wrong impression for
what you're trying to achieve. (Clicking your link, I expected a rant, not a
idea for a equivalence-lookup service.)

To express curiosity about the right answer -- "what is the equivalent of trim
in Python?" -- but with the same sort of irreverence possible via 'swear'
words, a more likely wording from a native speaker would be "how the hell do
you do trim in Python?"

"How the hell" expresses exasperation but also suggests some genuine interest
in a 'right' answer. (You sometimes see "how the fuck _do I_..." or "how the
fuck _do you_..." also, but anything starting "how the fuck" is far less
common than either "how the hell" or "what the fuck".)

In general, using 'fuck' casually can be a problem, for a number of reasons. I
believe the primary reason is that it is distracting -- it claims that the
containing statement is emotionally important and demands special attention.

Is a simple cross-programming-language lookup facility emotionally important?
No.

So some people will act 'offended' at use of a word with other
'naughty/private' connotations, and even some people who like to swear will
feel like you've diluted the word's value.

You need to save 'fuck' for really important uses, or it won't have any
fucking meaning left at all.

------
inerte
I hope there's no problem submitting my own blog post. I've been thinking
about making a website like the one I described on the post for a long time
but never got up and did it.

Anyway, I also hope the "fuck" up there isn't too offensive. I don't live in
the USA (and english isn't my primary language), and while it seems people use
this word every minute of their lives, on written material (and social
contexts) of the web is rarely seen, so I don't quite grasp the ethic
relationship of daily english and the internet.

If you could read my mind (in portuguese) and see what I really think when I
am trying to remember how trim is named in Python, worse profanities would
appear anyway :)

Oh, and I don't know if this is "HN material". I've complained about some
articles that appeared here, blog posts without much content at least. But
I've also seen worse stuff live longer on the main page, so I thought, what
better way to see if what I wrote would survive than just submitting it?

~~~
jsdalton
I think it's a really awesome idea. As others have pointed out, "what the
fuck" is the right way to say it.

More common than that these days is "WTF" (the abbreviation). This allows you
to get the same point across without using profanity. (Keep in mind that in
some environments like schools or corporations, sites with profanity can get
flagged and blocked.)

So maybe "WTF is ___ in ___?"

~~~
j2d2
I gotta disagree about "what the fuck" being the right way to say it. I am not
concerned about the rebellious nature of cursing, but I am bothered by using
words that contribute so little to the meaning. I've heard arguments that they
serve to express things in a more emotional manner. Like anything, they've
been so over used that the emotional enhancement is diluted to simply being a
socially rebellious expression.

 _Edit: On this topic, I think people, at some level, are aware of this.
That's why it's not as commonly found in written word vs. spoken word._

~~~
tptacek
The nice thing about it here is that it very effectively conveys the
frustration that underlies the value proposition for the site.

~~~
SapphireSun
At some level I would like to use this sort of site for the humor value. It
not only sympathizes with me; it empathizes with me AND works to solve my
problem - so long as it works right. If it doesn't I'd be adding a few more
colorful words to the mix :-)

Edit: Grammar

------
sam_in_nyc
I think this is a great idea.

What the fuck is <Language>'s [some string] in <another Language>?

[some string] can even be common objects methods, like Array.splice

For each mapping, you should allow comments to fill in the specifics. For
example, VB has "String.left()" and "String.right()", which can both be
achieved in by PHP's substr() if you pass the right params. Boy.. am I going
to be hated for the languages I just mentioned...

~~~
NyxWulf
I don't hate you. I think pity or scorn would be more appropriate. ;)

------
nir
Cool idea. There's already a similar site for PHP->Rails -
<http://railsforphp.com/> \- would be great to have something that works for
multiple languages.

My $0.02: Allow user annotation (ie, comments). Back when PHP was new, user
comments on the function pages were very helpful for figuring out how to do
stuff, what to avoid, known bugs etc. I often miss it when working with other
languages.

------
graywh
That can be one of the most frustrating things about using a new language.
Great idea, hope you can implement it yourself.

------
mattmcknight
While the initial function mappings could be quite simple, I see the future of
this being a bit like Google Translate for computer languages. We just need a
Mechanical Turk wiki like process to get the longer snippets code translated.
I used to work with ESRI ArcView software and its Avenue scripting language.
When they changed their internal scripting to Visual Basic for Applications,
there was a lot of work to be had translating scripts. (Now they support
Python as a scripting language as well.) I wonder if for any given JVM
language (Java, JRuby, Jython, etc.) you could write a decompiler for the
bytecode that would take you back to a different source code language.

------
eli
"How" seems like the wrong interrogative. Perhaps "Where the fuck is 'trim' in
Python?"

------
strlen
One thing: what works for PHP isn't necessarily a good approach to learning
another language, such as Python.

PHP's global space and the feel of "batteries included" is sharply contrasted
to Python's typing and object oriented feel. Having people write PHP in Python
would not only be counter-productive, the people being brought up on that
style wouldn't get much out of python.

The trim example specifically: line = "foo\n" new = line.rstrip("\n")

vs. if we were to directly to transliterate from php, it would be
string.rstrip(line,"\n")

(which is quite a different style)

This approach also under-emphasizes using language specific tools (e.g.
interactive python, pydoc).

~~~
NyxWulf
Typically the learning curve on a new language goes something like this.

1\. Knows old language

2\. Learns the syntax of new language

3\. Writes old language style in new language

4\. Through continued practice and learning in the new language, starts to
pick up the idioms and styles of the new language.

5\. Becomes fluent and well versed in the idioms, styles, advantages, and
flaws of the new language. Can contrast old language with new language well
and use the style most appropriate to the problem.

6\. rinse and repeat

Not everyone progresses all the way through the process when they pick up a
language. In fact I'd argue that some people never even pick up the idiomatic
way of doing something in a language even if that is their only language.

I think you could think of this like an english-spanish dictionary. It's not
going to teach you the idiomatic way of speaking, but it will give you the
correct word to use. Which I would suggest is a milestone on the path to
idiomatic speaking.

* edit for formatting

------
callmeed
Ah, now I understand what you're getting at ...

Indeed, this is a great idea. Would love to see someone like Joel Spolsky
implement this as part of StackOverflow.com.

I'd be interested in doing this in Rails ... if anyone wants to collab with
me, let me know (email in profile)

------
jgfoot
I started a project like this once, but never finished. Contact me if you want
my incomplete "Perl to Python phrasebook." My goal was to help unfortunate
Perl programmers migrate to Python.

One thing to look out for: things that are functions in some languages are
syntax in others, methods in others, and complicated recipes in others. You
need to give people sample code. For example, look at how each language wants
you to express "length of an array/list:"

Python: numbers = [4,8,15,16,23,42] print len(numbers) # yields 6

Perl: @numbers = (4,8,15,16,23,42); print $#numbers + 1; # yields 6 # or...
$numlen = @numbers; print $numlen;

Not really a "function" at all in Perl.

------
decadentcactus
Oh man, I was thinking the same thing. Mine was going to be something along
the lines of 'phptopython', where I could half document, half make a site
about converting php code to python, or how to do similar things. I wanted it
because I found it didn't exist when I was trying to learn Python. I figured
if I knew what it was in php, it'd be easier to work on.

Then, like yours, I figured a wiki would be good, and have each page dedicated
to a code snippet, whether it is "using trim" or "finding the square root of a
number".

Haven't got around to it though

------
jodrellblank
Once you get past integers and strings I think you'd start hitting language
and library limitations where things don't translate smoothly - the same core
reason that the languages are usefully different in the first place.

Not at all web 2, but the PLEAC project ( <http://pleac.sourceforge.net> ) has
been working on equivalent samples of code in different languages for a number
of years.

These days I'd half expect it to be a crossbreed of Google Code and Google
Translate.

------
russell
He also asked if anyone was offended if he linked to his own site. I've been
wondering myself. I have been considering submitting some issues for
discussion in the form of a two or three paragraph statement backed by an
essay elsewhere. Given that the topic is of general interest to HN and is not
self-promotional spam, does it fit with the HN etiquette?

------
ivank
For operating systems, there's <http://bhami.com/rosetta.html>

~~~
nailer
That's vastly out of date - DGUX anyone?

I've started on a modern RHEL / Ubuntu / Powershell Rosetta Stone in my own
time. Let me know if you want to see it.

------
csytan
This is a really good idea. Whenever I learn a new language, it is always a
pain re-learning how to do common tasks.

Is anyone interested in working on this as an open source side project with
me? My preferred stack is Python, Django, Appengine, and jQuery.

------
ntoshev
Google would give you the answer if you just type any such phrase.

------
jawngee
Best quote in the article: "Web 2.0 baby, the users provide all the content,
we make all the money."

~~~
inerte
OP here, I am watching this thread but not replying to anyone yet, but I want
to clarify this phrase. It's not really mine (at least its meaning) but I
couldn't find who said it first to give credit, since the words aren't exactly
how I typed.

Anyway, it's something that has bugged me for some time. Lots of "web 2.0"
companies think that users will come and start to post a lot of stuff, and the
reality is that unless you can give them some kind of semi-instantaneous
gratification, they'll never post anything.

Wish I could find who said it first. I think it captures a lot of the hype
behind the web 2.0 buzzword.

------
paddy_m
can anyone else not find the link to the actual site. I can't. I tried
<http://HTFITIP.com>

what's the url?

~~~
raghus
_I’ve been feeling lazy lately so go ahead and implement this if you want.
Should be an useful tool._

There's no such site now. He wants someone to write this because he thinks it
will be useful

------
hs
"how the fuck is trim in Python? It’s called strip by the way."

too much sex in holland (fat in usa)

