Talk:AMPL

From Wikipedia, the free encyclopedia
Jump to: navigation, search
WikiProject Computing  
WikiProject icon This article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
 ???  This article has not yet received a rating on the project's quality scale.
 ???  This article has not yet received a rating on the project's importance scale.
 

Internal error[edit]

Can't delete this article because it contains new block-compressed revisions, which are not supported by the new selective undelete feature and could result in data loss if deletion and undeletion happened. This is a temporary situation which the developers are well aware of, and should be fixed within a month or two. Please mark the page for deletion, protect the page and wait for a software update to allow normal deletion. If there is an actual complaint from a copyright holder or other suitable legal complaint and they are unwilling to accept page blanking and protection as a temporary measure, please ask a developer for assistance.

AMPL will have to be a redirect to AMPL programming language until this error is fixed. Rafał Pocztarski 19:42, 19 Mar 2005 (UTC)

Ack!! -- Taku 19:30, Mar 21, 2005 (UTC)

"Influenced by" section of programming language Infobox[edit]

The sample code at the AMPL pages suggests nothing of C, nor does a quick scan of the AMPL homepage (link at AMPL) appear to justify this, but don't know enough about AMPL to comfortably judge.

I have added a corresponding --Dubious-- tag to the "Influenced" item on the C page.

The IP editor has also added AWK to the influenced by list (and AMPL at the AWK page). And AWK isn't something I do a lot of, but this also appears somewhat dubious. Rwessel (talk) 07:19, 18 October 2010 (UTC)

AMPL borrows much of its expression syntax (most notably !, &&, ||, == and != operators, although they have alternative spelling as well) and comments (/* ... */) from the C programming language. The syntax of scripting subset of AMPL also similar to AWK (compare, for example, the print and printf statements, as well as the indexing expression (i in I). Please refer to Fourer, Robert; David M. Gay, Brian W. Kernighan (2002). AMPL: A Modeling Language for Mathematical Programming. Duxbury Press. ISBN 978-0534388096. 78.149.137.19 (talk) 07:51, 18 October 2010 (UTC)
I don't have access to the book you cite. However, http://www.ampl.com/REFS/amplmod.pdf is a 1990 paper on the language by three of the same authors. The only language the cite as a reference is XML. They also unambiguously describe the language as declarative, and that "AMPL closely resembles the symbolic algebraic notation that many modelers use to describe mathematical programs," which would both tend to discount much C influence.
So other than a couple of (very) minor keyword similarities (and I believe &&, || and == are, indeed C innovations, !, != and /* comments are not), is there evidence of a resonably direct influence of C on AMPL on any substantive design points? Clearly by the time 1990 rolled around, all of the authors (obviously so in Kernighan's case) would have been familiar with C (as would the designers of almost any language at that point), and so some indirect influence could have existed, but I don't think that's the criteria. Consider that K&R would certainly have been aware of some of the design goals and choices made by Cobol, yet we'd hardly claim that Cobol was an influence on C (except perhaps in the sense of "let's not do anything like *that*"). Likewise I'd not assume that the use of := for assignment implies a meaningful relationship to Pascal.
Frankly, I'm just looking for a bit more justification. Rwessel (talk) 09:31, 18 October 2010 (UTC)
You are right that the 1990 paper described AMPL as a declarative language and even in this declarative subset you can see very strong influence of C syntax: expressions as I mentioned before, /* comments (which are introduced into C from BCPL I believe) ending the statements and declarations with semicolons, free form, case sensitivity, floating point literal format, string literal format. Of course many of those are not C innovations but taken together they form a significant part of the language syntax. After 1990 AMPL was extended with scripting features (see for example http://www.ampl.com/NEW/loop1.html), in particular C-like printf statement, compound statements surrounded by {}, the break and continue statements were added. I think this is enough evidence showing the influence of C on the AMPL language. Here I stress that the influence is purely syntactic, the languages are completely different in design and purpose. This is similar to the way C influenced AWK. IMHO here the relation is even more evident than in case of AWK. 134.83.1.241 (talk) —Preceding undated comment added 10:43, 18 October 2010 (UTC).
Perhaps there are some more recent code samples online? The ones I see just don't seem to show what you're claiming. For example, the ones at ampl.com seem to seem to use # for comments, and frankly if I had to say what they bore a vague (and I mean _vague_) resemblance too, I'd say Algol-68, not C. Nor do things like the literal formats (string, or float) say anything particularly C-like (and AMPL seems to use both single and double quoted strings – perhaps there’s a meaning to that), and printf also dates back to Algol-68 (although the format string options are certainly C-like, rather than Algol-68-like). There are a few C-like functions (can't tell if they're built-ins or library), like ceil, and min/max, but that's really thin too.
And the looping constructs seem to share little with C (I haven’t seen but one example of break, and none of continue, but the for and repeat are certainly different), True there are curly-brace blocks (again, not meaningfully different than any other block delimiter), but the loop parameters are *also curly brace delimited. And the if…then construct is rather basic-like (not to mention let and set).
Without doubt there are some small bits and pieces that clearly look C-like, it’s nothing that strikes me as anything other than minor syntactical details. And there’s a smattering of all sorts of other stuff in there.
Which really begs the question: What exactly is the threshold for “influenced by?” And why not Algol-68, Basic, whatever, too? Rwessel (talk) 04:26, 19 October 2010 (UTC)
As you don't have access to the book you can use the online interface to the AMPL translator at http://ampl.com/cgi-bin/ampl/amplcgi . For example, try the following:
param
  p = /* Note free form, float literal format and compulsory ';'
         at the end of a declaration. */
    110.0e-1;
 
repeat
while (1 == 1) {
  /*
    Note non-nested /*-comments and printf, string literal format,
    compulsory ';' at the end of a statement and C library functions.
  */
  printf "He%go, %s!\n", floor(exp(log(p))), "world";
  break;
  continue;
}
The above code illustrates many of the features that I mentioned. As a C developer I think it is very close to a valid C. Major differences are 'param' instead of 'double' (AMPL has only one scalar type - double), extra 'repeat' and lack of parenthesis around printf argument list. Loop conditions are not curly brace delimited, what you are referring to is a special form of a 'for' statement which iterates over a set. And you are right about the comments and string literals - as many scripting languages AMPL accepts # and single-quoted literals which are in fact much more popular (probably because they save typing). Refer, for example, to csh and AWK which are considered to be influenced by C.
You posed a valid question and I think the answer is to consider other examples where the influence is not questioned. I think that C-AMPL relation is very similar to the one between C and AWK. AWK is very different from C but as AMPL it borrowed substantial amount of C syntax. 78.149.137.19 (talk) —Preceding undated comment added 08:38, 19 October 2010 (UTC).
At the end of the day, I really don’t have a dog in this fight, and clearly the criteria for “influenced by” are somewhat subjective. It’s clear that there are some borrowings from C, although more in later versions of the language (which frankly, just confuses things more). Many of the examples we’ve discussed are not, IMO, particularly significant (you’ve got to call the log() function something, and while both languages use log(), so do many others, the actual name is not really all that significant – especially when there appear to be many case of divergence – repeat instead of do/while, for example).
Anyway, it seems that the core of the language is not very C-like, but that there have been some procedural bits added on over time where there’s a more pronounced borrowing from C. Not being an AMPL user, I can’t tell you how significant the procedural bits are in practice (most examples I’ve found seem to avoid them), but they nonetheless seem to be there. And since there’s not a “corner of language influenced by” category, and as something as divergent from C like AWK can claim influence (although it appears to me that AMPL is yet further afield), I half-heartedly withdraw my half-hearted objection… Although clearly some expansion of the AMPL article would be nice. Rwessel (talk) 17:45, 19 October 2010 (UTC)