- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Lets you do cool things like
Let x=(3 AND item$="hat")+(5 AND item$="shoe")
Where and is bitwise.
Rich
Admin
"Visual Basic (at least since version 4, and before the .Net stuff) is built on COM. And it just so happens that in COM, true is defined as -1. Go check the PSDK headers if you want: VARIANT_TRUE is -1 and VARIANT_FALSE is 0. This is the definition VB uses."
I think you'll find that COM's definition was chosen to be compatible with even earlier versions of VB. In many ways, using "all 1 bits" is rather more consistent than "using one 1 bits". In any case, I think you'll find that C introduced the world to the idea that any non-zero value is true. (The C language has boolean expressions, but no boolean type. What's that all about?)
(BTW, I speak as someone who likes C and dislikes VB. I'm just not religious about it.)
Admin
I think that they should review their code and choose one way of setting TRUE value to avoid problems. Using VB and VB.NET conventions at the same time is asking for trouble.
Captcha: quake... Who wants to play? :)
Admin
Displaying 100Ks of records to a client application without filtering what is actually needed is a WTF born of laziness.
A human can't process that much data, so it's best to let the database server do what it is meant for - get only the data you need and return that (smaller) data set to the client.
If you need different data, then just query the thing again. If you use well-written SQL, that's not a problem. The problem happens when developers who don't truly understand databases start writing SQL and thinking it's better for the application to do data filtering and sorting, rather than the database server.
That's what the database server is for. Use it wisely - don't treat it like a file, like most developers do...
Admin
In this case, it is much, much easier to map logical representation on to physical representation. Thus, 0xFFFF.... == ~0x0000.... Why twat around with arbitrary bit selections when your cpu instruction set is explicitly designed for this sort of thing?
The result of a needless division between the logical and the physical, IMHO, is confusion and silliness:
Please note that I am suggesting that VB is silly here, not that KattMan is. (I'm very taken with the idea of "nothingness in the purest sense of the word.")It's a little disingenuous to point out that "these values are not equivalent to each other." I mean, that's the whole point, isn't it? If they were equivalent, you'd only need one (plus, of course, FILE_NOT_FOUND).
In the real world (ie the application domain, not the programming domain), who the hell needs to hold all four separate concepts in their head? When does one apply? When does another? The difference between "Nothing" and "Null" is particularly non-intuitive. Throwing in a function, IsEmpty(), is not helpful. This is a crass and objectionable language design.
(It should be noted that Perl, for example, suffers from similar problems. You don't have to hate an entire language. You can pick and choose, by feature.)
Anyway, to follow KattMan's logic, why would a programmer in a high-level language be overly concerned by the exact physical representation of a boolean? (Provided it works correctly. Which in VB, without excruciating care, it seems that it does not.)
Admin
What's the boolean value of MAYBE in VB?
Not that I'd really want to know. Just curious.
Admin
Actually, it is VB's fault.
You are aware that VB existed prior to verion 4, aren't you?
You are aware that VB started as a 16-bit language, aren't you?
You are aware that VB actually predates COM, aren't you?
You are aware that COM's design was, to a large extent, a reaction to the VBX (Visual Basic Extensions) components (which didn't work very well any more when you shifted fom 16-bit VB to 32-bit VB).
COM's True value is a result of VB. Not the other way round. Oh, and that silly 16-bit integer size in VB5? Yep, due to the way that VB started out as a 16-bit language.
Admin
Actually I totally agree with this one. In higher level languages we are usually only concerned if a value has been initialized or not and if that value is null or not. This could drop us to Is Nothing and Is Null without any other concern.
As far as VB Booleans not working correctly, well they work correctly within VB. Please not that earlier I mentioned that my Booleans were pure bi-valued booleans and nothing more, I also kept them contained within VB. Anything that needed to communicate outside of VB had these values converted to 0 = False and 1 = True. So perhaps I protected myself from any strange behavior with intercommunications with other processes.
Admin
You sir, are an idiot.
Admin
However, and at the risk of hammering this one into the ground, not every VB programmer is as careful about encapsulation as you are -- which accounts for a large proportion of VB WTFs on this site. I contend that VB on its own (16 bit, 32 bit, 43.5 bit, VB5, VB4--, whatever) is a language ill-suited to good programming style.
VB.Net, on the other hand, may well be a significant improvement in this respect. Unfortunately, as far as I'm concerned, it loses in so many other respects that it really isn't an adequate step forward.
Admin
I knew about the 16-bit Integer though, and am very glad they changed that for VB.NET.
I started my programming life in GW-BASIC, and still have a bit of a soft spot for, regardless of the prejudices associated with the language. Although I can write numerous other languages including Java and C# and can argue the finer points of ISO standard C++, I still like VB. For ASP.NET and Windows Forms development, it remains my preferred language (mainly because of the WithEvents syntax). Yes, I know you can write terrible code in VB (I can't look at code I wrote a decade ago without cringing (in my defense, I was 15)). But everybody's gotta start somewhere.
If that makes me less "cool" or whatever in the eyes of some, so be it.
Admin
It gets better: In VBScript (at least, maybe also VBA) Nothing is an assigned value, just like Null. Simply declaring a variable lets IsEmpty() return True (or -1 if you prefer), but it Is Not Nothing at that time. Dereferencing an object (like a class or COM object) by using Set obj = Nothing is the only way to get a variable reporting its Nothingness correctly.
Admin
Using "Boolean" columns in SQL tables is like a code smell. It wouldn't surprise me if there were also an IsRegistered and an IsCanceled column. Might be better to come up with an encoding scheme and use a status code column.