[Off topic] Software epigrams

M

marduk

My, it's been a long time since I've seen these:

http://pu.inf.uni-tuebingen.de/users/klaeren/epigrams.html

They pre-date the Zen of Python by at least a decade, and quite frankly I
think many of them miss the mark. But whether you agree or disagree with
them, they're worth reading.

Yes, they're all over the place, but worth reading. My favorite is:

101: Dealing with failure is easy: Work hard to improve. Success is also
easy to handle: You've solved the wrong problem. Work hard to improve.
 
C

Chris Angelico

My, it's been a long time since I've seen these:

http://pu.inf.uni-tuebingen.de/users/klaeren/epigrams.html

They pre-date the Zen of Python by at least a decade, and quite frankly I
think many of them miss the mark. But whether you agree or disagree with
them, they're worth reading.

8. A programming language is low level when its programs require
attention to the irrelevant.

So much a matter of debate. Indentation is irrelevant, why should
Python programs pay attention to it? Block delimiters are irrelevant
too, the interpreter should be able to figure them out from the code
layout. But this one is absolutely right:

16. Every program has (at least) two purposes: the one for which it
was written and another for which it wasn't.

48. The best book on programming for the layman is "Alice in
Wonderland"; but that's because it's the best book on anything for the
layman.

LGTM.

ChrisA
 
C

Chris Angelico

I think "irrelevant" in this context means stuff like memory management.

Sure. That one's pretty clear (if you care about memory management,
you want a low level language). But there's still plenty that are less
clear. Though in generalities, I think I agree; paying attention to
minutiae is the consequence of taking a lower-level language. It's
just that the difference between relevant and irrelevant is hard to
define.

ChrisA
 
N

Neil Cerutti

I think "irrelevant" in this context means stuff like memory
management.

I thought I liked that one at first, but upon reflection it
speciously inserts the word "irrelevant" in order to avoid
stating a tautology: A programming language is low level when its
programs require attention to low level details.
 
F

Fábio Santos

I thought I liked that one at first, but upon reflection it
speciously inserts the word "irrelevant" in order to avoid
stating a tautology: A programming language is low level when its
programs require attention to low level details.

It's not a tautology in disguise. Irrelevant != low level. When low level
details are relevant to the scope of my program, I use a low level language.
 
C

Chris Angelico

And if I've designed my program the right way, what's relevant in one
place (package, module, function, line of code) is different from what's
relevant in another.

Absolutely. Layered systems FTW! Nothing matters but your current
layer and those it touches.

ChrisA
 
N

Neil Cerutti

It's not a tautology in disguise. Irrelevant != low level. When
low level details are relevant to the scope of my program, I
use a low level language.

It is a tautology is disguise. When you use a low level language,
low level details are relevant to the scope of your program.
 
F

Fábio Santos

(...)


It is a tautology is disguise. When you use a low level language,
low level details are relevant to the scope of your program.

I don't see it that way. I think relevance and level are two unrelated
concepts.

For example, in python you are handling irrelevant things if you are trying
to start a program and redirecting its standard output into another
program's standard input instead of just using the shell and a pipe to do
it.

And in C you are just at the right level to write something for a
microchip, but then again you are doing a load of irrelevant stuff if you
need to work numbers larger than the maximum permitted.
 
N

Neil Cerutti

I don't see it that way. I think relevance and level are two
unrelated concepts.

For example, in python you are handling irrelevant things if
you are trying to start a program and redirecting its standard
output into another program's standard input instead of just
using the shell and a pipe to do it.

And in C you are just at the right level to write something for
a microchip, but then again you are doing a load of irrelevant
stuff if you need to work numbers larger than the maximum
permitted.

If you need numbers larger than the maximum permitted then all
the code you write to handle them is relevant.

If I want to bake bread I hope I don't have to till a garden,
plant the wheat, harvest the wheat, and grind the wheat. But
gardening is relevant to bread baking weather or not I do it.
 
F

Fábio Santos

If you need numbers larger than the maximum permitted then all
the code you write to handle them is relevant.

If I want to bake bread I hope I don't have to till a garden,
plant the wheat, harvest the wheat, and grind the wheat. But
gardening is relevant to bread baking weather or not I do it.

Then memory management t is relevant to every python program even though
it's done by the interpreter?

And in Java we have factories, builders and builderfactories. What's so
relevant about them? Java is high level, no?
 
R

rusi

http://www.memorymanagement.org/articles/lang.htmlsays:

    C programmers think memory management is too important to be
    left to the computer. Lisp programmers think memory management
    is too important to be left to the user.

    (from Ellis and Stroustrup's The Annotated C++ Reference Manual)

Notable physicist David Bohm wrote that the difficulty in
understanding quantum physics is largely a result of the limitation of
the subject-predicate format of Indo-European languages.

He suggested some experiments in languaging called rheomode that makes
English more process-oriented and less (abstract)noun oriented.

One part of this project is to learn to use the word 'relevate' --
which is 'relevant' verbified with an element of 'elevate' as in 'lift
into relief'

I guess the Ellis and Stroupstrup quote above just shows that C++
programmers relevate in one direction whereas Lisp programmers
relevate in another.

More http://www.mindstructures.com/2010/04/meaning-and-context/

Twenty two years ago I wrote about this http://www.the-magus.in/Publications/chor.pdf

Suddenly I am finding glowing references to this
http://dieswaytoofast.blogspot.in/2013/01/why-i-grown-to-loathe-c.html

And I am uneasy because these questions are far less rhetorical/
tautological than I imagines in 1990!

So here's a (rather incomplete/preliminary) rebuttal to myself
http://blog.languager.org/2013/02/c-in-education-and-software-engineering.html
 
N

Neil Cerutti

Then memory management t is relevant to every python program
even though it's done by the interpreter?

Yes, I think so. If you didn't understand how Python managed
memory, you couldn't write it effectively. You would end up
making unecessary copies, and other pathological programming
practices.
And in Java we have factories, builders and builderfactories.
What's so relevant about them? Java is high level, no?

When I tried to pin down what an irrelevant detail in a computer
program could be, I couldn't do it. I guess comment decorations,
maybe? But those would have no bearing on the level of problem
for which a programming language is most appropriate.
 
C

Chris Angelico

When I tried to pin down what an irrelevant detail in a computer
program could be, I couldn't do it. I guess comment decorations,
maybe? But those would have no bearing on the level of problem
for which a programming language is most appropriate.

Let me give you a real example.

One of the programs I wrote at work is a simple daemon that runs on
every node in a network. It periodically sends out a heartbeat signal
that the other nodes hear, and if any node hasn't been heard from in X
seconds, it is deemed "down". (It might technically not be down, if
there's a network problem, but the point is that we don't care about
the difference. It's down.) There's also some incidental statussy data
included, for convenience. This is implemented using UDP.

Do I care about how a UDP packet is structured? No.

Do I care about the mechanics of IP routing? No.

Do I care about MAC addresses? No. They might feature in our IPv6
addresses, but I still don't care - the IP addresses (v4 or v6) of the
nodes are treated as opaque tokens.

All I care about is that I call a function with a string of data and a
corresponding function gets called in the other program with that same
string. All the details of how that happens in between aren't
important to my program. They're somewhat of note in the design phase,
but not to the program itself. They are, in fact, irrelevant.

ChrisA
 
R

rusi

Let me give you a real example.

One of the programs I wrote at work is a simple daemon that runs on
every node in a network. It periodically sends out a heartbeat signal
that the other nodes hear, and if any node hasn't been heard from in X
seconds, it is deemed "down". (It might technically not be down, if
there's a network problem, but the point is that we don't care about
the difference. It's down.) There's also some incidental statussy data
included, for convenience. This is implemented using UDP.

Do I care about how a UDP packet is structured? No.

Do I care about the mechanics of IP routing? No.

Do I care about MAC addresses? No. They might feature in our IPv6
addresses, but I still don't care - the IP addresses (v4 or v6) of the
nodes are treated as opaque tokens.

All I care about is that I call a function with a string of data and a
corresponding function gets called in the other program with that same
string. All the details of how that happens in between aren't
important to my program. They're somewhat of note in the design phase,
but not to the program itself. They are, in fact, irrelevant.

ChrisA

You are just saying (in specific detail) what I said, viz that the
programmer is one who 'relevates' ie sifts the relevant from the
irrelevant and a good programming language is one that gives good
relevating tools:
http://blog.languager.org/2013/02/c-in-education-and-software-engineering.html
 
C

Chris Angelico

When I tried to pin down what an irrelevant detail in a computer
program could be, I couldn't do it. I guess comment decorations,
maybe? But those would have no bearing on the level of problem
for which a programming language is most appropriate.

Let me give you a real example.
[snip]

You are just saying (in specific detail) what I said, viz that the
programmer is one who 'relevates' ie sifts the relevant from the
irrelevant and a good programming language is one that gives good
relevating tools:
http://blog.languager.org/2013/02/c-in-education-and-software-engineering.html

Right. All I'm adding is a concrete example - which, I think, will be
helpful to Neil, and perhaps to others too.

ChrisA
 
C

Chris Angelico

python help,

I've tried this code which I got from:

http://www.tutorialspoint.com/python/python_sending_email.htm

I build this file and run it

After running the the file and I get

"Successfully sent email"

My question is why doesn't webmaster get an email?

First point: Please send *plain text* emails. Your message came out
double-spaced and with absolutely no indentation, which destroys the
structure of Python code. (Your script is sufficiently simple that
it's fairly clear how it had to be laid out, but when you force us to
use our crystal balls for simple stuff like indentation, we can't use
them again for something more important. The cooldown on these babies
is pretty stiff sometimes.)

Secondly, it helps a LOT to tell us what you're running under - Python
version, OS, etc. One easy way to do that is to quote the text that
the interactive interpreter opens with, eg:

Python 2.4.5 (#1, Jul 22 2011, 02:01:04)
[GCC 4.1.1] on mingw32

Python 3.4.0a0 (default:5dcd7ee0716a, Mar 30 2013, 08:17:06)
[GCC 4.7.2] on linux

Now, on to your actual code.

The docs say:
"""This method will return normally if the mail is accepted for at
least one recipient. Otherwise it will raise an exception. That is, if
this method does not raise an exception, then someone should get your
mail."""

That's nice confidence-inducing language, but I take exception (if
you'll pardon the pun) to the last part. The only thing this function
can know is that the mail has been accepted by the next hop. After
that... well, the internet is a scary place, anything could happen.
See if your SMTP server (the one running on localhost) has a nice log;
you may be able to watch the message get processed by the next hop.

By the way, I wouldn't bother with the try/except here. Just let the
exception bubble up and be emitted to stderr. It'll be more useful
that way :)

ChrisA
 
D

Dennis Lee Bieber

python help,

I've tried this code which I got from:
http://www.tutorialspoint.com/python/python_sending_email.htm


I build this file and run it
---//---

#!/usr/bin/python

import smtplib
sender = "(e-mail address removed)"
receivers = ["(e-mail address removed)"]

message = """From: jol
To: webmaster
Subject: SMTP e-mail test

This is a test e-mail message.
"""

try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
except SMTPException:
print "Error: unable to send email"

--//--

After running the the file and I get
"Successfully sent email"

My question is why doesn't webmaster get an email?

Since you specified "localhost", that implies you have an SMTPd
running on your own machine. Since you didn't get an exception, that
SMTPd accepted the message.

You now need to find out what that SMTPd did with the message... Is
it configured to relay to the mail server for "inqvista.com"?

This is outside the domain of Python.
 

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

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top