Programing language
Moderator: Forum Moderators
Forum rules
Before posting a new idea, you must read the following:
Before posting a new idea, you must read the following:
Re: Programing language
I would just like to point out that the keys "description" and "user_description" have already been corrected in the development version to "id" and "name" so they are easier to understand, and there is really no need to explain whether the values of "canrecruit" should be "yes"/"no" or "1"/"0" or "true"/"false", etc because all of those values are in fact allowed.Viliam wrote: It needs an explanation about the meaning of "_", the difference between "description" and "user_description", and whether the values of "canrecruit" should be "yes"/"no" or "1"/"0" or "true"/"false", etc. But generally the meaning is obvious for non-programmer.
You can omit "_" if you don't care about translation, but I agree that it is confusing.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
-
- Posts: 126
- Joined: April 19th, 2008, 7:12 pm
- Contact:
Re: Programing language
I've tried to search programming language on Ideas forum.Viliam wrote:Changing the scripting language should probably be included into "frequently proposed ideas". A few times I proposed something like this too... or at least heavy changes into WML syntax so that macros will not be used so frequently.
But I like about your proposal that you actually wrote the scenario code in another language. If I remember correctly, nobody did this until now, so it was not even possible to discuss whether the code in another language would really be easier or not. Now at least the discussion based on real example is possible.
As I said - I have tendency to write short, legible-for-me code...Viliam wrote:It surprised me that the Ruby code does not seem more legible, it is the opposite.
Well - for me it easier to think about side called @player. s.sides I used only for the registration of sides. It was written fastly as near 1-1 rewrite.Viliam wrote:Maybe I probably chosed the part where the WML is strongest... describing a list of key-value pairs. But this code is very simple. It needs an explanation about the meaning of "_", the difference between "description" and "user_description", and whether the values of "canrecruit" should be "yes"/"no" or "1"/"0" or "true"/"false", etc. But generally the meaning is obvious for non-programmer.Code: Select all
[side] side=1 type=Dwarvish Fighter description=Burin user_description=_ "Burin the Lost" canrecruit=yes [/side]
This is just scary. Yes, it is a nice idea to use "<<" and "new" for adding a new side into a list of sides, but... this is just too complicated, and not really necessary. Thinking "side number 1" is easier concept than using dynamic arrays; and in 99% cases it does the work. Also I sometimes dislike WML for being too verbose, but in this Ruby example the "burin" keyword is really over-used.Code: Select all
s.sides << Side.new(:human, :dwarves) do |side| side.leader = Unit.create_or_recall(side, :burin) do |burin| burin.id = :burin burin.type = UnitType.lookup("Dwarvish Fighter") burin.desc = _"Burin the Lost" burin.can_recruit = True end end
The loading can be done automagically even. However I guess labels are more UF then need to access by number.Viliam wrote:I guess it could be done more effectively -- not sure how, I am not good in Ruby, but I guess just somehow writing key-value pairs should be enough, without repeating the object variable. Maybe. Instead of using things like "s.sides << Side.new(...)" and "UnitType.lookup(...)", it would be simpler to use methods, something like "side(...)" and "unittype(...)". The scenario object could be a subtype of "Scenario" class, and would inherit these methods.
Improved version. The example was written in 0.5h so it did not solved all API problemsViliam wrote:So the challenge (for all readers who love Ruby) is to make the Ruby code really simpler than the WML code. Do not try to make it more powerful than WML; just try to do the same thing somehow more simply. Use your programming skills for thinking about implementations of used functions, but keep the interface at least as simple as it is now.
Re: Programing language
They intimidate me already. (Perl doesn't.)Dave wrote:I think that Ruby/Python/Lua/whatever is always going to be intimidating for non-programmers.
Also, most posts on this topic are not on the Ideas forum. They are either in WML Workshop or Coder's Corner, or moved to General Development to restrict discussion...
Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm.
- loonycyborg
- Windows Packager
- Posts: 295
- Joined: April 1st, 2008, 4:45 pm
- Location: Russia/Moscow
Re: Programing language
I think that you can design non-intimidating and clean interfaces with Python which don't require much dots, "<<"'s, "@"'s and other horrors.Dave wrote: I think that Ruby/Python/Lua/whatever is always going to be intimidating for non-programmers.
"meh." - zookeeper
- Viliam
- Translator
- Posts: 1341
- Joined: January 30th, 2004, 11:07 am
- Location: Bratislava, Slovakia
- Contact:
Re: Programing language
I think the cause of intimidation is not because they are programming languages, but because the parts of code you see contain difficult concepts. And by "difficult" I mean "more difficult than your task really requires".Shadow Master wrote:They intimidate me already. (Perl doesn't.)Dave wrote:I think that Ruby/Python/Lua/whatever is always going to be intimidating for non-programmers.
For example if you are trying to do something that requires variables, then the mere fact of using variables should not scare you. But if you are doing something that does not (in your opinion) need variables, and someone gives you a code that uses them, that is scary. Compare the following pieces of code:
Code: Select all
For x = 1 To 10
WriteLine x
Next x
Code: Select all
for (int x = 0; x < 10; x++) {
write_line(1 + x);
}
For programmer, both pieces of code do the same thing. But for non-programmer the second example contains many new parts that need to be explained and understood. Memorizing "For ... = ... To ... Next" is similar to memorizing "for(...;...;...) {...}", but after you have memorized the first one, you are able to write the code, while after memorizing the second one, you also have to remember that first parameter is type declaration and initialization, second parameter is condition, third parameter is the end of loop. What?! All I wanted to do was to display numbers from 1 to 10, why do I have to learn such difficult concepts?
The point is not comparing languages, but rather the way they are used (although some languages will not give you too much choice). For example here are two (not necessarily syntactically correct) examples in Perl. They could do the same thing. Yet the first one is IMHO not intimidating, but the second one surely is.
Code: Select all
$side1 = {
"name" => "dwarves",
"leader" => {
"type" => "Dwarvish Fighter",
"id" => "Burin",
"name" => _"Burin the Lost",
"canrecruit" => YES
}
};
Code: Select all
my $side1 = Wesnoth::Model::Side->new();
$side1->setName("dwarves");
my $leader1 = Wesnoth::Model::UnitInstance->new(
Wesnoth::Model::UnitType->getFactory()->getUnitTypeByName("Dwarvish Fighter"));
$leader1->setId("Burin");
$leader1->setName(Wesnoth::Localization->translate($textdomain, "Burin the Lost"));
$leader1->setCanRecruit(1);
$side1->setLeader($leader1);
push(@sides, $side1);
Re: Programing language
i have only one thing to say.
a huge part of the reason i downloaded wesnoth was the advertisement of "FULLY MODIFYABLE!" "very easy to make new things"
im sure im not alone in that. the basic game itself does get dry after a while. theres new UMC like every day. i am a programmer. VB C++ and i do some web designing as well (By hand in notepad, not that dreamweaver crap). And I must say WHY THE HECK WOULD YOU WANNA GO BACK TO THAT? WML IS SO EASY!
and as for your "reinventing the wheel and not even doing it right" bulldung. go open up wesnoth. click addons. sort by name. scroll down to bob the mighty. download everything by him. play it all.
AND THEN TELL ME YOU CANT DO ANYTHING AWSOME WITH WML (without lying )
you cant say it honestly. and then download all the other addons and play all of them. they're so diverse. nothing is "reinvented" (except maybe art ).
you sir are just to lazy to put in the time writing out WML to make something. if you really want to do something incredible, then you have to put in some time. even if it takes you your entire summer vacation. if i may quote Eldest here
"its like making lace. it isnt strenous. it just takes some time."-Nasuyda
mods im sorry for the flaming but this touched a cord
a huge part of the reason i downloaded wesnoth was the advertisement of "FULLY MODIFYABLE!" "very easy to make new things"
im sure im not alone in that. the basic game itself does get dry after a while. theres new UMC like every day. i am a programmer. VB C++ and i do some web designing as well (By hand in notepad, not that dreamweaver crap). And I must say WHY THE HECK WOULD YOU WANNA GO BACK TO THAT? WML IS SO EASY!
and as for your "reinventing the wheel and not even doing it right" bulldung. go open up wesnoth. click addons. sort by name. scroll down to bob the mighty. download everything by him. play it all.
AND THEN TELL ME YOU CANT DO ANYTHING AWSOME WITH WML (without lying )
you cant say it honestly. and then download all the other addons and play all of them. they're so diverse. nothing is "reinvented" (except maybe art ).
you sir are just to lazy to put in the time writing out WML to make something. if you really want to do something incredible, then you have to put in some time. even if it takes you your entire summer vacation. if i may quote Eldest here
"its like making lace. it isnt strenous. it just takes some time."-Nasuyda
mods im sorry for the flaming but this touched a cord
Re: Programing language
I don't think it's just the syntax that's confusing; it's the concepts. I am very doubtful a Python interface could end up as easy for a non-programmer as WML is.loonycyborg wrote: I think that you can design non-intimidating and clean interfaces with Python which don't require much dots, "<<"'s, "@"'s and other horrors.
Not at all; thank you for pointing things out from a campaign developer's perspective.Gambit wrote: mods im sorry for the flaming but this touched a cord
David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
- loonycyborg
- Windows Packager
- Posts: 295
- Joined: April 1st, 2008, 4:45 pm
- Location: Russia/Moscow
Re: Programing language
I don't see any concepts in python that are inherently harder to grasp than ones in WML. Besides, a well designed interface will use only those concepts that map neatly to problem domain. You can make interface that will make programs using it look almost like WMLDave wrote:I don't think it's just the syntax that's confusing; it's the concepts. I am very doubtful a Python interface could end up as easy for a non-programmer as WML is.loonycyborg wrote: I think that you can design non-intimidating and clean interfaces with Python which don't require much dots, "<<"'s, "@"'s and other horrors.
Code: Select all
side1 = Side(
name = "dwarves",
leader = Leader(
type = "Dwarvish Fighter",
id = "Burin",
name = "Burin the Lost",
canrecruit = True
)
)
"meh." - zookeeper
Re: Programing language
I think plenty of people would disagree with you fairly strongly on that.loonycyborg wrote: I don't see any concepts in python that are inherently harder to grasp than ones in WML.
But this will put the user in a little sandbox inside Python which is just a clone of WML anyhow. Any stepping outside this sandbox and they will be in a complex programming language.loonycyborg wrote: Besides, a well designed interface will use only those concepts that map neatly to problem domain. You can make interface that will make programs using it look almost like WML
Additionally, several very useful WML features won't be possible, such as [+append] and x,y=4,8 style syntax.
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'm not sure about error messages, but I'd imagine they might end up harder to read with Python.
David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
-
- Posts: 126
- Joined: April 19th, 2008, 7:12 pm
- Contact:
Re: Programing language
Well - what is more easy:Gambit wrote:i have only one thing to say.
a huge part of the reason i downloaded wesnoth was the advertisement of "FULLY MODIFYABLE!" "very easy to make new things"
im sure im not alone in that. the basic game itself does get dry after a while. theres new UMC like every day. i am a programmer. VB C++ and i do some web designing as well (By hand in notepad, not that dreamweaver crap). And I must say WHY THE HECK WOULD YOU WANNA GO BACK TO THAT? WML IS SO 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]
Lack of else if is also rather painful in some contexts.
PS. I do not propose C++ as language. I did propose some scriptiong language.
As WML is turing-complete AFAIK you can write any algorithm in it. You can write a compilator in WML.Gambit wrote:
and as for your "reinventing the wheel and not even doing it right" bulldung. go open up wesnoth. click addons. sort by name. scroll down to bob the mighty. download everything by him. play it all.
AND THEN TELL ME YOU CANT DO ANYTHING AWSOME WITH WML (without lying )
So are assemblers. You can do awsom things in assembler - but they are not easy. You can do awsom thing in Wesnoth. But it tends to be neighter easy nor intuitive if you want to do something unusual.
Of course - WML is much simpler then assembler - but I guess they you have seen my point. Long time ago everything was programmed in assembler. In fact you can do anything in assembler. But it does not make assembler an easy language to program with. There is no implication.
You miss my point. The reinvention was about WML as language - not addons.Gambit wrote:you cant say it honestly. and then download all the other addons and play all of them. they're so diverse. nothing is "reinvented" (except maybe art ).
Thanks. But you see - I don't consider myself lazy as concerning to programming languages. I'm currently maintain activly one project in Ruby, one in C.I've also do a bit of programming in Perl, C++, Haskell, C#, Python, shell, x86 assembler (both Intel and AT&T syntax)[1] and several others. So I KNOW what I'm talking about that the WML takes me much more time and pain then others - especially from it's level(scripting languages).Gambit wrote:you sir are just to lazy to put in the time writing out WML to make something. if you really want to do something incredible, then you have to put in some time. even if it takes you your entire summer vacation. if i may quote Eldest here
So please anything (I may be dumb etc.) but not that I'm lazy in concern to programming languages "just too lazy to put in the time". May be I'm not fluent in them but I know several of them.
[1] There was usually small projects just to recognize the features of language. However I guess that they had similar or bigger complexity than what I want to achive in WML.
Please - DO NOT MAKE PERSONAL ATTACKS. I could say that knowing 2-3 languages do not make you a programmer - in similar way I was accused of being lazy. I don't know neighter your level[1] neither what you can consider 'knowing the language'[2].mods im sorry for the flaming but this touched a cord
[1] Could be anything from hello-world level to top-high-paid consultant
[2] Similar can be from hello-world to professional level
Re: Programing language
Completely agree.loonycyborg wrote:I think that you can design non-intimidating and clean interfaces with Python which don't require much dots, "<<"'s, "@"'s and other horrors.Dave wrote: I think that Ruby/Python/Lua/whatever is always going to be intimidating for non-programmers.
Here's my version:
Code: Select all
from factions import dwarf
from wesnoth.campaign import Side, Leader
burin = Leader(type=dwarf.fighter, name='Burin the Lost', canrecruit=True)
dwarves = Side(leader=burin)
In Python you can reuse and modify existing objects and keep everything organized. Anything non-trivial in WML becomes a mess.
The main problem I see is that it will require almost complete rewrite of Wesnoth, and this is a real problem.
- loonycyborg
- Windows Packager
- Posts: 295
- Joined: April 1st, 2008, 4:45 pm
- Location: Russia/Moscow
Re: Programing language
WML itself isn't omnipotent either. But there's no complex programming language to resort to if needed.Dave wrote: But this will put the user in a little sandbox inside Python which is just a clone of WML anyhow. Any stepping outside this sandbox and they will be in a complex programming language.
I still don't know much about WML and can't say whether there's a way to provide something equivalent or better with python.Additionally, several very useful WML features won't be possible, such as [+append] and x,y=4,8 style syntax.
I don't see how WML preprocessor is more convenient than defs or classes in python.It'd also be a lot less convenient than WML unless you plan to add a pre-processor on top of Python as well.
There are ways to serialize python code objects.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).
"meh." - zookeeper
Re: Programing language
And plenty of people would strongly agreeDave wrote:I think plenty of people would disagree with you fairly strongly on that.loonycyborg wrote: I don't see any concepts in python that are inherently harder to grasp than ones in WML.
x,y=4,8 is perfectly valid Python syntax. I don't know what [+append] means, but I'm sure something similar can be implemented in Python.Dave wrote: Additionally, several very useful WML features won't be possible, such as [+append] and x,y=4,8 style syntax.
Python functions and objects are powerful enough to be more useful than any WML pre-processors.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.
Agreed. WML is far superior for some data than scripting languages. Even if Python (or Lua/Ruby) will be used to script scenarios and campaigns, WML should stay for maps and UIs.Dave wrote: 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).
-
- Posts: 126
- Joined: April 19th, 2008, 7:12 pm
- Contact:
Re: Programing language
Add the code to last node of this type. The only use I find for it as far is:ivan wrote:x,y=4,8 is perfectly valid Python syntax. I don't know what [+append] means, but I'm sure something similar can be implemented in Python.Dave wrote: Additionally, several very useful WML features won't be possible, such as [+append] and x,y=4,8 style syntax.
Code: Select all
{SOME_MACRO}
[+something]
customize_the_macro_content
[/something]
Re: Programing language
Every dynamic language can do it. You can change and add anything to any object any time.uzytkownik wrote:Add the code to last node of this type. The only use I find for it as far is:ivan wrote: x,y=4,8 is perfectly valid Python syntax. I don't know what [+append] means, but I'm sure something similar can be implemented in Python.Code: Select all
{SOME_MACRO} [+something] customize_the_macro_content [/something]