Stories
Slash Boxes
Comments

SoylentNews is people

posted by LaminatorX on Monday October 06 2014, @08:48PM   Printer-friendly
from the totally-not-cocaine dept.

I'm a fairly seasoned developer, and over the years I've learned how to be productive. But lately I feel like my ability to actually write code is greatly diminished. I try to do all the "right" things: exercise, sleep, lighting, monitors, coffee, the whole nine yards. But I have a really hard time getting motivated to get going.

The community here always has very insightful things to say and I really appreciate and value the input from other people. So my question to the community is this: what are you work habits and environment like that enables you to be the most productive? What kind of music/snacks/monitor/time of day helps you best get "in the zone" and really start cranking out the work?

This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 0) by Balderdash on Monday October 06 2014, @08:58PM

    by Balderdash (693) on Monday October 06 2014, @08:58PM (#102641)

    You should go in the bathroom and crank out a number 3.

    --
    I browse at -1. Free and open discourse requires consideration and review of all attempts at participation.
    • (Score: 3, Funny) by edIII on Monday October 06 2014, @09:36PM

      by edIII (791) on Monday October 06 2014, @09:36PM (#102675)

      Your claims are baseless and unsubstantiated.

      During my own research, with very large sample sizes, I determined that "number 3s" mostly just result in increased frequencies of malware attacks, and increasingly required allocations of resources for hand lotion.

      As for motivation? Not so much.

      I blame Internet porn myself. It reduced the cost to acquire media so dramatically. The traditional quests for young men to find a stash somewhere lead towards critical thinking, devious fuckery, knowledge of the street laws of capitalism, level one Ninja skills, and some knowledge of logistics.

      It was the search for porn, and the boons of success, that provided the motivation. Not the number 3 on its own. What is Lewis-and-Clarkian about hitting a bathroom stall and going back to the still open tab on Porn Hub on a device that can literally show you a million boobies?

      You show that to some man in the Yukon circa 1850 and he would have handed you a pile of gold. Kids these days would break down and hyperventilate if the device just stopped working for a little while. NO. Motivation is provided when you lock out the porn completely.

      My hypothesis is easily testable. Just take away Internet from young people for around 2 months. They get it back if they build a cabin.

      I believe your cabin would be made in 3 days, or all the test participants would have killed themselves.

      --
      Technically, lunchtime is at any moment. It's just a wave function.
    • (Score: 0) by Anonymous Coward on Monday October 06 2014, @10:24PM

      by Anonymous Coward on Monday October 06 2014, @10:24PM (#102722)

      Just so everybody is clear:

      #1: Urine.
      #2: Feces.
      #3: Two large black buttplugs simultaneously crammed up one's anus.

  • (Score: 2) by kaszz on Monday October 06 2014, @08:59PM

    by kaszz (4211) on Monday October 06 2014, @08:59PM (#102642) Journal

    Perhaps you need to do other things to let that coding part of the brain rest?

    And if you code all kinds of stuff because someone else wants this or that. Maybe you need something that is just because you feel like it? Lost curiosity?

  • (Score: 2) by SlimmPickens on Monday October 06 2014, @08:59PM

    by SlimmPickens (1056) on Monday October 06 2014, @08:59PM (#102643)

    For me personally, if I'm relaxed I work smarter and get more done in the end.

    The other thing is that I get bored easily. People say that "multitaskers" don't get much done, however for me personally, I find that breaking the day into 2-4 hour chunks which will be allocated to different tasks means I don't get bored and therefore focus better. That might not be the best thing for any particular task, and may not work for a coder (I'm not one) but it does raise my overall productivity.

  • (Score: 1) by slartibartfastatp on Monday October 06 2014, @09:00PM

    by slartibartfastatp (588) on Monday October 06 2014, @09:00PM (#102645) Journal

    My personal anedocte: after almost 10 years professionally coding everyday (20+ non-professionally), and assuming a managing position (which didn't stoped me from coding, also at home), I'm starting to lose interest at some coding tasks, like regular CRUD/workflow software. This makes me procrastinate and it's harder to focus. Other stuff I consider interesting, like my PhD pet project [github.com] or research related tasks, I can go on several hours without losing focus.

    I try to eat salad everyday, sleep at least 7h, and drink anything between 3-4 cups (200ml) of coffee/day, but I don't do any exercise. However I feel like crap when waking up and can't run for more than 30s, I don't think it did affect my coding habilities (yet?).

    • (Score: 1) by slartibartfastatp on Monday October 06 2014, @09:02PM

      by slartibartfastatp (588) on Monday October 06 2014, @09:02PM (#102648) Journal

      btw: I don't hear any music when coding. For me, it's a easy way to lose focus.

    • (Score: 1) by Bill Evans on Monday October 06 2014, @09:24PM

      by Bill Evans (1094) on Monday October 06 2014, @09:24PM (#102666) Homepage

      Dude, you gotta exercise. Many of the comments here have good ideas, but don't skip exercise. You'll be more alert, more attentive. As a bonus, you'll possibly live longer.

      • (Score: 1) by Ethanol-fueled on Monday October 06 2014, @10:21PM

        by Ethanol-fueled (2792) on Monday October 06 2014, @10:21PM (#102719) Homepage

        Sex. As a sadly pathological vagina addict, having regular sex (at least 3 times a week) puts the spring in my step and the motivation back into my drudgerous life. The only problem is that the withdrawal symptoms are a bitch, and masturbation doesn't even come close. Having to hustle up some poon is also an annoying chore because most women are not worth the effort put into scoring that sweet, sweet poon.

        And I may have to soon, as my favorite suitoress is not talking to me because I bit her in the vagina twice after she asked me to be more rough, and my old default placeholder who I hadn't seen in months now has pustules around her mouth and (respectfully and for obvious reasons) doesn't ask me to kiss her anymore. Yecch!

      • (Score: 1) by slartibartfastatp on Tuesday October 07 2014, @12:27AM

        by slartibartfastatp (588) on Tuesday October 07 2014, @12:27AM (#102810) Journal

        Yeah, I liked to practice martial arts, but my knees got hurt long ago and I`ve never fully recovered. I pretty much hate every other sports, including running, gym and our national sport, soccer. so since then, I'm filling up my time with more and more work.
          I guess I'll start doing mountain bike or something.

        • (Score: 2) by germanbird on Tuesday October 07 2014, @04:09AM

          by germanbird (2619) on Tuesday October 07 2014, @04:09AM (#102867)

          I've heard swimming is very good exercise -- especially for someone with joint issues. I've never done much as it requires the ability to regularly access to a pool and I've never really enjoyed it.

          My personal first choice would be hiking. Not too strenuous and getting out and seeing nature keeps it interesting. You can vary the amount of physical labor by varying your speed and the terrain you tackle. Of course, this all depends on access to the countryside or at least some nice urban parks with trails.

          Since I don't always have time to make it out for a hike, I have resigned myself to a series of more traditional bodyweight exercises (plus some dumbbell stuff). Its something along the lines of crossfit, but I wasn't ready to embrace the religious fervor or the intensity that crossfit seems to have (apologies to any crossfitters out there). I spend about 30 minutes twice a week and although it is exhausting for an out of shape guy like me, I have noticed an improvement overall.

          I guess overall my advice would be try to find something you like to do and keep it quick and simple (at least at first). You'll be more likely to actually do it that way (although there is always going to be some level of discipline required to push through the dry spells).

  • (Score: 2) by MrGuy on Monday October 06 2014, @09:00PM

    by MrGuy (1007) on Monday October 06 2014, @09:00PM (#102646)

    The times I feel least motivated to get productive don't have to do with my sleep schedule, lighting, or how I manage my day. It's the work I'm doing.

    I'm one of those people who's motivated when there's an interesting problem I can sink my teeth into in front of me. After a while, all jobs get stale - even if the nature of the stuff you're doing is the same, sometimes just "getting used to it" on the problem makes it go flat. A change of problem can do wonders. This is basically why I'm a consultant - every few months, I'm doing something completely different.

  • (Score: 2) by buswolley on Monday October 06 2014, @09:05PM

    by buswolley (848) on Monday October 06 2014, @09:05PM (#102651)

    Early morning light, let Soylent, a Tomato timer, https://coffitivity.com/ [coffitivity.com], more vacation, and last, find work that is more interesting to you. You live once.
    If you have to do work that is less interesting (because it is so easy), try some audio-books...although that does interfere with programming generally.

    --
    subicular junctures
  • (Score: 0) by Anonymous Coward on Monday October 06 2014, @09:06PM

    by Anonymous Coward on Monday October 06 2014, @09:06PM (#102652)

    I think the most basic things for me is that I'm on purpose. That I'm doing what I like doing and of course achieving it.
    In an emergency I can do anything I suppose, but not as a career. If my "pay" is not that I get to do what I do then I don't really want to do it day in.

    The people who are the recipients of what I do must be people I WANT to support with my products. I could never help someone who's being a criminal or just a slimebucket.

    If the environment does not allow me to be me and I'm fired then that's a good thing because it would be the wrong environment, and I would never be allowed to expand personally and professionally.

    The above really has to do with integrity. Am I being true to myself?

    If you cannot like yourself then you won't let yourself win.

    The opposit is also true, if I am on purpose or can rehabilitate it by being true to my own goals and purposes then the sky is the limit.

  • (Score: 3, Insightful) by Thexalon on Monday October 06 2014, @09:08PM

    by Thexalon (636) on Monday October 06 2014, @09:08PM (#102653)

    Best time of day: about 8-10 AM is my prime time.
    Music: none
    Snacks: nothing nearby, or my monkey brain will focus on eating instead of coding
    Monitor: Umm, something I can look at for a while? I'm not always staring at a screen when I'm programming, which probably helps with that.

    However, I really have to question the assumptions behind your question: I've seen great programmers and lousy programmers both work, and in my experience the great programmers are typing slower than the lousy ones. The difference is not whether each is focused on their task, but on the fact that the great programmers are doing something along the lines of "read specs-think-type", while the lousy ones are doing "read specs-type-pray". It's not that they get in a zone, it's that their everyday work is darned good.

    Also, quality over quantity wins every time. If you aren't slinging 3000 lines a day, chances are you're creating fewer bugs along the way, which means your work is ultimately faster.

    --
    "Think of how stupid the average person is. Then realize half of 'em are stupider than that." - George Carlin
    • (Score: 2) by mendax on Monday October 06 2014, @10:13PM

      by mendax (2840) on Monday October 06 2014, @10:13PM (#102713)

      That is beyond strange. All true geeks are night owls. After all, Ambrose Bierce wrote in his Devil's Dictionary that dawn is the time when men of reason go to bed. I am most productive when I sleep until noon, wait until a couple hours for my body to completely wake up, and then work until I'm too tired to work any more (or something else more interesting becomes available), taking occasional breaks for food, naps, and dealing with the demands of my evil black cat, a goddess must be worshipped by frequent petting and treats. All of these things, of course, are incompatible with a work life that operates out of a cubicle in an office building.

      --
      It's really quite a simple choice: Life, Death, or Los Angeles.
  • (Score: 2) by mendax on Monday October 06 2014, @09:15PM

    by mendax (2840) on Monday October 06 2014, @09:15PM (#102656)

    People who are really productive don't have the brain cycles or time to waste time coming to this venerable site or that other site [slashdot.org] whose name we no longer mention (but the sl****code does). Of course, what really is productivity? You are older, but perhaps what you are producing more slowly is of better and a more seasoned quality. Well, maybe.

    --
    It's really quite a simple choice: Life, Death, or Los Angeles.
  • (Score: 2) by VLM on Monday October 06 2014, @09:18PM

    by VLM (445) Subscriber Badge on Monday October 06 2014, @09:18PM (#102661)

    "getting motivated to get going...."

    .... because?

    I used to get distracted by thinking about other tasks. get things done strategy of get it on paper (emacs .org mode, later evernote, whatever) to get it totally outta your mind, then you're not distracted by other tasks anymore.

    The problem isn't being fixated on replacing the air filter for the furnace on some kind of emotional level, its having to run an occasional dram refresh cycle on my brain that distracts, because otherwise I know I will forget. Or its thinking about the other tasks related to this task. Well with something like GTD, no fear, its on the calendar, now focus on todays work.

    Another example is in the really olden days (just barely post clay tablet) I used to pay physical paper bills using chronological stacks of them in a physical in-basket. Its all e-billing and e-payment now and I extensively use a GTD like system, so I just don't think about it any more. I don't need to remember that I have to pay the mortgage this week because its the first full week of the month, its all in the system.

    Its a DRY don't repeat yourself development strategy as applied to time management. I don't think about repetitive or scheduled tasks at all.

    If your problem is something else, then this solution is likely a waste of time, but whatever.

  • (Score: 3, Insightful) by bzipitidoo on Monday October 06 2014, @09:23PM

    by bzipitidoo (4388) on Monday October 06 2014, @09:23PM (#102665) Journal

    I've been facing this problem for years. Coding is no fun when most of your time is spent puzzling over bad documentation and buggy, obfuscated libraries, and there's a lot of that out there. OOP was supposed to make things easier by hiding things you didn't need to know. It didn't work. You do need to know more than the names of the classes and member functions. Many times I've given up on the documentation and written tiny programs to see how some library function or language feature really works.

    Worse is hunting for library functions. You figure there's probably some function that does what you want, but you don't know what it would be called. Long gone are the days of knowing everything in the C libraries because stdlib and friends have only a few hundred functions. The good side is that now you don't have to implement your own stacks, queues, hash functions, memory management routines, and other basics of Computer Science/

    Then there's the problem of trying to decide which combinations of several competing languages and libraries to use. C/C++, or one of the P's (Python, Perl, PHP), or Java, Javascript, Haskell, or LISP. Will databases and SQL be used? As for libraries, GNOME or KDE? Or FLTK, or something else? Maybe HTML and SVG, or Flash? OpenSceneGraph or OGRE, or neither and go with raw OpenGL? Or (gasp) Xlib and Motif or LessTIF? Some of those choices are clear, but it can be really hard to judge, and most people end up picking them almost randomly.

    • (Score: 2, Interesting) by slartibartfastatp on Tuesday October 07 2014, @12:34AM

      by slartibartfastatp (588) on Tuesday October 07 2014, @12:34AM (#102814) Journal

      In the lastest project my team got, we spent more time talking and planning than coding - we discussed the general design and patterns, documented the main features on the backlog then started coding. No one were in charge of a whole module, everything had an interface for something somebody else was coding. I don't know if it was incidental, but it was the best code we've ever write and the most fun we've had coding in such a long time.

      TL;DR: a team that goes along working in the same project=fun; working alone bugfixing=needs to be done.

      • (Score: 2) by urza9814 on Wednesday October 08 2014, @03:57PM

        by urza9814 (3954) on Wednesday October 08 2014, @03:57PM (#103631) Journal

        I think I'm the exact opposite of you and the GP...

        Particularly with my personal projects, I can have fun coding without a design, or I can have fun doing the design. The more work I put into the design, the less fun the coding is -- because if you've got all the specs fully detailed laid out in front of you, all you're doing coding is translating. There's no more puzzles, no more challenges, nothing fun or interesting! Where it starts to get enjoyable again is when you realize your detailed spec is missing something and you've gotta figure out how to fix it without totally screwing up everything else.

        This is probably why most of my personal projects never get beyond around 80% completion. At that point it stops being fun and I either just stop working on it, or redesign the whole damn thing from the ground up and start over!

        • (Score: 1) by slartibartfastatp on Thursday October 09 2014, @02:39AM

          by slartibartfastatp (588) on Thursday October 09 2014, @02:39AM (#103881) Journal

          There's no more puzzles, no more challenges, nothing fun or interesting

          However, I feel that coding in this situation is faster. What also contributes to the fun factor are unit tests - it's kind of a game to get 100% coverage and all tests successfull. And when you know exactly what you need to accomplish before starting to code, writing tests can be enjoyable rather than a chore.

          Where it starts to get enjoyable again is when you realize your detailed spec is missing something and you've gotta figure out how to fix it without totally screwing up everything else.

          In a group, that is even more "fun", now in quotes: you'll probably need to refactor something. The quotes are because if your deadline is approaching, the temptation of using a duct tape is huge and the theoretical discussions of "which object responsability is this?" seems a waste of time.

          This is probably why most of my personal projects never get beyond around 80% completion. At that point it stops being fun and I either just stop working on it, or redesign the whole damn thing from the ground up and start over!

          even on personal projects, it is important to have goals beyond self satisfaction. Sure it's fun to refactor a lot till your design is so flexible you ended up writing a 2-pass compiler (been there hehe), but code is not an end in itself.

          • (Score: 2) by urza9814 on Thursday October 09 2014, @01:08PM

            by urza9814 (3954) on Thursday October 09 2014, @01:08PM (#104014) Journal

            In a group, that is even more "fun", now in quotes: you'll probably need to refactor something. The quotes are because if your deadline is approaching, the temptation of using a duct tape is huge and the theoretical discussions of "which object responsability is this?" seems a waste of time.

            Yeah, currently I'm doing performance testing at work, so not much code at all. Even when I was in dev I was doing Unix batch scripts, Nothing really requiring a ton of group work. I'm more of a scripter than a developer to be honest -- favorite languages are bash and PHP. And IMO, if you've got a bash script that requires a large team to develop...you've REALLY fucked up somewhere ;)

            even on personal projects, it is important to have goals beyond self satisfaction. Sure it's fun to refactor a lot till your design is so flexible you ended up writing a 2-pass compiler (been there hehe), but code is not an end in itself.

            Yeah, my most recent personal project is a home theater system (Raspberry Pi connected to a projector...with a massive mess of PHP controlling everything). First design was scrapped because both the code and the web page were awful and I decided to go a very different direction with how it's all set up. Second design was scrapped after I started trying to add a recommendation engine, bit torrent client, and Pirate Bay integration and the code was getting too unwieldy. Now I want to post the code online at some point, and it's absolutely atrocious, so on to rewrite number four! Plus I've added an authentication system when it was never designed for permissions or remote access so that just doesn't really work. At this point I'm really building a framework for building a home theater setup...haven't quite gotten to the point of building a *compiler* yet ;)

            ...Then again, I'm not using a compiled language. I guess that basically *is* what stage I'm on :)

  • (Score: 1, Informative) by Anonymous Coward on Monday October 06 2014, @09:35PM

    by Anonymous Coward on Monday October 06 2014, @09:35PM (#102674)

    Obviously, you haven't mentioned what your home life is like. If you're doing everything "right", it could be that you're unfocused because your home life is affecting your ability to concentrate. If you've ruled out other possibilities, it's at least something to think about. Again, I hate to be that guy, but at least consider it as a possibility.

    If it's not that, at least make sure you're getting enough vitamin D. I'm not sure what you meant by "lighting", but direct sunlight can make a big difference for some people.

  • (Score: 3, Insightful) by PizzaRollPlinkett on Monday October 06 2014, @09:42PM

    by PizzaRollPlinkett (4512) on Monday October 06 2014, @09:42PM (#102682)

    My thing is to work in short, intense bursts of an hour or two, and then back off. I can get a maximum of output cranked out, and then cool down and have time to think about what's next. I'm sure everyone is different, but after a few hours my concentration tanks. Also helps to have a clear goal, and to break it down into small steps to accomplish. When I am most unfocused, I realize I don't know what I'm trying to do, and have to step back and reassess what I'm working on and make it clearer in my mind. The times I'm not "working" in the sense of grinding out code and making things appear on the screen is actually the most important part. That's where the road map comes from that makes the grinding possible. To me, clarity is what makes getting in a "zone" possible - knowing exactly what I need to do to accomplish a goal.

    I'm not sure what this will tell anyone, though, because everyone is different and every project is different.

    Everyone has different motivation. Can't help anyone find motivation. You have to find your own. Most work is uninspiring and boring, or people wouldn't have to get paid to do it. If you find your identity in your work, then you'll realize some day that everything you do is ultimately meaningless. I know that from my own experience. (I don't think anything I did in the 90s or 00s is still in use. All of it was important to someone at the time, important enough to pay me to do it, but ... !) Consider how many lines of code were written in the 1980s. How much of it is still in use? I guess the only motivation is the next paycheck.

    --
    (E-mail me if you want a pizza roll!)
    • (Score: 1) by Squidious on Tuesday October 07 2014, @12:01AM

      by Squidious (4327) on Tuesday October 07 2014, @12:01AM (#102799)

      Agreed, short intense bursts for the win. If you can work to music, queue up a playlist of your favorite stuff and do not allow yourself to open a web browser or an email reader or otherwise distract yourself until that playlist is completed. After the burst take a break and hit your time wasters in one greasy bunch.

      --
      The terrorists have won, game, set, match. They've scared the people into electing authoritarian regimes.
  • (Score: 1) by SrLnclt on Monday October 06 2014, @09:54PM

    by SrLnclt (1473) on Monday October 06 2014, @09:54PM (#102693)

    You are asking me? I just clicked on this site yet again in hopes of finding something new at 10 minutes until 5PM local time, for the sole purpose of not wanting to be productive for the remainder of my work day.

  • (Score: 1) by dltaylor on Monday October 06 2014, @10:32PM

    by dltaylor (4693) on Monday October 06 2014, @10:32PM (#102731)

    I've worked with a lot of different managers of over the years. Some of them have been very good about letting me be productive and some have been a complete drain on my work output.

    Managers who understand how programmers work is more important than their sheer technical expertise. Some of us are larks, some are owls, most in-between; a manger that understands which of us can be productive after an 8AM "scrum" (almost none, really), vs doing a bit of "management by walking around", giving us a three-minute "How's it going? What do you need?" at a point where she's observed that we usually hit a lull anyway is incredibly valuable. Some times/some projects benefit from temporary close-knit work groups (a bit like "paired programming"), sometimes we need to be able to work alone, but pause and bounce ideas off other staff, and there are the times where I can get more done between 7PM and 5AM than in a week, otherwise. A truly special manager gets to know the balance between interaction, doodling for inspiration, and being "in the zone" for each of the staff and does her best to make that happen.

    I used the female pronoun because one of the best I've ever worked for was a ex-programmer working her way up the management responsibility tree, although the absolute best was the male VP of engineering at my first engineering job back when I was a junior hardware engineer.

  • (Score: 2) by mhajicek on Monday October 06 2014, @11:11PM

    by mhajicek (51) on Monday October 06 2014, @11:11PM (#102770)

    Deadlines.

    --
    The spacelike surfaces of time foliations can have a cusp at the surface of discontinuity. - P. Hajicek
    • (Score: 2) by fliptop on Monday October 06 2014, @11:42PM

      by fliptop (1666) on Monday October 06 2014, @11:42PM (#102792) Journal

      Deadlines

      I was going to mention this. A deadline has ways of removing everything from focus except the task at hand.

      --
      Our Constitution was made only for a moral and religious people. It is wholly inadequate to the government of any other.
  • (Score: 2) by jasassin on Monday October 06 2014, @11:22PM

    by jasassin (3566) <jasassin@gmail.com> on Monday October 06 2014, @11:22PM (#102784) Homepage Journal

    Only one time in my life did I personally have to write some C code. I had to do it! It was an ultimate hack. Allocating memory for reading an arbitrary string length from a file was difficult. It came down to allocating more memory, but finally the program stopped wigging out and did its job.

    I had one thing I really wanted to do. If you don't want to do something, you most likely won't.

    I am not a C coder, what is the code to allocate memory for a string you read in from a file? I don't know how long the string in the file might be. How do I create a variable if I don't know how long the string will be? If the string is too long, it overruns the array. I had to do something like char[99999]. I know its fucked but my program worked. I didn't (and still don't) know how else to do it.

    --
    jasassin@gmail.com GPG Key ID: 0xE6462C68A9A3DB5A
    • (Score: 1) by slartibartfastatp on Tuesday October 07 2014, @12:40AM

      by slartibartfastatp (588) on Tuesday October 07 2014, @12:40AM (#102819) Journal

      you create a linked list with chunks of 4kb or whatever, or you get the filesize from the fs, or even for(unsigned long size=0;fgetc(F);size++); [pardon my french] before allocating memory

      • (Score: 0) by Anonymous Coward on Tuesday October 07 2014, @01:34AM

        by Anonymous Coward on Tuesday October 07 2014, @01:34AM (#102831)

        Just to be complete, if you use the approach you gave of looping and reading characters into 4 KB (or whatever size) chunks of dynamically allocated memory and creating a linked list of those chunks, you must add that, when you're done reading the file, you must convert the linked list into a string. You do that by creating a dynamically allocated array of characters of the same size as the number of characters in your linked list, plus 1 for the terminating NULL char that C strings require. You then copy chars from the linked list into this array using memcpy().

        TL;DR
        You need to use dynamically allocated memory using malloc() (or calloc()), not statically allocated memory (mystring[somehardbiglimit]).

        • (Score: 1) by slartibartfastatp on Tuesday October 07 2014, @03:02AM

          by slartibartfastatp (588) on Tuesday October 07 2014, @03:02AM (#102853) Journal

          You need to use dynamically allocated memory using malloc() (or calloc()), not statically allocated memory (mystring[somehardbiglimit]).

          not to mention that a file that is somehardbiglimit+X bytes long can be made to run arbitrary code of size X

    • (Score: 2) by kaszz on Tuesday October 07 2014, @01:58AM

      by kaszz (4211) on Tuesday October 07 2014, @01:58AM (#102838) Journal

      open()
      for(;;){
      realloc(current_size + buffer_size)
      read()
      if( done ) { exit.. }
      }

      Enables you to load a string using up all your virtual memory if so required.

      If you don't know how your own code works. It's likely to fail for "unknown" reasons in bad way later.

    • (Score: 0) by Anonymous Coward on Tuesday October 07 2014, @07:04AM

      by Anonymous Coward on Tuesday October 07 2014, @07:04AM (#102896)

      Read in chunks and realloc. Or use mmap.

      What's the world coming to ... :)

  • (Score: 3, Insightful) by goodie on Tuesday October 07 2014, @02:02AM

    by goodie (1877) on Tuesday October 07 2014, @02:02AM (#102839) Journal

    I'm not a full-time coder anymore (at least for now). But between teaching, working on papers, pet projects etc. I've found that like many other coders I know, my level of interest dwindles once I am past the initial "super cool idea to try out" stage. Once it's more "routine" (not that it's not hard), I lose interest quickly. When I was a full-time coder, I was secretly dying to get some database performance problems to debug because it was genuinely interesting to me. At the end of it I'd always come out like I've learnt something. CRUD stuff is fine, but if it's only that, it's painfully boring.

    Nowadays, there's just too much I can learn. I want to do too many things (brush up on my stats, learn R, etc.), and with family life etc. I realize it's too much. But my reaction is to be paralyzed... weirdly enough. So to try and help I've been trying to stick to a schedule which focuses on different activities every day (e.g., Monday: paper 1; Tuesday: paper 2 + prepare for Wednesday's class etc.). This way I actually get to look forward to doing something the next day. And I'm usually not done by the end of the day. But I stick to not doing the same the next day, which creates a sense of eagerness for the next time I get to do that again. In the meantime, I get to think about it in my head when I have a bit of time. But surely enough, it's a delicate balance to maintain. For example, if a kid is sick and you have to stay home that day, your schedule gets screwed. And that can be frustrating at times.

    I haven't been exercising for a while. My diet is pretty good though (I think...). I should exercise but there is simply no time as far as I can tell. Maybe that's a lousy excuse and I should actually do it. But truth be told, I am up early, work whenever I can, and go to bed early exhausted so I'm confident that I'm currently doing my best. Maybe once the semester is over I get to have a chance to shuffle things around and try to exercise somewhere in there.

    Food while I work is a no-no to me. Water or tea is fine, but I am on a different floor from the kitchen and I find that anyway I am not really hungry outside of meal times. I eat plenty of fruit for breakfast, try not to eat too much at lunch time, and not work in the evening most of the time so I can do house chores.

  • (Score: 0) by Anonymous Coward on Tuesday October 07 2014, @02:14AM

    by Anonymous Coward on Tuesday October 07 2014, @02:14AM (#102846)
    If you first get the file size like below, you can then malloc a string with the right size.

      //get file size
      fseek(f,0,SEEK_END);
      int size = ftell(f);

      //rewind to start of file
      fseek(f,0,SEEK_SET);

  • (Score: 3, Insightful) by jelizondo on Tuesday October 07 2014, @05:32AM

    by jelizondo (653) Subscriber Badge on Tuesday October 07 2014, @05:32AM (#102882) Journal

    I love coding. Really, really love it. However I find it harder and harder. After 30 years of doing it, somehow it becomes a "Not this shit again!" for me. Same type of problem, same type of solution.

    But as others have commented, now you have to deal with thousands of functions in a library, which may not be properly documented, if at all. So you have to choose between reinventing the wheel or spending hours finding out a pre-cooked solution.

    Long time ago I used TurboPascal and some Turbo libraries (some German outfit, I think) which were great. I saved uncounted hours and could concentrate on solving the problem instead of fighting the library, the framework, the OS API, the stupid and ever-changing requirements, the powers-that-be who think is a matter of pushing some buttons and the problem is solved.

    So, I no longer code for a living. If I find an interesting project, I work on it. Sometimes I make money out of it; sometimes, I don't. I really don't care for the money, I care that it allows me to do something I love doing, on my own terms. If your requirements are stupid, I don't take the project. If you mandate a given language/framework, I don't take the project. You give me complete freedom to create the best solution but don't have much money? I'll do it!

    BTW, I do project management for telecomm, physical plant planning/implementation, video surveillance, infosec and other stuff unrelated to coding for a living now. It gets crappy, but it is a job and it does NOT take away from what I really love doing. (Except time.)

    • (Score: 2) by metamonkey on Tuesday October 07 2014, @01:33PM

      by metamonkey (3174) on Tuesday October 07 2014, @01:33PM (#103021)

      I find that if I'm forced to do something, I grow to hate it. I'm a voracious reader, but when I was in school and was told "you must read this book," I hated that book. Especially "As I Lay Dying." My God that was awful.

      Like you, I took a job in something barely related to coding. I'm an analyst, so I work with numbers and write SQL. And I'm surprised at how much they pay me to write SQL. But, since I can zombie through the stuff they're forcing me to do I have plenty of time left over for things I want to do, whether that's a coding project or just spending time with my kids.

      --
      Okay 3, 2, 1, let's jam.
  • (Score: 2) by migz on Tuesday October 07 2014, @08:16AM

    by migz (1807) on Tuesday October 07 2014, @08:16AM (#102909)

    You are burnt out.

    Take all the leave you can as soon as you can, and switch off all the tech. Go off grid. Take a couple of dead-tree-books and get into the country and breath real air.

    Do nothing.

    If that doesn't work, ask you company about taking a sabbatical (1 year somewhere else doing something else, NOT involving sitting behind a pc, preferably studying). They probably won't, but no harm in trying. Then quit. Go do something wierd for a year, take a gap year. Best thing I've ever done.

  • (Score: 2, Insightful) by infodragon on Tuesday October 07 2014, @11:32AM

    by infodragon (3509) on Tuesday October 07 2014, @11:32AM (#102949)

    I have been professionally coding now for 21 years, mostly C++ in areas requiring high performance. What I have found that helps, besides the obvious exercise, good sleep... is to find something you enjoy that is very different from anything to do with coding, which means away from the computer.

    For me this ended up being RC rock crawling. I get exercise and enjoy a completely different hobby. I've had to learn to work with my hands in 3D real-space. I had to learn to solder, DC electrical stuffs, radio technology (what resolution is the digital/analog conversion), servo durability/strength/speed, lithium battery technology and all about mechanical cars. Not to mention the physics of a four wheel vehicle attempting to scale a 70+ degree uneven surface. This also gets me outside and I've discovered some amazingly beautiful areas. I have also been getting involved in local groups so I'm socializing with people who are completely different from the programming world.

    The completely different world, requiring me to LEARN new things, has reinvigorated my desire for coding and bettered the quality of my work. This also has the advantage that by learning you are increasing or maintaining the neuro-plasticity of the brain which leads to a happier healthier brain.

    In summary my cocktail of better productivity... (all are equally important, if one suffers my professional and personal life suffer)
    1. Maintain a healthy balance of everything.
    2. Eat healthy (increase protein, make sure good balance of amino acids)
    3. exercise
    4. volunteer somewhere (giving something helps in ways unimaginable, google the psychology of giving)
    5. get plenty of sleep
    6. find something you enjoy completely different from your work, aka hobby.

    --
    Don't settle for shampoo, demand real poo!
  • (Score: 0) by Anonymous Coward on Tuesday October 07 2014, @12:54PM

    by Anonymous Coward on Tuesday October 07 2014, @12:54PM (#102987)

    Caring about what you're doing, not because you want to make your company even more successful than it's been, but because you care about your own brand and skillset.

  • (Score: 3, Insightful) by Phoenix666 on Tuesday October 07 2014, @02:28PM

    by Phoenix666 (552) on Tuesday October 07 2014, @02:28PM (#103048) Journal

    I enjoy these discussions because they lay bare the humanity behind the complexity. The 3am "A-ha" moments might anchor the progress of our civilization, but it's the stuff before, after, and in-between that make us men.

    Me, I don't have an answer. My best moments come when I don't give a fuck. So now I try to cultivate that attitude and create as many of those moments as I can. Maybe you'll get paid and maybe you won't, but you will make the biggest dent you can on the universe. After you're dead, what else matters?

    --
    Washington DC delenda est.
  • (Score: 0) by Anonymous Coward on Tuesday October 07 2014, @08:31PM

    by Anonymous Coward on Tuesday October 07 2014, @08:31PM (#103304)

    I have a really hard time getting motivated when I have allergy attacks. Even minor attacks sap all of my strength. I still try to run and lift weights but after that I feel like doing nothing.

    • (Score: 2) by Common Joe on Wednesday October 08 2014, @05:18AM

      by Common Joe (33) <{common.joe.0101} {at} {gmail.com}> on Wednesday October 08 2014, @05:18AM (#103448) Journal

      For some people, this idea may seem like crap at first glance, but I am going to support the idea that sometimes allergies (even if they appear to be minor) have a profound effect on thinking abilities and energy levels. I don't think it is the problem that the poster has, but it is an interesting idea for IT people to think about.

      Over-the-counter allergy pills also have an effect on my coding too.