Python dos2unix one liner

J

John Bokma

Steven D'Aprano said:
When do people learn that a
language is just a tool to do a job?

When do people learn that there are different sorts of tools? A
professional wouldn't use a screwdriver when they need a hammer.
[...]

Languages are not just nebulous interchangeable "tools", they're tools

A hammer is just a tool to do a job. Doesn't mean one must or should use
a hammer to paint a wall.
for a particular job with particular strengths and weaknesses, and
depending on what strengths you value and what weaknesses you dislike,
some tools simply are better than other tools for certain tasks.

In short, we agree.
 
D

Dennis Lee Bieber

Steven D'Aprano, 28.02.2010 09:48:

That wouldn't be very interesting. You could just write a code generator
that spits out tons of garbage code including a line that solves the
problem, and then let it execute the code afterwards. That beast would
always win.
This is beginning to sound like the final project someone did at my
college (he was a year ahead of me, and this is hearsay); supposedly he
couldn't figure out how to write the code for the solution but since the
instructor had given the test data and the correct results he'd created
some ugly spaghetti coded (we are talking late 70s here -- flow charts
were still considered coding tools) that somewhere read the input, and
after lots of obscure operations, had output statements that gave out
the canned result.
 
S

Steven D'Aprano

Steven D'Aprano, 28.02.2010 09:48:

That wouldn't be very interesting. You could just write a code generator
that spits out tons of garbage code including a line that solves the
problem, and then let it execute the code afterwards. That beast would
always win.

Obfuscated code competitions could do the same: insert your simple,
straight-forward, completely unobfuscated algorithm somewhere in the
middle of 15 GB of garbage code. Who would even find it?

But they don't, because human judges decide the winner, not some silly
rule of "the most lines of code wins".

In any case, I wasn't serious. It would be a bit of fun, if you like that
sort of thing, and you might even learn a few things (I never knew that
ints don't have an __eq__ method), but I can't see it taking off. I
prefer to use my powers for inefficiency to be sarcastic to strangers on
Usenet.
 
A

Albert van der Horst

Well that would be an obvious rule that garbage code that does not
contribute to the end result (ie can be taken out without affecting the
end result) would not be allowed. Enforcing the rule is another beast
though, but I would leave that to the competition.

Thinking of the international obfuscated c contest (iocc).
It is easy to make a mess of a program using the preprocessor.
It is also easy to preprocess then prettyprint the program.
If the result is not obfuscated, it impresses nobody.
Likewise the judges would think nothing of a program with garbage,
and would rate it low, so such rule is unnecessary.
Though the idea of a code generator is solid, but instead of generating
garbage, produces a virtual machine that implements a generator that
produces a virtual machine, etc. etc.

That was actually done by Lennart Benschop. He made a Forth program
run by an interpreter written in C.
Although Forthers thought it was straightforward comprehensible
code, it was a winner in the iocc.

Groetjes Albert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top