Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » Additional programming languages

This thread is locked; no one can reply to it. rss feed Print
Additional programming languages
Thomas Fjellstrom
Member #476
June 2000
avatar

Oh, I also use PHP. But only because I'm being paid fairly well for it.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Trezker
Member #1,739
December 2001
avatar

If HTML was a programming language, we wouldn't need any javascript.

Johan Halmén
Member #1,550
September 2001

I used to write Z80 Assembler some 20 years ago. It was great fun. I thought of picking up that again. I could use it on my son's TI calculator, which probably will be useless now, when he finishes high school.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

axilmar
Member #1,204
April 2001

Trezker said:

If HTML was a programming language, we wouldn't need any javascript.

Indeed. I've been saying this for years now. Not only we wouldn't need Javascript, we wouldn't also need to wait for the WWW consortium to extend the standard, and we wouldn't have these big differences between how browsers render HTML, because the rendering would be the result of running the HTML program rather than its conversion to another internal form.

Thomas Fjellstrom
Member #476
June 2000
avatar

Of course then it wouldn't be HTML, nor a Markup Language. And then you'd have a hard time separating your presentation layer from your control logic.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Tobias Dammers
Member #2,604
August 2002
avatar

I make fun of myself, why would I care what someone else said about me? You could make an HTML Compiler that reads say "<H1>This is a string!</H1>" and the compiler has been told to interpret H1 as the instruction output string between <H1></H1> at <terminal font + 3 or something. HTML isn't instructions, but if you made a compiler you could (under the hood) tell it to interpret the tags as instructions. Variables? Name = "" where 'name' could be interpreted as a variable and the data in "" could be placed in memory. This is what I meant by anything can be turned into a programming language because if the person is bored enough and has the know how they could make a compiler that does most the work under the hood and turn a structure of documents into a programming language. (Does this prove I don't care how crazy people think I am (or stupid for that matter)?)

You'd still have a document structure language, not a programming language; the expressivity would still be limited to describing a document structure. The fact that you have produced a program that can turn HTML into a native executable which, when run, displays a rendering of the original document, doesn't change that a bit, just like the fact that you can pre-compile sprites into machine instruction doesn't magically turn PNG into a programming language. You still won't be able to implement anything that requires a quasi-Turing-complete language in it without severely extending HTML or giving radically new meaning to its tags and attributes.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Specter Phoenix
Member #1,425
July 2001
avatar

Dammers, the point of my remark was to show bamccaig I didn't care if people made fun of me so I made off the wall remarks about turning HTML into a programming language. Let me take it one step further. A Game Maker like app that takes each tag and has predefined things in it that turns each one into a game aspect, lists can be the menu, H# tags can correspond to menu items (1 is title, 2 is start item, 3 load, 4 options, 5 high score, 6 quit), title is app title bar name, marquee can be movement, etc. Crazy enough for you yet?

"Can't a man even talk to himself without being interrupted?" -Krull(1983)
"Through vengence I was born. Through war I was trained. Through love I was found. Through death I was released. Through release I was given a purpose." -- Specter Phoenix
"Programming == AWESOME the rest is just tools to accomplish it."
END OF LINE

axilmar
Member #1,204
April 2001

Of course then it wouldn't be HTML, nor a Markup Language.

I don't think that's important, is it?

Quote:

And then you'd have a hard time separating your presentation layer from your control logic.

Not really. The same HTML documents we have now could work as programs, unaltered. Separating the presentation from the control logic is a matter of designing the API correctly, it has nothing to do with if the language is markup or programming.

You still won't be able to implement anything that requires a quasi-Turing-complete language in it without severely extending HTML or giving radically new meaning to its tags and attributes.

Well, in the case HTML was a programming language, the tag 'H1' would be a function that it would render its sub-elements with a specific font. The H1 function itself would use code of a Turing-complete language. Something along this:

    function h1(list of elements) {
        Font font = get_font(points = 150);
        for(element : elements) {
            draw_element_with_font(element, font);
        }
    }

Arthur Kalliokoski
Second in Command
February 2005
avatar

Let's see you persuade HTML to list the first ten Fibonacci numbers without listing them explicitly. Even BASIC can do that.

They all watch too much MSNBC... they get ideas.

Thomas Fjellstrom
Member #476
June 2000
avatar

axilmar said:

Not really. The same HTML documents we have now could work as programs, unaltered. Separating the presentation from the control logic is a matter of designing the API correctly, it has nothing to do with if the language is markup or programming.

Sure it does. You just turned HTML into PHP by making it a programming language. :P and look what that did to the programming world. >:(

Let's see you persuade HTML to list the first ten Fibonacci numbers without listing them explicitly. Even BASIC can do that.

You can do that in CSS (probably?). \o/

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Tobias Dammers
Member #2,604
August 2002
avatar

axilmar said:

Well, in the case HTML was a programming language, the tag 'H1' would be a function that it would render its sub-elements with a specific font. The H1 function itself would use code of a Turing-complete language.

That doesn't prove anything. Of course you can implement a non-Turing-complete language in a Turing-complete language. Just because you can implement language A in language B doesn't mean that B being Turing complete makes A Turing-complete as well. The other way around, however, does hold: if A is Turing-complete, and can be implemented in B, then B is also Turing-complete.

HTML is quite obviously not Turing-complete; as long as you retain its meaning, writing an HTML interpreter, compiler, renderer or similar thing in a Turing-complete language doesn't make HTML Turing-complete.

Reinterpreting HTML, however, so that tags are symbols for operations, can make HTML Turing-complete. For example, the <em> tag could be interpreted as an assignment (the id attribute indicating the variable name and the content the value), <a> could mean addition (add the value you get from evaluating the tag content to the variable referred to by the tag's id); <div> could mean print; etc. With just a handful of definitions, Turing completeness can be achieved. But this new language, even though its source code would also be valid HTML, would not be HTML anymore - it would be some sort of imperative Turing-complete programming language with a syntax that coincidentally looks exactly like HTML.

Let's use C as an example to look at it from a different angle. I assume you are familiar with the International Obfuscated C Code Contest (http://ioccc.org/); many of the winning entries are not only valid C code, they also qualify as ASCII art. The source code is 'valid' as either: it compiles and does something (so it is valid C, source code in a Turing-complete language), but it can also be displayed in a text editor or on a terminal, and humans will be able to identify it as an image of something (so it is also image data, that is, static data in a purely presentational format without any chance of being Turing-complete). The source code is valid as both, but that doesn't make ASCII art a Turing-complete language, even though the ascii art in the ioccc entries happens to be valid C.

Going back to HTML / H# (lacking a better name for the hypothetical programming language), if you implemented H# such that all valid HTML documents were also valid H#, and vv., and H# would be Turing-complete, then HTML would still be non-Turing-complete, even though every valid HTML document would also happen to coincide with a valid program in a Turing-complete language. This is the same as if you were to design a C dialect that is extremely forgiving, treating all invalid syntax as comments (like the satirical programming language INTERCAL does). Let's call this hypothetical C dialect C/F (C Forgiving). Let's also broaden our definition of 'valid' ASCII art, such that everything you can view in a text editor would qualify - if in doubt, we'll assume it's some kind of abstract or experimental art. Given these two languages, we'd have the same situation as with HTML vs. H#: anything valid in one is also valid in the other, yet one of them is Turing-complete and the other not.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

axilmar
Member #1,204
April 2001

You just turned HTML into ... a programming language.

You failed to mention why turning HTML into a programming language is a bad thing.

Quote:

That doesn't prove anything...bla bla bla

Proving that HTML is Turing-complete was not the purpose of my comment. I just wanted to show that it would be viable to have a programming language instead of a markup language while retaining the markup language properties.

Trezker
Member #1,739
December 2001
avatar

Should we turn jpeg into a programming language too?

Thomas Fjellstrom
Member #476
June 2000
avatar

axilmar said:

Proving that HTML is Turing-complete was not the purpose of my comment. I just wanted to show that it would be viable to have a programming language instead of a markup language while retaining the markup language properties.

I think you ignored his point. You didn't turn HTML into a programming language. You just implemented a new renderer for it.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

bamccaig
Member #7,536
July 2006
avatar

I don't see why people are assuming that this hypothetical HTML "programming language" (or H#, as Tobias dubbed it) would render a document. That doesn't make sense. If it's a programming language then it's going to do whatever the program does! Prompt the user for a number, calculate a sum, print "Hello, World" on the standard output device. Whatever. That said, it would no longer be HTML, as Tobias said, it would be something that just happens to also be (different) HTML.

axilmar
Member #1,204
April 2001

Trezker said:

Should we turn jpeg into a programming language too?

There are no requirements for interactivity on a jpeg image.

I think you ignored his point. You didn't turn HTML into a programming language.

I did ignore his point, because what I discussed is not what he discussed. I agree with him, I didn't turn HTML into a programming language. That was not my purpose. What I wanted to show is that there could be a programming language, that its programs looks like markup, and still be a fully-fledged programming language.

bamccaig said:

I don't see why people are assuming that this hypothetical HTML "programming language" (or H#, as Tobias dubbed it) would render a document. That doesn't make sense. If it's a programming language then it's going to do whatever the program does! Prompt the user for a number, calculate a sum, print "Hello, World" on the standard output device.

Exactly. And one use of it would be to output a gui within a browser.

Tobias Dammers
Member #2,604
August 2002
avatar

axilmar said:

What I wanted to show is that there could be a programming language, that its programs looks like markup, and still be a fully-fledged programming language.

XSLT pretty much shows this already. If you load the right functions into the XSLT processor to hook into the host environment, you can do pretty much anything with it.

I was originally arguing about this statement:

Well I've been told that any scripting language can be a programming language and any programming language can be a scripting language, just takes a person making the interpreter and compiler for each language. With HTML I suppose it could be, but don't think it would be very powerful by itself and without a overhaul.

The point being that HTML is neither a scripting language nor a programming language, and the fact that you can write a compiler that compiles HTML into machine code doesn't change a bit about the expressivity of the original language (that is, if it cannot be expressed in HTML, then the HTML-to-machine-code compiler cannot produce it either).

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Thomas Fjellstrom
Member #476
June 2000
avatar

axilmar said:

What I wanted to show is that there could be a programming language, that its programs looks like markup, and still be a fully-fledged programming language.

Except you didn't show that. And IMO a markup language and a programing language are mutually exclusive. And for good reason. Why in the love of god would you want to write a complex program in xml? It makes no sense. Simple template logic is different, but a full program? You'd have to be insane.

XSLT pretty much shows this already. If you load the right functions into the XSLT processor to hook into the host environment, you can do pretty much anything with it.

XQuery and friends are probably better suited for that. XSLT is a horrible horrible HORRIBLE thing.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

axilmar
Member #1,204
April 2001

XSLT pretty much shows this already. If you load the right functions into the XSLT processor to hook into the host environment, you can do pretty much anything with it.

XSLT is a tool for transforming XML, isn't it? I am talking about a programming language. Perhaps XSLT is Turing-complete, but I've read somewhere that's difficult and awkward to use as a general-purpose programming language.

Quote:

The point being that HTML is neither a scripting language nor a programming language, and the fact that you can write a compiler that compiles HTML into machine code doesn't change a bit about the expressivity of the original language (that is, if it cannot be expressed in HTML, then the HTML-to-machine-code compiler cannot produce it either).

Agreed.

Except you didn't show that.

Please reread my post carefully. I presented an example of how the tag H1 actually represented a function in a library that made the output present headers in big font style.

Quote:

And IMO a markup language and a programing language are mutually exclusive. And for good reason. Why in the love of god would you want to write a complex program in xml? It makes no sense. Simple template logic is different, but a full program? You'd have to be insane.

They are not mutually exclusive. A markup language has the advantage of easy parsing, and if it's a programming language, then the presentation can be specified in terms of the language itself. The big advantage is that the rendering will be the SAME in all browsers, and also maintaining the advantage for web designers.

Thomas Fjellstrom
Member #476
June 2000
avatar

axilmar said:

Please reread my post carefully. I presented an example of how the tag H1 actually represented a function in a library that made the output present headers in big font style.

You know, or you could use CSS. I really don't see the point in tying it to a library.

HTML already does what you show. It renders specific text and objects given various markup. Add in some CSS, and you get EVERYTHING you wanted. Why this pointless discussion?

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Tobias Dammers
Member #2,604
August 2002
avatar

axilmar said:

Please reread my post carefully. I presented an example of how the tag H1 actually represented a function in a library that made the output present headers in big font style.

Yes, you did. It doesn't show your point though. If the compiled code behaves like a user agent would if fed the original HTML, then you haven't changed the language itself a bit. You have merely implemented a way to produce a self-rendering machine-code representation of it.

Quote:

XSLT is a tool for transforming XML, isn't it? I am talking about a programming language. Perhaps XSLT is Turing-complete, but I've read somewhere that's difficult and awkward to use as a general-purpose programming language.

It is a tool for transforming XML into other XML, or HTML, or arbitrary text, yes. And you are right, it is terribly verbose and uncomfortable. The interesting point, however, is that it is both a Turing-complete programming language AND a valid subset of XML. You can feed it to any XSLT-agnostic generic XML tool, and it will process it without problems (in fact, you can use XSLT to process XSLT source); but you can also run it as XSLT, in which case it is just another interpreted programming language. Taken to the extreme, any source code format would work, since they're all valid text files, but I picked XSLT because its XML-based source code is closely related to HTML.

You know, or you could use CSS. I really don't see the point in tying it to a library.

The only reason I can think of would be when you have to deploy the HTML to a system that is both severely crippled (in terms of hardware resources) and lacks a useable HTML user agent. These days, I'd be hard pressed to find such an environment.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

weapon_S
Member #7,859
October 2006
avatar

Perhaps some math savvy individual could manipulate a rendered HTML-file to solve geometrical problems, in the kind of fashion the ancient Greeks did ;D

Evert
Member #794
November 2000
avatar

And IMO a markup language and a programing language are mutually exclusive.

TeX is Turning complete, so is PostScript. I realise that neither of those is eactly what you were thinking of and I wouldn't try writing complicated programs in either of them, but it's still clear that the distinction is not necessarily as clear-cut as you might think if you're comparing HTML and PHP (say).

Thomas Fjellstrom
Member #476
June 2000
avatar

I wouldn't say either of those are pure markup ;)

When you can use PostScript to infect your printer with a virus/trojan, its not really just markup :P

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

axilmar
Member #1,204
April 2001

It seems my point was completely missed. So, here it is again, this time with examples:

Right now, the situation is like this:

#SelectExpand
1//mozilla code 2void render_h1(context *context) { 3 ... 4} 5 6//IE code 7void RenderH1(HCONTEXT context) { 8 ... 9} 10 11//chrome code 12void render_H1(Context &context) { 13 ... 14} 15 16//safari code 17void renderH1(Context *context) { 18 ... 19}

In other words, each browser has its own rendering engine, making pages render differently on each browser.

Not only that, but extending the markup with new tags takes a huge amount of time.

The problem could be eliminated, if the actual rendering code was part of the code of the page itself. Then, every browser would run this:

//this code is in the page itself, it's not in the browser.
void render_H1(Context &context) {
    ...
}

The function 'render_H1' would be called by the browser when the tag 'h1' was found during parsing.

Thus, two major problem would be solved:

1) rendering incompatibilities between browsers.
2) extension of the language with new tags.

Since the rendering code would be part of the page, the HTML would no longer be simply a markup language, but a fully fledged Turing-complete programming language.



Go to: