- 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
So? It's just doing (only) what you told it to, and it's immediately apparent that you're getting 0 because you didn't explicitly return anything. Implicitly, automatically returning the result of any last instruction is anything but intuitive.
The beauty of a language that lets you "shoot yourself in the foot" is that it also actually shoots real bullets, making it just as much the shortest path to well-written code and solid functional design as to WTF material. Alternatively, just look at the multiple context-specific design patterns and gymnastic contortions one must undergo in strongly typed languages just to make interface calls mapping to dynamically initialized implementation. In a language like Perl or PHP, there would be no elegant architecture and only a handful of the most simplistic patterns ever used because you would just DO it--no coaxing or sleight of hand required. And yet the foe we are supposedly fighting with restrictions built into languages themselves shows no sign of weakness--bad programmers just learn the same limitation-overcoming contortions to write bad code as we learn to write good code.
Speaking more generally, yes, a poor craftsman blames his tools. But the implication by that statement is that a good craftsman does better with the same tools. In reality, poor craftsmen often actually have bad tools because they cannot afford better with the prices they can charge. Good craftsman have better tools and their output benefits from that as well as from skill. What's more, both craftsman will limit their own quality of work to find a practical balance between quality and productivity, which means the "bad" craftsman may very well be most limited by his tools. You may be able to produce anything with an auger and a hand saw, but just try making an equitable profit building cabinets that way.
In programming there is no equivalent situation except that programmers in junior or otherwise subjugated positions often cannot choose their own tools at all. The only time a programmer should be faulted for blaming his tools (without actually being able to review his output) is when said programmer chose the very tools he blames. After all, even good tools can be a bad fit, and only people doing the actual work are truly qualified to recognize when this is the case.
Admin
Not necessarily an "ugh" if you, say, want to work with multiple versions of Excel via the Office Automation API, taking advantage of later version features when available. (More about late binding than weak typing, but they're tightly-coupled features). I wouldn't want to write an entire application in VB.NET, but it can be useful for writing libraries that you can compile into a C# application through the magic of CLR interoperability.
VB.NET certainly isn't the only language to support weak typing (LISP, anyone? Python?). I personally think the benefits of strong typing generally outweigh the benefits of weak typing -- but only generally, not 100% of the time. So, while there are plenty of reasons to criticize VB.NET, I'd say this isn't one of them.
Admin
I'm spamming because I have tried several times to post a proper answer and your stupid spam bot keeps rejecting it no matter what I do, without telling me WHY it thinks it's spam..
Funny if doesn't detect real spam.
So SPAM off.
Admin
That's a pretty lame example. What's the special awesome functionality here? Why isn't there a return statement in the property?
Admin
[quote user="Bremer"][quote user="Spivonious"] [...] and if you ask me, verbosity is much easier to read then stupid nipple brackets.[/quote] Now I don't use VB, but I do use PL/SQL, which has a verbose syntax that has been devised and implemented with the amount of thought that you would expect from Oracle.
Quite frankly, I prefer the relatively sparse syntax that Java offers me. But it's a personal preference, of course.
Admin
Using () as an alternative to [] is something you can do in C++ too and has the advantage of allowing multiple parameters, thus you can write something like this
see C++ FAQ
Admin
Admin
Now this is the WTF here:
I was able to post what I originally wanted by first posting something, then editing my post to what I really wanted.
Which is the above post about Matrix and overloading the brackets.
Admin
I think this example will give them a more personal experience of the pain:
100 LET I = 0 200 GO TO 700 300 IF I <> 51 GO TO 500 400 GO TO 900 500 PRINT "HELLO WORLD" 600 GO TO 200 700 LET I = I + 1 800 GO TO 300 900 END
(Also known as the, "Validate this!" WTF.)
(The astute reader might think the goto at 600 should jump directly to 700, or even be omitted entirely. The astute reader would be wrong: Obviously 200 is the top of the loop; and the increment must follow the loop; and the test must be before the loop. We must be structured! And, yes, I have seen code that bad.)
Admin
I think you should curb your enthusiasm for VB.
Admin
Crappy developers are everywhere, with VB or without. They use every language, every database, every OS, and work in every type of business of every size. This site only publishes stories about a tiny percentage of these developers.
If you want to bash on VB, I'm all for it, but let's not try to compare languages by comparing how many "crap devs" we think use them.
Admin
Happy birthday, by the way.
Admin
I think the truth of the matter is that for those of us who have been around since early VB days, we liked the language until about VB6. That is because VB6 purported to be an oop language without actually being oop. There were "Classes" and (especially the WebClass) that seemed like VB was just being screwed with. Prior to VB6, at least for me, all VB apps were data-centric. After VB6, people starting looking to them to do more advanced stuff. Then you got this influx of horrible "coders" who had just designed their umpteenth webpage using Frontpage and ASP. They figured that with the bottom falling out of the DotCom boom, they'd better market themselves out of that sphere. So they started writing in VB6 and making those of us who have spent hours worrying about allocation/deallocation of memory, pointer math, and all that C/C++ stuff frustrated when we inevitably had to fix some horrible bug in that horrible code. So we harbor these bad feelings. I'll admit, that even today, if I have to touch VB.net code or someone says "I code in VB.Net", vile thoughts come immediately to mind. There are horrible coders working in all languages, let's jut hate THEM and not the language...does that work for everyone?
Admin
But properties and methods are the same thing in .Net, really. Properties are just syntatical sugar for getters and setters that can be abused to cause side effects and block indefinitely. The same is true for indexers. I'm not sure why you think C# is any better, because the underlying mechanism is the same. Disclaimer: I don't even like VB.Net.
Admin
TRWTF isn't VB, it's the coder. I haven't read very many of the comments on this one, but this is a classic example of when NOT to use a property. The fact that you can do this with a property has nothing to do with the language since VB, C#, etc can do this and makes many things much more simple (I'd rather use VB and C#'s properties than the stupid Get/Set functions that are forced upon us in Java, PHP, c/c++, etc).
Admin
Private Function _getFoo as Int Return 1 End Function
Public Readonly Property Foo as Int Get return _getFoo() End Get End Property
fixed it for you
now return 1
Admin
TRWTF is that that code compiles. I mean, the Property and Get means it has to return something right? (I'm none too familiar with VB), so the fact that you've not explicitly returned anything should be a syntax error, it should never compile. There is no way any reasonable developer should use the fact that it implicitly returns 0. (I said /reasonable/) So that code will surely be a case of coding sans caffeine and missing a 'return'
Admin
Oh, cool, you probably have something like activerecord or maybe a good DBA around!
Ooops...
captcha: ingenium. Speaks for itself.
Admin
Admin
or maybe
if you wanted to restrict who could set it.
Admin
Usability is for end-users, not programmers. Death to VB!
On a related note: Isn't Ruby often touted for it's simplicity also? I guess Ruby is still too new for its haters club to have as many members.
Admin
Admin
Admin
Admin
Admin
Just because the language allows crap like that doesn't make it a bad language. VB.Net is just as capable as C# in the hands of a "Programmer". I can work in either language, but prefer VB for its readability and productivity enhancements provided by the Visual Studio environment. That example is all about the programmer and not the language.
Admin
Admin
Well that's where the analogy to a craftsman fails since craftsmen are often self-employed people pretty much fully in charge of their situation (and tools). I on the other hand worked for 4 months (co-op term) at a software shop that was supporting software running on versions of Java and 3rd party libraries that were 8-10 years out of support. 20% of the bugs that came in would be fixed by upgrading to newer versions of our dependencies. 5% of the new code we wrote already belonged to the newer standard libraries. Our development environment was centred around Netbeans 3.5 when 6.5 was 10 years newer and free.
Can you imagine our frustration when every time we tried to invest in new tools and dependencies, management accused us of blaming our poor productivity and quality on our tools?
Can you understand why we eventually would take a stance of blaming things on our tools?
Admin
Easy.
VB:
C#:
For the string comparison, the VB version calls a bunch of VB string comparison crap kept around for backward compatibility with old VB (6 and earlier). The C# version calls op_Equality() which is a much more efficient method.
If you don't believe me, compare the MSIL. If you want to make your VB more efficient, rewrite that string comparison to
Admin
Admin
Admin
Admin
Ask google about "unsafe vb.net" and you'll see the big one. A VB coder could not have written a fast AVI file writer. I've done it in C#. It requires the ability to pack bytes into uint32's. Packing requires all manner of fun bitwise operations, and VB just isn't cut out for that. Now, you can do it in VB, just not at any useful speed. To get useful speed out of that operation requires unsafe code. And VB can't do it.
Admin
Actually, that's exactly the way you'd want to implement this scenario on an embedded system with no file system.
Admin
Not a C# guy, but in most languages that would return "true", which is not what the VB or the original looked like they were doing. Am I missing something, or is your chosen screen name for this post taking on a bitter irony in your mouth right about now?
Admin
Admin
Also, he misspelled "than".
Admin
Whenever a Code SOD featuring Visual Basic is published here, a flood of The Real WTF is VB comments ensues. As mindless and unoriginal of a comment as it is, there's a good reason for the sentiment: Visual Basic is designed for beginners, is often used by beginners, and beginners write an awful amount of awful code.
Admin
"Thou doth protesteth too much"
That is my response to all those who consistently bash VB.
Truly good programmers are comfortable and confident in their work without the need to randomly bash an entire language and all developers using that language, just to...what...cover up for some...deficiency?
Admin
Admin
COmmon Business Oriented Language A Programming Language.
Signs of a mis-spent youth? Maybe.
And I have 3.5 years on you. I started on a Commodore Pet, with the built-in cassette drive and the ghastly horrible keyboard. From there I progressed (?) to a Sinclair ZX80 (bounce, bounce, bounce).
((Editor's note: the only way to understand that last remark is to have used a ZX80, on a TV where the vertical hold control was set just, but only just, on the stable side of completely losing hold.))
But, hey, my mother started programming on a LEO 3.
In 1963.
Admin
This is why you want to be able to do this in VB.net :)
Admin
This is why you want to be able to do this in VB.net :)
Admin
Reading is fundamental. When two things are the same, there is no ambiguity.
Admin
The product has little to do with the quality of the tools and much to do with the skill of the craftsman.
See what you can do with crayons?
http://www.kristinanelson.com/collections/originals-and-prints?page=1
Akismet is useless.
Admin
The difference, though, is that Pascal has evolved into one of the most powerful, readable and productive languages around, and BASIC has evolved into... well... VB.
Admin
Um, no. Sorry. The code you "corrected" demonstrated a point about C# vs VB. Yours demonstrated your failure to grasp the point. Passing the compiler is sort of irrelevant in this case, don't you think?
Admin
Admin
Your comment seems to assume that Microsoft, whose VERY FIRST RELEASED PRODUCT was Microsoft BASIC, years before IBM even started to THINK about releasing a PC, actually had a choice in the matter of whether or not to keep releasing versions of BASIC. This assumption is faulty.
Programmers were fucking ADDICTED to Quickbasic for DOS. (Hell, some people STILL USE IT.) Not releasing VB for Windows would have been cutting their own throat. Someone else would have released BASIC for Windows to capitalize on the market. That would have been embarrassing in the extreme.
Admin
It's that kind of thinking that creates the WTF found here, you fscking imbicile.