Author Topic: Which language and library to use  (Read 49423 times)

TheCreator

  • Rogueliker
  • ***
  • Posts: 370
  • Karma: +0/-0
    • View Profile
    • Fame
    • Email
Re: Which language and library to use
« Reply #30 on: July 04, 2014, 11:42:29 AM »
Java doesn't have pointers, but references. There's a nice and simple explanation how they differ from C pointers at http://programmers.stackexchange.com/questions/141834/how-is-a-java-reference-different-from-a-c-pointer

They don't actually differ as Java references are implemented using C pointers - that's why the exception message I have mentioned complains about a "null pointer". My point is that something is happening under the hood and the programmer cannot understand what his code is doing. So you may have pretty references instead of ugly pointers, but as soon as you do something wrong in the code, Java shows its ugly nullpointerexceptionary face.
Fame (Untitled) - my game. Everything is a roguelike.

Bear

  • Rogueliker
  • ***
  • Posts: 308
  • Karma: +0/-0
    • View Profile
Re: Which language and library to use
« Reply #31 on: July 04, 2014, 03:43:15 PM »
For what it's worth, I program in C (and other languages but the roguelike game I'm working on is in C).

And pointers are, honestly, no big deal once you understand their limitations and design properly for them.  They are useful and efficient but you don't ever want more than one copy of a pointer to dynamically allocated data to exist in a persistent structure because you don't ever want one that *still* exists after you free something.  They are succinct and handy but you don't ever want to assign a pointer to point at anything whose scope is narrower or whose extent is shorter than that of the pointer.   

All these rules are just plain sense and follow directly from what a pointer is.  You just have to understand what it is and keep them in mind when designing your program.

I see languages like Java getting it wrong with references, because people want something they can use like pointers but want the sharp edges filed down.   The problem isn't that the knife is sharp, the problem is that they're cutting in the wrong direction. 

Cfyz

  • Rogueliker
  • ***
  • Posts: 194
  • Karma: +0/-0
    • View Profile
    • Email
Re: Which language and library to use
« Reply #32 on: July 04, 2014, 05:08:39 PM »
Totally agree with Bear.

From my experience, I've seen a lot of students struggle similarly with arrays. At start it feels complicated with all these matrix and cube and whatnot analogues, full of nuances of unknown importance like which dimension stored first and which of them can or cannot be of different size. But given just a bit of practice this suddenly becomes totally obvious to the point of not being worth mentioned.

Also, modern C++ brings memory control on a bit higher level allowing to express/enforce memory ownership right in the code.

Kevin Granade

  • Rogueliker
  • ***
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Which language and library to use
« Reply #33 on: July 04, 2014, 06:37:26 PM »
Because it's an utterly terrible language that delivers on none of the things it promises.
And yet, people have made great games in both it, and tonnes of arguably worse languages.  Got a languages you wouldn't wish on your worst enemy?  People have more than likely written games other people have enjoyed in it.
Just because you CAN use the language to do something doesn't mean the language is any good.  As mushroom patch points out, they are after all Turing complete, so in theory you can write any program in any language.  The important distinction is the experience of writing the game, and sometimes performance issues when running the resulting program.
Just pick one and start working.  Those who can, do, those who can't, just talk about it.
Wait, are you seriously saying a prospective program author should not consider the pros and cons of the language they use?  The process of deciding on a programming language, platform, libraries, etc is a critical piece of defining your project, it can easily decide whether your project succeeds or fails.

"really truly object oriented" - has magic objects that programmers cannot replicate, such as magic handling for enum.
Terribly broken inheritance model that the *language author* has acknowledged was a mistake.

Could you provide more details on these two? Not that I want to advocate Java, which is insanely slow, limits programmer's every step, and of course "portability" of Java code is  a huge bullshit. However, I have no idea what is wrong with Java's enums and I have never heard such comments about the inheritance model (at least not from the language authors, a link is welcome!).
The enum thing is just an example.  The enum class has a special property of being a runtime-enforced singleton. The recommended way to implement a singleton class is to make it a subclass of enum so you can get that magic.  This is an absurd way to operate, why can't classes just ask to be included in the magic without subclassing enum?  There are quite a lot of other built-in Java classes and operations that are similarly privileged, which makes a mockery of the hype about the language being "pure" OO.
http://www.javaworld.com/article/2073649/core-java/why-extends-is-evil.html third paragraph.
To be fair, the inheritance model for C++ is pretty damn broken too, but it's flexible enough that it's not a problem to simply ignore it, and "pure OO" is not a strongly stated goal of the language, which is why I don't criticize C++ as harshly for it's OO failings as I do Java.

chooseusername

  • Rogueliker
  • ***
  • Posts: 329
  • Karma: +0/-0
    • View Profile
    • Email
Re: Which language and library to use
« Reply #34 on: July 05, 2014, 12:47:13 AM »
Because it's an utterly terrible language that delivers on none of the things it promises.
And yet, people have made great games in both it, and tonnes of arguably worse languages.  Got a languages you wouldn't wish on your worst enemy?  People have more than likely written games other people have enjoyed in it.
Just because you CAN use the language to do something doesn't mean the language is any good.  As mushroom patch points out, they are after all Turing complete, so in theory you can write any program in any language.  The important distinction is the experience of writing the game, and sometimes performance issues when running the resulting program.
You're making an argument against a point I never made.  The language is good, if someone has already made good games in it.  That's it.  No argument.  No nonsense about turing completeness, which someone looking for a language doesn't have to care about.  You claimed Java was no good, yet you only offered subjective opinions and bitterness.

Just pick one and start working.  Those who can, do, those who can't, just talk about it.
Wait, are you seriously saying a prospective program author should not consider the pros and cons of the language they use?  The process of deciding on a programming language, platform, libraries, etc is a critical piece of defining your project, it can easily decide whether your project succeeds or fails.
No, that's you projecting your opinion onto what I said.  Likely the doer will see that some other game was written in this language, and then say that's the one for me.  And it will be good enough.  Point in case: Minecraft, which was written in Java.  The post I responded to was you going on a personal rant about how people shouldn't use Java.  I argue that is better to go and choose a language based on it having been used for a game you like, than to go on a forum and to get the biased opinions of whomever likes the sound of their own voice the most.

chooseusername

  • Rogueliker
  • ***
  • Posts: 329
  • Karma: +0/-0
    • View Profile
    • Email
Re: Which language and library to use
« Reply #35 on: July 05, 2014, 12:51:17 AM »
I see languages like Java getting it wrong with references, because people want something they can use like pointers but want the sharp edges filed down.   The problem isn't that the knife is sharp, the problem is that they're cutting in the wrong direction.
Some people cut with their left hand, some people cut with their right and others who have no hands probably cut with their feet.  Java is the right direction for some people, and C the wrong.  Not everyone is the same.  People boil things down to right and wrong, and claim their side is the right, without establishing that it is the only possible right or conflating an ideal perfection that helps no-one with the solution which should be adopted.

chooseusername

  • Rogueliker
  • ***
  • Posts: 329
  • Karma: +0/-0
    • View Profile
    • Email
Re: Which language and library to use
« Reply #36 on: July 05, 2014, 12:54:54 AM »
Totally agree with Bear.

From my experience, I've seen a lot of students struggle similarly with arrays. At start it feels complicated with all these matrix and cube and whatnot analogues, full of nuances of unknown importance like which dimension stored first and which of them can or cannot be of different size. But given just a bit of practice this suddenly becomes totally obvious to the point of not being worth mentioned.
Yes, a lot of the issues people have with things, are often simply repeated and not understood or selectively picked out as well known myths to use to substantiate their side as being the right side.  Pointers is easy to learn.  Just one detail amongst many.

Also, modern C++ brings memory control on a bit higher level allowing to express/enforce memory ownership right in the code.
Some of the most disappointing code I have ever had to fix, has been written in C++.  People who wrote acceptable code in C would get lazy in C++ and introduce careless bugs.. to do with pointers even.  That doesn't mean that C++ is bad, just that it isn't a panacea for solving C's reputed problems.  Anyone can write bad code in any language, after all.

Raas

  • Newcomer
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Which language and library to use
« Reply #37 on: July 05, 2014, 01:48:10 AM »
After reading this thread, I feel terrible for programming my roguelike games/prototypes in Java! It was my first language and the one I'm most used to and enjoy. Plus the portability of it and libgdx are huge positives to me.

I was relatively unaware of all the downfalls of Java, but I still like the language. Informative thread so far with all the responses.

Kevin Granade

  • Rogueliker
  • ***
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Which language and library to use
« Reply #38 on: July 05, 2014, 02:07:24 AM »
Just because you CAN use the language to do something doesn't mean the language is any good.  As mushroom patch points out, they are after all Turing complete, so in theory you can write any program in any language.  The important distinction is the experience of writing the game, and sometimes performance issues when running the resulting program.
You're making an argument against a point I never made.  The language is good, if someone has already made good games in it.  That's it.  No argument.  No nonsense about turing completeness, which someone looking for a language doesn't have to care about. 
"The language is good, if someone has already made good games in it." is precisely the point I'm arguing against.  Analogy time, "A spoon is a good digging tool if someone has already excavated a good ditch with one.".  It's an utterly absurd argument that ignores the fact that the measure of a programming language is not whether it CAN do something, but whether it is well-suited to doing it.
You claimed Java was no good, yet you only offered subjective opinions and bitterness.
No, I offered a number of failings of the language, none of which you've addressed.  The issues I mentioned make Java a painful environment to operate in.
Wait, are you seriously saying a prospective program author should not consider the pros and cons of the language they use?  The process of deciding on a programming language, platform, libraries, etc is a critical piece of defining your project, it can easily decide whether your project succeeds or fails.
No, that's you projecting your opinion onto what I said.  Likely the doer will see that some other game was written in this language, and then say that's the one for me.  And it will be good enough.  Point in case: Minecraft, which was written in Java.  The post I responded to was you going on a personal rant about how people shouldn't use Java.
So what you are saying is the only measure of whether a language is suitable for a purpose is that it has been used for it previously?  How then do you distinguish among the languages that all have that trait?  Likewise both good and successful games have been written in nearly any language you care to mention.  This was precisely my point with turing completeness, you CAN write a game in any language, that's not an issue.   The issue is which one will get in your way the least.
I argue that is better to go and choose a language based on it having been used for a game you like, than to go on a forum and to get the biased opinions of whomever likes the sound of their own voice the most.
This is a terrible criteria for choosing a language, what if your programming style and abilities are utterly different from the author of the game you're basing your decision on?  Are you operating under the assumption that such a prospective game author knows nothing about programming language features?  If the discussion about the pros and cons of various programming languages go over your head, and/or you have insufficient experience to evaluate the merits of the arguments being made, of course you shouldn't base your decision on said arguments, but neither should you base it on popularity of a particular game, which is based more on circumstance, the style of the author, and social forces than on which tools were used to make it.

After reading this thread, I feel terrible for programming my roguelike games/prototypes in Java! It was my first language and the one I'm most used to and enjoy. Plus the portability of it and libgdx are huge positives to me.

I was relatively unaware of all the downfalls of Java, but I still like the language. Informative thread so far with all the responses.
I think Java is a terrible language, but I don't see why anyone should feel bad for writing things in it.  No matter what your language of choice is, it's an extremely good idea to broaden your horizons and get experience with new programming languages, not least of which because it will give you a perspective to chose which language is best for a given task.

Raas

  • Newcomer
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Which language and library to use
« Reply #39 on: July 05, 2014, 02:20:50 AM »
Quote
I think Java is a terrible language, but I don't see why anyone should feel bad for writing things in it.  No matter what your language of choice is, it's an extremely good idea to broaden your horizons and get experience with new programming languages, not least of which because it will give you a perspective to chose which language is best for a given task.

Well after reading your thought-out explanations, it seems like Java is not the best of choice for roguelikes (I learned a bit from the cons you listed, good to know). Seems like a taboo language! I'll still use it because it's the language I feel most efficient in and I do enjoy it. Although it is really verbose...

As far as broadening my programming language horizons, I couldn't agree more. I've learned C# this past year, and I'll be taking classes this fall in C and Python. So I have no doubt I'll continue learning new languages while I finish college and during my own time. I'm forever learning. But I agree, choose the best language/tool for the job depending on the task.

For the record, this forum is chock full of good info for roguelike creation, so glad I discovered it.
« Last Edit: July 05, 2014, 05:47:32 PM by Raas »

Bear

  • Rogueliker
  • ***
  • Posts: 308
  • Karma: +0/-0
    • View Profile
Re: Which language and library to use
« Reply #40 on: July 05, 2014, 04:25:40 AM »
I have also observed people who write good C code getting careless when given C++ and making dumb mistakes they wouldn't make in C. I've thought about it and tried to understand it a lot, because I'm one of the people who makes dumb mistakes more easily in C++.

C has semantics that are simple enough to be ... relaxing?  I don't know if relaxing is the right word, but in C it causes me no stress to understand everything the statements are doing. At least I won't often think a statement does something and then realize it's doing something else. 

And in C++ it's more effort.  Not impossible, or even really hard, but more effort.  Staying  aware of all the overloads and knowing exactly which overload I'm calling,  knowing which effect is had by a keyword that means one of three or five  different things depending on where it's encountered, etc. One thing that bites me again and again is getting callbacks and code that's going to get stuck into some template expansions right so that the situation when the callback happens, or the scope where the template is expanded, is exactly what it needs to be to be bugfree.  There's just a lot more stuff in C++ that looks *almost* alike but does something subtly different or gets inserted as raw code in a dozen contexts that you aren't thinking about all of when you write it.  So C++, for me at least, requires a higher level of mental focus to write well in. 

It's lame, but I find that my ability to code well just doesn't last as many hours in C++ as it does in C.  If my time is taken up with meetings or some other non-flowstate activity, and I have 2 hours a day to actually code?  Then C++ is more productive.  But If I can focus on code all day long?  My brain will stop sorting all the stuff it needs to sort in C++ after about three hours and then I'll be useless for coding in any language.  In C I can maintain flow state for six or even ten hours at a stretch, and if I actually have more than, say, four hours a day for writing code, then in the long run I get more done (and done correctly) in C than in C++.

I used to think this effect would go away as I got used to C++ but it hasn't.




Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Which language and library to use
« Reply #41 on: July 05, 2014, 10:03:31 AM »
People who wrote acceptable code in C would get lazy in C++ and introduce careless bugs.. to do with pointers even.  That doesn't mean that C++ is bad, just that it isn't a panacea for solving C's reputed problems.

If you behave well and write rigid constructors and destructors that handle the class resources then it's actually easy to avoid pointer problems and memory related bugs. When you become more advanced in C++ you start to realize that pointers change to handles of an instance and kind of become the instance (object) itself. It's also easier to maintain ownership of instances with container classes. I would go as far as to say if you have problems with pointers in C++ you are still programming in C.

mushroom patch

  • Rogueliker
  • ***
  • Posts: 554
  • Karma: +0/-0
    • View Profile
Re: Which language and library to use
« Reply #42 on: July 05, 2014, 10:52:19 AM »
[...]

"The language is good, if someone has already made good games in it." is precisely the point I'm arguing against.  Analogy time, "A spoon is a good digging tool if someone has already excavated a good ditch with one.".  It's an utterly absurd argument that ignores the fact that the measure of a programming language is not whether it CAN do something, but whether it is well-suited to doing it.

[...]

So what you are saying is the only measure of whether a language is suitable for a purpose is that it has been used for it previously?  How then do you distinguish among the languages that all have that trait?  Likewise both good and successful games have been written in nearly any language you care to mention.  This was precisely my point with turing completeness, you CAN write a game in any language, that's not an issue.   The issue is which one will get in your way the least.


I'm just guessing here, but I suspect that chooseusername is making a point not too different from the one I attempted to make: Namely, any language someone who asks this question (in more than just idle curiosity) has heard of will be "good enough" and that the most important thing is to make a decision and write something.

You raise the question of which languages among various reasonable choices are better or worse and in particular, you say Java is so bad you shouldn't use it. On the other hand, quite a few people find themselves in the (perhaps unenviable) position of knowing Java, having some experience with it, and not knowing anything else nearly as well. For these people, obviously the answer is Java. (And it would be unfortunate, if a little silly, were someone to see your discussion and think, "Damn, what am I doing writing a game in Java? I should go learn another language first!")

More to the point, among these reasonable language choices, the differences are not particularly interesting fodder for discussion. It's surface level generalities that you could read about anywhere (except Q&A style sites that sensibly close such discussions as unproductive).
« Last Edit: July 05, 2014, 01:07:03 PM by mushroom patch »

Numeron

  • Rogueliker
  • ***
  • Posts: 88
  • Karma: +0/-0
    • View Profile
    • Numeron Reactor
Re: Which language and library to use
« Reply #43 on: July 07, 2014, 03:00:31 AM »
IDK, I've used java for all my games (and also use it for the commercial application I work on as a job). It has its quirks and flaws just like any language, but I'll never understand the hard-on some people get for rallying against it. Its not just here, but I've heard it in other places too.

It might be that some people don't like the level of control they think they're missing out on when it comes to references, garbage collection and a more rigid type hierachy? I get that for an experienced programmer, these things count against java - but they're a very good reason to pick it up for those less experienced.

In fact, if a developer doesn't know enough about programming to even know what language best suits their needs then, IMO its the perfect choice. Now obviously you can write bad code in any language, but forcing a new developer to write verbose code under a rigid type hierachy, while hiding pointers and memory management is a great thing.

Then when this inexperienced programmers game turns into a hairy spaghettified mess anyway, they'll have theoretically learnt some of the strengths and weaknesses of the language and be ready to take on the extra features of something more hardcore like C++.
« Last Edit: July 07, 2014, 03:10:22 AM by Numeron »

Kevin Granade

  • Rogueliker
  • ***
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Which language and library to use
« Reply #44 on: July 07, 2014, 05:52:50 AM »
It might be that some people don't like the level of control they think they're missing out on when it comes to references, garbage collection and a more rigid type hierachy? I get that for an experienced programmer, these things count against java - but they're a very good reason to pick it up for those less experienced.

In fact, if a developer doesn't know enough about programming to even know what language best suits their needs then, IMO its the perfect choice. Now obviously you can write bad code in any language, but forcing a new developer to write verbose code under a rigid type hierachy, while hiding pointers and memory management is a great thing.

Then when this inexperienced programmers game turns into a hairy spaghettified mess anyway, they'll have theoretically learnt some of the strengths and weaknesses of the language and be ready to take on the extra features of something more hardcore like C++.
I don't dislike Java for not having pointers, or being an interpreted language, or having a VM, or having GC*.  I love the hell out of Ptyhon**, Perl, and lisp in addition to C and C++.  There's even a place for such monstrosities as bash and tcl in certain tasks.  My problem is that for any feature or subset of features Java has, there's some other language that does them better.  It's not that Java has the wrong features, it's that it's bad at them.

*I don't follow what you're saying about type heirarchy.
**Python is hands down my pick for new programmers.