• Omniscient (unregistered) in reply to onitake
    onitake:
    And the real WTF is, of course, the Option Explicit! VB6 is such a clean language, why do we need to bother with the pesky details of strong typing all of a sudden?
    Because otherwise you could get values of 32769, or even beyond, getting into variables that are meant to be Integers!
  • (cs) in reply to John Doe
    John Doe:
    Also I missed the number "50". Got to understand there are hundreds of page faults occuring every second. This number 50

    On the machine I am using right now I launched firefox a few hours ago and it has had over 1.3 million page faults. Time to switch browsers I guess....

    Also memory manager in windows is lazy so first time many things are access a page fault occurs. Things like memory mapped files (loading of any dll or exe into memory) will page fault like crazy until they are loaded.

    Any sane demand-paging OS does that. There is only one page in an executable module (DLL, EXE, .so, whatever) that is guaranteed to need to be paged in: the page that contains the initial entry point of the module. All other pages might be never referenced, so why waste time explicitly loading something that isn't in the working set, and might never be in the working set? And the module is 'loaded' as soon as the mapping of 'this page in the address space corresponds to this page in the executable file' has been established. Even on the sainted Linux, OK?

    Further twiddle on the working set debate: the Windows NT line actually has three kinds of page fault: soft, hard, and invalid. Invalid page faults are easy, you touched a place in your address space where there isn't supposed to be a page, and these are probably what the article was referring to. Hard page faults aren't so difficult to understand - the page is not in physical memory, but is a real page, so the OS goes out to bring it in as soon as you touch it.

    Soft page faults are interesting. The page is in physical memory, but isn't marked as present in your address space. Why might that be? Imagine: another program has caused a page-in event, and to make room, the OS decides to page out one of your writable (and written-to) pages. Because the page is "dirty" (modified since last load) it is queued for writing to disk, while being marked as "out" in your page table. While the page is in the queue (along with dozens of others, presumably), you touch it. A page fault happens, and the OS removes the page from the page-out queue, marks it as being present in your page table, and lets you proceed. Without the page fault, the OS would not be able to remove the page from the page-out queue.

    There are also cases like an executable page in a DLL loaded by another process that you load. Sure, the OS could spend time copying in/out state from the other process to yours, but it could also do lazy loading and allow you to trigger soft faults against the pages that are used in both processes. Also, for various reasons, the DLL might need to be loaded in a different place in your process, and this will cause endless hilarity due to relocations being different in the two processes, but pages affected by that are arguably not soft-faultable. Whatever...

  • Anonanon (unregistered) in reply to Robert B.
    Robert B.:
    ... If the thing were written in Java, it would probably be as fast or faster than the similar C program ...
    I can't believe you said that. Go wash your mouth out.
  • retard fixer (unregistered) in reply to Gibbon1
    Gibbon1:
    PG4:
    Spivonious:
    Can VB6 even get page faults? It's a managed runtime.

    It's so cute went application devs, and the OP/editor, try to talk about OS basics they nothing about.

    Page faults happen all the time, code asks for memory that isn't there because it's be swapped out, interrupt occurs, process suspended until the OS gets around to swapping it back in, then the offending instruction is retarded.

    Now a double page fault. But that's not an app developers problem.

    FTFY

  • Bob (unregistered) in reply to John Doe
    John Doe:
    The comment about the page faults is retarded.
    Are you people so sick that you don't realize that there are people hurting as they deal with this sorrowful condition? Please stop using this hateful, offensive word.

    This is not a joke. Askimet, you racist bastard.

  • TheJonB (unregistered) in reply to Matt Westwood
    Matt Westwood:
    And another one: the indenting is 3 spaces, when standard programming style is 4 as everybody knows.

    2 spaces!!!

    Will you people stop pissing horizontal space away!

  • Geoffrey T. Buchanan (unregistered)

    Goodness, what the youth of today waste their time on! Inventing problems and over-engineering unnecessary solutions and even wasting time arguing about GOTO statements and page faults! You couldn't make it up.

    Back in the day we would solve this sort of problem in 30 seconds by tasking one of our secretaries to clear out the network drives manually each morning, thus allowing us to continue with our more important COBOL development.

    If you really need to clear the files as frequently as once every 60 seconds (!) as the script suggests then I suggest you are doing something wrong. You shouldn't be writing the files in the first place if you so urgently need to delete them.

  • Rick (unregistered)

    It be interesting to know what happens to objFSO after every call to GetFolder() ... Does it allocate more space?

    Set objKillFolder = objFSO.GetFolder(strKillFileLoc)

  • Math Ninja (unregistered)

    Here are some WTFs that haven't been mentioned:

    What happens if I start two instances in different locations with two different Lemming.ini(s)? Shit is gonna get fucked up. Blame the shitty requirement(s?) if you want but first rule of programming, End Users Are Stupid.

    Why isn't there any logging? Even as an internal application, it should at least log starting and terminating.

    Why isn't the sleep duration part of the INI file? That's what they are for, ya know, initialization, configuration, settings. The precursor to XML config files.

  • Henry (unregistered) in reply to Rick

    It be interesting to know what happens to objFSO after every call to GetFolder()

    VB6 (well, COM in general) is reference-counted. On each call to GetFolder(), the previous folder object is dereferenced and thus deallocated. I'm not sure what you think might happen to objFSO, but there's no obvious memory leak or anything here.

  • mh (unregistered) in reply to johnckirk

    I see, thanks for correcting me. Actually, when I checked half a year ago, Microsoft web said it will not work on Windows 8, good to know they changed their mind.

  • Jay (unregistered) in reply to Robert B.
    Robert B.:
    1. GoTo's are not inherently bad on their own. Modern constructs merely mask the use of them a lot of the time. Furthermore, in VB1-6, that was the standard way of performing error handling as VB6 did not have try/catch/finally. You either do On Error GoTo (|GoSub) or there was no error handler in that function.

    Not quite. VB has On Error Resume Next, meaning it simply continues onto the next line - which is where you put your error handling. eg:

    On Error Resume Next Open "file"...... If Err Then "MsgBox" FileNotFound etc...

    Much neater than the old GoTo handler crap.

    On Error Resume Next is a favourite a poor coders as you can use it to suppress all errors. Awesome, code that never fails!

    As for the WTF, meh. Could have been a VBScript that executed once, kicked off by the scheduler every so often, but yeah, meh.

  • Jay (unregistered) in reply to Bob
    Bob:
    Please stop using this hateful, offensive word.

    Go to hell. I retarded my carburettor yesterday, and shall continue to do so in the future.

  • Oi de La RocheFoucauld (unregistered) in reply to wllmsaccnt

    I'm rusty, but I'm pretty sure that code wasn't written to run as a service. I suspect this is why he put that word in quotes. Proper services shut down in ways prescribed by the service shutdown code - this program has no terminate condition at all.

    It's possible that he confused the term page fault with segmentation fault - someone mentioned earlier that VB is a managed environment and while that's true of later versions, I think VB6 was pre dotnet. I don't remember VB being particularly segfault-prone, but then I never used VB very much beyond writing a simple media player in VB4, enthusing at how quickly one could prototype code, and then going back to C++ because I needed the better lower-level access for the kind of code I wrote. I also tended to program defensively - I've always liked code that doesn't fail - so I've typically avoided API Terra Incognito. This code isn't doing that. Terminating it involves removing a file to which it expects access. We're not seeing the whole picture here, but this corner of it isn't very pretty.

  • (cs) in reply to Severity One
    Severity One:
    I decided to make it into a headless application.

    That poor puppy ... shudder

  • Tud (unregistered) in reply to Steve The Cynic
    Steve The Cynic:
    Tud:
    VB6 hater:
    Wow, so much hate for the author...there must be a lot of VB6 enthusiasts reading today.

    Would you mind enlightening us by explaining where the WTF is? No one has done that yet.

    There, I can't edit so I'll just double post. Who the hell invented that "Reply to" shit anyway? Either make the "In reply to" more useful(tooltips would be fine) or just remove the "Reply" button and let people use the "quote" (they can always delete the quote anyway).

    You can't edit because you haven't registered.
    . .. . .. . Yes. I know. ... . .. . So what?

  • ni (unregistered) in reply to Bob

    strewth dude ... it's a bit tardy to be saying that in this forum

  • GA2K (unregistered) in reply to Jay
    Jay:
    Bob:
    Please stop using this hateful, offensive word.

    Go to hell. I retarded my carburettor yesterday, and shall continue to do so in the future.

    I think you meant to say you retarded your ignition timing.

  • Shinobu (unregistered)

    Just looked at the Windows services running on my computer. About 10k per process, which is not unexpected given what a page fault is. Something tells me that people were just being judgemental and that someone needed an excuse. Instead of doing what they should have been doing (pointing out problems in the code) they probably just wasted his time with pointless nerdy anti-VB rants. The thing about programmers that has annoyed me the most is that so many seem to be religious zealots. Some don't want to talk to you for the text editor you use; others fight tooth and nail against the (sorely needed because of type safety issues) introduction of C++ in an existing C code base because they don't want ‘the OOP that will just complicate everything’ and still others rant against VB or Java when they have no experience with those themselves.

  • LOADING (unregistered) in reply to Knaģis
    Knaģis:
    The code is not something one would be very proud of but where is the WTF?

    Also the author does not seem to know what a page fault is: http://en.wikipedia.org/wiki/Page_fault.

    It has been many years since I have touched VB6 but page faults sounds familiar. One thing that I am sure about is that I remember VB stability not being the greatest, but nothing was stable on win9x.

  • LOADED (unregistered) in reply to LOADING
    LOADING:
    Knaģis:
    The code is not something one would be very proud of but where is the WTF?

    Also the author does not seem to know what a page fault is: http://en.wikipedia.org/wiki/Page_fault.

    It has been many years since I have touched VB6 but page faults sounds familiar. One thing that I am sure about is that I remember VB stability not being the greatest, but nothing was stable on win9x.

    This is what we're talking about: http://www.fixerror.net/wp-content/uploads/2009/04/kernel32-error2.png

  • LOADED (unregistered) in reply to Brødreskift
    Brødreskift:
    First, captcha: transverbero Means transfix. I'm wondering what they meant by page fault, lol. Did they have really really slow disks, like page faults were handled by an old librarian finding the right pages in the book on some shelf in the basement? (Maybe they meant segfault, lol)

    They meant invalid page fault but as that's usually the only one you care about it gets shortened to page fault.

  • Shinobu (unregistered)

    So their server was running 9x huh? And these people were complaining about VB6?

  • Cbuttius (unregistered)

    So to stop a loop where blnLoopEternal is False and is tested on being true, you create a state of FileNotFound...

  • Cbuttius (unregistered) in reply to Tud

    [quote user="Tud"][quote user="Steve The CynicYou can't edit because you haven't registered.[/quote] . Yes. I know. . So what?[/quote]

    In order to have edit rights they would need to identify you as the original poster. If you post anonymously, you cannot be identified as such.

    By the way I have registered myself as Cbuttius, I just can't be butted to log in.

  • SuperDre (unregistered) in reply to mh
    mh:
    VB6 is 14 years old, no longer supported, gets no security updates, and VB6 applications will not work on Windows 8. That, in addition to VB6 being a crappy language that encourages programmers to write dangerous and/or unmaintainable code. Like "on error resume next".

    VB6 runs perfectly on Windows 8 (desktopversion, not on ARM, but any .NET application that is out there now won't run either on ARM). VB6 isn't a crappy language that encourages programmers to write dangerous and/or unmaintainable code, ANY language can do that, it's just as easy to write fubar code in C#, it's all up to the developer.. And yes, the error handling is a bit harder, but if done right you can get exactly the same as with any other language, again, it's just up to the developer.. If you really think otherwise, then you really are a dumb developer.. Personally I like the original VB6 language, it's much cleaner to read compared to C# (or any language with all their brackets), BUT yes it lacks a lot of newer programming paradigms, and I still hate MS for dumping VB7 and going with VB.net (yes there is actually a VB7 which is real OOP and has try/catch, but MS never released/finished it, because they went for the .NET framework). You can do about anything you want with VB6 if you take the time to understand the underlaying workings, hell there has been people who have even created inline assembly possibilities.. Saying VB6 is slow, means you just don't know how to handle it, as I said If you know how it works/does things you can speed up a lot, but that's something that goes for ANY language..

    And in regard to the posted code, I also don't see any real problems, especially since we didn't see any of the implementation of the used functions.. Would I do it like this in VB6? I don't think so.. would I use VB6 for something like this? Why not (if I know the VB6 runtimes are available on the server anyway), if it gets the job done..

  • Anon (unregistered)

    I think this post was a fail at a WTF itself, as the mistakes in its description presents more lack of knowledge than the script itself.

Leave a comment on “The Lemming Switch”

Log In or post as a guest

Replying to comment #:

« Return to Article