Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
How would I go about creating my own web programming language?
Firstly I don't want to be told why not to write another language... Even if I never use it I want to be able to just learn how to do it.
So how would I do it?
Ideally I'd want to create a Server Side language which can be run from the Client Side too with constant small data transfer updating the page (kind of like AJAX / PHP but where the Client Side code actually executes on server, or the server allows it to execute in the clients browser, either way the clientside code directly executes on the server (again I don't want to know about security or anything, I just want to know how to do it))
Does anybody know any sites that can teach me how to do this or can anyone help me themselves?
I do know the difference between clientside and serverside code, I think I just didn't word it right. I want to make a serverside code that can be executed from clientside kind of like using AJAX with PHP but directly executing the code from clientside.
3 Answers
- Lie RyanLv 61 decade agoFavorite Answer
Before you start creating your own web language, you should be familiar with the distinction between client-side language and server-side language. From the way you speak, you seems to still be confused about it.
So the first step is to actually learn to use an existing web language and write a real website using it; you should get a decent amount of experience in using a web language before you can create your own.
Next is designing the language, you need to design the look and feel of your language (i.e. syntax). Whether to use braces or indentation or keywords for block structure or if you have other ideas for structuring the program.
You then need to write a parser for the language. The parser will read a text string and turn that into an in-memory representation (e.g. abstract syntax tree) that can either be compiled (for compiled language) or interpreted (for interpreted language).
If you take the compiled language approach, you will either need to learn assembly and write a compiler that turns the in-memory representation to assembly, or you have to learn some other language (e.g. C) and write a compiler that turns the in-memory representation to this other language and leverage that language's compiler to actually turn your program into assembly.
Otherwise, if you take the interpreted language approach, you will need to write an interpreter, which reads the in-memory representation and execute the instructions there.
Next up, since this is a web language, is you need to integrate it with a server program. You can either use an existing server application (e.g. Apache) and write modules that allows that server framework to use your language; or you can write your own server application that listens to a specified port for connections and serve the requests appropriately.
- ?Lv 71 decade ago
"clientside code that executes on the server is a contradiction in terms". AJAX stands for Asynchronous Javascript and XML. The client side code is Javascript- it sends XML data back to the server. The server, written in PHP, C, Java, Python, Ruby, Perl, Tcl, Go, or anything else you can think of then takes the XML, generates some more markup, and sends it back to the client where the Javascript on the client's machine interprets it. The server has absolutely zero control over what the client actually does- all it can do is send data to the client, and it's up to the browser to interpret it.
As far as writing another language, you'd have to write either a compiler or interpreter for it. So first thing you need is the grammar, a specific set of rules describing what the program looks like. At this point, you have a syntax tree. You need a program that takes this syntax tree (the computer version of diagramming sentences) and turn it into instructions. You can either have a virtual machine that just interprets the tree, or you can have a compiler that turns the stuff in the tree into a set of machine instructions (a compiler). You need to make a way in your program to access the system's socket interface- to sit on a port and read data coming in, then write data coming out.
- 1 decade ago
You can write an interpreter or a compiler. An interpreter reads your source code and runs it. A compiler transforms your source code to another file that you can run.
You can search for "how to write an interpreter" and it can give you some tutorials.
And if you want a languages that can be run both on the client side and server side, I recommend that you see these:
haXe: http://haxe.org/
It is a multiplatform language. haXe code can be compiled/transformed into JavaScript and PHP code. It can compile to other type of files as well.
Aptana Jaxer: http://jaxer.org/
You can write both server side and client side code in one language, JavaScript.