Results 1 to 13 of 13

Thread: [RESOLVED] Can VB simulate all pointer operations in C language?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,447

    Resolved [RESOLVED] Can VB simulate all pointer operations in C language?

    We know that C language is a highly efficient language. The main reason for this is that C language uses pointers to directly manipulate memory in most cases. I'd like to know whether VB can completely (100%) simulate all pointer operations in C language, so as to provide apps that are as efficient and compact as C language. Thanks.

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,906

    Re: Can VB simulate all pointer operations in C language?

    What's the background for this question?

    To write C programs using the VB IDE?

  3. #3
    Addicted Member
    Join Date
    Feb 2015
    Posts
    158

    Re: Can VB simulate all pointer operations in C language?

    I'm not sure if VB6 can simulate C or c++ style pointer operations or not but as far as creating compact & efficient apps, VB6 is actually very good for this in its own right. Over the years, I've created many small, fast, stand-alone executables in VB6 which rely on nothing beyond the basic runtimes. I would pit any of them against equivalent C++ code any day and likely see little to no performance difference. VB6 still to this day has one of the best 32-bit compilers out there, with many optimizations available.

    Also, pointer usage can be a double edged sword - on one blade there is complete control. On the other blade there are many potential bugs/memory leaks if one isn't careful.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,447

    Re: Can VB simulate all pointer operations in C language?

    Quote Originally Posted by SomeYguy View Post
    I'm not sure if VB6 can simulate C or c++ style pointer operations or not but as far as creating compact & efficient apps, VB6 is actually very good for this in its own right. Over the years, I've created many small, fast, stand-alone executables in VB6 which rely on nothing beyond the basic runtimes. I would pit any of them against equivalent C++ code any day and likely see little to no performance difference. VB6 still to this day has one of the best 32-bit compilers out there, with many optimizations available.

    Also, pointer usage can be a double edged sword - on one blade there is complete control. On the other blade there are many potential bugs/memory leaks if one isn't careful.
    C language is not a very complicated language, it's much simpler than C++. It's not only suitable for junior programmers to learn, but also leaves infinite vast development space for advanced programmers. The C language field often produces some small and great works, such as SqliteDB, Cairo-Graphics. However, such excellent works cannot appear in the field of VB6.

    If VB6 can simulate all pointer operations in C language, then I can convert many excellent C-algorithms into VB6-algorithms.

  5. #5
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,443

    Re: Can VB simulate all pointer operations in C language?

    Can VB simulate all pointer operations in C language?
    No!...
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,447

    Re: Can VB simulate all pointer operations in C language?

    Quote Originally Posted by Zvoni View Post
    No!...
    In theory, it should be possible.

    It's just that those who can do it are already very proficient in the C language. For them, it is not necessary to simulate the pointer operations of the C language with VB6, and they are not interested in studying this problem. But this question is very valuable to me.

    Science is to make one impossible after another possible.
    Last edited by SearchingDataOnly; Jul 6th, 2021 at 06:32 AM.

  7. #7
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,443

    Re: Can VB simulate all pointer operations in C language?

    Quote Originally Posted by SearchingDataOnly View Post
    In theory, it should be possible.
    In theory i should be a millionaire......

    I quote Bruce McKinney from his "Hardcore Visual Basic"-Bible:
    There is only one thing you can do with a pointer: Pass it to the Windows-API

    If you think it a good idea to "manipulate" a pointer in your code, all bets are off, and the User can lean back and witness a spectacular crash
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,447

    Re: [RESOLVED] Can VB simulate all pointer operations in C language?

    <<Advanced Visual Basic 6>> -- Matthew Curland
    https://www.developerfusion.com/book...isual-basic-6/

    Editorial Reviews
    Written by a Microsoft insider and well-respected Visual Basic expert, Matthew Curland's Advanced Visual Basic 6: Power Techniques for Everyday Programs is a unique guide to extending the reach of VB into COM and object design. This compendium of tips and strategies for doing more in VB is perfect for intermediate to advanced developers who seek to overcome bottlenecks in performance and functionality in their favorite programming tool.

    The underlying message is that VB lets you work more efficiently with Microsoft COM if you implement a few extra routines that look under its hood. The more notable techniques use memory more efficiently (including code that creates large numbers of objects faster). More advanced readers will appreciate the in-depth guide to building COM objects programmatically within VB. (The book shows you how to create lightweight COM objects by using custom routines.) For the real guru, there's even a section on how to use inline assembly language within VB. Later sections turn to a host of techniques for multithreading, doing more with windows, and how to manage and customize COM-type libraries for successful real-world deployment. Armed with these custom routines and an expert's-eye view of VB internals, you'll be able to get more out of VB with faster, more versatile programs. --Richard Dragan

    Topics covered:
    • Tips and strategies for extending Visual Basic by using COM

    • VB pointers and memory management

    • Extending VB arrays (accessing underlying SAFEARRAY COM objects and speeding up array performance)

    • Accessing the IUnknown COM interface from within VB

    • Binding names and COM vtables in VB

    • Improving code reuse by using aggregation in VB (overriding functions in child classes and simulating polymorphism)

    • Improving object cleanup in VB (circular, weak, and strong references and strategies for improving memory use in class hierarchies)

    • Using COM class factory APIs within VB

    • Loading DLLs and OCX controls directly

    • Lightweight COM objects in VB

    • Strategies for creating large numbers of objects efficiently

    • Accessing the VB Running Object Table (ROT)

    • Calling function pointers in VB

    • Simulating inline assembly instructions

    • Threads in VB (apartment models, worker and UI threads, and synchronization tips)

    • Improving VB performance with strings

    • Generating and customizing type libraries

    • Binary compatibility of COM objects

    • Tips for working with windows in VB (subclassing, custom window creation, and windowless controls)

    • VBoost (custom library of advanced VB routines)


    In Advanced Visual Basic 6, leading Visual Basic expert Matthew Curland demonstrates powerhouse techniques programmers can use to write high-performance, robust, and reusable VB code. Readers learn how to leverage the close relationships between VB, COM, and OLE Automation, extending the envelope of VB's capabilities and building high-quality, object-based systems. Key topics include how to:

    * Control VB array variables explicitly to directly access arbitrary memory locations
    * Call pointers to standard, cdecl, and class module functions
    * Aggregate complete interface implementations into any VB object
    * Override functions on any interface, including those implemented automatically by VB
    * Turn any user-defined type into a lightweight COM object
    * Minimize memory usage in systems with a large number of objects
    * Safely create and manage threads in ActiveX EXEs and DLLs
    * Interact with messages to customize windowed and windowless UserControl objects.

    The Web site accompanying this book contains extensive source code samples to enable all techniques without external DLLs. It also provides integrated type library add-ins for creating and editing referenced libraries, modifying binary compatibility files, and customizing the type libraries that VB generated for ActiveX components. With this compendium of best practices, sophisticated techniques, and valuable utilities, VB programmers will gain a deeper understanding of VB's inner workings and be able to extend its object-oriented capabilities.
    Last edited by SearchingDataOnly; Aug 5th, 2021 at 11:53 AM.

  9. #9
    Addicted Member
    Join Date
    Feb 2015
    Posts
    158

    Re: [RESOLVED] Can VB simulate all pointer operations in C language?

    So given the extra versatility and capabilities shown above, then why oh why oh why did Microsoft ever abandon VB6???

  10. #10
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: [RESOLVED] Can VB simulate all pointer operations in C language?

    Because it didn't fit their strategies and the direction they intended for the languages yet to come.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  11. #11
    Addicted Member
    Join Date
    Feb 2015
    Posts
    158

    Re: [RESOLVED] Can VB simulate all pointer operations in C language?

    Quote Originally Posted by yereverluvinuncleber View Post
    Because it didn't fit their strategies and the direction they intended for the languages yet to come.
    Unfortunate of course but true .

  12. #12
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,600

    Re: [RESOLVED] Can VB simulate all pointer operations in C language?

    Quote Originally Posted by SearchingDataOnly View Post
    We know that C language is a highly efficient language. The main reason for this is that C language uses pointers to directly manipulate memory in most cases. I'd like to know whether VB can completely (100%) simulate all pointer operations in C language, so as to provide apps that are as efficient and compact as C language. Thanks.
    This is not actually about the languages themselves. This is about their compilers. The VB6 compiler will forever remain unchanged and compared to C, it puts a lot of stuff into it's binaries with little ability to control this. Array bound checking is an example of this.

    VB6 will never be able to produce binaries as compact and lean as a typical C compiler and this is for a very good reason. There is a very fundamental difference between VB6 and all BASIC languages and C, BASIC and their derivates are safe languages while C is not.

    BASIC was originally meant for non-programmers to be able to program, and as a "training wheels" language for people wanting to learn programming. This means that BASIC must protect programmers from themselves. It does this by shielding programmers from the harsh realities of how dumb computers really are. Think of all the typical errors you would see a newbie or script kiddie get when trying to write programs. Integer overflows, null references, array out of bound errors, stack overflow errors, type mismatches. This is all thanks to BASIC compilers which put all that stuff into their binaries to keep you safe, and in many cases before protected mode became a thing, it kept your system safe. This is also why BASIC languages typically don't give you access to pointers. It's to prevent you from doing things the compiler cannot protect you from.

    C compilers do not have all these safety nets, which is why C programs are so compact and lean. If you write outside of an array bounds in C, you're not going to get a nice little error informing you of this, it's just going to do what it's told and write beyond the array. Maybe 2 hours later your program seg faults and the OS terminates it abruptly leaving you with no clue why. Maybe you overwrite some critical function in the operating system's memory that causes the plane your program is running on to crash and kill 200 people.

    C was meant for serious programmers that really know what they are doing working on very serious stuff. The lack of safety nets in C means the language is more flexible and more powerful. It allows you complete control over the system by allowing you to implement your own safety nets however you see fit.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  13. #13
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,600

    Re: [RESOLVED] Can VB simulate all pointer operations in C language?

    Quote Originally Posted by SomeYguy View Post
    So given the extra versatility and capabilities shown above, then why oh why oh why did Microsoft ever abandon VB6???
    The short answer is that VB6 had too much historical baggage to be brought comfortably into the modern age. If they tried, the internals would have just been a huge mess. It was better to start from scratch with a solid modern foundation.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width