Boreal
Level 6
Reinventing the wheel
|
|
« Reply #4080 on: June 08, 2015, 10:54:46 AM » |
|
Dag and nat mean day and night in Danish. wat r u do
Dag -> Directed acyclic graph Nat -> Natural number (0, 1, 2, etc.) Also, what's std::future? Never heard of it. .-.
It encapsulates any asynchronous computation. The easiest way to use them is with the `std::async()` function, which simply runs any function on another thread and wraps up the pending result in a future. For example: auto expensive()->std::string { using namespace std::chrono_literals; std::this_thread::sleep_for(1000ms); return "Hello, world!\n"; }
void main() { auto result = std::async(expensive); std::cout << "Doing some other work...\n"; std::cout << result.get(); // std::future::get() blocks until the future is finished }
|
|
« Last Edit: June 08, 2015, 11:03:14 AM by Boreal »
|
Logged
|
|
|
|
oahda
|
|
« Reply #4081 on: June 08, 2015, 11:31:23 AM » |
|
Oh, I've barely done any multithreading in C++, but that looks really handy.
How come you're using auto syntax for that function declaration BTW since you have to specify the return type after the arrow anyway? s:
|
|
|
Logged
|
|
|
|
Boreal
Level 6
Reinventing the wheel
|
|
« Reply #4082 on: June 09, 2015, 12:12:43 PM » |
|
It's recommended for all new C++ codebases since it matches the lambda syntax. The use of `decltype` requires that syntax as well, so it just keeps things more uniform.
Typically, I will still write the signatures for void functions in the normal way.
|
|
|
Logged
|
|
|
|
Schrompf
|
|
« Reply #4083 on: June 09, 2015, 01:59:38 PM » |
|
No, it's not recommended except you need to do it this way. Please don't clutter your codebase needlessly. Principle of least surprise, and all that.
|
|
|
Logged
|
Snake World, multiplayer worm eats stuff and grows DevLog
|
|
|
Boreal
Level 6
Reinventing the wheel
|
|
« Reply #4084 on: June 09, 2015, 08:14:39 PM » |
|
It is recommended, by Herb Sutter himself. If you're not keeping up with the language standard then that's your problem, not mine.
I'm not saying that you should refactor an old codebase to do this, obviously. But what reason (other than potential portability issues for embedded systems or, god forbid, MSVC) is there to not adhere to at LEAST C++14 when starting something new nowadays?
|
|
|
Logged
|
|
|
|
TheLastBanana
|
|
« Reply #4085 on: June 09, 2015, 10:23:47 PM » |
|
Interesting. I had no idea that function declaration syntax was a feature of C++11. I find it kind of ugly, but as I understand it, at least it solves this problem: ReallyReallyLongClassName::SomeNestedClass ReallyReallyLongClassName::getNestedClass() { ... } which is now: auto ReallyReallLongClassName::getNestedClass() -> SomeNestedClass { ... } Not sure I'm going to adopt it for my current codebase, even though the rest of it is C++11. I guess I could write a script to switch the declaration syntax for the existing code, but that seems like a lot of work.
|
|
|
Logged
|
|
|
|
oahda
|
|
« Reply #4086 on: June 10, 2015, 03:27:32 AM » |
|
The definite proof that C++ has finally turned into a modern language: you can actually write non-ASCII literals directly in your code and they WORK:
|
|
|
Logged
|
|
|
|
Boreal
Level 6
Reinventing the wheel
|
|
« Reply #4087 on: June 10, 2015, 07:47:47 AM » |
|
Interesting. I had no idea that function declaration syntax was a feature of C++11. I find it kind of ugly, but as I understand it, at least it solves this problem:
<snip>
Another big reason for it is, as I said before, `decltype`. It's not as elegant as true return type inference (which lambdas already support to some extent) but it goes a long way. template<typename T, typename U> auto add(T x, U y)->decltype(x+y) { return x + y; }
|
|
|
Logged
|
|
|
|
oahda
|
|
« Reply #4088 on: June 10, 2015, 08:03:27 AM » |
|
Is it possible with some sort of similar syntax in modern C++ to create a function that might return a different type depending on some factor so that the return value of that function has to be caught in with an auto variable and then used somehow?
|
|
|
Logged
|
|
|
|
Boreal
Level 6
Reinventing the wheel
|
|
« Reply #4089 on: June 10, 2015, 08:24:57 AM » |
|
Is it possible with some sort of similar syntax in modern C++ to create a function that might return a different type depending on some factor so that the return value of that function has to be caught in with an auto variable and then used somehow?
No, but if you think about it for a second that's just polymorphism.
|
|
|
Logged
|
|
|
|
oahda
|
|
« Reply #4090 on: June 10, 2015, 10:50:23 AM » |
|
Is it possible with some sort of similar syntax in modern C++ to create a function that might return a different type depending on some factor so that the return value of that function has to be caught in with an auto variable and then used somehow?
No, but if you think about it for a second that's just polymorphism. Actually your answer is yes, because the code you posted in the exception thread with visit seems to be doing exactly what I was thinking of. Thanks!
|
|
|
Logged
|
|
|
|
InfiniteStateMachine
|
|
« Reply #4091 on: June 11, 2015, 08:28:43 AM » |
|
Finally got all my projects off of git onto a good source control system. My productivity has increased profoundly. still have to use it at work though
|
|
|
Logged
|
|
|
|
kamac
|
|
« Reply #4092 on: June 11, 2015, 08:51:10 AM » |
|
QUESTION NUMBER ONE
What's wrong with GIT for you?
QUESTION NUMBER TWO
What did you switch to?
|
|
|
Logged
|
|
|
|
InfiniteStateMachine
|
|
« Reply #4093 on: June 11, 2015, 09:30:12 AM » |
|
1)
Bear in mind 75% of my work is in games, robotics, computer vision, education research and other projects with a large data/content portion of the project so this comes from that perspective.
I don't hate git but I'd say it's the worst CMS after CVS (for the types of projects I work on). When working with a large team doing things like reviewing each others code is annoying as hell. You have to make a patch and send it to someone else to load up. It's about 20x slower than doing the same thing in perforce.
Constantly chasing head to resolve is annoying for very large projects (100k + commits, millions of lines of code). The worlds worst data store support, it's so bad people have to hack on a side store and keep 2 stores in sync. The submodule system is annoying to deal with.
It has relatively bad automerging. Setting up resolve with a decent diff tool like araxis,beyond,codecompare takes longer than any other CMS I've worked with. It's not terrible but still annoying.
Traning new employees to use it takes significantly longer than any other CMS because of the shitty api.
If I were to go with a distributed paradigm I would use Mercurial which has a much better interface and some nice branch history reworking features. Even has a solution for large binary files.
2) I switched to perforce, specifically their new perforce helix cloud for personal projects. Easily the best CMS I've ever used (I haven't used Plastic SCM yet, so bear that in mind). They've even gone so far as to now implement a distributed model that allows you to use the git api on a perforce repo. I never use that though.
When I think of all the projects that have suffered from distributed model because they are influenced by dogmatic academic and theoretical arguments I cringe. Distributed model excels for SOME PROJECTS such as the linux kernel. It's not a solution that works for all cases.
I don't have to because of the FOSS and low usage pricing model but if I did I would pay the 1000$ for perforce.
This tweet I posted illustrates my general thoughts.
"This will most likely be my most controversial tweet. Perforce >>>>>>>>>>>>>>>>>>>>>>>>>>>> SVN >>>>>> mercurial >>>>>>>>>>>>>>> git > CVS."
EDIT : that tweet is a little hard on mercurial. Mercurial is about the same level as SVN. It's decent and clean.
|
|
« Last Edit: June 11, 2015, 09:38:12 AM by InfiniteStateMachine »
|
Logged
|
|
|
|
oahda
|
|
« Reply #4094 on: June 11, 2015, 09:37:39 AM » |
|
I like git more than subversion. ._.
|
|
|
Logged
|
|
|
|
InfiniteStateMachine
|
|
« Reply #4095 on: June 11, 2015, 09:38:55 AM » |
|
I like git more than subversion. ._.
Replace git with Mercurial and on a project that is 100% code then I would agree with you. Once again I am speaking from a certain perspective. Don't take my points as dogmatic
|
|
|
Logged
|
|
|
|
oahda
|
|
« Reply #4096 on: June 11, 2015, 09:43:10 AM » |
|
Dunno what sort of non-code files you mean, but I haven't had any problems working in web or games using git with image files and sounds and stuff.
|
|
|
Logged
|
|
|
|
InfiniteStateMachine
|
|
« Reply #4097 on: June 11, 2015, 10:06:10 AM » |
|
Dunno what sort of non-code files you mean, but I haven't had any problems working in web or games using git with image files and sounds and stuff.
Some examples would be AAA games with 200GB+ of content. Machine learning stuff I worked on where the training database is in the multi-gigabyte range. Unreal engine games and game mods are other examples. For a small web game with under 10MB content I've used mercurial before and it was fine. That said I would still use perforce for that.
|
|
« Last Edit: June 11, 2015, 10:12:10 AM by InfiniteStateMachine »
|
Logged
|
|
|
|
ThemsAllTook
|
|
« Reply #4098 on: June 18, 2015, 01:45:43 PM » |
|
In a recent conversation, I learned something about myself and coined the term "hedonistic programming". When I'm working by myself with no particular time constraints, instead of choosing the most efficient way to implement something, I choose to do it in the way which gives me the most pleasure.
Some of my more opinionated programmer friends are often vexed by my preference for inventing things rather than finding an existing solution and adopting it. They'll butt in and try to argue that I shouldn't be trying to solve some problems myself, because it's not as efficient, or because they think I'm too dumb to do it, or because it's Not How Things Are Done. Realizing and explaining that I make these choices for pleasure rather than practicality gives me a much better way to counter their negativity than trying to justify my choices pragmatically.
...that was kind of rambly and almost turned into a grumpy programmer post, but I wanted to put it someplace.
|
|
|
Logged
|
|
|
|
oahda
|
|
« Reply #4099 on: June 18, 2015, 01:50:03 PM » |
|
Haha, yeah. I've been working more on the water waves and stuff in my games today. Still haven't checked out those cool algorithms for proper solutions based on true wave physics given to me in the Rain World thread, but just playing around and looking at the resulting visuals instead. It's a game. It doesn't have to be physically accurate. Just look good. And it's fun to play around with the constants and see what happens. Not to say the water in Rain World doesn't look amazing but it's fun to be able to figure something working out from scratch, which I guess is your point!
|
|
|
Logged
|
|
|
|
|