• Quick note - the problem with Youtube videos not embedding on the forum appears to have been fixed, thanks to ZiprHead. If you do still see problems let me know.

Programming Help

GoTos in VB.NET

VB.NET has the following inherent goto statements.

Exit Do
End
on error goto
error
goto
return
stop
 
VBA is essentially VB6 with major limitations. Unless you're using it specifically because you need to interact with Word or Excel in a way that is distributable to other users as a single file, I would not really recommend it....

Better to go with VB.Net 2005 Express Edition and get a somewhat full featured IDE geared towards programming. The VBA IDE is pretty lacking. Especially when it comes to telling a novice user why their application won't compile.... :(

The Pig has not yet expressed any of those concerns. So far, I get the impression that his needs are very basic. What would satisfy his needs with the least amount of complication? The answer would entail what is most readily available and something he can experiment with quickly enough. Since he has XP he could easily enable the .NET framework on his system from the CDs or download it from MSDN and start using some of the fancy languages there. But it would be overkill for his needs.

What is a good language for writing programs to work through fairly simple algorithms? I'd be mainly looking to calculate odds and probabilities, nothing fancy, I don't care how it looks.
 
Bah, this forum software just wiped out my response and I don't feel like retyping it even though it was short.

Here's the gist...

  • Visual Basic Express Edition is free and has a fairly full featured, simple to use IDE for a beginner.
    http://msdn.microsoft.com/vstudio/express/vb/download/
  • The full version of Visual Studio would be overkill.
  • In the end he can probably do what he is looking for with just Excel functions. No "programming" needed at all. But that is only if he already has Excel.
  • He is probably not reading this thread anymore anyway so it does not matter. ;o)
 
Now I am certain that you are completely uninformed (as in ignorant)

Both VB.NET and C# share the same features. They differ only in SYNTAX. Semi-Colons and different keywords. Its not debatable. It is exactly what Microsoft intended (their goal is to eventualy move everyone to the same language, controlled by them)
This is not entirely true. There are two features in particular I can think of that are missing in Visual Basic.NET

There is no Lock statement in Visual Basic.NET, yet.

In Visual Basic.NET you can not write the following because you cannot overload the + and = operators.

if (3 + Imaginary(2)) = (3 + Imaginary(2)) then
msgbox "The two imaginary numbers are the same."
end if
 
aiya....

Operator overloading was implemented in VB.Net 2005 and VB.Net's SyncLock is equivilant to C#'s lock.

Currently the biggest, typically encountered, differences between the two languages are; VB.Net's My namespace (not CLS compliant), C#'s implementation of anonymous methods/delagates (CLS compliant), and C#'s easy access to delegate covariance/contravariance (CLS compliant).

It's mostly a question of syntax preference these days.....
 
Well, I'm pretty much a C person, however CPP has some advantages for certain things like making database programs or for certain programs that involve passing complex data between things.

Java? Java is damn ugly. It makes you do a lot of stuff, even if you don't need it for your program. It's extremely strict. If you say "Hmm..for this program, I think I'm going to do things *this* way and since it's just a small program, I won't bother doing *this* because it's really not necessary"

And in reply Java says "NO! YOU CANT DO THAT! YOU MUST DO AS I SAY AND BE LIMITED AND WRITE YOUR PROGRAMS LIKE THIS!" Then it destroys all your will to live and mocks you.
Every programming language forces a grammatical or canonical structure. This is no different in C or C++. The point of Java is to take away the lower level details of C++ and provide higher lever structure. So in many ways, C++ is more complex than Java. For example, you don’t have to deal with pointers and memory management, you have an array type and bounds checking, you have string types, a Boolean type, multi-threading, etc.

Also, C is a well balanced language, it is effecient but not overly low-level. Java is slooooooooooooooooow. Java is designed to run on different machines and be cross-platform. You *can* compile it to an executable, but it's not as optomized for that. Hence, instead of running on one system well, it runs on all systems, badly....very very badly. It's like Esperinto: nobody speaks it natively. It would be better to make a cross-platform compilable package.

C is not good for gui interface, but is good for speed. VB is great for making a nice interface, but isn't very effecient for heavy stuff.

Java can be used for both and sucks equally at each. Java won't allow you to use stuff liek OpenGL, because that's platform-based. You could put it in the VM, if you don't mind even more overhead.
What is this heavy stuff you are talking about? Are you talking about business applications, Internet applications, Web Services, off-the-shelf programs like Word, Exel, etc., or Gaming software, something else?

Aside form questioning your claim that Java is inefficient, I would like to inform you that efficiency is not always the most important thing. That is why many development environments give you the option not to do it. For most applications, programmers should not focus too much on efficiency at the low level but at the higher, algorithmic level making sure to select the right approach. Efficiency for the business application developer would be defined differently as it is for those developers creating the algorithms for a database engine.

Your analogy with Esperanto is way off. Esperanto happens not to be the language of choice except for a very limited number of linguistics researchers. Whereas Java is a language of choice—especially where there is a very possible need to have something run on multiple platforms. Think of what you are doing right now: surfing the net. You will find that the vast majority of applications on the Internet have Java and not C nor C++ as their underlying language. Go ahead and do a right-click on your browser right now and view the source code behind the web page. You will likely find scripting code. It is probably Java Script or VB Script and your Windows environment probably has a Java virtual machine.

So that all depends on your point of view. Welcome to this world!

java programs are huge...actually....massive. If you want to write a hello-world program, you need to make sure your PC has at least a few gigs to hold the files in.
I guess you consider a “hello world” program to be heavy stuff. In some cases Java programs are wordier than C++ programs. Of course, the “hello world” program is not one of those cases. How would you do it in C++.

http://en.wikipedia.org/wiki/Java_programming_language
// Hello.java
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}

Also read the part on performance on the Wikipedia.

But it's not the programs I really hate. It's the language. I hate java so goddamned much.... I would *never* take a job where I'd work with it. You may say "Well, that would limit your job options and pay." Okay, that may be true, but there are certain things that I just won't do to myself. I wouldnt want a job as an undertaker either.
So the tool is more important to you than its use. Interesting!

However, to be completely fare to you. Your C++ skills may come in handy in the world of .NET where you are again re-integrated into the world. But if you want to continue to progress in the computer industry, I would pay some attention to C# or something new if I were you.
 
Last edited:
aiya....

Operator overloading was implemented in VB.Net 2005 and VB.Net's SyncLock is equivilant to C#'s lock.

Currently the biggest, typically encountered, differences between the two languages are; VB.Net's My namespace (not CLS compliant), C#'s implementation of anonymous methods/delagates (CLS compliant), and C#'s easy access to delegate covariance/contravariance (CLS compliant).

It's mostly a question of syntax preference these days.....
Thank you. You are correct and I remember now the SyncLock statement. The one time I tried before I actually used the framework itself to lock. However, I had not realized overloading had been incorporated into the language.
 
np.

The 2005 version of .NET happens to be absolutely amazing. If you have not had the chance, I would check out some of the new features. Things like generics (sort of like C++ templates but with many added features), partial classes, and full implementation of windows ACLs have made it my #1 choice for almost all of my commercial programming projects. And that's a very small part of everything that has been added. VB.Net also happens to be CLS compliant now which is a huuuge plus. Performance is stellar as well.
 
Just browsed through the new features of the language and you're right, it is quite impressive. Does the language also treat statements like expressions like in C and I possibly Java and C++? That would be the only difference between the languages.

Also, did you download the refactoring add-in. It is great stuff.

The next thing to come would be some aspect-oriented tools as extensions to the Generics or attributes features.
 
Just browsed through the new features of the language and you're right, it is quite impressive. Does the language also treat statements like expressions like in C and I possibly Java and C++? That would be the only difference between the languages.

I don't quite get you. I think you accidentally deleted a sentence or two somewhere in there..... Can you clarify?

Also, did you download the refactoring add-in. It is great stuff.

Most definitely. Everyone was ecstatic when Refactor! became free.

The next thing to come would be some aspect-oriented tools as extensions to the Generics or attributes features.

I believe there are already several implementations but AOP is not currently my cup of tea so I can't comment. A google search should yield ample results.
 
np.

The 2005 version of .NET happens to be absolutely amazing. If you have not had the chance, I would check out some of the new features.

Indeed!

Things like generics (sort of like C++ templates but with many added features)

I would hardly call generics 'sort of like' templates. Generics end up being productive. Templates end up being retarded :) Basically, generics is 'the important stuff' from templates, without all the retardation. For sure they arent as powerfull.. but then thats not the point. Templates should have never been added into the C++ definition as there literally isnt a single 'fully compliant' C++ compiler due to the addition.

Performance is stellar as well.

They need to do better function inlining. Small functions that take reference types (where efficiency usualy isnt a concern) seem to be inlined while small functions that take non-native value types are hit or miss (more miss than hit in my experience so far)

Also, it would be nice if they offered a better optimiser for non-jit cases. I can understand a jit optimiser not being as good as a regular optimiser due to jit compilation speed considerations .. but it would be nice if there was an alternative that didnt make sacrifices.

A glaring example of the JIT 'missing' an obvious optimisation that even VS98 didnt miss is cases where you need both division and modulus of the same values... the jit doesnt 'know' that the processors integer division instruction computes both values simultaneously. Clearly this is only of 'minor' importance... but just the same..
 
Indeed!

I would hardly call generics 'sort of like' templates. Generics end up being productive. Templates end up being retarded :) Basically, generics is 'the important stuff' from templates, without all the retardation. For sure they arent as powerfull.. but then thats not the point. Templates should have never been added into the C++ definition as there literally isnt a single 'fully compliant' C++ compiler due to the addition.

Comparing languages features in a negative way usually leads down a slippery slope. I try to stay away....

They need to do better function inlining. Small functions that take reference types (where efficiency usualy isnt a concern) seem to be inlined while small functions that take non-native value types are hit or miss (more miss than hit in my experience so far)

A procedure is guaranteed to not be inlined when any of the following conditions are met under the current version of the runtime:

Method:
is greater than 32 bytes of IL.
is Virtual.
has complex flow control.
has a try/catch block.
has a parameter that is a structure. :(

In most cases it should not be a significant performance issue. And in those where it is, you'll just have to restructure your code for the time being.... :(

Also, it would be nice if they offered a better optimiser for non-jit cases. I can understand a jit optimiser not being as good as a regular optimiser due to jit compilation speed considerations .. but it would be nice if there was an alternative that didnt make sacrifices.

A glaring example of the JIT 'missing' an obvious optimisation that even VS98 didnt miss is cases where you need both division and modulus of the same values... the jit doesnt 'know' that the processors integer division instruction computes both values simultaneously. Clearly this is only of 'minor' importance... but just the same..

That's the beauty of .NET. As the JIT gets upgraded, new optimizations can be applied to your application by simply binding it to a newer version of the CLR. (After thoroughly testing for introduced bugs of course). I've been very happy with .NET performance to date in %99.9999 of cases.

Also, in terms of JIT speed, you always have the option of using NGEN to "pre-compile" your application. However you must do this on the computer which the application is being run on (in actuality a good thing as it creates an image specifically optimized for the current system) and it can take a bit for larger apps. Luckily you only have to do it once every time you distribute a new version of the application. The nice thing is that in .NET 2005, all the pain in the ass work of recompiling executables and referenced assemblies is done for you automagically. Use this tool wisely though. Sometimes it is just not worth it....
 
I don't quite get you. I think you accidentally deleted a sentence or two somewhere in there..... Can you clarify?
An assignment statement is actually an expression that evaluates to a value than can also be used or assigned. For example,

in x = (Y = 5)

Y = 5 is an assignment that also evalutates to 5 by its meaning in the language. So that value is then assigned to x. So in essense you end up assigning 5 to both x and y in a single line of code.
 
Last edited:
ah, you didn't say that.
You said:
statements like expressions like in C and I possibly Java and C++?
;)

Always been supported in C#.

Can't be implemented in VB.NET syntax without a breaking change as = is both for equality and assignment. So the statement is equivalent to Dim x as Integer = y.Equals(5) in vb....

It doesn't matter much though. You save two or three characters but end up with the same IL code. I personally shy away from multiple assignments on the same line whenever I can. It can make code confusing to other programmers who end up reading my code. (Not to mention me when I read my code months or years later. ;o)
 
A procedure is guaranteed to not be inlined when any of the following conditions are met under the current version of the runtime:

Method:
is greater than 32 bytes of IL.
is Virtual.
has complex flow control.
has a try/catch block.
has a parameter that is a structure. :(

What is the source for this info? I tried and tried to find it on the WEB MSDN and couldnt :( Resorted to running a debugger and 'guessing' :(
 

Back
Top Bottom