Hacker News new | ask | show | jobs
by aidenn0 5765 days ago
Only thing I can think of is AWK, but that's only slightly more readable than perl and is probably less maintainable since perl has vastly superior profiling and debugging tools.

I mostly use Python for the sorts of things you are mentioning. And from what you're saying you don't like a bout Python, I suspect that going to Ruby or Haskell or such is going to be worse. Python can more easily call the underlying C routines then either of those.

It would be nice if you could provide an example of something you think is inelegant and/or awkward in Python so that we could figure out which direction to point you.

I do a lot of coding in common lisp and some programming in haskell, but wouldn't recommend either of those based on what I've heard from you so far. There's a few dataflow style languages I've seen that would probably allow very succinct code, but they were all toys and performed quite poorly.

1 comments

> It would be nice if you could provide an example

For me personally the main source of unhappiness is error messages. In C I can say

if (!(f = open(name, "r"))) die(name);

where die is a tiny function that prints name, followed by whatever strerror has to say to the subject, formatted in the usual fashion. One line, done with it. The obvious, conventional Python equivalent is four lines long because both try: and except: insist on a line of their own. Since I cannot tell Python to produce succinct unixy error messages instead of rambling stack traces I have to catch and examine more or less every plausible exception. Some exceptions I can deal with close to the base level of my call stack in a butt-ugly fourty-line catch-all clause but a large proportion of my syscalls end up taking three lines extra each. I know it's a trivial problem, but I agree with pg you tend to get the more productive the more of your actual application logic you can see.

> I do a lot of coding in common lisp

We did experiment with clisp a while back; it turned out not to be a natural fit for problems that involve a lot of pathname, datetime, and stat info manipulation. If there was a reasonably modern Lisp that let me say things like (localtime (nth 9 (stat "/foo"))) I would go looking for it this very afternoon.

> Since I cannot tell Python to produce succinct unixy error messages instead of rambling stack traces

`sys.excepthook` is how you can do that.

Without:

     x = {}
     def f():
         print(x['foo'])
     f()
     # ...

      Traceback (most recent call last):
	File "stack.py", line 6, in <module>
	  f()
	File "stack.py", line 4, in f
	  print(x['foo'])
      KeyError: 'foo'
With:

     import sys

     def short_err(exc_type, exc, tb):
         sys.stderr.write("error: tracebacks too long\n")

     sys.excepthook=short_err

     x = {}
     def f():
         print(x['foo'])
     f()

     #...

     error: tracebacks too long
So don't worry about catching exceptions if you're just printing errors.
> `sys.excepthook` is how you can do that.

Awesome. Thank you kindly.

> error: tracebacks too long

I like your style.