Programing language

Brainstorm ideas of possible additions to the game. Read this before posting!

Moderator: Forum Moderators

Forum rules
Before posting a new idea, you must read the following:
User avatar
Gambit
Loose Screw
Posts: 3266
Joined: August 13th, 2008, 3:00 pm
Location: Dynamica
Contact:

Re: Programing language

Post by Gambit »

Well - what is more easy:

Code: Select all

if($var1 == 1 || $var2 == 2) {
  ...
}

Code: Select all

[if]
  [variable]
    name=var1
    equals=1
  [/variable]
  [or]
    [variable]
      name=var2
      equals=2
    [/variable]
  [/or]
  [then]
    ...
  [/then]
[/if]
that depends largely on how you define easy. while the first one is SO very much shorter, it is quite noticably a very mechanical language. it looks like foriegn jargon to anyone who doesnt already know the language.

the second one, while quite long, is a very very human language that all can easily read and understand. it flows and has words.

i apologize for the personal attacks.


all in all the fact taht anyone and everyone can mod wesnoth with just a few hours of reading is what makes it so awsome.

if you replace WML with anything else out there you will not only scare newbies away from ever modding, but also render everything done thus far obsolete.


also when i made a mistake i would hate to get an error message about invalid pointers and missing arguments.

its much easier to track down "missing closing tag for tag option in such and such a file


why fix what isnt broken? its constantly being upgraded and made better and more power and what not.
uzytkownik
Posts: 126
Joined: April 19th, 2008, 7:12 pm
Contact:

Re: Programing language

Post by uzytkownik »

Gambit wrote:
Well - what is more easy:

Code: Select all

if($var1 == 1 || $var2 == 2) {
  ...
}

Code: Select all

[if]
  [variable]
    name=var1
    equals=1
  [/variable]
  [or]
    [variable]
      name=var2
      equals=2
    [/variable]
  [/or]
  [then]
    ...
  [/then]
[/if]
that depends largely on how you define easy. while the first one is SO very much shorter, it is quite noticably a very mechanical language. it looks like foriegn jargon to anyone who doesnt already know the language.

Code: Select all

if(var1 == 1 or var2 == 2) {
   ...
}
Better?

The WML Code would be only verbose if it'd look like:

Code: Select all

[if]
  [alternative]
    [or]
      [variable]
        name=var1
        equals=1
      [/variable]
    [/or]
    [or]
      [variable]
        name=var2
        equals=2
      [/variable]
    [/or] 
  [/alternative]
As otherwise I landed with code:

Code: Select all

[if]
   {1}
   [and]
      {2}
      [or]
        {3}
      [/or]
   [/and]
[/if]
to express:

Code: Select all

if ({1} and ({2} or {3})
And this is solution proposed by my friend (well - in form "if at least it would be")

Code: Select all

[if]
  {1}
  [alternative]
    [or]
      {2}
    [/or]
    [or]
      {3}
    [/or]
  [/alternative]
Gambit wrote: the second one, while quite long, is a very very human language that all can easily read and understand. it flows and has words.
The above example is not human. At least not to me. But I do agree that the 'normal' cases the WML handles very well.
Gambit wrote:if you replace WML with anything else out there you will not only scare newbies away from ever modding, but also render everything done thus far obsolete.
I could bet I mentioned it (well sort of).
Gambit wrote:also when i made a mistake i would hate to get an error message about invalid pointers and missing arguments.
Well:
1. I DO NOT PROPOSE C/C++. No problems with pointers ;). Much less occasions to shoot yourself in foot.
2. I do want to have an error. It is SO easier to find errors if they are reported. I made a misspelling of "description" in message and it wasn't detected neighter by wesnoth nor by wmllint. The same problem I had with macro.
Gambit wrote:its much easier to track down "missing closing tag for tag option in such and such a file
Well - syntax errors still will be recognized. Runtimes errors WML do not detect.
Gambit wrote:why fix what isnt broken? its constantly being upgraded and made better and more power and what not.
Well I listed several pros.
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Programing language

Post by Sapient »

Viliam wrote: Yet the first one is IMHO not intimidating...

Code: Select all

$side1 = {
  "name"   => "dwarves",
  "leader" => {
    "type"       => "Dwarvish Fighter",
    "id"         => "Burin",
    "name"       => _"Burin the Lost",
    "canrecruit" => YES
  }
};
There are so many ways that a novice could stumble here.
#1 - it's not evident to a non-programmer why "canrecruit" must have quote marks around it but side1 and YES do not. If the role of quote marks is not evident then they are very likely to omit them or put them in when they shouldn't have.
#2 - the difficulty of balancing { }'s -- if you forget one of them or accidentally add one too many or delete one too many while editing your code, then you can end up with an unbalanced mess that is very difficult to untangle.
#3 - oops I forgot a comma... it still "looks" right, though, because the comma is easy to overlook when you are scanning the code.
#4 - oops I forgot a semi-colon... it still "looks" right, though, because the semicolon is easy to overlook when you are scanning the code.


I think some of them would be very likely to throw their hands up in frustration.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Re: Programing language

Post by Dave »

ivan wrote:
Dave wrote: I think plenty of people would disagree with you fairly strongly on that. :)
And plenty of people would strongly agree :)
What with the statement that there are no python concepts that are harder to grasp than WML concepts?

Mutability. References to objects. Meta-classes. Lambda functions. List comprehensions.

Are you seriously telling me that these aren't much more complicated than any feature found in WML?
ivan wrote: x,y=4,8 is perfectly valid Python syntax.
Not when calling a function with named parameters it's not.

Which is a very good example of the kind of thing that will confuse people who don't want to feel like they're programming.
ivan wrote: I don't know what [+append] means, but I'm sure something similar can be implemented in Python.
Not without it looking like programming.

---

We have this discussion every few months. People tell us that WML is terrible/bad/awful/crappy and we should be using Python/Lua/their favorite pet technology which can do anything. Even if I was writing Wesnoth from scratch, I think I would still use WML, because I believe that its use is the biggest reason why we have such a vibrant community of custom scenario makers.

Additionally, as far as I have seen, almost no-one who suggests moving to some scripting language has spent any significant time making Wesnoth content. They just take one look at WML, and say "oh that's silly, they should use my favorite technology."

I'm more inclined to listen to the actual makers of Wesnoth content and hear what they want.

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
User avatar
Wintermute
Inactive Developer
Posts: 840
Joined: March 23rd, 2006, 10:28 pm
Location: On IRC as "happygrue" at: #wesnoth-mp

Re: Programing language

Post by Wintermute »

Anectodotal I know, but I have a friend who assured me in the strongest terms - multiple times - that he was not a programmer and could not possibly learn WML. However, he has learned enough to contribute some great user made content to the community.
"I just started playing this game a few days ago, and I already see some balance issues."
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Programing language

Post by Sapient »

uzytkownik wrote: As otherwise I landed with code:

Code: Select all

[if]
   {1}
   [and]
      {2}
      [or]
        {3}
      [/or]
   [/and]
[/if]
to express:

Code: Select all

if ({1} and ({2} or {3})
And this is solution proposed by my friend (well - in form "if at least it would be")

Code: Select all

[if]
  {1}
  [alternative]
    [or]
      {2}
    [/or]
    [or]
      {3}
    [/or]
  [/alternative]
Look. Maybe you should actually learn the syntax before criticising it.
Wesnoth supports both nesting and/or/not and listing it sequentially.

So all of the following are equivalent:

Code: Select all

{1} 
[and]
  {2}
  [or]
    {3}
  [/or]
[/and]

Code: Select all

{2} 
[or]
  {3}
[/or]
[and]
  {1}
[/and]

Code: Select all

{1} 
[and]
  #deprecated or-syntax, but it still works
  [or]
    {2}
  [/or]
  [or]
    {3}
  [/or]
[/and]
this last example, which your friend likes, is the least natural when compared with spoken english. You wouldn't say "I'd like or an apple or an orange", no, so I think the first style is more intuitive. That is one of the reasons why it's deprecated.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
Viliam
Translator
Posts: 1341
Joined: January 30th, 2004, 11:07 am
Location: Bratislava, Slovakia
Contact:

Re: Programing language

Post by Viliam »

Dave wrote:It'd also be a lot less convenient than WML unless you plan to add a pre-processor on top of Python as well.

Also after reading this data in, I don't think it'd be possible to serialize back to the same format (correct me if I'm wrong on that).
I guess that after WML macros have been expanded, it would be also impossible to return the data to the original form. This also makes it difficult to make a campaign editor.


By the way, with heavy use of macros one could turn WML to something like Lisp. :twisted: Like this:

Code: Select all

{IF {OR {EQUALS $var1 1} {EQUALS $var2 2}}
  ...
}
Sapient wrote:it's not evident to a non-programmer why "canrecruit" must have quote marks around it but side1 and YES do not.
I am not sure about Perl syntax, but probably the keys in hashmap do not have to be in quotes, which would make the example even more similar to WML.
Sapient wrote:the difficulty of balancing { }'s -- if you forget one of them or accidentally add one too many or delete one too many while editing your code, then you can end up with an unbalanced mess that is very difficult to untangle.
I hate to admit it, but you are right about this. For me as an experienced programmer, it is easy to keep lines in source files correctly indented without thinking, which would make wrongly placed {}'s obvious. But I am teaching small kids programming in Java, and they have big problems with this -- they just copy-paste some piece of code, randomly put it either inside {}'s or after them, and it seems to make no difference for them. And they absolutely do not care about indenting lines, despite the Eclipse environment can do it automatically for them, and it would explain half of their errors. But they just don't do it, and I do not know how to explain them that it is really necessary. So it is almost sure that beginning WML developers would have the same kind of problem.

Dave wrote:What with the statement that there are no python concepts that are harder to grasp than WML concepts?

Mutability. References to objects. Meta-classes. Lambda functions. List comprehensions.
None of these things needs to be used in a "standard Wesnoth library".

And this is exactly why suggestions like "could we use langauge X in Wesnoth" are very incomplete. It is not enough to propose usage of the language X; it is also necessary to specify how exactly it should be used, because that can make a great difference in difficulty.

For example if we would use Ruby for Wesnoth scripting, what exactly would be things like "side", "unit" -- hash maps? objects? What would be "message" -- hash map? object? function? There are many design decisions, each brings us a very different "Wesnoth scripting in Ruby". So it is up to proponents to bring out an exact example of how to write a WML scenario in scripting language X so that it 1) is not more difficult, and 2) brings some advantage. And even then it would be very questionable if the advantage is worth of the necessary work. Probably not.
uzytkownik
Posts: 126
Joined: April 19th, 2008, 7:12 pm
Contact:

Re: Programing language

Post by uzytkownik »

Sapient wrote:
uzytkownik wrote: As otherwise I landed with code:

Code: Select all

[if]
   {1}
   [and]
      {2}
      [or]
        {3}
      [/or]
   [/and]
[/if]
to express:

Code: Select all

if ({1} and ({2} or {3})
And this is solution proposed by my friend (well - in form "if at least it would be")

Code: Select all

[if]
  {1}
  [alternative]
    [or]
      {2}
    [/or]
    [or]
      {3}
    [/or]
  [/alternative]
Look. Maybe you should actually learn the syntax before criticising it.
Wesnoth supports both nesting and/or/not and listing it sequentially.

So all of the following are equivalent:

Code: Select all

{1} 
[and]
  {2}
  [or]
    {3}
  [/or]
[/and]

Code: Select all

{2} 
[or]
  {3}
[/or]
[and]
  {1}
[/and]

Code: Select all

{1} 
[and]
  #deprecated or-syntax, but it still works
  [or]
    {2}
  [/or]
  [or]
    {3}
  [/or]
[/and]
this last example, which your friend likes, is the least natural when compared with spoken english. You wouldn't say "I'd like or an apple or an orange", no, so I think the first style is more intuitive.
I know - but it do not help much. I didn't know the deprecated syntax - but I do like it (compared to others).
When I look on the syntax the least factor I look is the similarity to natural language. It is sometimes much simpler to have logical structure - not gramatical.

Code: Select all

[code]
{2} 
[or]
  {3}
[/or]
[and]
  {1}
[/and]
[/code]

Is it

Code: Select all

if ({2} or ({3} and {1}))
or

Code: Select all

if (({2} or {3}) and {1})
I cannot say on the first sight - the first expression ({2}, {3}) 'should be' more nested then the outer ({1}) to visually indicate the... well I call it now AST from lack of better name coming to my mind (I know it is not AST but I guess you know what I mean).
ivan
Posts: 15
Joined: April 28th, 2008, 12:42 pm

Re: Programing language

Post by ivan »

WML is great game markup language. I agree.

But, in my opinion, it's not the best tool for certain tasks. It is a pain to program in markup language, and, maybe it is the biggest reason why most people who know Lua, Ruby, Python or JavaScript are complaining instead of being part of scenario-maker community.

I love Wesnoth and I do want to make something to make it better, that's why I am discussing this here.

Ivan
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Programing language

Post by Sapient »

ivan wrote: WML is great game markup language. I agree.

But, in my opinion, it's not the best tool for certain tasks. It is a pain to program in markup language, and, maybe it is the biggest reason why most people who know Lua, Ruby, Python or JavaScript are complaining instead of being part of scenario-maker community.

I love Wesnoth and I do want to make something to make it better, that's why I am discussing this here.

Ivan
Honestly I doubt that typing [/closing] tags is such a deterrent to contribution that you would have us believe, but if you are serious then I suggest you try the Emacs mode for WML, which has tab-completion among other features. I love Python, C++, and also WML. I also believe WML is the best choice out of these three for coding scenarios in Wesnoth.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Re: Programing language

Post by Dave »

ivan wrote: WML is great game markup language. I agree.

But, in my opinion, it's not the best tool for certain tasks. It is a pain to program in markup language
I agree with this. Our design is to try to minimize the programming in WML by making it mostly a configuration/data language with the engine containing as much programming as possible. The ability to perform programming-like operations in WML is a fallback for times when the engine really doesn't do what you want.

If you look at the WML we ship with the game, I'd say that only a very small percentage is "programming" and most is just data.

We actually do have a "formula language" that can be embedded in WML that we're starting to add to certain select areas of the game.

A full-scale "Pythonization" though, would be more effort than it's worth in my opinion.
ivan wrote: maybe it is the biggest reason why most people who know Lua, Ruby, Python or JavaScript are complaining instead of being part of scenario-maker community.
Well, a couple of things: I don't think "most" people who know these languages are necessarily complaining.

Very importantly, and this goes to my entire philosophy of making a content system for Wesnoth, I don't think that the overlap between the set of programmers and the set of good scenario designers is very large. That is to say, I think most people who are decent programmers and want to contribute to Wesnoth will end up contributing code -- whether it be to the core game engine, or support tools. Even if the game engine used Python, or Lua, or whatever, it's my opinion that people who know these languages would look and say "well, that's cool", and then go do something else.

I think that to attract lots of scenario designers, one has to aim at that audience. That group of people want tools that allow them to pull of what they want to do as easily as possible. They are usually imaginative people, often have played with tools like RPGMaker, scenario builders for commercial games, and want something more powerful, but don't or can't learn to program.

The other side of the coin is simplicity in the game engine. Implementing decent Python or Lua bindings is a pain, and a great maintenance burden on the engine.

I think that Wesnoth's record bears out the advantage of our approach and speaks for itself. There are plenty of open source game projects that use Python or Lua or Lisp as a main data/scripting language. Can you point to an example of an Open Source game project that uses one of these languages as its language and has a large amount of user-made content?

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
User avatar
loonycyborg
Windows Packager
Posts: 299
Joined: April 1st, 2008, 4:45 pm
Location: Russia/Moscow

Re: Programing language

Post by loonycyborg »

Dave wrote: A full-scale "Pythonization" though, would be more effort than it's worth in my opinion.
I agree with that. In fact I wouldn't even bothered to post there if not for your silly idea that Python scripting can't be made simple enough for general consumption.
The other side of the coin is simplicity in the game engine. Implementing decent Python or Lua bindings is a pain, and a great maintenance burden on the engine.
As opposed to implementing and maintaining your own markup language which is a piece of cake</sarcasm>
Can you point to an example of an Open Source game project that uses one of these languages as its language and has a large amount of user-made content?
Vegastrike.
"meh." - zookeeper
Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: Programing language

Post by Max »

i think some here miss the fact that wml is used both as a way to offer scripting for campaigns and as a way to store information.

and i don't think that the language wesnoth uses matters much from a beginners perspective. there are lots of things that are much more confusing.
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Re: Programing language

Post by Dave »

loonycyborg wrote:
Dave wrote: A full-scale "Pythonization" though, would be more effort than it's worth in my opinion.
I agree with that. In fact I wouldn't even bothered to post there if not for your silly idea that Python scripting can't be made simple enough for general consumption.
Well, I think that using Python as a data language is a silly idea, and it's more difficult and complicated than a general data language.

If you want some powerful scripting in your game though, Python is a good choice. I think it's reasonable to use a data language and then use Python for scripting in places it's needed. To use Python for everything though, I think is a bad idea.
loonycyborg wrote:As opposed to implementing and maintaining your own markup language which is a piece of cake</sarcasm>
Actually it is. It's much easier than maintaining Python bindings in my view.
loonycyborg wrote: Vegastrike.
Looks interesting; I shall have to check it out. (I remember trying it a long time ago, wonder if it's progressed since then).

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
ivan
Posts: 15
Joined: April 28th, 2008, 12:42 pm

Re: Programing language

Post by ivan »

Dave wrote: Actually it is. It's much easier than maintaining Python bindings in my view.
But we already have Python bindings for core C++ objects (team, unit, map) and, in fact, Python interpreter is already inside Wesnoth executable.

Also, we have full-featured Python WML parser (in data/tools/wesnoth). That means that WML can be converted to Python and used from Python.

It took me about 1 hour to add working generic Python bindings to Wesnoth source based on ai_python.cpp/ai_python.hpp. This was much more easier than I initially thought. All the hard work was already done before.
Post Reply