Author Topic: Chaosforge's DRL/D**m RL goes open source  (Read 32396 times)

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Chaosforge's DRL/D**m RL goes open source
« Reply #15 on: December 10, 2016, 09:47:18 PM »
Sorry if I'm being harsh - other than my personal style preferences

Who the fuck writes code like you just did? Are you seriously calling a function every time you do something? Do you have any idea what it's doing under the hood (well, other than the compiler trying to optimize away things like that some idiot is writing).

javelinrl

  • Rogueliker
  • ***
  • Posts: 86
  • Karma: +0/-0
  • Creator of Javelin
    • View Profile
    • Javelin - party-based roguelike (open-source RPG / strategy game)
Re: Chaosforge's DRL/D**m RL goes open source
« Reply #16 on: December 10, 2016, 10:25:37 PM »
Who the fuck writes code like you just did?

Anyone who thinks readability is important, I guess?  :D

Do you have any idea what it's doing under the hood (well, other than the compiler trying to optimize away things like that some idiot is writing).

Yes, I have! Which is why I touched on the subject in my post and why it isn't a big deal!

I was going to apologize for using the word "terrible" since that is not exactly what I meant but you're handling this so poorly I won't even bother  ::) you need to be a little more open-minded if you're posting your code in a thread where people are discussing coding style! There will always be someone out there who doesn't like your approach... You could even use this as a learning opportunity instead of swearing at the replies.... (just an idea)

In honor of the D**mRL this thread is created for I've went in and found a function that looks a lot like my example, except with a few conditionals added in  ;D Also if you look at that entire file there's like 2 or 3 functions that don't fit inside a screen-worth of height... even when they grow a little bigger it's not much more than that... https://github.com/ChaosForge/doomrl/blob/master/src/dflevel.pas#L212

Are you learning yet?  ;D
« Last Edit: December 10, 2016, 10:36:05 PM by javelinrl »
Javelin, party-based roguelike (free RPG / strategy game for Win/Mac/Lin)
https://javelinrl.wordpress.com/

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Chaosforge's DRL/D**m RL goes open source
« Reply #17 on: December 12, 2016, 03:51:02 PM »
Are you learning yet?  ;D

No. You will learn some day I hope. Let's just say that the way you are using member functions in not very -functional-. Even in C++ functional approach is good in a limited way, mostly using parameters as generic structure (rather than return values). Splitting up everything in thousands of small functions is inefficient, harder to read in fact when you have to jump around reading all those small functions and also harder to debug. As you probably will find out sooner or later, it will also become a nightmare to manage the source code when it's getting to large scale.

javelinrl

  • Rogueliker
  • ***
  • Posts: 86
  • Karma: +0/-0
  • Creator of Javelin
    • View Profile
    • Javelin - party-based roguelike (open-source RPG / strategy game)
Re: Chaosforge's DRL/D**m RL goes open source
« Reply #18 on: December 12, 2016, 05:04:45 PM »
Are you learning yet?  ;D

No.

Aw that's a shame  :D

the way you are using member functions in not very -functional

The word you're looking for is "procedural". C++ isn't a functional language (LISP is fun though - I like it, but I wouldn't use it to write a roguelike). About "procedural" though: I sure hope my code isn't like that, I mean it's almost 2017 not 1960  ;D

Splitting up everything in thousands of small functions is inefficient, harder to read

You're still ignoring my first reply to your code sample?  ::) I'd rather take a page from D**mRL code than yours on this. I've worked with the style you're describing a lot (for example when writing patches for DCSS) and I know for a fact which of those I want in my own codebase. 

"Smaller functions are hard to read".  You sound kinda desperate now, don't you? I mean, if your code has files with thousands and thousands of lines then I'm sure it's hard to find a small function inside those but if you're properly organizing your code in relation to the responsability of each module and regarding high-cohesion, low-coupling directives then how is it possible small functions are harder to read and debug? Especially if you're using an IDE that visually indexes all of those function for you and makes jumping through stack frames while debugging super simple.

As you probably will find out sooner or later, it will also become a nightmare to manage the source code when it's getting to large scale.

As I've said I've worked with large codebases in both styles  and I know for a fact that having long functions is more often than not a big pain in the ass to refactor, reutilize and alter without having to spend hours on it or causing unexpected side effects all over the code - especially when the function that handles user input takes screen coordinates as mandatory parameters... If that is the best one you found to show us how good of a programmer you are I shudder to think of the rest. The inline comments were nice though...
« Last Edit: December 12, 2016, 05:11:32 PM by javelinrl »
Javelin, party-based roguelike (free RPG / strategy game for Win/Mac/Lin)
https://javelinrl.wordpress.com/

Worthless_Bums

  • Newcomer
  • Posts: 44
  • Karma: +0/-0
    • View Profile
    • Steam Marines - squad based roguelike
    • Email
Re: Chaosforge's DRL/D**m RL goes open source
« Reply #19 on: December 13, 2016, 02:09:17 AM »
At least one of the people here doesn't release software, so.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Chaosforge's DRL/D**m RL goes open source
« Reply #20 on: December 13, 2016, 09:57:01 AM »
The word you're looking for is "procedural". C++ isn't a functional language (LISP is fun though - I like it, but I wouldn't use it to write a roguelike). About "procedural" though: I sure hope my code isn't like that, I mean it's almost 2017 not 1960  ;D

I guess it goes like this most of the time. When I started programming in C++ about 11 years ago I also wrote lots of methods without parameters, because you get excited about the class scope. But as time has passed it starts to shift towards functional (or also known as procedural in real world terms) styles, which is sort of funny discovery if you think about it. Of course some people never evolve, they stay at the same place, repeating the same mistakes over again. What you actually want to do with classes is minimize the number of member functions and even use outside functions in generic style especially when they don't have side effects (pure functions).
« Last Edit: December 13, 2016, 09:59:57 AM by Krice »

Samildanach

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 453
  • Karma: +1/-0
    • View Profile
    • The Indie Ocean
Re: Chaosforge's DRL/D**m RL goes open source
« Reply #21 on: December 13, 2016, 10:53:42 AM »
At least one of the people here doesn't release software, so.

 ;D Case closed.

javelinrl

  • Rogueliker
  • ***
  • Posts: 86
  • Karma: +0/-0
  • Creator of Javelin
    • View Profile
    • Javelin - party-based roguelike (open-source RPG / strategy game)
Re: Chaosforge's DRL/D**m RL goes open source
« Reply #22 on: December 13, 2016, 02:06:44 PM »
functional (or also known as procedural in real world terms) styles

The reason you can't use "functional" in this case even in"fantasy world" terms is because functional is a whole different programming paradigm, as opposed to the imperative approach used in procedural languages like C and C++ and most other popular and common languages, from Jave to C# to Python to Ruby to BASH. It's a common mistake though since it's easy to think "it has functions then it must be functional". - I've made this mistake myself more than once. Doesn't change the fact it's wrong though.

as time has passed it starts to shift

I think as with all things in life there is a balance to be found. You surely don't want functions having too many parameters (especially in a language where there are no optional parameters) and handling more than one responsibility when you could use different objects and methods for that instead. You also don't want code where you have several classes with only one method spread around dozens of files (unless they're very utility-like as with Comparator implementations).

Learning what good func procedural code is and what good object-oriented code is will let you choose the best approach for each problem, even in a single codebase. The same way you don't want to be using CGI to produce webpages when you can use a template system instead (like PHP and so many other template solutions for almost every conceivable language out there) or even a CMS like Wordpress .

Also, a disclaimer since this seems to be dying down for now: I don't claim I don't produce shitty code. I sure do! Time constraints, being tired, having to work with old code or previous implementations, etc or just plain making bad decisions will always lead to shitty code from time to time. I could easily find files that do not follow my own advice to post here. I'm just saying this before someone calls me a hypocrite or something  ::) I do try to produce code that is in alignment with what I consider to be good practices but I don't always succeed.
Javelin, party-based roguelike (free RPG / strategy game for Win/Mac/Lin)
https://javelinrl.wordpress.com/

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Chaosforge's DRL/D**m RL goes open source
« Reply #23 on: December 13, 2016, 04:25:23 PM »
It's a common mistake though since it's easy to think "it has functions then it must be functional".

Well, now that you mentioned, yes, it is. Remember, C++ is a multi-paradigm language.

Quote
Also, a disclaimer since this seems to be dying down for now: I don't claim I don't produce shitty code. I sure do!

Also good to remember that release rate and code quality are two different things. Game programmers for sure are notorious for writing quite bad code. The amount of bugs can be a telltale sign of bad programming. My approach is famous "zero bugs release". I think current release version of Teemu did have one bug (+couple of potential bugs), but that's how it is sometimes. But the current dev version is actually even better in code quality. You'll see it soon.

Darren Grey

  • Rogueliker
  • ***
  • Posts: 2027
  • Karma: +0/-0
  • It is pitch black. You are likely to eat someone.
    • View Profile
    • Games of Grey
Re: Chaosforge's DRL/D**m RL goes open source
« Reply #24 on: December 13, 2016, 04:41:14 PM »
Coding arguments remind me of the old days of rgrd... What language do you think is best, guys? ;)

javelinrl

  • Rogueliker
  • ***
  • Posts: 86
  • Karma: +0/-0
  • Creator of Javelin
    • View Profile
    • Javelin - party-based roguelike (open-source RPG / strategy game)
Re: Chaosforge's DRL/D**m RL goes open source
« Reply #25 on: December 14, 2016, 01:43:29 AM »
C++ is a multi-paradigm language.

My approach is famous "zero bugs release".

You're rich, man. Show me your declarative C++ code and keep thinking your code has zero bugs. Meanwhile I'll be hanging out with my very real honest girlfriend Angeline Jolie and balling with my 0% fake home boy Kanye.

Darren I'm not sure if your question is troll bait or not but I think that could be a good discussion, considering this thread has been derailed from the very start ;D which ones do you use for your 7DRLs? Did you ever change languages for them along the way and if so why?
« Last Edit: December 14, 2016, 01:45:17 AM by javelinrl »
Javelin, party-based roguelike (free RPG / strategy game for Win/Mac/Lin)
https://javelinrl.wordpress.com/

Darren Grey

  • Rogueliker
  • ***
  • Posts: 2027
  • Karma: +0/-0
  • It is pitch black. You are likely to eat someone.
    • View Profile
    • Games of Grey
Re: Chaosforge's DRL/D**m RL goes open source
« Reply #26 on: December 14, 2016, 10:15:05 AM »
Darren I'm not sure if your question is troll bait or not but I think that could be a good discussion,

It was a joke. Coding styles and language choices are personal things, and arguments over them are a pointless waste of time.

Arguing with Krice is often quite futile too :P

javelinrl

  • Rogueliker
  • ***
  • Posts: 86
  • Karma: +0/-0
  • Creator of Javelin
    • View Profile
    • Javelin - party-based roguelike (open-source RPG / strategy game)
Re: Chaosforge's DRL/D**m RL goes open source
« Reply #27 on: December 14, 2016, 03:15:09 PM »
Coding styles and language choices are personal things, and arguments over them are a pointless waste of time.

You could say that about anything. What is even worth discussing, then? Where I'm from there's a saying that goes " anything is worth it if you got enough soul". Wisdom is found on unexpected places and I don't see discussion about something that is directly related to my hobbies and interests as waste of time. I guess as long as no one's hurt and we're all being polite then discussing these very topics is probably the reason why this forum came into existence to begin with?

Arguing with Krice is often quite futile too :P

I noticed that. One can always hope that more constructive fellas will join in on the conversation at some point though or take something away from reading it.
« Last Edit: December 14, 2016, 03:20:29 PM by javelinrl »
Javelin, party-based roguelike (free RPG / strategy game for Win/Mac/Lin)
https://javelinrl.wordpress.com/

Worthless_Bums

  • Newcomer
  • Posts: 44
  • Karma: +0/-0
    • View Profile
    • Steam Marines - squad based roguelike
    • Email
Re: Chaosforge's DRL/D**m RL goes open source
« Reply #28 on: December 19, 2016, 01:40:58 AM »
Darren I'm not sure if your question is troll bait or not but I think that could be a good discussion,

It was a joke. Coding styles and language choices are personal things, and arguments over them are a pointless waste of time.

Arguing with Krice is often quite futile too :P
int i, j, k in that order. Anything else is heresy and has direct, negative empirical results for code performance.

javelinrl

  • Rogueliker
  • ***
  • Posts: 86
  • Karma: +0/-0
  • Creator of Javelin
    • View Profile
    • Javelin - party-based roguelike (open-source RPG / strategy game)
Re: Chaosforge's DRL/D**m RL goes open source
« Reply #29 on: December 19, 2016, 02:49:30 PM »
direct, negative empirical results for code performance.

You are wrong and I'm triggered - anyone with an inch of brain in their skulls knows this is nothing compared to not properly using camel case to name functions, parameters and variables!!
Javelin, party-based roguelike (free RPG / strategy game for Win/Mac/Lin)
https://javelinrl.wordpress.com/