12 Replies - 1047 Views - Last Post: 13 August 2015 - 01:57 AM Rate Topic: -----

#1 Chucke  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-July 15

the place of languages in game development

Posted 30 July 2015 - 12:26 PM

Hi there!


I am currently developing a game. Originally it was a web-form based RPG text quest, written in Java, with UI framework. It grew from pure text quest engine that I wrote in an couple of hours - basically eternal while loop with simple handler of input choices, based on resources. No thing interesting.

Then I created, due to inspiration, simple Battle Arena in C# + WinForms - text based pseudo random imitation of battle (high level character unable to defeat low lever though. But for example same level characters had a result based on pure luck I suppose (they could parry, block, cross the attack based on their attack and defence + some kind of luck (random generatio)).

Then I decided to concentrate on writing real text game with the desire to port from C# to Java my battle arena. However I was not able to implement it fully because I got tired writing resources for it (I mean for example I had dialog system similar to Mass Effect where different choices led to different results + ability NPC behavior varied depending on whether I am doing NPC quest or etc. It was so hard to write all this routes) - I had dialog system, different stats, different skills, inventory, equipment(armor, accessory), leveling (at least I added mechanism for it - I did not implement it though), different NPC in different locations, basic descriptions of locations, prototype of WIKI for skills, enemies and etc. As for battle arena - I created the UI platform it but did not port the backend.

Also I had basic threading - at least I had ability to set daemon tasks - like aging of NPCs (I could create tasks in resources by specifying want task, what stat affect and for whom, its start and end time). I additionally added saving/loading functionality via serialization. Nevertheless as I dropped development it got stuck on < 10000 lines of pure code. Nothing special.

But anyway - I got tired of writing resources for it (I had to create SDK for it, I wanted to use C# and its Windows Forms but It was also rather tedious. After all I prefer pure coding over everything).

So I decided to rewrite everything from the very beginning, but using my Java experience (it my main skill as I am working most of the time with Java EE) in C++.
Well that was an introduction.

As for technology stack I decided to use SDL + GEGUI, backend - C++ and Boost + some additional libraries that I'll find useful. Also I use Sqlite as a data storage and I'm planning to use IDL - interface description language - some kind of my own XML which allows to describe facilities for UI. Basically declarative UI. For AI I maybe use Lua - because I am interested in learning it.

For communication with Sqlite I decided to use python(Sqlite support is basically integrated in it) - I've been waiting for its use for a long time - and for parsing XML (beautiful soup).

As always I started developing from backend - to be more precise - repository level -> facilities for operating with database. I created C++and Python bridge, though I haven't fully leveraged it yet. Anyway It allows me to communicate with python.

However I found out that some things are simply too time consuming to develop using C++. It's of course interesting to implement but still - something like for example compressing/decompressing of files, database communication or recently dll memory loading are easier to do in python than C++. It's easier to create data exchange between python and C++ then writing this in pure C++.

I understand that such I approach won't work for game runtime - if I had to compress file during game runtime I had to write it in C++ and I won't have any slightest idea to use some Java language wrapper for renderer, but at the same time during game resource loading - it's better and easier to operate with higher level abstractive languages.

So my the question is - could it be that scripting and languages with higher level of abstraction have its best use in all the facilities that do not lie in game runtime? It will allow not to drop game runtime performance but at the same simplify the development. Because a lot of things was easier to do in Java and sometimes I though to write some intermediate layer for C++ to communicate with Java using JNI, or I even had ideas to use C++\CLI when Java was not a real helper or something I like in C# better.

P.S. Sorry for the wall of text :sweatdrop:/> - I just like talking :bigsmile:/>

Is This A Good Question/Topic? 0
  • +

Replies To: the place of languages in game development

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13483
  • View blog
  • Posts: 53,820
  • Joined: 12-June 08

Re: the place of languages in game development

Posted 30 July 2015 - 12:41 PM

Quote

could it be that scripting and languages with higher level of abstraction have its best use in all the facilities that do not lie in game runtime?

No, not always.
Was This Post Helpful? 0
  • +
  • -

#3 Chucke  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-July 15

Re: the place of languages in game development

Posted 30 July 2015 - 12:50 PM

View Postmodi123_1, on 30 July 2015 - 12:41 PM, said:

Quote

could it be that scripting and languages with higher level of abstraction have its best use in all the facilities that do not lie in game runtime?

No, not always.


So sometimes C++ is better even for external functionality? But I don't get for what it's can be easier to use and more effective than higher level languages? Sometimes I feel like C++ was designed not be used outside C scope.
Was This Post Helpful? 0
  • +
  • -

#4 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon


Reputation: 6979
  • View blog
  • Posts: 14,598
  • Joined: 16-October 07

Re: the place of languages in game development

Posted 30 July 2015 - 12:56 PM

General purpose languages are general purpose. You can write an entire project in any such language. If you have some kind of resource, like sqlite or SDL, as long as you language has bindings for such things, you're good to go.

The real question is why you'd feel the need to jump from on language to another. What do you feel another language offers that the one you've already chosen doesn't? And, if that property is important enough, why not just use that language to begin with?
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13483
  • View blog
  • Posts: 53,820
  • Joined: 12-June 08

Re: the place of languages in game development

Posted 30 July 2015 - 12:58 PM

I am not understanding the issue. Languages can come and go and operate as they do for the tasks they have been opened to. c++ works great in directx and opengl. .NET and monogame are great, Unity's engine and scripts are fun, java does it's thing, etc.
Was This Post Helpful? 0
  • +
  • -

#6 Chucke  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-July 15

Re: the place of languages in game development

Posted 30 July 2015 - 01:26 PM

View Postbaavgai, on 30 July 2015 - 12:56 PM, said:

The real question is why you'd feel the need to jump from on language to another. What do you feel another language offers that the one you've already chosen doesn't?

I use different languages because I want to learn different languages and the best way to do it - use it!
Most of the feels comes from my own tastes I suppose.
For example in Java and C# I don't like anything belong to streams - it's just to bulky. In C++ it's even worse. By in python it's an eye candy.
In Java I like to develop web applications and I don't like to do it using C# (though I never tried anything outside ASP there).
At the same time I like pointers and smart pointers in C++. Also I like its overloaded syntax. But I don't like templates and lack of reflection in C++ (at least not at the same level as in Java and C#).
I like python's approach with functions as first-class citizens. C# delegates too. But in Java I had to implement pattern in order to achive required functionality. In C++ it has function pointers and function objects however I never tried then and I think they are no mactch for python.
And so on...Some languages are better for me. And sometimes it's just too time consuming to find some workaround for some functionality.

View Postbaavgai, on 30 July 2015 - 12:56 PM, said:

And, if that property is important enough, why not just use that language to begin with?

Because I want the core to be written in C++. It's not even about the performance - after I doubt that anything I create will have the same performance or functianlity as UE3. If my goal was to develop a game for sell I'd no way started it from the very beginning and develop engine myself. At least I would not aim for CryEngine level of graphics - alone I won't be able to achieve it anyway even in multiple years (less than 5 I presume hah)

View Postmodi123_1, on 30 July 2015 - 12:58 PM, said:

I am not understanding the issue. Languages can come and go and operate as they do for the tasks they have been opened to. c++ works great in directx and opengl. .NET and monogame are great, Unity's engine and scripts are fun, java does it's thing, etc.

The main question is that what are the tasks that can be opened for higher level language from the game point of view.
Was This Post Helpful? 0
  • +
  • -

#7 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13483
  • View blog
  • Posts: 53,820
  • Joined: 12-June 08

Re: the place of languages in game development

Posted 30 July 2015 - 01:28 PM

Go check out something like Unity or the Unreal engine. See how they are using scripting languages (and for what) with their engines.
Was This Post Helpful? 0
  • +
  • -

#8 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon


Reputation: 6979
  • View blog
  • Posts: 14,598
  • Joined: 16-October 07

Re: the place of languages in game development

Posted 30 July 2015 - 05:14 PM

View PostChucke, on 30 July 2015 - 04:26 PM, said:

I use different languages because I want to learn different languages and the best way to do it - use it!


Fair enough. Have at.

View PostChucke, on 30 July 2015 - 04:26 PM, said:

I like python's approach with functions as first-class citizens. C# delegates too. But in Java I had to implement pattern in order to achive required functionality. In C++ it has function pointers and function objects however I never tried then and I think they are no mactch for python.


Hmm, Python makes passing function around easy enough. However, the lambda syntax is cludgy, and thus dynamic function creation.

The C# lambda syntax is nice. So nice that Java stole it in the latest versions; sort of, it's more interface candy. Modern C++ has it's own lambda syntax, too.

However, the winner for passing functions around are the functional languages. Second only to them, wait for it, would be Javascript.

Just for fun:

Python:
def doMath(name, func):
    print name, "=", func(2,3)
    print name, "=", func(5,6)

def test():
    def add(x,y):
        return x + y
    for (n,f) in (("add",add),("mul",lambda x,y: x * y)):
        doMath(n,f)



Java:
interface IntegerMath { int operation(int a, int B)/>;   }

private static void doMath(String name, IntegerMath op) {
    System.out.println(name + "=" + op.operation(2,3));
    System.out.println(name + "=" + op.operation(5,6));
}

private static void test() {
    IntegerMath add = (a, B)/> -> a + b;
    IntegerMath mul = (a, B)/> -> a * b;
    doMath("add", add);
    doMath("mul", mul);
}



OCaml (and F#, sort of):
let doMath (name,func) =
  let call (x,y) = print_endline (name ^ " = " ^ (string_of_int (func x y))) in
  List.iter call [ (2,3); (5,6) ]

let test() = List.iter doMath [ ("add",(+)); ("mul",(fun x y -> x * y)) ]



Haskell:
doMath (name,func) = mapM_ call [ (2,3), (5,6) ]
    where call (x,y) = putStrLn $ name ++ " = " ++ (show $ func x y)

test() = mapM_ doMath [ ("add",(+)), ("mul",(\x y -> x * y)) ]



Javascript:
function doMath(name,func) {
  var call = function(a) { console.log(name + " = " + func(a[0],a[1])); };
  [ [2,3], [5,6] ].forEach(call);
}

function test() {
    [
    ["add", function(x,y) { return  x + y; } ],
    ["mul", function(x,y) { return  x * y; } ]
    ].forEach(function(a) { doMath(a[0],a[1]); });
}



I'll leave C++ to the curious.
Was This Post Helpful? 0
  • +
  • -

#9 Chucke  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-July 15

Re: the place of languages in game development

Posted 31 July 2015 - 12:33 PM

View Postmodi123_1, on 30 July 2015 - 01:28 PM, said:

Go check out something like Unity or the Unreal engine. See how they are using scripting languages (and for what) with their engines.

I was planning and I am planning to look into it but further in the development. But I want to reinvent wheels myself.

View Postbaavgai, on 30 July 2015 - 05:14 PM, said:

Hmm, Python makes passing function around easy enough. However, the lambda syntax is cludgy, and thus dynamic function creation.

Well sometimes Python feels more like a simplification over plain procedural and oop paradigm. As lambdas belong to functional paradigm in python it more like "well yeah we have that feature. but let's better look at libraries...". Also I think it's possible to avoid it in python. In C# I used it extensively, but in Java (we use 7) I have never actually had situation where there was need in them.

View Postbaavgai, on 30 July 2015 - 05:14 PM, said:

The C# lambda syntax is nice. So nice that Java stole it in the latest versions; sort of, it's more interface candy. Modern C++ has it's own lambda syntax, too.

C# has a lot of useful features. Well...A lot of syntax sugar too. It was developed looking at Java mistakes and C++ mistakes after all. Also I think lambdas has their hidden side in Java - as with generics - I actually think that it was developed keeping legacy code in the mind.

Well at least unlike C++ its every new version does not try to solve problems brought by previous version. And it seems Java versions does not decrease readability of code either :lol:/>/>/>/>/>

Also due to existance of Groovy and Scala it's possible to stay without need for new Java version features.

View Postbaavgai, on 30 July 2015 - 05:14 PM, said:

Just for fun:


Java:
interface IntegerMath { int operation(int a, int B)/>/>/>/>/>/>/>;   }

private static void doMath(String name, IntegerMath op) {
    System.out.println(name + "=" + op.operation(2,3));
    System.out.println(name + "=" + op.operation(5,6));
}

private static void test() {
    IntegerMath add = (a, B)/>/>/>/>/>/>/> -> a + b;
    IntegerMath mul = (a, B)/>/>/>/>/>/>/> -> a * b;
    doMath("add", add);
    doMath("mul", mul);
}


As I thought - it does not feel natural. Well it's always a problem - when a feature was not put originally in the language - after long time of waiting for it, when it actually was added it feels more like a third leg than really functional thing. It will take some time before it will be used often. Also don't like how it looks.

View Postbaavgai, on 30 July 2015 - 05:14 PM, said:

OCaml (and F#, sort of):
let doMath (name,func) =
  let call (x,y) = print_endline (name ^ " = " ^ (string_of_int (func x y))) in
  List.iter call [ (2,3); (5,6) ]

let test() = List.iter doMath [ ("add",(+)); ("mul",(fun x y -> x * y)) ]



Haskell:
doMath (name,func) = mapM_ call [ (2,3), (5,6) ]
    where call (x,y) = putStrLn $ name ++ " = " ++ (show $ func x y)

test() = mapM_ doMath [ ("add",(+)), ("mul",(\x y -> x * y)) ]


Well for functional languages lambas are their blood and flesh so they'll look fancy.

View Postbaavgai, on 30 July 2015 - 05:14 PM, said:

Javascript:
function doMath(name,func) {
  var call = function(a) { console.log(name + " = " + func(a[0],a[1])); };
  [ [2,3], [5,6] ].forEach(call);
}

function test() {
    [
    ["add", function(x,y) { return  x + y; } ],
    ["mul", function(x,y) { return  x * y; } ]
    ].forEach(function(a) { doMath(a[0],a[1]); });
}


Don't like javascript, but there it more or less convenient. Also I do not there are a lot cases for using lamba expressions.

View Postbaavgai, on 30 July 2015 - 05:14 PM, said:

I'll leave C++ to the curious.

Well there it will be something like this I presume.
    typedef std::function<int (int, int)> math_func;
    typedef std::function<void (std::string, math_func, int, int)> lambda_func;
    lambda_func do_output = [] (std::string name, math_func method, int a, int B)/> ->
    	void {
            std::cout << name << " = " << method(a, B)/> << std::endl;
        };
    std::vector<std::tuple<int,int>> vector = { std::make_tuple(2, 3), std::make_tuple(5, 6) };
    for_each(vector.begin(), vector.end(), [&do_output] (std::tuple<int, int>& item) {
    	int a = std::get<0>(item);
    	int b = std::get<1>(item);
    	do_output("add", [](int x, int y) { return x + y; }, a, B)/>;
    	do_output("multiply", [](int x, int y) { return x * y; }, a, B)/>;
    });


I believe it can be done much better(after all I iterate over tuples of parameters because I didn't want to call myself functions) :surrender:

Also there are also a way to do it using boost. But it will be something similar I presume because they always do everything according to standarts.
Was This Post Helpful? 0
  • +
  • -

#10 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13483
  • View blog
  • Posts: 53,820
  • Joined: 12-June 08

Re: the place of languages in game development

Posted 31 July 2015 - 01:29 PM

Quote

But I want to reinvent wheels myself.

Well.. I take a dim view on that.
Was This Post Helpful? 0
  • +
  • -

#11 Chucke  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-July 15

Re: the place of languages in game development

Posted 31 July 2015 - 01:48 PM

View Postmodi123_1, on 31 July 2015 - 01:29 PM, said:

Quote

But I want to reinvent wheels myself.

Well.. I take a dim view on that.

Maybe it's a bad approach but I enjoy more the process than end result :punk:
Was This Post Helpful? 0
  • +
  • -

#12 _AB  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 10
  • Joined: 31-July 15

Re: the place of languages in game development

Posted 02 August 2015 - 12:09 AM

Hi

Speaking of reinventing the wheel, just dropping my two cents here...
Maybe you wanna check out Handmade Hero.

This guy is making a game and explaining everything he's doing during. The project is still very much alive. His aim is to create a game using C, period.
No libraries, no physics engines, not even a helper library, nothing... Everything for that game (even the art and sounds) are made by this fella.

It could give you some inspiration at the very least.

Best of luck...
Was This Post Helpful? 0
  • +
  • -

#13 viktormilly  Icon User is offline

  • D.I.C Head

Reputation: -16
  • View blog
  • Posts: 106
  • Joined: 12-August 15

Re: the place of languages in game development

Posted 13 August 2015 - 01:57 AM

I see same symptoms I have in you. Don't end up like me http://www.dreaminco...for-everything/

Limiting factor in software development right now isn't in tools, it's programmers themselves. They can't keep more than 7 things in their head at once, and they keep dancing around that.

C#, C, Java, Lua, python, all these have some disadvantages. C# compiler is too complex and is closed sources, and it's advantages over C++ are not so oblivious in gamedev. C is way too old, working in it is pain. Java doesn't work natively with windows api. Lua only supports floating point numbers. Python is way too dinamic and can't be compiled. You can deal with their inperfection, or try to change them, probably wasting few years of your life. And even if you'll manage to archive something not many will even know about it.

After some time you should be satisfied and feel that you have everything you need to actually start doing something. Maybe you should just give some result already. Maybe you shouldn't. Painters have a pretty primitive tools, but they managed to do great things with them. It's up to you. I don't know. Maybe it's worth it.

You probably will be interested in automatic convertion from one language to another, codegeneration and codeparsing. If you'll archive it, your current problems may flush away instantly. I tried to find something like this in the past, but to little success. I needed a convertor from PHP to javascript, because I hade same code on both serverside and clientside. It's dangerous to create something you will not be able to manage, code converters may reduce risks of being tied up to one language.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1