9
\$\begingroup\$

So the title pretty much says it, but I'll repeat: What actually defines something as a "new" programming language and not just a library of functions for an existing language? I know that golf languages like Japt and Pyth are written through Javascript and Python, but what makes them fundamentally different from their "parent languages" in a way that they can be called new languages? Because, arent they just writing functions and things that are short then compiling through python/JS? Sorry if this sounds crazy and makes no sense. I just dont really get this whole "create a new language" thing. As a begginer, the idea sounds appealing, but I want to understand the implications of this and what it means. Also, as a beginner to programming in general, is creating a new language a good idea/a good way to learn or should I wait until I know so more. (See my StackOverflow profile/questions for a basic idea of where I am right now.)

Edit: Found this post, thought it might help the dicussion here: Creating new language. Would it be legal?

\$\endgroup\$
  • \$\begingroup\$ In general, I would think the syntax/semantics of the language itself is more important than which libraries are available. Java ME, Java SE and Java EE have different libraries, but are still basically the same language. \$\endgroup\$ – Paŭlo Ebermann Dec 6 '15 at 15:19
  • \$\begingroup\$ @PaŭloEbermann good point. I suppose that makes sense. I just started writing my language. I have some ideas for the syntax but it's still a little hazy. I'll make sure to think it out. \$\endgroup\$ – Ashwin Gupta Dec 6 '15 at 16:43
  • 1
    \$\begingroup\$ I think that golfing a classic language like Python is much more impressive than a short language like Pyth. I've started to assume Pyth can get it shorter, so I just ignore all Pyth answers now -- not worth the upvote. When everything is basically an alias for something in Python, it shows that you care more about the length of your program than about the process of golfing. \$\endgroup\$ – mbomb007 Dec 11 '15 at 21:48
  • \$\begingroup\$ Eventually if every user creates their own short golfing language. Nothing is impressive anymore, and the site becomes exclusive. The learning curve is raised. Nothing is fun anymore, and fewer and fewer answers can be read by each user. The site was better when everyone used the same few languages. \$\endgroup\$ – mbomb007 Dec 11 '15 at 21:50
  • 2
    \$\begingroup\$ I'm particularly unimpressed with "languages" which are simply special byte-packed encodings or which lean on such a feature for more easily hardcoding constants. Code golf languages which represent a toolkit of built in functions and constants that come up frequently (or are hoped to) can be interesting from a programming language design standpoint in some ways, but text compression schemes that are never meant to be directly used by a human are forcing codegolf in irreversibly anticompetitive directions. \$\endgroup\$ – JohnE Dec 13 '15 at 0:03
15
\$\begingroup\$

The compiler/interpreter defines the language

If you can take a sequence of bytes and feed it to a program that does something based on those bytes, it's a programming language in the general sense. By our standards, it must do the same thing for the same input, and be capable of adding two numbers and testing primality, as well as the other details in that answer. Simply having a specification does not count - it needs a compiler or interpreter (or transpiler, or whatever you want to call it) to count.

Japt and Pyth compile to Javascript and Python (respectively), but Japt/Pyth code is not Javascript/Python code. If you attempt to run Pyth code in Python, it will not work. You have to run the Pyth code through the Pyth compiler to get Python code.

There's an additional clarification that needs to be made, on the subject of polyglots and languages sharing syntax: two "languages" (as defined by their compilers/interpreters) are identical if and only if every valid program in one is valid in the other, and the same valid program results in the same behavior in both "languages".

For example: any sequence of bytes is a valid Seriously program. Therefore, any Python program is a valid Seriously program. However, they are absolutely not the same language; just try running some Python code in Seriously. You will almost certainly get a very different result.

Another example: Brainfuck. There are many compilers and interpreters for Brainfuck, and some might argue that you haven't truly programmed until you have written one. Because all valid Brainfuck programs (i.e. those with matching braces) produce the same behavior in all correct implementations (those that are incorrect need not apply), all of those implementations represent the same Brainfuck language (and those that don't produce the same behavior don't represent it).

\$\endgroup\$
  • \$\begingroup\$ ok, I sort of get it. Going to wait for some more answers though, just want to see what everyone has to say. Thanks! \$\endgroup\$ – Ashwin Gupta Dec 1 '15 at 4:14
  • \$\begingroup\$ oh my gosh, just read your Bio. You made Seriously? Awesome! It looks "seriously" awesome! (see what I did there?) I saw someone using it the other day(on the 99 bottles golf), it looked neat. I might try to learn your langauge, I want to learn a golfing langauge. What better person is there to answer my question than someone who has created their own language!? \$\endgroup\$ – Ashwin Gupta Dec 1 '15 at 4:26
  • 1
    \$\begingroup\$ @AshwinGupta ןnɟuɐɯɹɐןoɯ also references his own language (𝔼𝕊𝕄𝕚𝕟, which he wrote an encoding for), mroman made Burlesque, I've made Vitsy (or Flasp, as it is now called)... There are a ton of new languages here. c: \$\endgroup\$ – Addison Crump Dec 3 '15 at 10:41
3
\$\begingroup\$

That's probably hard to tell in general. If you take two OOP languages with roughly the same set of features and just look at the plain language (not accounting for libraries) then the only thing that is different is the syntax.

You can not run programs written in Java 8 with earlier Java versions (due to Java 8 having added several features not present in earlier versions). This in some way actually already makes a new language.

It's really hard to draw a 'hard line' for when a language is new. There are many brainfuck derivatives that can run plain brainfuck programs. This also means that there are programs writen in brainfuck derivatives that can be run with the original brainfuck as well. Then there are 'brainfuck equivalents' such as Ook! which are basically the same language with different syntax. There's a trivial 1:1 mapping for Ook <-> brainfuck. Yet, you can't directly run Ook on brainfuck or brainfuck on Ook. But you can write a compiler/transpiler that translates between the two languages.

As soon as you change the syntax of a language, add or remove a feature you end up with a new language that is incompatible without translation.

All turing-complete languages are alike in terms of "power". Thus you can compile any turing-complete language to any other turing-complete language. However, I use the term "equivalent" if there is an easy translation from A to B and from B back to A so that you get the exact same program back. You can compile C to Assembler, and you can compile Assembler to C but getting the same program back is rather non-trivial so although C and Assembler can do the same things they are not equivalent.

Also consider two languages F and G with one valid operator +. + in F prints "Hi", in G it prints "Bye". Now this means that all programs in either language are valid programs in both languages but that doesn't mean they are the same languages. Using the definition "if all programs can be run in the language" is thus fundamentally flawed since this doesn't account for whether the programs actually do the same things.

\$\endgroup\$
  • \$\begingroup\$ Actually, turing-completeness only captures one part of the power of a language. In addition, you can have stuff like input and output in different forms (bit/byte stream, graphical interface, ...), multithreading, ability to access a clock, to pause, ... \$\endgroup\$ – Paŭlo Ebermann Dec 6 '15 at 15:15
  • \$\begingroup\$ Yeah, but that's based on what hardware you run it on and what functionality your OS provides etc. etc. so I usually don't consider that a direct part of the language. Besides, you can hook a process between brainfuck (google esoapi) and then you have suddenly access to new I/O functionality without actually changing the language itself. \$\endgroup\$ – mroman Dec 6 '15 at 17:38
1
\$\begingroup\$

If it don't run right in its parent lang, it's its own lang


PROOF/EXAMPLE: Try running this 𝔼𝕊𝕄𝕚𝕟 code in any (proper) Javascript environment: . Throws an error? There you go: 𝔼𝕊𝕄𝕚𝕟 is a new language.

Simple as that (I think).

\$\endgroup\$
  • \$\begingroup\$ Hmm, intresting philosophy. Here is the reason I disagree: This would mean that no 2 languages (or no parent/child language) can share the same function names/syntax at all for anything. \$\endgroup\$ – Ashwin Gupta Dec 1 '15 at 4:41
  • \$\begingroup\$ Not necessarily - I guess I'm trying to say that if the child language in question has syntax that the parent language doesn't have, then it's a new language. The converse doesn't have to be true. \$\endgroup\$ – Mama Fun Roll Dec 1 '15 at 4:43
  • \$\begingroup\$ Okay, that makes a bit more sense. The problem is, you could still write a library that has some new syntax can't you? Or maybe that really is where you cross the fine line into new language or at least a serious language modification. \$\endgroup\$ – Ashwin Gupta Dec 1 '15 at 4:44
  • \$\begingroup\$ No - something like jQuery or Underscore doesn't really add any syntax, just function names and maybe some structure. Syntax is beyond that - it's not a part of the parent language's specs. \$\endgroup\$ – Mama Fun Roll Dec 1 '15 at 4:46
  • \$\begingroup\$ Lol, i didn't even realize that 𝔼𝕊𝕄𝕚𝕟 was a serious language. I thought it was a placeholder for an "example language" for the purpose of our question. \$\endgroup\$ – Ashwin Gupta Dec 1 '15 at 4:48
  • \$\begingroup\$ Nah, I made that language. It's my child language :) \$\endgroup\$ – Mama Fun Roll Dec 1 '15 at 4:48
  • \$\begingroup\$ XD good for you! Seems neat, I will give it a shot sometime. Or is it not public? \$\endgroup\$ – Ashwin Gupta Dec 1 '15 at 4:48
  • \$\begingroup\$ It's open-source, but the docs are shoddy. Of course, if you're well-versed in ES6, then you could learn from the interpreter source code. \$\endgroup\$ – Mama Fun Roll Dec 1 '15 at 4:49
  • \$\begingroup\$ I think im going to accept Mego's answer because he is pretty much saying what you are but in a more official way. But thanks! This helped a lot. \$\endgroup\$ – Ashwin Gupta Dec 1 '15 at 4:50
  • \$\begingroup\$ Can i have a link for the docs/git page or whatever? I can't find it anywhere. You should put the doc link on ur bio. \$\endgroup\$ – Ashwin Gupta Dec 1 '15 at 4:50
  • \$\begingroup\$ github.com/molarmanful/ESMin \$\endgroup\$ – Mama Fun Roll Dec 1 '15 at 4:52
  • \$\begingroup\$ Great thanks! Bye! \$\endgroup\$ – Ashwin Gupta Dec 1 '15 at 4:53
1
\$\begingroup\$

Mathematically they are the same...

...when they are an abbreviated form of another language, with a one-to-one mapping into and out of the original language. I don't really see how one could argue that there's anything original there. They have the same expressive power as the original, which in some cases is considerable. This make them great for golf, of course.

When there's not a one-to-one mapping, but when the child languages exposes elements of the parent language, it's a direct descendant. An extreme case of this is eval in perl or python. If a child language allows those constructs, then programs written in the parent language to run in the offspring. In this way, the descendent is a super-set of the original language.

Furthermore, lineage is implied between languages that share the same runtime, such as Java, Scala and Jython. I think most would argue that this is an implementation detail.

Creating a new language is a really interesting, but not very productive endeavor. I've created a few, and they're really useful only for teaching and learning. Otherwise, pick an existing language with idioms that you like, and find or build the right libraries to make yourself productive.

\$\endgroup\$

You must log in to answer this question.

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