DSPRelated.com
Forums

OT: Code Examples

Started by Fred Marshall February 28, 2011
On 3/1/2011 12:43 AM, Erik de Castro Lopo wrote:
> Fred Marshall wrote: > >> I'm interested in developing Python-based programs, including an >> engineering app. ... re-writing from Fortran and C versions. One of the >> objectives would to be make reasonable use of the available structure >> (objects, etc.). So, I'd like to read a couple of good, simple >> scientific-oriented programs that do that kind of thing. > > Why Python? I really can't understand the rush of every man and > his dog to Python. > > Its not that I'm a stick in the mud stuck with C and C++, rather > that I used Python for a number of years from 1998 to 2004 and > rejected it in favour of strict statically typed functional > langauges like Ocaml and Haskell. > > Erik
Erik, Thanks much for the reply. I'll save by not cross-posting... Python was recommended as one of the languages one might ought to learn - along with Lisp as I recall. I can program in Fortran, have done some programs in C and am not doing enough to stay well-practiced. So, I thought a Python adventure might be worthwhile. And I rather like the idea of being able to run scripts on an interpreter. My Microssoft IDE is quite old and I've never done any Windows or GUI programming. Yet I have an app that I'd like to have a GUI front end. So that was a rather immediate objective. Then, to get familiar, I thought I'd port one of my Fortran/C programs to the new language. I don't particularly want to buy tools as my use is pretty limited if and when I get around to actually doing it. As it stands I'm chipping away at installing Python pieces.... So I guess you could say that my requirements are: - available tools - GUI capabilities - not particularly huge or hard to learn.... - reasonable libraries available Fred
Fred Marshall wrote:

> Python was recommended as one of the languages one might ought to learn > - along with Lisp as I recall. I can program in Fortran, have done some > programs in C and am not doing enough to stay well-practiced. So, I > thought a Python adventure might be worthwhile. And I rather like the > idea of being able to run scripts on an interpreter.
Ok, if you're not doing enough C to stay practiced then I would agree that Python is a better choice than either Ocaml or Haskell. The main reason for this is the simplicity of Python. Ocaml and Haskell do require more thought and are significantly less forgiving for people who only program ocassionally. I suppose my exasperation on the rush to Python is better directed towards people who choose to code widely used applications in a language that can hide so many errors until run time. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
Erik de Castro Lopo wrote:

> Paul Rubin wrote: > > > Anyway, try googling "evil mangler" > > I know what the "evil mangler" is. It was called that because it > threw away all the principles of good software design in favour > of expediency. GHC now has a new LLVM backend which does not > depend on the evil mangler and I strongly suspect that the backend > which uses the evil mangler will be dumped in the next year or > two.
I have some more information about the replacement of the Evil Mangler. According to this paper: http://llvm.org/pubs/2010-09-HASKELLSYM-LLVM-GHC.pdf the new LLVM backend for the GHC compiler still has a mangler phase, but the new LLVM Mangler is 180 lines of heavily commented Haskell code which replaces a 2000 lines of poorly commented Perl script. Full disclosure: the Perl mangler needs to parse the GNU assembler code while the Haskell mangler only needs to operate on data structures already defined elesewhere. However, the Evil Mangler only handled a small subset of CPU architectures, while the new LLM Mangler works on the architecture independent LLVM intermediate representation.
> > and ask why it wasn't done in Haskell. Same idea. > > Expediency over common sense?
Ignoring the parsing issue, this shows that Haskell was certainly up to the task of doing everything the Evil Mangler was doing. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/