3 ms·
Visual Basic was actually strongly typed (unlike JavaScript). What it did differently to Pascal was that it allowed for lazy / inferred typing along with some
by pushpop 7y ago
Visual Basic was actually strongly typed (unlike JavaScript).
What it did differently to Pascal was that it allowed for lazy / inferred typing along with some transparent type conversation in places where the intention was obvious. However in VB once a variable is defined a type (either when defined or when assigned a value - depending on how the variable was defined) you couldn’t change it. Eg you cannot overwrite an integer with a string
Weirdly, despite being branded a toy language, this meant VB actually had one of the more sophisticated type systems out of the languages of that era because you had the laziness of languages like JS and PHP but without having the === et al kludge that some loosely typed languages need.
Perl is another language that frequently gets mocked but it’s eq vs == solution for differentiating between strings and numeric types is genius and again solves the whole type comparison problem that JavaScript has.
- tluyben2 7y agoThanks for that enlightenment; underestimated vb there I guess. I did work in vb and vba, but very minimal and very long ago. Now that you mentioned the example of not being able to change a type once set, that seems to ring a bell. I did a lot of code in Delphi. (And also in Perl actually which I liked and P6 looks good to me: many interesting concepts.)
- ptx 7y agoWhere does VB infer types? If you don't specify types (which is usually enforced with "Option Explicit"), everything ends up with a Variant type, i.e. a union type that can contain a value of (almost) any actual type and will be implicitly converted on use.
- pushpop 7y agoAhh yes, I’d forgotten about the variant type. I loved “Option Explicit”. To the extent that it was almost always the first line I’d write for any new project, module and class.