News for hackers. Stuff that matters.
Re:Confessions of an Intermediate Programmer by Bahamut on Monday March 03, 2014 @07:49PM (#7337705)
I've actually been down this route when I was a kid experimenting with making programs. I did not understand what was the point of functions - why not just copy/paste blocks of logic?

It wasn't something important to me for a long time since I did other stuff instead, but coming back to programming in an effort to make a career out of it, a lot of that stuff became instantly obvious & I felt foolish for not recognizing it in the first place.

Re:Confessions of an Intermediate Programmer by einhverfr on Monday March 03, 2014 @10:57PM (#7338372)
> It wasn't something important to me for a long time since I did other stuff instead, but coming back to programming in an effort to make a career out of it, a lot of that stuff became instantly obvious & I felt foolish for not recognizing it in the first place.

I think one of the key things experienced programmers finally get is that we never stop understanding that there are things which we are doing sub-optimally and can continue to be reflective and self-critical of that. How can I structure my code better? How can I solve this software development problem that seems to come up frequently?

And then as we solve them, the solutions seem so obvious we wonder why we didn't realize it sooner.

Re:Confessions of an Intermediate Programmer by poopicus on Monday March 03, 2014 @08:00PM (#7337745)
It's funny, as a kid I can remember thinking: "Right, everything has to go in the main function unless absolutely necessary, it will just be easier to read that way."

Nowadays, it's the exact opposite!

Re:Confessions of an Intermediate Programmer by daigoba66 on Monday March 03, 2014 @08:09PM (#7337790)
As a kid I wrote a few games using QBasic. I apparently didn't have a firm grasp on control flow because every call to a sub routine ended with a call to another subroutine; sometimes to a sub routine that was already called earlier in the stack. You win the game by beating it before crashing with a stack overflow.
Re:Confessions of an Intermediate Programmer by Sammi on Monday March 03, 2014 @08:17PM (#7337831)
Nah you just invented continuation passing style. You just needed tail recursion too, and you would be good to go ;)
Re:Confessions of an Intermediate Programmer by doktrin on Monday March 03, 2014 @08:13PM (#7337813)
My code changed in a similar way, however I recently devolved.

I've mostly worked with higher level languages, and recently delved back into C. I had forgotten what a complete pain in the ass it is to pass complex data structures around between functions.

I'm a bit ashamed to admit my functions got pretty damn beefy real quick.

Re:Confessions of an Intermediate Programmer by marvin on Monday March 03, 2014 @08:28PM (#7337871)
Don't worry, you can do this in C# or Python as well. Just structure your small, gradually growing proof-of-concept and soon-to-be-finished-product program correctly. No classes! Or at the very least a few monolithic ones, which cannot be instantiated. Use static methods whenever possible. I have never ever ever done this.

(I am getting ready to write an essay titled "Confessions of a Shitty Programmer").

Re:Confessions of an Intermediate Programmer by lstamour on Monday March 03, 2014 @09:20PM (#7338036)
Try C++, join the dark side! In addition to chocolate chip cookies, we promise C++11 move semantics for returned objects/values. The cookies/cake might be a lie. :-)
Re:Confessions of an Intermediate Programmer by krapp on Monday March 03, 2014 @09:50PM (#7338133)
I had to create a small ADO class for advanced C++ last year.

It was... terrifying.

Re:Confessions of an Intermediate Programmer by Nursie on Monday March 03, 2014 @08:24PM (#7337855)
&structure ... ?
Re:Confessions of an Intermediate Programmer by doktrin on Monday March 03, 2014 @09:35PM (#7338078)
> &structure

AFAIK, that's only a legal function signature in C++.

To the point of the question : when I wrote that, I was specifically thinking of 2-dimensional arrays, not structs per se.

Re:Confessions of an Intermediate Programmer by Nursie on Tuesday March 04, 2014 @09:31AM (#7340329)
I meant passing a pointer rather than a by-ref call (which is indeed C++ only).

i.e. void myfunc(thing* stuff) { return; }

int main() { thing stuff; myfunc(&stuff); }

Re:Confessions of an Intermediate Programmer by doktrin on Tuesday March 04, 2014 @02:59PM (#7342645)
Oh, totally agreed. What I had difficulty with, specifically, was passing around a struct that contained a multidimensional array of a size determined at runtime.

I'm sure the problems I had could be solved by either a full re-design (not really an option), or accomplished by someone with more C experience.

Re:Confessions of an Intermediate Programmer by ATLobotomy on Wednesday March 05, 2014 @01:09AM (#7345621)
It shouldn't matter what the struct is holding, you are passing a pointer, it's always the same size.
Re:Confessions of an Intermediate Programmer by runiq on Tuesday March 04, 2014 @04:55AM (#7339323)
This sounds like the mammoth version of "sleeping on it", which has worked remarkably well for me.