Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 591 592 [593] 594 595 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 902747 times)

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8880 on: January 26, 2016, 09:08:12 pm »

Or in short, just use Orthodox C++. https://gist.github.com/bkaradzic/2e39896bc7d8c34e042b
Because that's how you get future-you and future-you's coworkers to thank current-you, instead of sacrificing goats while cursing current-you's name because that's now part of the workflow you designed.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8881 on: January 26, 2016, 10:06:50 pm »

Ispil, I'm not entirely sure how your first paragraph squares with the second? It sounds like you're disdainful of a particular ideology then immediately follow up with a statement that you shouldn't be disparaging of ideologies.

Also, I think DF is written in that silly C with classes-type C++? Toady's used phrases along the lines of "mess of C and C++" and "doesn't follow any reasonable standard" before, so I figure.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8882 on: January 26, 2016, 11:13:29 pm »

But a matrix library needs to be as fast as humanly possible, not readable to a human. Matrices tend to be used for big data sets and parallelism, and needs to be built around an understanding of CPU + memory architecture (with shitty design, almost identical-looking matrix code can run literally 10-20 times slower, and that's before any "tricky" optimizations).

Basically, if you're using someone elses maths library, you expect them to have implemented every possible optimization that exists for that problem domain. If they haven't, why are you using that library rather than the next one?
« Last Edit: January 26, 2016, 11:24:00 pm by Reelya »
Logged

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8883 on: January 26, 2016, 11:23:07 pm »

No documentation?
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8884 on: January 26, 2016, 11:34:52 pm »

I think you need a new library.
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #8885 on: January 27, 2016, 12:06:48 am »

Armadillo C++ seemed like a good linear algebra library last time I checked...Good documentation and sane formats.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

jaked122

  • Bay Watcher
  • [PREFSTRING:Lurker tendancies]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8886 on: January 31, 2016, 11:32:23 am »

It seems most likely that the best format for the language you are working with is the one that best uses the features of the language itself, rather than a different one.


Maybe we can't use English grammar to speak fluent Spanish, or more likely English grammar to speak fluent Latin.


Also didn't C++11 have some kind of support for custom garbage collection? Like one level more automatic than the various smart and unique pointer types? The fact that I haven't seen that used seems to speak great volumes about what C++ programmers like about their language, namely that they prefer RAII instead of this nonsense about not needing to call the destructor.

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8887 on: January 31, 2016, 02:41:16 pm »

Yeah, not sure what I was going for with the first sentence. Just the whole "use the C runtime libraries instead of the C++ ones" peeved me in its unnecessity. I mean, the idea of "don't use what you don't need" is pretty damn straightforward. As for manual memory management... eh, you'd be hard-pressed to need that level of precision on most projects. The thing linked at the bottom elaborates in a way that makes it make more sense to me, at least. I mean, his example of "design rationalle" in Boost really only applies in the sense of "if you're not making a generic library, don't make shit generic unless you can re-use it in your own code."

I believe that first one is probably a matter of running into a compiler-specific library. Linking against cmath in Visual Studio and linking against it in a GCC compiler or some other compiler is very different.

As for memory management, every performance-critical application needs to do it. Which is to say games and any product that takes more than a second to do at least one of its features. Garbage collection is why Minecraft has terrible performance, for example, with its characteristic frame stuttering every other second for upwards of 100ms+ if you have a bunch of mods loaded and it starts running low on memory. Console games almost always use their own custom memory management tech due to the constraints on those platforms. Memory allocation and deallocation calls to the OS are themselves slow, and so even PC games often use their own custom memory management tech -- especially if they want to multithread their engine.

The problem with RAII is that it isn't explicit. It's pretty common practice to have an empty constructor, have an Init function to do the real construction, have an empty destructor, then have a Release or Kill or Destroy function to do the real deconstruction. Reason being that Resource Acquisition Is Often Not Initialization; especially because memory is not the only kind of resource which may need to be acquired for an object. It also makes things explicit, which is beneficial for readability.

And really, that's what it comes down to: A programming language is an interface between a multitude of human brains and the machine. It doesn't exist to type code faster, it exists to allow for the creation of an accurate mental model of what the hardware is doing in a minimal amount of time and effort. If it needs external documentation, stop using C++ and write your gobble-de-gook in assembly so as to let everybody know it's indecipherable garbage from the outset. If you go through half a dozen levels of templates before your program actually runs any code, congratulations, you are special! Special in that you will be the only human who ever understands how your terrible code works. Even the compiler will have a hard time matching itself up against your brilliance! The most expertly written code, the sort that's a joy to work with, is that which you can sit a first year student fresh out of fundamentals of C++ in front of and have them understand not only what the machine is doing with the code, but why you are having it do that.
Logged

Lightningfalcon

  • Bay Watcher
  • Target locked. Firing main cannon.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8888 on: February 01, 2016, 01:24:42 pm »

So, quick questions. I have a recursive function in C++ that has int &groupCount as a parameter. First, so I can look up any other problems that arise from this, what is doing that called? Second, will doing so this in a recursive function give me any errors?
Logged
Interdum feror cupidine partium magnarum circo vincendarum
W-we just... wanted our...
Actually most of the people here explicitly wanted chaos and tragedy. So. Uh.

Lightningfalcon

  • Bay Watcher
  • Target locked. Firing main cannon.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8889 on: February 01, 2016, 01:48:14 pm »

Well, it's a pass-by-reference; what this means is that any time you modify groupCount, you modify it for every function that uses this variable. So, it all depends on where you modify the variable in your function- before or after the recursive call.
Know it is pass by reference. Should have specified that I want to know what it is called when you pass by reference using the & in the parameter headings, instead of just giving it a pointer normally.
Logged
Interdum feror cupidine partium magnarum circo vincendarum
W-we just... wanted our...
Actually most of the people here explicitly wanted chaos and tragedy. So. Uh.

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8890 on: February 01, 2016, 02:44:30 pm »

Found this last week. Thought someone here might enjoy it. The fourth puzzle on "Experienced" was a doozy at first.
Logged

3man75

  • Bay Watcher
  • I will fire this rocket
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8891 on: February 01, 2016, 11:04:58 pm »

Hey guys i'm stuck on a problem in Java. I'm sending the number 20,000 to a different class to be displayed but I'm having trouble displaying it correctly. My assignment is to make a simulated bank account so I want to use 20000.00 instead of 20000.0.

Code here
Spoiler (click to show/hide)

Okay so things I've tried is use the format class that I found online but I'm not using it correctly or maybe I just coded into a brick wall. Any help is welcomed and I hope i've clarified.
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8892 on: February 01, 2016, 11:18:03 pm »

If your using a formatting class then shouldn't you need to tell it what format you want? You're not asking for any specific format anywhere in that code. How could it know how many decimal places you want?

The c/c++/java standard string "%0.2f" means to print a floating point value to two decimal places. See here:

https://docs.oracle.com/javase/tutorial/java/data/numberformat.html

« Last Edit: February 01, 2016, 11:20:38 pm by Reelya »
Logged

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8893 on: February 01, 2016, 11:24:32 pm »

If rounding/truncation concerns you at all, there's also java.math.BigDecimal.
Logged

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8894 on: February 01, 2016, 11:27:20 pm »

If rounding/truncation concerns you at all, there's also java.math.BigDecimal.
Yeah.  And you can give it a 0.00 initializer which will retain the .xx unless you do something that gives it more decimals.
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.
Pages: 1 ... 591 592 [593] 594 595 ... 796