• (cs) in reply to notchulance
    notchulance:
    Log.writeTrace("Txns built");

    For some reason I expect either a log level as argument or that the method name reflect the log level. Could be worth investigating.

    Which is why the log level is in the method name (Trace).

  • Slapout (unregistered) in reply to Some Damn Yank

    Who said he passed the class?

  • Singleton (unregistered)
    Runtime runny = Runtime.getRuntime();
    See, that line shows the problem with OOP. The developer wanted to have an object that represents the current runtime. So they call Runtime.getRuntime() and that returns the runtime, which is of type Runtime. You have to name your variables silly things like "my_thing" or "thingie" instead of "thing" because otherwise you'd get
    Runtime runtime = Runtime.getRuntime();

    In what way does Runtime.getRuntime() make sense? Do you enter a house to find the house? Why have a class that represents something of which there is only one instance (i.e. is not a class)? And why do you have to call a function to get it? Next thing you'll be calling

    int four = 2.getInteger() + 2.getInteger();
  • trtrwtf (unregistered) in reply to Singleton
    Singleton:
    Runtime runny = Runtime.getRuntime();
    See, that line shows the problem with OOP. The developer wanted to have an object that represents the current runtime. So they call Runtime.getRuntime() and that returns the runtime, which is of type Runtime. You have to name your variables silly things like "my_thing" or "thingie" instead of "thing" because otherwise you'd get
    Runtime runtime = Runtime.getRuntime();

    In what way does Runtime.getRuntime() make sense? Do you enter a house to find the house? Why have a class that represents something of which there is only one instance (i.e. is not a class)? And why do you have to call a function to get it? Next thing you'll be calling

    int four = 2.getInteger() + 2.getInteger();

    This shows the problem with being stupid. If you can't distinguish between "object-oriented programming" and "one language's way of doing object-oriented programming" you're pretty much disqualified from further discussion. Now go sit in the corner.

    No, first get me another cup of coffee, then go sit in the corner.

  • (cs)

    Fuck off; that corner is mine. Piss off to the basement or something.

    Oh, and mine has milk, no sugar.

  • trtrwtf (unregistered) in reply to eViLegion
    eViLegion:
    Fuck off; that corner is mine. Piss off to the basement or something.

    Oh, and mine has milk, no sugar.

    No, the basement is where I'm building the robot, I don't want him fucking with that. Put him in the attic.

    And mine is cream and sugar, and don't forget the bourbon.

  • chris (unregistered) in reply to Singleton
    1. you could do Runtime runtime = Runtime.getRuntime(); because Runtime with a capital R is not the same thing as runtime

    2)Runtime is a singleton. Therefore you wouldn't new up a new runtime

  • jay (unregistered) in reply to Singleton
    Singleton:
    Runtime runny = Runtime.getRuntime();
    See, that line shows the problem with OOP. The developer wanted to have an object that represents the current runtime. So they call Runtime.getRuntime() and that returns the runtime, which is of type Runtime. You have to name your variables silly things like "my_thing" or "thingie" instead of "thing" because otherwise you'd get
    Runtime runtime = Runtime.getRuntime();

    In what way does Runtime.getRuntime() make sense? Do you enter a house to find the house? Why have a class that represents something of which there is only one instance (i.e. is not a class)? And why do you have to call a function to get it? Next thing you'll be calling

    int four = 2.getInteger() + 2.getInteger();

    I routinely write code like:

    Widget widget=new Widget();
    

    Sure, it sounds repetitious. But I'm not writing a poem: I'm writing a program. I don't care how it sounds: I want it to work and to be clear to the reader.

    As to the second part: A class is not an instance, so we are not "going into a house to find a house". Rather, we are thinking about the general idea of a house to find a specific house. I think it makes perfect sense to say, "Let's think of the general idea of houses. Now, within that idea, let's find a house that meets such-and-such condition." Like House.findHouseOwnedBy(person).

    I suppose you could make a case that Runtime.getRuntime is an imprecise name because it doesn't tell us what Runtime we're getting. Perhaps a better name would be Runtime.getCurrentRuntime. But so what? Read the docs and you'll know what it means.

    What's the logical fallacy in the idea of a class of which there is only one instance? In set theory, there's nothing absurd or even particularly special about a set with only one member. Even in common English, we have the phrase "in a class by itself", meaning something that is the only member of its class. If a class with 2, 3, 4, or 1000 members is legitimate, why not a class with only 1 member?

    The whole point of classes in OOP languages is that a class is a container for data and functions related to some logical entity. There is no reason why something that there is only one of would not have data and functions related to it. Like, in the context of a given system, there might be only one server. But that server might still have all sorts of data about it that we want to keep, like when it last booted, its network address, amount of free memory, etc. If we accepted some definition of "class" that says there must be more than one, then we'd have to make up some other kind of construct for the things of which there are only one, and they'd have to do many of the same things classes do. If it worked exactly the same but had a different name, why bother to have two names? If it accomplished the same purpose but worked differently, wouldn't that be a lot of extra complexity for no benefit?

  • Meep (unregistered) in reply to in_denial
    in_denial:
    Surely newHire.release()

    In modern Java,

    try(Hire bob = new Hire("bob")) { 
        bob.doWork();
    }

    But that assumes that the thing is a useful resource and not just a waste of space that will get cleaned up by garbage collection.

  • Meep (unregistered) in reply to jay
    jay:
    What's the logical fallacy in the idea of a class of which there is only one instance? In set theory, there's nothing absurd or even particularly special about a set with only one member. Even in common English, we have the phrase "in a class by itself", meaning something that is the only member of its class. If a class with 2, 3, 4, or 1000 members is legitimate, why not a class with only 1 member?

    Good rant.

    And however you may feel about OOP and singletons and whatnot, don't ever fucking write a goddamned fucking constructor that is only fucking called to initialize some goddamned static variables. Seriously, that shit makes no sense.

    (Got at least two motherfuckers who do that all through their code.)

  • Meep (unregistered) in reply to Singleton
    Singleton:
    Do you enter a house to find the house?

    I see you've never tried alcohol before.

  • trtrwtf (unregistered) in reply to Meep
    Meep:
    And however you may feel about OOP and singletons and whatnot, don't ever fucking write a goddamned fucking constructor that is only fucking called to initialize some goddamned static variables. Seriously, that shit makes no sense.

    You're right, you don't initialize static variables in a constructor. That would be stupid - why would you want to "initialize" something every time an instance is created? In Java you'd use a static initializer block.

    What does this have to do with anything? And where's my goddamn coffee?

    (can't get a good intern these days for love or money)

  • Mel (unregistered) in reply to Dim

    You'd like that think that would get through to people, wouldn't you. Sadly, I once worked with someone who had to be "asked to leave" after I had to revert two giant commits he did.

  • np (unregistered) in reply to trtrwtf
    trtrwtf:
    xaade:
    Doesn't give an excuse to be blind to memory usage.

    Once had a program look like it's leaking all over.

    Realized someone was keeping track of records in a map which items were never removed from.

    1 gig of memory later...

    Right - your job as the developer is to free up objects that you no longer need, not to tell the machine how to dispose of them.

    Fortunately, the implementation is free to ignore this call, at least in java:

    public static void gc() Runs the garbage collector. Calling this method suggests that the Java virtual machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the virtual machine has made its best effort to recycle all discarded object

    So in a sane implementation, this is like the "door close" button in the elevator: it's there so the impatient will have something to fiddle with, it doesn't actually do anything under normal circumstances.

    The "door close" button in the elevators in Japan work as intended. People don't want to wait 5 seconds to watch a door close when they know no one else is getting on or off. (If the person was wrong, there is a "door open" button that still works when the doors are closing).

  • C-Derb (unregistered) in reply to faoileag
    faoileag:
    Or, using the wonderful function from 2013-06-18th WTF:

    changeClass($newHire, $exEmployee);

    +10 I like what you did here.

  • (cs) in reply to Meep
    Meep:
    And however you may feel about OOP and singletons and whatnot, don't ever fucking write a goddamned fucking constructor that is only fucking called to initialize some goddamned static variables. Seriously, that shit makes no sense.
    Don't say “never”, say “hardly ever”; there are a few cases where you have to do such things (such as when you're trying to mediate between libraries with obstreperously different concepts of how to manage allocation). But if you do need it, feel dirty as it is definitely a horrible hack.
  • (cs) in reply to Mel
    Mel:
    You'd like that think that would get through to people, wouldn't you. Sadly, I once worked with someone who had to be "asked to leave" after I had to revert two giant commits he did.
    TRWTF is having to “revert” when you could just edit the repository history to make the commits go only on a branch (and hence not mess everyone else up).

    Oh, your SCM doesn't allow that?

  • bitti (unregistered)

    Can nobody see the WTF?

    Performance enhancements; reduced memory usage.

    I can see the WTF here. You should write your commit messages in present tense:

    Performance enhancements; reduce memory usage

    Also the period is superfluous in the summary line.

  • Herp (unregistered) in reply to Mel
    Mel:
    You'd like that think that would get through to people, wouldn't you. Sadly, I once worked with someone who had to be "asked to leave" after I had to revert two giant commits he did.

    TRWTF is no code reviews.

  • Darth Paul (unregistered) in reply to trtrwtf
    trtrwtf:
    No, first get me another cup of coffee, then go sit in the corner.

    Coffee is a mission critical component. I only let competent members of my team make mine.

  • A Nerd With a View (unregistered) in reply to ochrist

    it's newhire.job.delete();

    newhire.freeJob() just returns the number of employment openings. =)

  • A Nerd With a View (unregistered) in reply to Herp
    Herp:
    Mel:
    You'd like that think that would get through to people, wouldn't you. Sadly, I once worked with someone who had to be "asked to leave" after I had to revert two giant commits he did.

    TRWTF is no code reviews.

    Yeah, too many companies see that as a waste of time. Personally, I've always seen it as a great mentoring opportunity. I've learned a lot from my code reviews.

  • Simon (unregistered) in reply to trtrwtf
    trtrwtf:
    So in a sane implementation, this is like the "door close" button in the elevator: it's there so the impatient will have something to fiddle with, it doesn't actually do anything under normal circumstances.

    Yes, I was about to point that out myself - it's not a directive to force the JVM to run collection immediately, it's a suggestion that now would be an appropriate time (e.g because you've just released references to a large amount of memory). In a container environment (e.g a web server), there's a good chance it won't do anything.

  • Richard (unregistered)

    TRWTF functions called freeMemory() instead of getFreeMemory()

  • (cs) in reply to Aron
    Aron:
    TRWTF is that you can't do using(var bob = new Hire()) { bob.Dispose(); }

    If Hire was properly implemented you could....so this reflects back to a bug in the Hire implementation.

  • (cs) in reply to np
    np:
    trtrwtf:
    xaade:
    Doesn't give an excuse to be blind to memory usage.

    Once had a program look like it's leaking all over.

    Realized someone was keeping track of records in a map which items were never removed from.

    1 gig of memory later...

    Right - your job as the developer is to free up objects that you no longer need, not to tell the machine how to dispose of them.

    Fortunately, the implementation is free to ignore this call, at least in java:

    public static void gc() Runs the garbage collector. Calling this method suggests that the Java virtual machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the virtual machine has made its best effort to recycle all discarded object

    So in a sane implementation, this is like the "door close" button in the elevator: it's there so the impatient will have something to fiddle with, it doesn't actually do anything under normal circumstances.

    The "door close" button in the elevators in Japan work as intended. People don't want to wait 5 seconds to watch a door close when they know no one else is getting on or off. (If the person was wrong, there is a "door open" button that still works when the doors are closing).

    Damn Japanese. The stuff they keep for themselves works; the stuff they fob off on us is crap.

  • (cs) in reply to dkf
    dkf:
    Mel:
    You'd like that think that would get through to people, wouldn't you. Sadly, I once worked with someone who had to be "asked to leave" after I had to revert two giant commits he did.
    TRWTF is having to “revert” when you could just edit the repository history to make the commits go only on a branch (and hence not mess everyone else up).

    Oh, your SCM doesn't allow that?

    Some things don't belong in a branch, they belong in a dumpster.

  • (cs) in reply to bitti
    bitti:
    Can nobody see the WTF?
    Performance enhancements; reduced memory usage.
    I can see the WTF here. You should write your commit messages in present tense:
    Performance enhancements; reduce memory usage
    Also the period is superfluous in the summary line.
    Grammar Nazi fail: "reduce memory usage" is future tense. "reducing memory usage" is present tense.
  • Nanny Poo (unregistered)

    TRWTF: method names that are unclear about whether they represent an action or a piece of data. By Java conventions, shouldn't it be getFreeMemory()?

    Oh, and where's the babushka of type boxes, factories and decorators around it? This can't be correct Java.

  • Nanny Poo (unregistered) in reply to Some Damn Yank
    Some Damn Yank:
    Grammar Nazi fail: [...] "reducing memory usage" is present tense.
    Heil Grammar, it's a gerund!
  • Stefan (unregistered)

    I think he knew exactly what freeMemory does....

    That is, I think he understood that it doesn't freeMemory but just has a look at how much spare mem is available - 'cause everyone knows if the computer has peeked at the memory then it can more efficiently allocate it later...

  • Yuri (unregistered) in reply to tin
    tin:
    pjt33:
    I wonder what response the culprit gave to the question "How much performance improvement did you measure?"

    I don't need to measure things. I code by feel.

    Look how quickly it runs on my desktop. That's like 10x as fast as the production server's going.

  • hgd (unregistered) in reply to paullik
    paullik:
    Isn't new hires' code supposed to be peer reviewd before commiting it? They get to push whatever changes they want?

    I think the WTF here is at a higher level, altough a new hire that cannot read a paragraph of documentation is bad enough.

    Should probably be peer reviewed before DEPLOYMENT (and there's no suggestion that this was ever deployed, BTW) but with good version control it shouldn't matter how files look when they check in (provided I'm not on my own branch).

  • Frink (unregistered)

    I don't really understand why people think freeing memory is a performance enhancement - unless you're using way more memory than you've got. But even then, freeing some probably won't make the world a happier place performance-wise.

  • Obelix (unregistered) in reply to A Coward!
    A Coward!:
    Ever come across developers who throw everything into a singleton.

    "Garbage collection just doesn't work in Java. I dereferenced the cache but its still in memory."

    "Is it hanging off a singleton?"

    "I dereferenced it"

    "Did you clear the static instance?"

    "I dereferenced it."

    "The referenced to the singleton or the instance?"

    "But java should take care of it."

    Managed languages can do a lot of things but it can't cope with morons.

    Which is zigactly why we real experts use C.

  • Obelix (unregistered) in reply to A Coward!
    A Coward!:
    Ever come across developers who throw everything into a singleton.

    "Garbage collection just doesn't work in Java. I dereferenced the cache but its still in memory."

    "Is it hanging off a singleton?"

    "I dereferenced it"

    "Did you clear the static instance?"

    "I dereferenced it."

    "The referenced to the singleton or the instance?"

    "But java should take care of it."

    Managed languages can do a lot of things but it can't cope with morons.

    Which is zigactly why we real experts use C.

  • fq3 a5y (unregistered) in reply to Some Damn Yank
    Some Damn Yank:
    paullik:
    Isn't new hires' code supposed to be peer reviewd before commiting it? They get to push whatever changes they want?

    I think the WTF here is at a higher level, altough a new hire that cannot read a paragraph of documentation is bad enough.

    I'm guessing he discovered and used this "technique" at school, and brought this "experience" with him to his new job. So TRWTF is his professor(s) who let him get away with it in class.
    hoiw many of us actually read documentation? At some stage he's obviously come across freeMemory and has assumed (understandably given Java's naming convention which perhaps suggests it should be something like getFreeMemory or countFreeMemory) it free's memory. Yeah, I know RTFM when you're not sure about something - easy to say, but I'll lay a pretty big bet that most if not all people on this site have at some stage made assumptions about what stuff does without looking it up.

    Without searching, what would people expect the following German words to mean? Gift, Objektiv, Artist, Kriminale, gross, herb

    Assumption is the mother of all fuckups.

  • 4square and 3 (unregistered) in reply to jay
    jay:
    Singleton:
    Runtime runny = Runtime.getRuntime();
    See, that line shows the problem with OOP. The developer wanted to have an object that represents the current runtime. So they call Runtime.getRuntime() and that returns the runtime, which is of type Runtime. You have to name your variables silly things like "my_thing" or "thingie" instead of "thing" because otherwise you'd get
    Runtime runtime = Runtime.getRuntime();

    In what way does Runtime.getRuntime() make sense? Do you enter a house to find the house? Why have a class that represents something of which there is only one instance (i.e. is not a class)? And why do you have to call a function to get it? Next thing you'll be calling

    int four = 2.getInteger() + 2.getInteger();

    I routinely write code like:

    Widget widget=new Widget();
    

    Sure, it sounds repetitious. But I'm not writing a poem: I'm writing a program. I don't care how it sounds: I want it to work and to be clear to the reader.

    As to the second part: A class is not an instance, so we are not "going into a house to find a house". Rather, we are thinking about the general idea of a house to find a specific house. I think it makes perfect sense to say, "Let's think of the general idea of houses. Now, within that idea, let's find a house that meets such-and-such condition." Like House.findHouseOwnedBy(person).

    I suppose you could make a case that Runtime.getRuntime is an imprecise name because it doesn't tell us what Runtime we're getting. Perhaps a better name would be Runtime.getCurrentRuntime. But so what? Read the docs and you'll know what it means.

    What's the logical fallacy in the idea of a class of which there is only one instance? In set theory, there's nothing absurd or even particularly special about a set with only one member. Even in common English, we have the phrase "in a class by itself", meaning something that is the only member of its class. If a class with 2, 3, 4, or 1000 members is legitimate, why not a class with only 1 member?

    The whole point of classes in OOP languages is that a class is a container for data and functions related to some logical entity. There is no reason why something that there is only one of would not have data and functions related to it. Like, in the context of a given system, there might be only one server. But that server might still have all sorts of data about it that we want to keep, like when it last booted, its network address, amount of free memory, etc. If we accepted some definition of "class" that says there must be more than one, then we'd have to make up some other kind of construct for the things of which there are only one, and they'd have to do many of the same things classes do. If it worked exactly the same but had a different name, why bother to have two names? If it accomplished the same purpose but worked differently, wouldn't that be a lot of extra complexity for no benefit?

    [code] #define BUFFALO new

    Buffalo buffalo = BUFFALO Buffalo(); Buffalo.buffalowBuffalo().buffalowBuffaloBuffalo();

  • 4square and 3 (unregistered) in reply to 4square and 3
    4square and 3:
    jay:
    Singleton:
    Runtime runny = Runtime.getRuntime();
    See, that line shows the problem with OOP. The developer wanted to have an object that represents the current runtime. So they call Runtime.getRuntime() and that returns the runtime, which is of type Runtime. You have to name your variables silly things like "my_thing" or "thingie" instead of "thing" because otherwise you'd get
    Runtime runtime = Runtime.getRuntime();

    In what way does Runtime.getRuntime() make sense? Do you enter a house to find the house? Why have a class that represents something of which there is only one instance (i.e. is not a class)? And why do you have to call a function to get it? Next thing you'll be calling

    int four = 2.getInteger() + 2.getInteger();

    I routinely write code like:

    Widget widget=new Widget();
    

    Sure, it sounds repetitious. But I'm not writing a poem: I'm writing a program. I don't care how it sounds: I want it to work and to be clear to the reader.

    As to the second part: A class is not an instance, so we are not "going into a house to find a house". Rather, we are thinking about the general idea of a house to find a specific house. I think it makes perfect sense to say, "Let's think of the general idea of houses. Now, within that idea, let's find a house that meets such-and-such condition." Like House.findHouseOwnedBy(person).

    I suppose you could make a case that Runtime.getRuntime is an imprecise name because it doesn't tell us what Runtime we're getting. Perhaps a better name would be Runtime.getCurrentRuntime. But so what? Read the docs and you'll know what it means.

    What's the logical fallacy in the idea of a class of which there is only one instance? In set theory, there's nothing absurd or even particularly special about a set with only one member. Even in common English, we have the phrase "in a class by itself", meaning something that is the only member of its class. If a class with 2, 3, 4, or 1000 members is legitimate, why not a class with only 1 member?

    The whole point of classes in OOP languages is that a class is a container for data and functions related to some logical entity. There is no reason why something that there is only one of would not have data and functions related to it. Like, in the context of a given system, there might be only one server. But that server might still have all sorts of data about it that we want to keep, like when it last booted, its network address, amount of free memory, etc. If we accepted some definition of "class" that says there must be more than one, then we'd have to make up some other kind of construct for the things of which there are only one, and they'd have to do many of the same things classes do. If it worked exactly the same but had a different name, why bother to have two names? If it accomplished the same purpose but worked differently, wouldn't that be a lot of extra complexity for no benefit?

    #define BUFFALO new
    
    Buffalo buffalo = BUFFALO Buffalo();
    Buffalo.buffaloBuffalo().buffaloBuffaloBuffalo();
    EDIT: What me puit the w in for and mess up code tag?
  • hugo (unregistered) in reply to np
    np:
    trtrwtf:
    xaade:
    Doesn't give an excuse to be blind to memory usage.

    Once had a program look like it's leaking all over.

    Realized someone was keeping track of records in a map which items were never removed from.

    1 gig of memory later...

    Right - your job as the developer is to free up objects that you no longer need, not to tell the machine how to dispose of them.

    Fortunately, the implementation is free to ignore this call, at least in java:

    public static void gc() Runs the garbage collector. Calling this method suggests that the Java virtual machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the virtual machine has made its best effort to recycle all discarded object

    So in a sane implementation, this is like the "door close" button in the elevator: it's there so the impatient will have something to fiddle with, it doesn't actually do anything under normal circumstances.

    The "door close" button in the elevators in Japan work as intended. People don't want to wait 5 seconds to watch a door close when they know no one else is getting on or off. (If the person was wrong, there is a "door open" button that still works when the doors are closing).

    Same here....and when you hear footsteps approaching the elevator you slam the "door close" button furiously and if people see you you try to pretend you're hitting "door open" for them and it's not working....

  • Hong Kong (unregistered) in reply to trtrwtf
    trtrwtf:
    So in a sane implementation, this is like the "door close" button in the elevator: it's there so the impatient will have something to fiddle with, it doesn't actually do anything under normal circumstances.

    Java is a part of Indonesia.

    In some parts of the world, the "door close" button in the elevator actually does close the door, even on passenger elevators.

    Incredably annoying when you then go to country where the "Door Close" button is not connected to anything, and you can stand there punching it and nothing happens.

  • TimC (unregistered) in reply to Mike
    Ram is there to be used. The gc will free memory when it needs to or when the system is relatively quiet and it won't effect performance.

    And yet every piece of unportable bloated crap I end up running that causes my workstation to bog to a crawl turns out to be Java. For what should be a simple TK widget interfacing with the server. Just how does Java end up being so slow on modern hardware? Why is that? Could it be because the system isn't actually as smart as its authors thinks it is? Or does Sun/Oracle just want to sell more hardware to throw at the problem that should be fixed by a few hundred lines of TK? Or does Java just attract crap developers that are so abstracted from reality and who have no idea what the bare metal is doing underneath?

    Software was better back in the days when people had to care about memory allocations. Higher entry bars and all that.

  • TimC (unregistered) in reply to Some Damn Yank
    The "door close" button in the elevators in Japan work as intended. People don't want to wait 5 seconds to watch a door close when they know no one else is getting on or off. (If the person was wrong, there is a "door open" button that still works when the doors are closing).
    Damn Japanese. The stuff they keep for themselves works; the stuff they fob off on us is crap.

    WFM in .au too. But then again, you do have to know when pressing the button will make a difference - no use pressing it while the door is still opening, because the microcontroller is still busy opening the door and will ignore you.

    And in a building with 4 lifts, you have to know which one it is where the door close button actually acts as an emergency stop and open the door and get off at this floor button and the door open button acts as a door open button. It seems there's no configuration management in lift controllers.

    (actually, I'm most amused by our below ground floor lifts where despite the floor buttons not being counters or toggles, they've still implemented de-bounce circuits in analogue, and they've been slowly degrading over time so that now you sometimes have to hold the button down for 3 seconds before it will latch. And they've implemented a different buzzer for every individual button. And some of the LEDs are dimmed or don't work at all once latched (but do work when pressing the button). All this in lifts that are less than 10 years old. TRWTF is lifts that haven't been fully virtualised yet. Damn real world)

  • victor (unregistered) in reply to TimC
    TimC:
    Ram is there to be used. The gc will free memory when it needs to or when the system is relatively quiet and it won't effect performance.

    And yet every piece of unportable bloated crap I end up running that causes my workstation to bog to a crawl turns out to be Java. For what should be a simple TK widget interfacing with the server. Just how does Java end up being so slow on modern hardware? Why is that? Could it be because the system isn't actually as smart as its authors thinks it is? Or does Sun/Oracle just want to sell more hardware to throw at the problem that should be fixed by a few hundred lines of TK? Or does Java just attract crap developers that are so abstracted from reality and who have no idea what the bare metal is doing underneath?

    Software was better back in the days when people had to care about memory allocations. Higher entry bars and all that.

    And the same for C#.

    The problem (as so often is the case) is that these languages are often designed to guard against fuck ups. The problem is, that the harder you make something to fuck up, the more people will claim qualification in it simply because they haven't broken anything. Yes, Garbage Collection and automatic memory management is a very convenient thing, but that doesn't necessarily make it good.

    More people want to be programmers, and languages are evolving and being created to both simplify things sufficiently for everyone to live the dream and to guard against (accidental or otherwise) stupidity. The problem (as MS should have found out by now) is that when you build things for morons, you tend to turn people into morons.

    Make a language any moron can use, and any moron will use it and some just-above moron people will degrade to morons. Make a language the average person can use, and the avergae person will use it - and the people on the cusp of being average will either sink to average or rise to average. Make a language that requires understanding, and you'll attract mainly the people with the understanding (and some just-above average types who put the work in to learn).

    In an ideal world, we want to keep thinks complex when they have to be - to ensure that there's not too many monkeys about, right? Well, actually, no. When we become too specialised, we see that there are small numbers of awesome people trying to fill a market demand for large numbers. This is why we need languages that idiots can use - because whether we like it or not, there are simply not enough people floating around capable of understanding what is going on to sustain the world's demand.

  • PRMan (unregistered) in reply to xaade

    I had one where a guy was opening IE instance "WebBrowser" in a tight loop and then throwing them away.

    WebBrowser web = new WebBrowser(); // Not using this web = _browser;

    7 senior developers couldn't find the performance bug.

  • Mr. Mumbles (unregistered) in reply to ochrist

    Yeah but that only returned the number of new hires that were about to be fired. It didn't actually fire any one.

  • (cs)

    Doing something idiotic...and failing at it because you can't read the doc: Priceless!

  • Geoff (unregistered) in reply to fq3 a5y
    fq3 a5y:
    Some Damn Yank:
    paullik:
    Isn't new hires' code supposed to be peer reviewd before commiting it? They get to push whatever changes they want?

    I think the WTF here is at a higher level, altough a new hire that cannot read a paragraph of documentation is bad enough.

    I'm guessing he discovered and used this "technique" at school, and brought this "experience" with him to his new job. So TRWTF is his professor(s) who let him get away with it in class.
    hoiw many of us actually read documentation? At some stage he's obviously come across freeMemory and has assumed (understandably given Java's naming convention which perhaps suggests it should be something like getFreeMemory or countFreeMemory) it free's memory. Yeah, I know RTFM when you're not sure about something - easy to say, but I'll lay a pretty big bet that most if not all people on this site have at some stage made assumptions about what stuff does without looking it up.

    Without searching, what would people expect the following German words to mean? Gift, Objektiv, Artist, Kriminale, gross, herb

    Assumption is the mother of all fuckups.

    I remember years ago having to build a native version of TeX on a Solaris machine. Knuth's intro says to read the instructions carefully before starting, but hey, we're experts here!

    Get to about item 5 and Knuth says something like "see, I told you to read ALL the instructions first, in step 2 you overwrote a critical file that you need next". After swearing and starting again from scratch, you get to item 10 and the same thing happens AGAIN!

    I know damn well (well, I assume :-) he set it up that way on purpose, just to catch us out. But twice!? Evil man.

  • Geoff (unregistered) in reply to TimC
    TimC:
    Ram is there to be used. The gc will free memory when it needs to or when the system is relatively quiet and it won't effect performance.

    And yet every piece of unportable bloated crap I end up running that causes my workstation to bog to a crawl turns out to be Java. For what should be a simple TK widget interfacing with the server. Just how does Java end up being so slow on modern hardware? Why is that? Could it be because the system isn't actually as smart as its authors thinks it is? Or does Sun/Oracle just want to sell more hardware to throw at the problem that should be fixed by a few hundred lines of TK? Or does Java just attract crap developers that are so abstracted from reality and who have no idea what the bare metal is doing underneath?

    Software was better back in the days when people had to care about memory allocations. Higher entry bars and all that.

    Try instrumenting the stream classes (as I did recently), and see just how many streams Java opens (and leaves dangling) just to load classes dynamically from a jar file.

    Not to mention Jetty (way too many dangling streams), or even socket connections that create 4 streams for every opened connection, but don't explicitly close them when you explicitly call closeConnection()! ;-( Why bother having a close() method?

    This is actually a case where periodically/dynamically calling the garbage collector was the only way to help prevent web requests failing under load due to having too many open file handles.

  • Matteo (unregistered)
    long java.lang.Runtime.freeMemory()

    Returns the amount of free memory in the Java Virtual Machine . Calling the gc method may result in increasing the value returned by freeMemory.

    ...and this is probably because of an IDE's autocompletion. That's why, if I really ain't in a hurry, I like to program in something like GNU Emacs. It makes repetitive tasks easier with the appropriate functions, but at least before typing a function call I don't know about, I have to read the documentation.

    And before you go into the "Emacs isn't used in enterprise, every professional who knows his/her craft uses an IDE" tantrum, go take a tour of Google or Red Hat.

Leave a comment on “Running for Free Memory”

Log In or post as a guest

Replying to comment #:

« Return to Article