Choice of interface / interpreter for scientific code

The modeling tool that I have developed over the past couple of years is written in C ++ and currently has a tcl interface that is interpreted as front-end. It was written so that it can be run either in an interactive shell or by transferring an input file. In any case, the input file is written to tcl (with many additional modeling commands that I added). This allows you to use quite powerful input files (for example, when you run sim-sim-carlo sims, random distributions can be programmed as tcl-procedures directly in the input file).

Unfortunately, I find that the tcl interpreter is becoming somewhat limited compared to what more modern interpreted languages ​​can offer, and its syntax seems a bit cryptic. Since the computing engine was written as a library with a c-compatible API, it should just write alternative interfaces, and I am thinking about moving to a new interpreter, however I have a little time choosing (mainly because I do not have much experience working with many interpreted languages). The options I started exploring are as follows:

Left with tcl:
Pros:
- No need to change existing code.
- Existing input files remain unchanged. (although I would probably keep the front of tcl as an option)
- Mature language with lots of community support.
Minuses:
- A sense of limited syntax of the language.
- Receiving complaints from users about the difficulty of learning tcl.

Python:
Pros:
- A modern translator, which, as you know, is quite effective.
- A large, active community.
- Well-known scientific and mathematical modules such as scipy.
- Commonly used in the academic scientific / engineering community (typical users of my code)
Minuses:
- I never used it, and therefore it will take time to learn the language (this is also a professional, since I have long wanted to learn python)
- Strict formatting of input files (indentation, etc.)

Matlab:
Pros:
- A very powerful and widely used math tool
- Powerful integrated visualization / printing.
- Extensible, through community-transmitted code, as well as commercial toolbars.
- Many in science / engineering are familiar with MATLAB and are comfortable with them. Minuses:
- Cannot be distributed as an executable file - there must be an extension / toolkit.
- Requires (?) The matlab compiler (which is expensive).
- Requires Matlab, which is also expensive.

These pros and cons are what I could come up with, although I have very little experience with interpreted languages ​​in general. I would like to hear any thoughts on all the interpreters that I suggested here, if these pros and cons are listed legit, and any other interpreters that I did not think about (for example, if php were suitable for something like this? Lua?). The initial experience of implementing an interpreter in your code is definitely a plus!

+6
c ++ python matlab tcl interpreter
source share
3 answers

I was a strong supporter of Tcl / Tk from the pre-release, until I did a fairly large project with it and realized how unattainable it was. Unfortunately, since prototypes are so lightweight in Tcl, you end up with one-time scripts by taking on your own lives.

Having adopted Python in the last few months, I find that this is all that Tcl promised and much more. Like many Python veterans, you can say that the initial indentation worries the first hour at the maximum, and then it seems that this is not a hindrance, but positively useful. By the way, the author of Tcl, John Ousterhout, alternately rated and wrote for writing a language that forced "One True Brace Style" on Tcl encoders (I was 1TBS, so it was great with me).

The only Tcl constructs that Python doesn't handle well are arbitrary eval "${prefix}${command} arg" constructors that shouldn't be used in Tcl anyway, but are operators like uplevel (which were a good idea, but were made for some hairy code). Indeed, Python feels a little opposed to dynamic eval , but I think this is a good thing. Unfortunately, I have not come with a language that covered its graphical interface as well as Tcl / Tk; Tkinter does the job in Python, but it hurts.

I can't talk to Matlab at all.

With a few months of Python under my belt, I almost certainly ported any Tcl program that is under constant development in Python for sanity purposes.

+5
source share

Do you find using Octave? From what I collect, it is almost a replacement for many of MATLAB. This may allow you to support Matlab for those who have it, and a free alternative for those who do not. Since the β€œmeat” of your program seems to be written in another language, performance considerations do not seem as important as providing an environment that has: graphing and visualization capabilities, is cross-platform, has a large user base and a language that, probably already knows that almost everyone in academia and / or is involved in modeling fluid flow. Matlab / Octave may potentially have all of those.

+3
source share

Well, if there are no other suggestions, the final answer I received is to go with Python.

I seriously considered matlab / octave, but while reading the octave API and the Matlab API, they are quite different that I will need to create separate interfaces for each (or get very creative with macros). With python, I get a single, easier-to-maintain base for the interface, and it is used by almost everyone we know. Thanks for the tips / feedback everyone!

0
source share

All Articles