4
$\begingroup$

I am probably lazy so I don't feel like thoroughly designing and implementing a new language. But maybe it already exists? Do any programming languages exist with the following traits?

  • no need for whitespaces, only between numbers, all identifiers are one-lettered. If we need a long identifier then use an indexed table element.

  • polish notation. Because I spent half my life on parentheses.

  • indexing arrays, tables, functions are the same: f1, t'field'

  • no if operator. Instead we make an array of statements with condition as index.

  • tacit functions

For example if x<10 then x=y+1 else y=x/2 end would be {=x+y1, =y/x2}<x10.

$\endgroup$
7
  • 1
    $\begingroup$ Added syntax flags as the difference between the mentioned and any other language would likely disappear after syntactic analysis phases. I doubt, however, that the approach is common as most languages tend to more or less use C-style syntax to be consistent with users' prior experiences. $\endgroup$
    – feldentm
    Commented Jul 13 at 15:34
  • $\begingroup$ When the code is trivial and you've done it a thousand times then having to press shift key for parentheses greatly annoys. But for a complex program I'd choose a clear traditional syntax $\endgroup$ Commented Jul 13 at 15:45
  • 3
    $\begingroup$ Try Uiua. $\endgroup$
    – Jon Purdy
    Commented Jul 13 at 20:37
  • 3
    $\begingroup$ Many golfing languages are concatenative and support array programming. Some examples are 05AB1E, Vyxal, Nekomata. $\endgroup$
    – alephalpha
    Commented Jul 14 at 1:45
  • 1
    $\begingroup$ @alephalpha: note that those three are all postfix (RPN) languages, and the OP is specifically asking for polish notation (prefix) $\endgroup$
    – Chris Dodd
    Commented Jul 15 at 22:06

2 Answers 2

2
$\begingroup$

Currently, there's no such programming language that satisfy all of your conditions. However, there are in fact some programming languages that have one or more of the characteristics you mentioned:

  • Forth: This is by far the closest one to what you're looking for that I can find. It uses reverse polish notation, is stack-based, and is concise in its syntax. However, it does use whitespace as a delimiter. Also, it uses the standard if-statement for conditional control-flow, albeit in a slightly different way, due to the fact that it is a stack-based language. Forth functions (subroutines) are called "words", and are usually small and concise, although there's no restriction of the length of the words' names.
  • APL: This is also very close to what you're looking for. Early implementations of the language do not have any control-flow statements (if-elseif-else, for, do-while, ...etc), rather programmers of this language use array operations to perform the task. APL syntax and operators uses many non-ASCII (Unicode) characters. For example, the Unicode character "ι" is used for iteration, "←" used for assignment, "+" is used to add a number to all elements of an array (versus appending), and "×" for multiplication. Note that APL does not satisfy the other features you mentioned; it uses parenthesis as part of the syntax, does not use reverse polish notation, and allows multiple-letter names. Whitespace is also required as part of the syntactic model.
  • Whitespace: For a programming language that is special in whitespace, this one should have a spot. However, this is the exactly opposite of what you're looking for; this programming language only uses whitespace as syntax. It's also an esoteric language, so don't use it for practical purposes.

Finally, let's evaluate the conditions you listed for their practicality:

  • no need for whitespaces, only between numbers, all identifiers are one-lettered. If we need a long identifier then use an indexed table element.

    As far as I can find, no (at least no used) programming language had a syntax that does not require any form of whitespace delimiting. There's not much sense in designing a language with such a feature anyway. I think the space key is perhaps the easiest key I can hit, and I would like to stick with that. As for single-lettered names, most programming languages allow single-letter names, but none enforce it. Again, there's not much sense in restricting the length of a variable or function name, since you can always do so yourself. So essentially, every programming language satisfy this condition. Note, however, that using single-letter names for everything in your program is almost always an extraordinarily bad software engineering practice. Using single-lettered names for some things are OK (think i and j for loop variables), but for everything it is not. See importance of variable names, single-letter variable names, the case of single-lettered names, naming classes- stackoverflow, and is single-letter names encouraged.

  • Polish notation: Many programming languages out there use reverse polish notation, so this one is not particularity hard to find.

  • indexing arrays, tables, functions are the same: f1, t'field'

    This one is also common. For example, in Python, indexing a dictionary (equivalent to a hash map or table in other languages) is the same as indexing a list (array). However, I don't think there's any programming language that allows indexing of functions. I guess you're referring to the indexing of a heap stack of functions, which some stack-based programming languages do support.

  • no if operator. Instead we make an array of statements with condition as index.

    Satisfied by APL. This isn't a common feature, so I guess APL is one of those, if not the only one that have this distinction.

I hope this helps!

$\endgroup$
7
  • $\begingroup$ FORTRAN would be a clear example of a used language that does not require whitespace delimiting in expressions, though there are others. I believe the indexing point requests that indexing and application share syntax (like BASIC), but presumably by juxtaposition. The question also seems to be asking for Polish notation rather than Reverse Polish notation, both explicitly and in the example code. $\endgroup$
    – Michael Homer
    Commented Sep 8 at 0:16
  • $\begingroup$ "However, I don't think there's any programming language that allows indexing of functions." Doesn't Mathematica use bracket syntax for both indices and function calls? $\endgroup$
    – Bbrk24
    Commented Sep 8 at 22:38
  • $\begingroup$ Any reason for downvoting? $\endgroup$
    – Luke L
    Commented Sep 9 at 3:26
  • $\begingroup$ @Bbrk24 Yeah, you're right. I never even know about that programming language before. Thanks for pointing out. But I don't think Mathematica is what OP's looking for, though. Still, I appreciate your reminder. $\endgroup$
    – Luke L
    Commented Sep 9 at 5:53
  • 1
    $\begingroup$ Regarding "indexing of functions": Arrays are (conceptually/mathematically) functions, and indexing an array is applying it. For instance, an int array of size n is a function from the set {0, 1, ..., n-1} to the set of int values. "Indexing" is just another way to think about what it means to apply a function. In fact, sometimes a function like that would be called "an indexed family of ints," instead of saying "function." $\endgroup$ Commented Sep 9 at 15:41
0
$\begingroup$

Other than single-letter identifiers, it sounds like you're looking for APL.

$\endgroup$
1
  • 2
    $\begingroup$ As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. $\endgroup$ Commented Jul 18 at 17:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .