- 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
you can't peek and poke in basic anymore, but you can peek and poke in C and C++
& and * That's peekin and pokin, folks.
Except i don't know if you can peek arbitrary values (probably, though)
in basic you would peek stuff like coordinates on the screen or a certain place in ram to see if there was a printer installed. or a floppy drive.
If i remember correctly, writing binary files to disk required poking. it's been so long i forgotten so much about really oldschool basic (like on the atari, for instance) that it makes me glad that i also forgot assembler on the Apple IIgs. can't have one worthless skill floating around with none of the other ones.
Peeking would have been a lot more useful if you could have coded multithreaded applications... have a flag that is true if the thread is done, false if it isnt, have the main logic peek the flag's location to see its value, then you know if it is done or not. but alas, no multithreading.
Admin
Declare @foo as int
Select @foo = idfield from stuff where something = 'nothing'
... valid in SQL 2000 at least
Admin
Is that the same as Select @foo = idfield from stuff where TRUE ? or am i missing the assignment part? Maybe. i do, after all, suck.
Admin
Code smells are fun.....
Looks like the framework maker had an error they couldn't fight through properly, so they devised a "Clever" way to eat it.
I know "I" like my frameworks to out-and-out hide errors from me. :s
Admin
I think you're missing the assignment part there...
Select @foo = idfield is the assignment...
where something = 'nothing' is the test part
Admin
My favourite is APL, which uses = for equality, and a non-ASCII character that looks like a left-pointing arrow (much like <-) for assignment. Very easy to grok. Quite possibly the only thing in APL that's easy to grok...
Admin
Do me a favor and define "real exception handling"?
Because last time i checked
Try cacheobject = createobject("cacheobject.factory", "moo") cacheobject.open("connection information") catch ex as CacheException write("an exception occured, it was ") writeline(ex) end try
Is real exception handling.
Admin
In VB the meaning of = depends on context. In a statement context
is shorthand forIn an expression context
compares two values for equality.Admin
It's been a while, but I think Pascal does it best:
a = b means "is a equal to b?" a := b means "assign to a the value of b"
This keeps = meaning what we always learned it to be, and simply introduces a new syntax for assignment. That's kind of the opposite of how C,C#,Java,etc do it, yet to me it makes much more sense.
Admin
Here:
x + 2y = 72 Solve for x (equality)
x + 2y = 72; x = 14 Solve for y (assignment)
Admin
Hasn't this always been the case for pretty much all flavors of basic?
Admin
If it behaves like classic BASIC (you remember, the one with numbered lines?) then, if my memory serves (as it sometimes does), then the first case will result in x being equal to z, and the latter case will result in x being a boolean, depending on the relative values of y and z.
In classic BASIC, the latter case would often equal 0 for false and -1 for true, though there were a mind-numbing number of implementations, all different, requiring someone writing code to write not just with the hardware platform in mind, but also the BASIC implementation in mind.
I'm glad that's changed (yeah, right!)
Admin
Without looking at the other comments, I see:
I'm trying mightily to avoid adding "using Visual Basic" to that list.
Admin
Weird. If Java doesn't need GOTO, why does C# ?
Admin
I don't use any dialect of BASIC anymore, but I used VB1 (before they had source files in text) and VB2. Other dialects, including TRS-80 and AppleSoft, before that. And Dartmouth BASIC before that, starting in late 1971. Anyone else learn from "Basic BASIC"?
Admin
I tend to agree. Although the VB way is not bad either; you'd put assignments in their own statements in any case. Using multiple assignments in one statement potentially causes all kinds of order-of-execution problems. The real WTF is that C & co. allow it.
Admin
No, my point was that I was amazed that they seemed to be processing the exception as part of the standard code flow, and not logging and rolling back (as a normal person would). Using exceptions as part of typical program flow is A Bad Thing, and the fact that they are anticipating this error at all means they have serious problems in the database layer.
Admin
Admin
No, that's solving a system of equations. It'd be the same as x + 2y = 72; x + y = 43. As a math major and a software engineer, I've grokked both = as equality only and the C system. It's just syntax, people. On the other hand, APL uses non-ASCII characters? That's a real wtf.
Admin
What I mean, is that in algebra, arguably there is no such thing as assignment. (There are other reasonable interpretations with which I'm not going to quibble.)
In your example: x = 14 x + 2y = 72 There are no assignments. Two axioms are presented. "x is equal to 14" and "x + 2y is equal to 72". Two truth-statements involving equality, in other words. (Again, just my world-view. I'm not saying other views are wrong.)
If I'm going to argue that algebra does not have assignment, then I'm going to conclude that programming languages ought to introduce a new syntax for assignment. Lots of languages did, VB did not. C took the unfortunate choice, IMO, of introducing a new syntax for equality while using the algebraic syntax of equality for assignment.
I'm not saying C should have introduced a non-ASCII character the way APL did, but there were other choices, such as Pascal's := assignment statement.
Admin
I'm surprised that no one feels funny about the way the code determines the kind of exception that got thrown. (And what if the database changes its error message strings slightly between versions?)
Admin
One expects that kind of thing in C. Peeking and poking at various naughty bits is how stuff gets done down there.
VB is supposed to be a higher level language though, higher even than (say) Java, so I'm not surprised for it to be gone.
Admin
Or, much more simply "UPDATE table SET field=1 WHERE otherField=2
However, SQL has very clear seperation between where comparisons are used and where assignments are. Conditionals in code, not always.
Admin
Maybe with Unicode, the world at large is finally ready for languages with non-ASCII syntax.
a ? b; // assignment a = b; // comparison a ? b; // negative comparison a = b; // less than ... etc ...
EDIT: well, apparently the forum software isn't ready for them, so maybe not. :-(
Admin
No, in this respect, VB has it right, like most languages. The point is not that the token (i.e. terminal) '=' is used for both assignment & logical-equals. It the conditional block (i.e. non-terminal) within IF (conditional) THEN.
Very few languages have side-effects inside an IF..THEN conditional. It is bad compiler design to do so. The conditional could change values before the THEN or ELSE block is executed to unwanted states. This is a major defect in C/C++ & Java compiler definitions. Pascal's definition forbids this.
Pascal even requires a counting loop-variable to be unchanged by the DO block. It restricts student programmers to good (i.e. safe) practices.
FOR I := 1 TO 10 DO BEGIN I := I + 1; (* This is illegal! *) END
I write code in C, & accept that is a "low-level" language. It allows code that is "like assembly". I understand, and use the side-effect operations in for, if, & other control structures appropriately.
Programmer's should KNOW that C is not a typical language, and NOT base their idea of a general programming language on it.
Admin
Actually incorrect, you forgot the declarations above those lines. In both cases x = false. Try it out sometime.
Admin
In relation to the Rorschach test, the code looks like ASCII art from that old Star Trek game on BBSes.
In regards to VB.NET. Get off it people. I grew up on C++, programmed in machine-code, assmebly, etc. Even used ADA once (Don't get me started on the WTFs of that language), and I can honestly say that VB.NET is NOT a WTF. Perhaps if you didn't have an aut-completing IDE I would agree with the verbosity being a small WTF, but with VS 2005, it takes imperceptably longer to write anything in VB.NET over C# and is SIGNIFICANTLY easier to maintain (More readable at a glance).
Additionally, the == crap in C++/C#/C/Java always drove me nuts. The fact that a good code practice in C++ was to always put the constant first when doing equality checks is a HUGE WTF. Throws a compiler error that way instead of causing a subtle bug from missing the second equals. Anyone who's written more then 1000 lines of C++ has had this happen ATLEAST once.
And yes, I still concider C++ my primary language, though I use VB.NET daily these days.
Captch: atari - Man I miss mine. THAT was a fun system.
Admin
Yes, except that it's misleading to describe "=" as an overloaded operator.
Basic has always clearly differentiated between assignment statements and equality expressions. There is a major difference between Basic and C-like languages here: C, and its friends, allow expressions to be statements. (In fact, most lines of C code are expressions, making the generation of terrifically obfuscated code possible.) A line of code in C like "i++;" or "x = 2;" is an expression with side effects. Basic's expressions don't have side effects, and an expression by itself is invalid syntax.
The equal sign only does assignment in a very limited context: the assignment statement, of the form "x = foo". In old-school Basic, this would have been "LET x = foo" to make it clear that this was a LET statement, not just some weird floating expression. The LET keyword was soon made optional, since it was unnecessary; "x = 2" always means "LET x = 2" and can never means anything else.
The statement-vs-expression difference can also be seen in, for example, the fact that QuickBASIC implements both SUBs and FUNCTIONs. A SUB is used as a statement, and does not return a value. A FUNCTION is used as part of an expression, and always returns a value. The syntax used makes this difference clear, as well.
Other languages have been influencing BASIC for a number of years now, with the result that a lot of newer language constructs make sense from, say, a C++ programmer's perspective, but are actually at odds with the traditional approach that BASIC has taken. I think this is a bad thing -- a language with an identity crisis is a lot easier to write seriously bad code in.
Admin
Agreed - sometimes you don't need to pull out the big guns. If your client just needs his Excel spreadsheet to talk to his Access database, VB makes a lot more sense from a lot of perspectives (not the least of which is that they can't see a difference - it's just a better spreadsheet).
Admin
Except Java. In Java goto is a reserved word, with no implementation.
Admin
I think this was introduced in VB5. It actually comes in handy when you have optional parameters and you want to leave some of them at their default values.
But it causes major confusion sometimes, when the function's parameter happens to have a name similar to the calling routine's variable.
Every language lets you shoot yourself in the foot. VB just comes with instructions.
Admin
Admin
10 PRINT "TOO MANY GODDAM PUPPIES!!!" 20 GOTO 10
Admin
First, allowing side effects in conditionals is not bad compiler design. If the language allows for it, your compiler must, too. Otherwise you've designed your compiler very badly indeed. Whether it is bad language design is debatable. While it can lead to unexpected states, so can lazy evaluation, short-circuit logic, dynamic typing, and about a thousand other concepts. It's what you do with them that determines whether they are good or bad. And why shouldn't C be used as a basis for comparison of general programming languages? It's basic structure is in use in some of the most popular programming languages in the world. Why not use the most common thing as a baseline?
Admin
No.
Before you set down the rules under which we can bash VB, you must do the following:
Prove that VB is a language worth using, at all, for anything; and
Eat a can of pork brains, cold.
Admin
While I typically don't use VB for anything critical, sometimes it's just the best tool for the job. Sometimes, however, it's not, and a language like C, C++, Perl, PHP, Python, Ruby, Java, *Script, AWK, sed, *nix shell, Windows batch, ... is more fitting to help solve the problem.
Newsflash, kids: Programming languages are problem-solving tools. They're not (or shouldn't be) marks of how 1337 you are or how M4D your 5K1LLZ are. A real programmer is able to adapt to their environment without too much effort.
True, X language may be able to do ABC a little better than Y language, but Y language may be better at DEF than X language. However, in the end, you should be prepared to completely abandon any given language, even if it is your favorite language to use.
Admin
No.
And If I had to do that on a turing machine tape, or a neural network memory, or on raw machine code, I'd be unable to do write good code either. Guess that makes me a bad programmer...
Admin
And there you have it .. a typical "vb-basher". Need I say more?
Admin
Maybe .. or, you don't know VB very well. Could be one or the other, for your sake I really hope it's the latter ... to claim that you cannot write any decent code in VB if you actually know how to use the language isn't really something I'd be proud of. It's actually quite easy, you know. Try it some time, and then criticize. (Though I do recommend VB.NET, definitely not VB<=6).
Admin
No it wouldn't. I cann't even imagine what makes you think that it would.
Admin
goto is a reserved word in Java, but not implemented.
I bet the original implementation probably had the compiler delete the offending source file immediately, but they couldn't get it past QA.
Here is a snippet from the bug report:
Responsibility: javac compiler team Priority: infinity Overview: I was trying to write a "master" test case that looped through some other test cases, and it keeps deleting the master.java file instead of compiling it.
Admin
Declare @A int Declare @B int
Select @A = Count(*) From Cars
If @A = 0 Set @B = 100 Else Set @B = 50
Admin
Yes I can, I have, I still do on occasion. And you are correct in your assessment, those that answer no just don't have sufficient experience with the language to do so, therefore are not qualified to bash it.
If this question were asked about C++ a few years back I would have had to say Maybe. These days, moving to C# I think is actually helping my understanding of C++. It also is proving that these days, who cares if it is VB.Net or C#, it all compiles to the same IL code so it is the same language, different syntax.
And for the poster that mentioned that VB just gives you instructions on how to shoot yourself in the foot, well I would much rather it be that way, don't want my neighbor misunderstanding the concept and shooting himself in MY foot.
Admin
Correct, The catch block would execute then fall out, of the try block. Following that you would get to the Next and continue executing the For loop. It would only completely exit the For loop if he was to throw the exception again.
Admin
True... I suspect more languages use = for comparison and assignment than use different operators.
In other words "I'm not familiar with that" != "screwed up"
Admin
x=y=z Most of the flavours of BASIC I have used would have treated the second = as an assignment. I thought BBC basic allowed the several assignments but I just tried it on a BBC emulator and it also made x=0 (false) becuase y<>z (!= for the C amongst you) Maybe one day I will try it on a real BBC B (I have one upstairs, anyone know where I can get a monitor?)
BASIC bashing time Yes, I could write a large system in VB .NET and have it maintainable. In fact we are in the first 6 months of such a system. I primarily use VB .NET and have used flavours of BASIC all my (programming) life. The only thing I have against BASIC is that GOTO should just not exist. I grew out of using it in high school, and believe me, I still managed to write some pretty nasty code! I also used to use STOS on an Atari ST, no procedures, AT ALL, only GOTO and GOSUB, and...
ON x GOSUB
You all remember that? Please tell me that no longer exists in any modern language.
VB .NET has improved greatly on the WTF's of its ancestors. We now have NO reason to use GOTO, even if it is still there. Line has a sane syntax, Try...Catch has arrived, we even have Using. Hey C# lot, you complain about VB using = for 2 different meanings, what about Using? I think VB .NET is a really cool language but maybe thats just becuase I am comfortable with it.
Admin
Admin
Rule #1 of the l33t hax0r: if it's different from what I'm used to, the language was designed wrong!
Admin
In other words, the converse is not true. Not everyone who "blames his tools" is "a poor workman".
If good workmen found it needful and proper to accept any quality of tool without comment, we would all still be biting sticks to make them pointy.
And coding everything in Visual Basic.
-Harrow.
Admin
And, lest we forget, it's not that VB([1-6]|.NET|Script|A)? is a WTF in and of itself, it's the little quirks that make life so much fun that are, such as Stop being a reserved word in VBScript but it doesn't do anything unless you're using it in a [CW]Script context, Escape not being mentioned whatsoever in any VBScript docs ever, but does the same as J(ava)Script's escape(), something set to vbUseDefault is also True (even though the internal value is -2 as against -1 [another WTF there]) or more properly Not(False) so you have to explicitly check instead of just a If variable Then, etc., etc...