3
$\begingroup$

I'm interested in the memory usage of various programming languages when implemented on actual hardware.

I believe that a Turing-complete programming language has, in general, unknowable memory usage since object lifetimes are not statically analyzable [1]. It also seems like a regular expression language (in the deterministic finite automata) has statically known memory use.

What is the most complex programming language for which that is true? And where do total languages [2] fall in relation to that?

[1] Given the caveat that we're implementing that programming language on a physical computer with all its requisite limitations.

[2] A total language is, for the purposes of this question, a language where all programs written in it are guaranteed to terminate.

$\endgroup$
  • 1
    $\begingroup$ What do you mean by a "language"? A set of valid strngs? A formalism for describing a computation? There is no relationship; I can create a formalism whose semantics are turing complete but whose syntax is regular (simply by adding the rule that "any other string" halts immediately.) $\endgroup$ – rici Feb 5 '16 at 2:29
  • $\begingroup$ A language used to compute in. I'm interested in semantics not syntax. $\endgroup$ – oconnor0 Feb 5 '16 at 3:54
  • 2
    $\begingroup$ I've edited your question based on your clarification. Note that programming languages have almost no overlap with formal languages. Anyway, what do you mean by a "total language"? What is your definition of "complex"? What makes you think there is a single "most complex" programming language? The question doesn't seem well-defined/well-posed as it stands. $\endgroup$ – D.W. Feb 5 '16 at 4:42
  • $\begingroup$ I understand neither what you mean by "regular expression language" (since you claim not to mean a language whose syntax is regular) nor your proposed complexity metric. -- Which seems to be what @D.W. just said. $\endgroup$ – rici Feb 5 '16 at 4:53
  • 2
    $\begingroup$ I don't think there's a useful theory of programming languages that would provide what you want. Also, one can always invent a language with known memory usage: e.g., C programs with a special version of malloc() that is guaranteed to return NULL after allocating 1MB of memory (and with bounds on recursion) would give you a language that a known upper bound on memory usage and is very complex... but somehow i doubt that's what you are looking for. $\endgroup$ – D.W. Feb 5 '16 at 5:38
2
$\begingroup$

Because total programs cannot run forever they cannot use infinite memory. You can know maximum, and best case cost from looking at what algorithm is implemented. Checkout these wikipedia pages to see the relationship between different grammars, algorithms, and machines:

$\endgroup$
  • $\begingroup$ Interesting. Is there a way to do more fine grained analysis than maximum used? Why do total programs only implement up to polynomial algorithms? $\endgroup$ – oconnor0 Feb 6 '16 at 2:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.