Jump to content


Photo

Very High Level Language Design


  • Please log in to reply
208 replies to this topic

#1 sylvan

sylvan

    GMC Member

  • New Member
  • 99 posts

Posted 26 January 2010 - 10:05 AM

This is a simple topic really, if you were to make a high level language (to very high level) how would you structure it? More specifically, how would you seek to make the language useful without needing a massively high learning curve.

This boarders on natural-language like algorithms. How would you structure a programming language, to get the most done, in the least amount code.

An idea that I thought of, was when browsing (and editing) wiki pages.

You would write code in a more or less natural way, then any syntax that is not understood by the machine is highlighted. The programmer then burrows down, filling in each word until the program is complete.

For example, here is the wiktionary definition of a circle.
http://en.wiktionary.org/wiki/circle
The words " two-dimensional", "geometric figure", "set", "points" and "plane" are all highlighted, and link to their respective definitions.

Now ideally, the programmer could write "draw circle" and the computer would trace through the definitions of draw and circle until it met things it understood (presumably, a definition would be written in a low level language that a compiler would understand).

Ultimately, if the wiki was complete, programmers wouldn't need to write code (it would all be there) and would just need to describe the application.

Of course, it's not a simple as that. Various rules would need to be in pace to prevent recursive definitions, the language would need to be structured so that natural language programming is kept to a minimum etc. The idea would be that any time anyone uses the language, the wiki would necessarily grow, and would never shrink. It would be like a open source library, that gets added to every time anyone writes an application, while remaining intuitive enough to be learnt with minimum fuss (they would just have to learn the syntax).

What are other people's thoughts on approaches to high level languages?

Edited by KC LC, 29 January 2010 - 10:16 PM.
Fixed spelling error in title. If you can't spell "high level", I'm not sure there's much more to say.

  • 0

#2 ramses12

ramses12

    6

  • GMC Member
  • 5769 posts
  • Version:GM8.1

Posted 26 January 2010 - 06:12 PM

Probably the most important aspect in a programming languace is the ability to extend itself. It doesn't have to be structured like a normal languace, but it should be understable by the programmer. IMO the best languace style is C++, because it uses a balanced amount of symbols and keywords, and bases itslef on functions, keeping organised and easy to divide into parts.
  • 0

#3 PlasticineGuy

PlasticineGuy

    GMC Member

  • New Member
  • 2384 posts

Posted 28 January 2010 - 02:31 AM

An example of a really bad high-level language is Visual Basic. It seems to rely on keywords too much:
Dim Var As Integer
As opposed to:
int Var;

Your idea sounds like it would take a very long time to compile. But as long as there is some way to extend it with a lower level language (asm or C, perhaps even DLLs) it sounds OK.
  • 0

#4 Endorel

Endorel

    GMC Member

  • Banned Users
  • 191 posts

Posted 28 January 2010 - 04:42 AM

This is just a silly concept that would only make all matters worse. Why not design a some-what low level language which doesn't require any references or manuals because it would have loose syntax rules, as well as have many pre-defined functions which can have multiple names. So if you think that the function for getting the direction between two points would most likely be angle_between_points, rather than point_direction, then so be it.

By the way, this topic is indeed related to GML because it is possible to create new low-level languages using GML.

Edited by SnowCream, 28 January 2010 - 04:53 AM.


#5 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 28 January 2010 - 05:00 AM

I am missing where this is related to GM or useful in any sense toward GM what so ever....

What we need is not another language in the midst of all the ones out there, but new capabilities using a pre-existing, but popular and extensible language in which to better empower each programmer as an individual to get more done quickly, a perfect example of this is C#. Using a super high level language will end up taking the programmer longer to write because they would need to use more useless words to describe all the details. For example: "draw circle" would not mean anything to any compiler, for where will its center be, how big is this circle, is it filled in or outlined, if outlined then how thick should the line be, what color is it, etc? You would end up writing a whole sentence for a simple command:

"Draw an outline of a circle whose center is at (10,10) that has a radius of 100 pixels, a line width of 1 pixels, and is the color blue".


Mean while using a lower, high level language such as GM you can just type:

"draw_set_color(c_blue); draw_circle(10,10,100,true);"

Its easier, and faster for the trained programmer to read and understand the second, rather than sentences.
  • 0

#6 ramses12

ramses12

    6

  • GMC Member
  • 5769 posts
  • Version:GM8.1

Posted 28 January 2010 - 08:30 AM

Yeah. High-level doesn't mean an AI understanding everything you write, it is giving many possibilities without using a huge base.
  • 0

#7 PlasticineGuy

PlasticineGuy

    GMC Member

  • New Member
  • 2384 posts

Posted 28 January 2010 - 09:07 AM

I define a programming language's level as the amount of code needed to do a given thing. For example, drawing a rectangle to a screen is easiest in Game Maker (one line), so it is a much higher level language, whereas with C, you need hundreds of lines of code to set up Direct3D.
  • 0

#8 sylvan

sylvan

    GMC Member

  • New Member
  • 99 posts

Posted 28 January 2010 - 09:14 AM

Your idea sounds like it would take a very long time to compile. But as long as there is some way to extend it with a lower level language (asm or C, perhaps even DLLs) it sounds OK.


Compiling would be long, especially if it's a wiki on the internet. The compiler would need to reference and link all the web pages, which would be a pain. Of course, some kind of cache could be used. Also, the syntax structure could make constructing the language more efficient (for example making lines of code tuples e.g. "john is person", "keyboard moves john", "john is 3d", etc)

mysql is the easiest language to understand but the problem is that its too easy, making it confusing to people who are use to more complex language and styles

My SQL isn't a programming language. You can't do loops in SQL. But I agree, it is (usually) easy to read.

This is just a silly concept that would only make all matters worse. Why not design a some-what low level language which doesn't require any references or manuals because it would have loose syntax rules, as well as have many pre-defined functions which can have multiple names. So if you think that the function for getting the direction between two points would most likely be angle_between_points, rather than point_direction, then so be it.

A low level language is like, assembly or machine code. But the problem of very loose syntax rules is that it makes the compiler very difficult to write. However, going back to what I suggested, I think you can achieve what you've outlined there. You could write the function point_direction, and make angle_between_points a redirect to it. Much like how you can go into wikipedia and type "SSBB" and get to the Super Smash Bros. Brawl article.


I am missing where this is related to GM or useful in any sense toward GM what so ever....

It's related to game development in general, and can be implemented in GML. It also relates to creating games that are genuinely re-usable. For example, writing game engines that are extremely customisable and very easy to install. I'll address the rest of your points at the same time as expanding on this. Sure, in game maker, it's fairly easy to write something that draws a circle, but what about if you want to pause the game perfectly? Or make items go into an inventory. The amount of code required to makes this happen is much higher in GML, and has to be re-invented by someone every time they want to do this. But if you could write in almost natural language, you could tell GM to pause the game, and it would do it.

For example, you could write:
view is first person
mouse turns camera
arrow keys move player
click is shoot
collide with ammo picks up ammo
collide with bullet reduces health
cannot move through walls

etc
This is obviously a non-working example, but just to show how it may be done. With relatively little code, you could create a first person shooter.

As a comparison, trying to write say, a simple platformer in Java takes massive amounts of code. (GML is a lot better in this regard, but still has some limitations)
  • 0

#9 blue_chu_jelly

blue_chu_jelly

    Shut your FMaj7

  • GMC Member
  • 228 posts

Posted 28 January 2010 - 12:03 PM

the problem I see is that this meothod would have to be incredibly good at understanding what is wanted.

For example, you could write:
view is first person
mouse turns camera
arrow keys move player
click is shoot
collide with ammo picks up ammo
collide with bullet reduces health
cannot move through walls


That's too vague. view is first person, but what's the FOV? where will it be initially orientated to?
  • 0

#10 sylvan

sylvan

    GMC Member

  • New Member
  • 99 posts

Posted 28 January 2010 - 01:40 PM

That would be all pre-defined by default. Kinda like the show_message function in GML. It'll show a message in the default text box, unless you overwrite it. It stops people having to reinvent the wheel every time they just want something that works. First person implies the camera should be stationed at head height of the central character object. Of course, what I wrote there was too vague to make a proper language out of, but I'm just illustrating a point.

The topic for discussion is along the lines: is such a language possible?

It would be integrating description languages such as (potentially) OWL and programming languages, to make a language that are very high level, but still usable for any application.
  • 0

#11 Endorel

Endorel

    GMC Member

  • Banned Users
  • 191 posts

Posted 29 January 2010 - 01:17 AM

For example, you could write:
view is first person
mouse turns camera
arrow keys move player
click is shoot
collide with ammo picks up ammo
collide with bullet reduces health
cannot move through walls

This would be kind of cool, except for the last 3 lines are laughably stupid.

#12 josh462365

josh462365

    GMC Member

  • GMC Member
  • 826 posts
  • Version:Unknown

Posted 29 January 2010 - 04:30 AM

For example, you could write:
view is first person
mouse turns camera
arrow keys move player
click is shoot
collide with ammo picks up ammo
collide with bullet reduces health
cannot move through walls

This would be kind of cool, except for the last 3 lines are laughably stupid.


all are stupid...you need to set variables for that to work... if you want the arrow keys to move players, how many pixels per step do you want them to move? or is the super high uber level language going to decide that for you? this is a joke....or at least that guys interpretation of it.
  • 0

#13 GameGeisha

GameGeisha

    GameGeisha

  • GMC Member
  • 2738 posts
  • Version:GM:Studio

Posted 29 January 2010 - 05:53 AM

Designing a language like this is pointless. You need to acknowledge that computers are no good at heuristics the way we are. Programming languages allow us to organize our abstract and creative thoughts into more procedural, black-and-white instructions that computers are designed for.

Let's take your sample code for instance:
view is first person
mouse turns camera
arrow keys move player
click is shoot
collide with ammo picks up ammo
collide with bullet reduces health
cannot move through walls

There remains ambiguities in the above "code", some of which are listed below:
- Where is the first-person projection from? What's on the projection? (e.g. score panel)
- How fast should the camera turn? Which way can it turn?
- How does the player move? Does the up arrow make the player jump or move forward?
- What is the player shooting? What kinds of ammo are in the game?
- Where does the ammo go? In the knapsack or straight into the gun?
- How much health does colliding with a bullet deduct? 1HP or instant kill?

Surely you can add the specifications for each of the ambiguities above, but doing so will require adding something else at arbitrary points of the source code. At some level when nothing is ambiguous, you would have been doing as much work as coding in a "lower" level language, around GML's range. The result is a completely disorganized verbose mess that a compiler would have some real trouble going through.

So far this seems like "a noob's ideal language", where the computer is doing mere guesswork and the user expects it to read his/her mind. This defeats the entire purpose of programming languages in itself. As of now I cannot see any practical avenue for implementing something like this.

GameGeisha

Edited by GameGeisha, 29 January 2010 - 05:57 AM.

  • 0

#14 sylvan

sylvan

    GMC Member

  • New Member
  • 99 posts

Posted 29 January 2010 - 07:34 AM

all are stupid...you need to set variables for that to work... if you want the arrow keys to move players, how many pixels per step do you want them to move? or is the super high uber level language going to decide that for you? this is a joke....or at least that guys interpretation of it.

Let me ask this: You mention pixels per step. Why question the number of pixels to move, when the step speed (30 per second) is totally arbitrary in the first place? Sure, you can change the room speed in GM, but it's just as easy to leave it at the default. Is that not the same thing?

So far this seems like "a noob's ideal language", where the computer is doing mere guesswork and the user expects it to read his/her mind. This defeats the entire purpose of programming languages in itself. As of now I cannot see any practical avenue for implementing something like this.

Ok, perhaps I was being a bit extreme with that example. But really, nothing stops using default values. In Java, for example, creating a button can be done in a dozen different ways. Many have their own defaults.

The sentence you've written may as well be applied to C++ vs assembly code. In assembly you have extreme control over the machine, where as in C++ you loose a bit of control, to make way for ease of use. The point is, languages prefer to be easy to use, as opposed to being machine readable.

You don't have to discuss the language I've proposed if you think it's dumb. Fair enough. It's not implemented, and probably will never be implemented. But looking at languages such as GML. It's obvious to see how much work Game Maker saves when compared to writing a similar program in Java. The difference is enormous. When I wrote this topic, I was thinking "what if there was a way to make a language more high level than GM". I personally think it would be nice if some of the advanced coders clashed heads and came up with ways of making GM more flexible to non-coders. A HLL is just one way of doing that.
  • 0

#15 PlasticineGuy

PlasticineGuy

    GMC Member

  • New Member
  • 2384 posts

Posted 29 January 2010 - 07:45 AM

I fail to see how GML could be higher-level. It contains functions for nearly everything.
  • 0

#16 general sirhc

general sirhc

    YW Creator

  • New Member
  • 1651 posts

Posted 29 January 2010 - 10:55 AM

I don't think anyone has mentioned it yet but this super dooper high level language would be horrible to type, for example this sentence has taken me a lot longer to type than...
if (!happy_with_typing) show_message("I don't like lots of typing")

GML has really covered an easy language as well as possible

if (shooting and not dead) move_towards_point(10,10, 5);

Easy eh?
  • 0

#17 GameGeisha

GameGeisha

    GameGeisha

  • GMC Member
  • 2738 posts
  • Version:GM:Studio

Posted 29 January 2010 - 02:44 PM

An important concept to grasp at this point is abstraction, a subconcept of encapsulation.

When a language enters a new level, a new layer of abstraction is laid so that the minimum area of full control is set at a higher level. Assembly is in near full control as it contains little abstraction away from how a machine works. A higher level language, C++ for instance, introduces a layer of variables, objects and methods, which is its mechanism of abstraction away from a machine's inner workings.

Highest level

Objects -> Methods and defined variables -> Reusable unit
Methods, reusable unit -> Definitions -> Basic construct
Basic construct -> Basic construct model (e.g. Object-oriented) -> Basic instructions
Basic instructions -> Binary data stream -> Machine

Lowest level


Abstraction can also occur outside the digital realm, occuring as part of development in processes such as the communication between designers and programmers. There is a layer between the two positions even when the same person is both simultaneously.

Highest level

Designer -> Design proposal -> Programmer
Programmer -> Programming language -> Compiler
Compiler -> Binary code -> Native code
Native code -> Runtime environment -> Machine

Lowest level


Now look at this language. If I write in this language, I am still defining objects (e.g. view is first person), creating methods (e.g. shoot bullet), and setting variables (e.g. decrease health) -- there is no additional layer of abstraction in the language itself compared to something like GML. However, I am doing so in a completely subjective manner, with required definitions still missing from the equation, which invalidates the language as a medium of communication between human and computer.

You don't have to discuss the language I've proposed if you think it's dumb.

When I described your language as "a noob's ideal language", I did not mean to say was not that your language is dumb in any way, but that it is so ambiguous and heuristic in nature, it approaches the abstraction level of natural languages used in design proposals, which is beyond the point of the programmer itself. You may as well just feed design documents through a scanner and expect the computer to make the final product based on them.

GameGeisha
  • 0

#18 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 30 January 2010 - 08:27 PM

Surely you can add the specifications for each of the ambiguities above, but doing so will require adding something else at arbitrary points of the source code. At some level when nothing is ambiguous, you would have been doing as much work as coding in a "lower" level language, around GML's range. The result is a completely disorganized verbose mess that a compiler would have some real trouble going through.

So far this seems like "a noob's ideal language", where the computer is doing mere guesswork and the user expects it to read his/her mind. This defeats the entire purpose of programming languages in itself.


Thats exactly what I'm saying.

You may as well just feed design documents through a scanner and expect the computer to make the final product based on them.


Now theres an idea worth exploring! As a matter of fact there is some similarity between the topics problem and the problem with creating a program such as this. There is so much ambiguity in what a particular letter looks like in terms of scale, skew, font, style, etc that a person writes that it is nearly impossible to create a program that reads an image and makes sense out of what is being said. Not to mention taking advantage of shapes and drawings that one might make that computer would then have to make sense of. Ambiguous Language is an art equivalent to drawing an idea. Neither of which is very good without specific structure. Let the Constitution of the United States of America be Exhibit A.

Edited by margoose, 30 January 2010 - 08:28 PM.

  • 0

#19 PlasticineGuy

PlasticineGuy

    GMC Member

  • New Member
  • 2384 posts

Posted 30 January 2010 - 10:19 PM

That's not actually possible.
  • 0

#20 Rusky

Rusky

    GMC Member

  • New Member
  • 2450 posts

Posted 01 February 2010 - 01:38 AM

OCR is possible, actually. Computers can also parse sentences and, if they have enough context, "understand" a lot. It's just not practical for a programming language.

High level programming languages generally allow you to be more concise, not more vague. They add or change concepts so that you can describe more complex ideas without becoming verbose. C++ is actually a very low-level language compared to some of the others out there, and Java and C# aren't much higher. Yes, they got rid of pointers and garbage collection, but that didn't really make them very much higher level.

An example of a language higher-level than C++ or Java is Lisp. Lisp does away with variables and methods and deals with functions. These functions are not the kind of functions you generally talk about, also called procedures, scripts or subroutines. They're closer to mathematical functions. They describe relationships between values. For example:
(define foo (x) x + 3)
Then the expression (foo 3) would evaluate to 6. You can build up extremely complicated relationships this way without the program becoming hard to understand. Of course you have to actually do things at some point, but in this paradigm that kind of thing is kept to a minimum. This makes it much easier to understand a program- you can understand it in pieces, and you won't have other parts of the program changing the system's state and confusing you. Because you think about higher level concepts- functions and expressions rather than a series of actions and locations to store data- Lisp is higher level.

An even higher level language is Haskell. Haskell adds types and type classes to Lisp's functional paradigm, and lets you work with functions that deal with more general types in a simpler way than C++ templates. This paradigm, called functional programming, also generally uses recursion rather than looping and has first-class functions- functions are also considered objects, and you can pass them around to other functions. You do things very differently in some respects, but overall, functional programming lets you focus

These aren't the only ways to be higher-level, either. But overall, functional programming makes it easier to create and use abstractions and is still concise. It's not just a magical compiler that understand vague statements.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users