Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 534 535 [536] 537 538 ... 796

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

Moghjubar

  • Bay Watcher
  • Science gets you to space.
    • View Profile
    • Demon Legend
Re: if self.isCoder(): post() #Programming Thread
« Reply #8025 on: October 02, 2015, 06:46:53 pm »

Speaking of !fun! dangerous things, heres a nice talk on compiler tuning and benchmarking: https://www.youtube.com/watch?v=nXaxk27zwlk 

Will make you appreciate compilers and the lower end of programming.
Logged
Steam ID
Making things in Unity
Current Project: Demon Legend
Also working on THIS! Farworld Pioneers
Mastodon

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8026 on: October 02, 2015, 06:57:26 pm »

@Telgin: Actually, you have some details backwards about dynamic memory and the stack vs heap.

Heap = dynamic, i.e. things created with new and delete. Dynamic things don't call their destructor, unless you tell them.

Stack = non-dynamic. i.e. things created as normal variables in functions or scope blocks. They automatically call their destructores when the scope ends.

~~~

So, if you made a regular string or had a string as a parameter for that function, it's likely that the string was packed in memory next to the array, and you over-wrote part of the class. Then, when the function ended, all local variables have their destructors called when the stack frame is cleared, and this would have caused the error. Actually, if you had made it a dynamic string that error would never have occured (though you'd have a memory leak instead).
« Last Edit: October 02, 2015, 06:59:00 pm by Reelya »
Logged

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8027 on: October 02, 2015, 09:25:04 pm »

Yeah, that's exactly what happened I guess.

I guess I shouldn't say I was surprised that it was crashing in the string's destructor despite the string being stack allocated.  I was more surprised that it was crashing at the start of a function invocation that took a string as a parameter, which I was constructing at that moment.  So, the string didn't even exist at the point that I was trashing the array.  I guess the compiler was reserving stack space for the string before that point or something.

Anyway, the behavior is most surprising since internally strings use heap memory anyway as far as I know.  I suspect that I was overwriting an internal pointer to the memory block, so when it tried to free the memory in its destructor it freed the wrong pointer.

Regardless, it sucks that Valgrind can't detect stack memory errors.  Well, its default Memcheck tool can't anyway, but I think one of the others can.  I should probably read up on that at some point.
Logged
Through pain, I find wisdom.

3man75

  • Bay Watcher
  • I will fire this rocket
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8028 on: October 02, 2015, 09:35:31 pm »

Not so much a programming question but where would be a good place to keep all of my programming projects for possible employers/curious individuals to see?
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8029 on: October 02, 2015, 09:37:31 pm »

Make a blog, and link screenshots + downloads from the blog. Then on the front page of the blog you can link your best projects as stickies, with a one/two-sentence description. Then you only need to provide the blog link, and interested parties have the option of browsing more content if they want to.
« Last Edit: October 02, 2015, 09:39:47 pm by Reelya »
Logged

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8030 on: October 03, 2015, 08:18:38 am »

Not so much a programming question but where would be a good place to keep all of my programming projects for possible employers/curious individuals to see?
I use bitbucket for my repositories, which can be linked to, and I have a StackOverflowCareers profile, where I can link these projects at a central point.
Logged
Taste my Paci-Fist

RoguelikeRazuka

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8031 on: October 03, 2015, 08:45:39 am »

What are friend classes (C++) useful for? For example, there are two classes A and B, and the A class is a friend of B. How can one apply this?
« Last Edit: October 03, 2015, 09:41:50 am by RoguelikeRazuka »
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8032 on: October 03, 2015, 09:08:26 am »

Well, if you want access to things in a class normally you have to make them public, or make public getters and setters. So they become part of the global interface for that class. But say you want to project a more limited public interface, because it's part of a library or something, yet there are some support objects that need to have direct acess to stuff inside the class. Using the friend keyword means that the support classes can do their jobs, but without exposing more details in the public interface of the class in question.

Also, since the "friend" system is a whiltelist, you can narrow down which other classes might have made changes to the object in question, so it might reduce overall program complexity and make it easier to track down bugs.
« Last Edit: October 03, 2015, 09:11:46 am by Reelya »
Logged

jaked122

  • Bay Watcher
  • [PREFSTRING:Lurker tendancies]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8033 on: October 03, 2015, 02:53:38 pm »

Not so much a programming question but where would be a good place to keep all of my programming projects for possible employers/curious individuals to see?
I've heard that it is pretty much industry standard to examine github pages. Those are generally better looking and have the upside of not requiring a curious programmer to deal with archives if they have git installed. Which they should.

Git is the best.

I should make a tutorial on git actually. That could be useful here.

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8034 on: October 03, 2015, 03:11:00 pm »

Yeah, git is great once you get used to it and I recommend anybody who can't use it to learn to use it.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

jaked122

  • Bay Watcher
  • [PREFSTRING:Lurker tendancies]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8035 on: October 03, 2015, 03:46:58 pm »

Yeah, git is great once you get used to it and I recommend anybody who can't use it to learn to use it.
It's been so long since I started using it that I just know how to look everything up. I can't remember having issues. It's a lot better than svn. That's not hard. Fossil is better than SVN, as is DARCS, Mercurial(hg) or any other distributed scm.

Also github just looks good. That's why I prefer it to the alternatives like bitbucket or sourceforge(do they still host code?).

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #8036 on: October 03, 2015, 04:00:49 pm »

To quote the CEO of Microsoft, everyone uses git and it's cool.
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

3man75

  • Bay Watcher
  • I will fire this rocket
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8037 on: October 03, 2015, 04:53:08 pm »

To quote the CEO of Microsoft, everyone uses git and it's cool.

Microsoft. You may not like our products but they work.

EDIT: IMO on how I feel about their stuff.
Logged

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8038 on: October 03, 2015, 05:22:58 pm »

To quote the CEO of Microsoft, everyone uses git and it's cool.
Microsoft. You may not like our products but they work.

EDIT: IMO on how I feel about their stuff.
What has that to do with git? Wikipedia says
Quote
Git was initially designed and developed by Linus Torvalds for Linux kernel development in 2005.

I prefer Mercurial. I don't really get what git's advantage is supposed to be. It just seems harder to use without offering anything useful in return.
Logged
Taste my Paci-Fist

jaked122

  • Bay Watcher
  • [PREFSTRING:Lurker tendancies]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8039 on: October 03, 2015, 06:35:31 pm »

I just don't see the difference after this long.
Spoiler: wow minitutorial (click to show/hide)
There are many more. But fortunately, there are man pages for these, and synopsis online, and tutorial videos, and textual tutorial. All that matters is that you understand that if you want your repo to be publicized, at the moment it is simpler to do it with git.
Pages: 1 ... 534 535 [536] 537 538 ... 796