Fog Creek Software
Discussion Board




VB and C

This might be just be me whining, in which case, flame away.

I'm most comfortable with C syntax, so learning PHP was a breeze.  I'm woefully ignorant of VBScript, so learning ASP is as frustrating as boxing a ghost.  Even the simplest constructions seem clumsy, and I spend a lot of time searching for how to do what "should be easy".

Do you have any suggestions for getting a hang of VB?  I'm giving VB the benefit of the doubt (I just don't "get it" yet), but so far it seems <boston accent>retahded</boston accent>.

bah!
Friday, May 21, 2004

Read VBScript Fundamentals under VBScript->Users Guide at this site:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vtoriMicrosoftWindowsScriptTechnologies.asp

Once you "get" it you'll love it. Productivity goes way up when you don't have to think about things like pointers and garbage collection.

For VB6, I would suggest the book "Pure Visual Basic" by Dan Fox.  It's full of straight to the point examples.

For any language, look at the examples on http://www.codeproject.com

Wayne
Friday, May 21, 2004

bah! I think it takes about 4 month for some of the stuff to come natural, less if you code more often. With a more consistent syntax like VB.Net it's a bit easier, but VBScript and VBA aren't that weird. As long as you write trivial programs just have lots of sample code accessible and you'll have something to remind you of the syntax. I have harder time with languages I use least often, since I don't write stored procedures day in day out I have a hard time remembering specifics of Transact-SQL too, I'd know what I want to say knowing it's possible or not, but forget how to say it.

Li-fan Chen
Friday, May 21, 2004

I know a lot of people who write ASP who got the ASP or VB/VBA nutshell books from O'Reilly and love it. It should be on your desktop. The snippets of code in them helps a lot to remind you of how to do things.

Li-fan Chen
Friday, May 21, 2004

thanks for the suggestions.  On hand, part of me was hoping everyone would say "yes, it IS terrible!".  On the other hand, it's good to know there is light at the end of the tunnel.

Thanks again.

bah!
Friday, May 21, 2004


I have a few issues with it...

I have been in the Java world for quite some time and although some javadoc stuff is cryptic, I find the quality pretty good all the way around.  Unfortunately, the msdn isn't quite as comprehensive.

It gets even worse when you have functions that work equally well with:

dosomething(itemA, itemB)

OR

dosomething itemA, itemB

It's the same function, does the same thing, but it looks really screwy because it encourages people to "choose their favorites" and promotes disparity.

Arg.

KC
Friday, May 21, 2004

I'll be the one to chime in with the "It Really Does Stink" voice. That's being said tongue in cheek though.  I do prefer to work in C or C++ when I can, and actually find that I'm more productive in those languages.  VB.NET, especially when used with the Visual Studio environment, is pretty easy to use and once you get used to the syntax you'll find it to be very productive. 

VB isn't as intuitive as some people would have you believe, so don't feel bad.  Based on some experience with training new programmers I've seen that learning PHP might actually be easier than VB.  ASP.NET in particular seems to give some people difficulty. 

Clay Dowling
Friday, May 21, 2004

ASP is in no real way attached to VBScript. VBScript was merely the language used in most of the examples on the Microsoft website and in most publications having to do with ASP.

ASP is a server environment, a collection of objects and methods in a .dll that runs on a server. VBScript is one of dozens of languages that can be used to access/utilize ASP.

This is not a minor discrepency.

I'm not familiar with php but would assume the same is true for it (that it is language independent).

seth
Friday, May 21, 2004

"On hand, part of me was hoping everyone would say "yes, it IS terrible!"."

The VB syntax and development makes sense when you are actually working in Visual Basic.  VBScript and ASP are terribly limited beasts compared to PHP.  Most of the limiting constructs are the ASP-part (as said above, ASP is language independent). 

You might want to look at using JScript with ASP.  It's Javascript so you'll have the C syntax and all the other features of Javascript.

Seth: "I'm not familiar with php but would assume the same is true for it (that it is language independent). "

PHP is not language independent -- PHP is the language.  The not-yet-released version 5.0 has a syntax very close to Java but you can still code procedurally (like C++).

Almost Anonymous
Friday, May 21, 2004

If you learned how to program in BASIC on a commodore PET, VB feels like an old shoe.

MilesArcher
Friday, May 21, 2004

If you move to the .Net environment, then the real challenge is wrapping your head around the huge number of classes - and a slightly confusing class structure - that gives the power to VB.Net (or C#.Net)

Ken Ray
Friday, May 21, 2004

<quote author="KC">

It gets even worse when you have functions that work equally well with:

dosomething(itemA, itemB)

OR

dosomething itemA, itemB

It's the same function, does the same thing, but it looks really screwy because it encourages people to "choose their favorites" and promotes disparity.

</quote>

One returns a value. The other does not. Should not be too difficult to find out which one is which. And they both have separate, valid uses.

KayJay
Friday, May 21, 2004

http://www.w3schools.com/

http://www.brinkster.com/

I'm not sure if the second one, a hosting firm, makes you log in to get to their code archives.  The first, however, does not, and it's a GREAT site for all things web-dev related.

Andrew Burton
Friday, May 21, 2004

"dosomething(itemA, itemB)
OR
dosomething itemA, itemB
..."

"One returns a value. The other does not. Should not be too difficult to find out which one is which. And they both have separate, valid uses."

Programming in VBA in Access, I wish I had a nickel for every time I didn't want the return value, but I put the parentheses anyway, and the compiler griped at me till I _removed_ them.  A stupid waste of time, and I say this as someone who _likes_ programming in VB.

Certainly you should be able to keep the return value or not, whichever your code calls for, but the parentheses should have nothing to do with it.

Kyralessa
Friday, May 21, 2004

If you want to call every subroutine with parens, if you don't have a return value on it just prefix it with Call.

NoNameNoJobNoNothing.
Friday, May 21, 2004

I started out programming in GW-Basica, later moved to QuickBasic, eventually to VB-Dos, then to VB Windows.  My first real software job was doing ASP apps with VB-Script.  In fact, I've spent more time writing in BASIC than any other language.  So I'd say I have a bit of experience with the BASIC language in various incarnations.

Having said that, I've always felt it was clunky.  I much prefer the structure of the Java/C# syntaxt.  I like using braces instead of keywords, and I like putting ;'s at the end of my statements.  I like having one construct for method declarations (instead of sub and function), and always putting parentheses on method calls.

I also hated when Visual Basic would complain and popup a message box alerting me to the fact that my line of code was invalid when I'd go to look at some code I'd written somewhere else.  "Yes, yes, I know it's wrong!  I'm not done yet!" is what I always wanted to yell at it.  Now that's a tool issue, not a language issue, but I think it represents the fundamental mindset of the VB paradigm.

OK...done with my soap box now.  Just wanted to make you feel better about not falling in love with it  =)  In its defense, VB Script did give you a lot of common built-in functions that other languages made you write yourself (things like AVG(), LEFT(), MID(), RIGHT(), etc), and the fact that it didn't make you do garbage collection was great for people just trying to write a simple app to get something done.  Keep in mind it stems from a day when "real programming" meant assembly...

However, these days, language preference really is just that...a preference.  That's why we have so many of them in common usage.  What's irritating is when programs like Access wrap themselves around a particular language and don't give you a choice.  But in the case of classic ASP, Almost Anon's suggestion of using JScript is a great one.

Joe
Friday, May 21, 2004

>If you want to call every subroutine with parenthes, if you don't have a return value on it just prefix it with Call.

I agree 100%

. Further, if the routine as a general rule does NOT return values..then it should be declared as a subroutine..and not as a function. Is not that the difference between the two?

For this reason…I have always used Call to call a sub, and ONLY used functions in expressions to return a value.

It really is a question of clarity to people who will read the code. The instant a function is used..then the question becomes what value(s) can/does it return?

However, there is a nasty coding exception to this good idea/rule!  Due to how the expression service works in ms-access,  then using a function() is often preferred EVEN when no value is being returned.


Albert D. Kallal
Edmonton, Alberta Canada
kallal@msn.com
http://www.attcanada.net/~kallal.msn

Albert D. Kallal
Friday, May 21, 2004

KC,

<quote>
dosomething(itemA, itemB)

OR

dosomething itemA, itemB
</quote>

The first form has never been valid in VB.

Seeya

Anon
Monday, May 24, 2004

KC,

Whoops - in my last comment, I meant 'VB 6' rather than VB.

Seeya

Anon
Monday, May 24, 2004

Kyralessa,

<quote>
Certainly you should be able to keep the return value or not, whichever your code calls for, but the parentheses should have nothing to do with it.
</quote>

Using brackets in VB 6 without a return value or Call indicates (as the docs specify) that you wish to treat what is in the brackets as an expression.

This is why:

DoSomething (a, b)

doesn't work - since the compiler doesn't know how to evaluate (a, b) as an expression.

Seeya

Anon
Monday, May 24, 2004

The OP isn't really talking about Visual Basic here, but rather VBScript.  And as someone with a ton of VB (5 and 6)  and PHP experience, the correct answer is that the OP is correct:  VBScript/ASP is an incredibly crappy solution.

My single biggest gripe about VBScript is that all variables are Variants -- it's impossible to declare the type of a variable when you dimension the variable --  but that in comparison operations, the variable type actually matters and if you don't cast the variable, your comparison will fail.  For instance:

dim x, y
x = 0
y = "0"

if (x = y) then
  [do something]
end if

This will fail because VBScript refuses to cast either of the variables for you.  To make this work you would need to change it to:

if (CStr(x) = y) then
[do something]
end if

If we're going to cast variables to make things like this work, why the hell can't we declare that our variables have a specific type to begin with -- especially as VB and VBA both allow this!

Working with JScript is a hell of a lot easier, but my experience has been that there somet things available in VBScript but not JScript, and vice versa; my ASP stuff has tended to use scripts in both languages.

I miss PHP. 

<sigh>

jburka
Monday, May 24, 2004

*  Recent Topics

*  Fog Creek Home