Results 1 to 40 of 2075

Thread: TwinBasic

Threaded View

  1. #11
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: TwinBasic

    Also, I want to point out a huge contraction in the arguments of the people who are against the addition of these short-hand operators. A lot of you also argue for TwinBASIC to be more low level. You cannot argue for syntax to be simple for beginners while at the same time arguing for more low level control. You guys post a lot of code with VarPtr this or CopyMemory that. This kind of code is not beginner friendly.

    I'd also point out that operators are integral to lower level programming. Let me raise an example based on a recent post I made about HRESULTs in the VB6 section. If you wanted to extract the facility code from an HRESULT, you must perform two low level operations. First you must mask out the irrelevant bits around the facility code, then you must shift all 32 bits to the right by 16.

    Now lets say in an alternate reality you guys get your wish and Wayne didn't include any new operators. How would we perform this low level operation? We'd have to do it like this:-
    Code:
    facility = (errorValue And &H7FF0000) / (2 ^ 16)
    Do you see a problem here? That code is using division to perform bit shifts. I don't know how many of you know assembly but an integer division operation at the machine code level is quite involved. It is also very slow. However, modern processors also have bit shift instructions which are among the fastest operations a processor can perform. If a higher level language does not include bit shift operators, then you're being denied access to a very powerful tool that could be used for significant performance gains in lower level programming. That same code looks like this in VB.Net which has bit shift operators:-
    Code:
    facility = (errorValue And &H7FF0000) >> 16
    The above would also look the same in just about every modern language. Even Python has them. This is how it would look in Python:-
    Code:
    hresult = -2146824582
    
    facilityCode= (hresult & 0x7FF0000) >> 16
    
    print(facilityCode)
    Which outputs:-
    Code:
    10
    Which is correct.

    Python is the furthest thing from a low level language possible. It's entirely interpreted and very sluggish in comparison to languages that produce native code and even they dared to include operators like this.

    You guys want to attract new talent to TwinBASIC. They are going to be looking at things like this when weighing their decisions about whether to adopt TwinBASIC or not. No one is going to want to perform a bit shift in 2021 using division.
    Last edited by Niya; Dec 15th, 2021 at 08:29 PM.
    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