Page 4 of 20 FirstFirst 123456714 ... LastLast
Results 121 to 160 of 761

Thread: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

  1. #121
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Schmidt View Post
    So, why not "hold" the Game-settings (including the "users inventory") in an InMemory-DB?

    To create an InMem-DB-Object is a OneLiner.
    (and there's several convenience-methods, to "push" structured data into such an Object as a new Table).

    And to retrieve filtered Lists (in the form of "Recordset-DataContainers") is just "another line of code".

    Olaf
    Because that is another layer of abstraction that isn't needed and I don't need to add that to do it how I want to do it.

    Again, if that works for you, great. I see no need to add another layer.

  2. #122
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,486

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by kfcSmitty View Post
    Because that is another layer of abstraction that isn't needed and I don't need to add that to do it how I want to do it.

    Again, if that works for you, great. I see no need to add another layer.
    Also if you are holding the data as a collection of objects, the objects can contain functionality above and beyond a simple in memory data store.

  3. #123
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,631

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by PlausiblyDamp View Post
    My previous reply was before I saw you asking for an example.

    Just knocked up a quick one using a file I had on my hard drive from some benchmarks I was running...
    Thanks - but can you make the input-file somewhere available (to be able to compare performance)?
    Maybe "anonymize" the data somewhat, in case it's confidential stuff...

    You say performance doesn't matter (until it does)...
    I say, I'd use the faster performing implementation any time -
    when it doesn't go overboard with "the necessary code to write" (in comparison to an alternative).

    <shrug>

    Olaf

  4. #124
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,631

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by kfcSmitty View Post
    Because that is another layer of abstraction that isn't needed and I don't need to add that to do it how I want to do it.

    Again, if that works for you, great. I see no need to add another layer.
    No, your larger Collection-List is an Object (an abstraction) as well.
    It stores InMemory:
    - "more data than needed in sub-routines, which prefer filtered sub-sets, derived from that larger "Main-Set".

    An InMemory-DB-Object (a Table in it) - is exactly the same "Object-Abstraction" as your "Main-Collection".
    It stores InMemory:
    - "more data than needed in sub-routines, which prefer filtered sub-sets, derived from that larger "Main-Set".

    HTH

    Olaf

  5. #125
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Schmidt View Post
    No, your larger Collection-List is an Object (an abstraction) as well.
    It stores InMemory:
    - "more data than needed in sub-routines, which prefer filtered sub-sets, derived from that larger "Main-Set".

    An InMemory-DB-Object (a Table in it) - is exactly the same "Object-Abstraction" as your "Main-Collection".
    It stores InMemory:
    - "more data than needed in sub-routines, which prefer filtered sub-sets, derived from that larger "Main-Set".

    HTH

    Olaf
    Ah so in-memory databases are built in to the framework and don't required any extra dependencies? Gotcha. Thanks for clearing that up.

    Seriously. You're being intentionally obtuse and I'm not sure why... just like not possibly being able to think of an example of storing data in memory vs pulling from the database at all times.

  6. #126
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,631

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by kfcSmitty View Post
    Ah so in-memory databases are built in to the framework
    In case of VB6 (using the RC6-Framework) - yes, that's directly built-in.

    Quote Originally Posted by kfcSmitty View Post
    Seriously. You're being intentionally obtuse and I'm not sure why... just like not possibly being able to think of an example of storing data in memory vs pulling from the database at all times.
    I think, you (like Niya) still haven't fully understood what I'm talking about.

    When you talk about "storing data in memory" (for example in a huge list-collection-object, which in turn holds e.g. "thousands of car-objects")...
    Now... where exactly did all those "car-objects" in that list materialize from?
    Right, you had to instantiate and populate all these car-objects - and then add those car-objects to your car-list-collection sometimes prior in your App
    (to be able to finally perform a Filter-Operation against that list of cars).

    Olaf

  7. #127

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,520

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Schmidt View Post
    No, you could simply write it this way:
    Code:
    For Each Ctl in Me.Controls
      If TypeOf Ctl Is Button Then
        If Not Ctl.Enabled Then ...
      End If
    Next
    It's roughly the same amount of Chars to type, as in your example.
    Code:
    For Each btn As Button In Me.Controls. _
       OfType(Of Button)._
          Where(Function(b) Not b.Enabled)
                '''
    Next
    Olaf
    Actually this is a more accurate rendition of the non-LINQ method:-
    Code:
            For Each c As Control In Me.Controls
                Dim b As Button = TryCast(c, Button)
                If b IsNot Nothing Then
                    If Not b.Enabled Then '''
                End If
            Next
    There will be cases where the control in question has methods, properties and events that are not implemented in the Control base class hence you will need to perform a cast to the specific Control type as well.
    Last edited by Niya; Feb 2nd, 2021 at 08:40 AM.
    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

    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

  8. #128
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Schmidt View Post
    In case of VB6 (using the RC6-Framework) - yes, that's directly built-in.



    I think, you (like Niya) still haven't fully understood what I'm talking about.

    When you talk about "storing data in memory" (for example in a huge list-collection-object, which in turn holds e.g. "thousands of car-objects")...
    Now... where exactly did all those "car-objects" in that list materialize from?
    Right, you had to instantiate and populate all these car-objects - and then add those car-objects to your car-list-collection sometimes prior in your App
    (to be able to finally perform a Filter-Operation against that list of cars).

    Olaf
    Again, being intentionally obtuse. I already gave examples where I queried the data from the database and stored it in my own list, dictionary, whatever. I can now easily use LINQ to search and filter the data in 1 line instead of having to loop through the data.

    Great that VB6 has something similar and you can do the same thing. I find it very handy to be able to query the data like that. Glad we're in agreement that it is a useful feature and I am very happy for you that your language has something similar to the feature I like in my language.

  9. #129

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,520

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Schmidt View Post
    I think, you (like Niya) still haven't fully understood what I'm talking about.

    When you talk about "storing data in memory" (for example in a huge list-collection-object, which in turn holds e.g. "thousands of car-objects")...
    Now... where exactly did all those "car-objects" in that list materialize from?
    Right, you had to instantiate and populate all these car-objects - and then add those car-objects to your car-list-collection sometimes prior in your App
    (to be able to finally perform a Filter-Operation against that list of cars).

    Olaf
    Oh I understand perfectly. You're advocating for dumping that external data in a lightweight database engine and use that to perform querying and filtering. What we are saying is that we don't have to do that. We could use plain old normal every day arrays and collections and use LINQ for querying and filtering. We also get the benefit of LINQ being more or less supported by .Net languages, which means intellisense support, type checking, compile time syntax checking etc. All of these little things add up to a more productive experience.
    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

    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

  10. #130

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,520

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    See what you're not getting Olaf is that these LINQ features are baked into the foundation of .Net itself. It's not just a library that you import. You can basically use LINQ anywhere at any time on any kind of array with complete support from the compiler and the intellisense. You don't need to even import anything. It's just there always available.

    It's not about whether or not SQLite is better or faster. It's about the actual experience of writing the code. It's just so much more pleasant just being able to use it and have the intellisense speed you up and the compiler making sure to warn when you muck things up right then and there rather than waiting for it to fail at runtime. LINQ is about developer productivity.
    Last edited by Niya; Feb 2nd, 2021 at 08:57 AM.
    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

    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

  11. #131
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,486

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Schmidt View Post
    Thanks - but can you make the input-file somewhere available (to be able to compare performance)?
    Maybe "anonymize" the data somewhat, in case it's confidential stuff...

    You say performance doesn't matter (until it does)...
    I say, I'd use the faster performing implementation any time -
    when it doesn't go overboard with "the necessary code to write" (in comparison to an alternative).

    <shrug>

    Olaf
    I can probably manage to do that, although the source file is only a 3 or 4 thousand lines, not really enough for a decent performance comparison.

    If we are always going to be aiming for the best performing code and eliminating all abstractions then shouldn't everything be written by hand in assembler? Everything we do that is above raw CPU instructions is an abstraction to a greater or lesser degree. We make a decision on which abstractions are worth it and which aren't.

  12. #132
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,631

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by kfcSmitty View Post
    Again, being intentionally obtuse.
    Not sure about that...
    (I understand you quite well in, that you will have to make a copy of the Select-resultset in your own "cars-Collection" first,
    before being able to perform sub-queries against that InMemory-represenation).

    FWIW - here's VB6-Code which demonstrates the needed steps via InMem-DB-approach:
    - how to populate an InMem-representation of a "larger set"
    - and how to visualize the result of a SubSet from that InMemory-represenation

    Code:
    Option Explicit
    
    Private MemDB As cMemDB
    
    Private Sub Form_Load() 'transfer an ADO-ResultSet (e.g. retrieved from SQLServer) into a MemDB-Table
      Set MemDB = New_c.MemDB
          MemDB.Cnn.CreateTableFromADORs MemDB.Cnn, "tblCars", AdoCnn.Execute("Select * From Cars")
    End Sub
    
    Private Sub Form_Click() 'visualize a filtered SubSet (retrieved from a MemDB-Table)
      Set MSHFlexGrid1.DataSource = MemDB.GetRs("Select * From tblCars Where Vendor='Nissan'").DataSource
    End Sub
    That's all what it comes down to, working with InMem-DBs as a "clientside, temporary datastore" in VB6.

    HTH

    Olaf

  13. #133
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Schmidt View Post
    Not sure about that...
    (I understand you quite well in, that you will have to make a copy of the Select-resultset in your own "cars-Collection" first,
    before being able to perform sub-queries against that InMemory-represenation).

    FWIW - here's VB6-Code which demonstrates the needed steps via InMem-DB-approach:
    - how to populate an InMem-representation of a "larger set"
    - and how to visualize the result of a SubSet from that InMemory-represenation
    With the obtuse comment I mean your line

    Now... where exactly did all those "car-objects" in that list materialize from?
    Right, you had to instantiate and populate all these car-objects - and then add those car-objects to your car-list-collection sometimes prior in your App
    They came from a DB, but saying I should just be filtering on the DB is being obtuse, since I gave examples where it is cleaner and faster to not use a DB to filter. I also gave an example where there is literally no DB.

    The code itself seems pretty decent (minus the VB.. I just can't get used to it... personal preference).

    However, not knowing VB6 (I barely knew it when I did stuff with it), is your example limited to only being able to bind to a datasource? Can I query the data and put it into an array or just have a single object be created from the resultset?

  14. #134
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,631

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by PlausiblyDamp View Post
    If we are always going to be aiming for the best performing code and eliminating all abstractions then -
    shouldn't everything be written by hand in assembler?
    Of course not - I thought I ruled that out already with my:
    "... when it doesn't go overboard with "the necessary code to write" (in comparison to an alternative)"

    Olaf

  15. #135

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,520

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by PlausiblyDamp View Post
    I can probably manage to do that, although the source file is only a 3 or 4 thousand lines, not really enough for a decent performance comparison.

    If we are always going to be aiming for the best performing code and eliminating all abstractions then shouldn't everything be written by hand in assembler? Everything we do that is above raw CPU instructions is an abstraction to a greater or lesser degree. We make a decision on which abstractions are worth it and which aren't.
    Even assembly itself is a thin abstraction around machine code. Some assemblers even allow certain high level constructs like IF THEN statements.

    Going even lower, to the machine code level, we find that a single machine code instruction is actually implemented as several microcode instructions. I mean how low to we have to go before this point about abstractions becomes ridiculous.
    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

    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

  16. #136
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Schmidt View Post
    Of course not - I thought I ruled that out already with my:
    "... when it doesn't go overboard with "the necessary code to write" (in comparison to an alternative)"

    Olaf
    IIRC, the first Roller Coaster Tycoon was written entirely in assembly. Definitely a feat.

  17. #137
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,486

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Schmidt View Post
    Not sure about that...
    (I understand you quite well in, that you will have to make a copy of the Select-resultset in your own "cars-Collection" first,
    before being able to perform sub-queries against that InMemory-represenation).

    FWIW - here's VB6-Code which demonstrates the needed steps via InMem-DB-approach:
    - how to populate an InMem-representation of a "larger set"
    - and how to visualize the result of a SubSet from that InMemory-represenation

    Code:
    Option Explicit
    
    Private MemDB As cMemDB
    
    Private Sub Form_Load() 'transfer an ADO-ResultSet (e.g. retrieved from SQLServer) into a MemDB-Table
      Set MemDB = New_c.MemDB
          MemDB.Cnn.CreateTableFromADORs MemDB.Cnn, "tblCars", AdoCnn.Execute("Select * From Cars")
    End Sub
    
    Private Sub Form_Click() 'visualize a filtered SubSet (retrieved from a MemDB-Table)
      Set MSHFlexGrid1.DataSource = MemDB.GetRs("Select * From tblCars Where Vendor='Nissan'").DataSource
    End Sub
    That's all what it comes down to, working with InMem-DBs as a "clientside, temporary datastore" in VB6.

    HTH

    Olaf
    Or working with Linq and an ORM it could be as simple as
    Code:
    dim db as new AdventureWorksContext
    
    dim products = (from p in ctx.Products select p).ToList()
    dim cheapProducts = (from p in ctx.Products where p.ListPrice < 100 select p).ToList() 'creates a list of products in memory by querying the DB
    dim demo = (from p in ctx.Products select new with {.p.Name, p.ListPrice, p.Id}.ToList()  'Creates a list of objects by querying the db and only retrieving the 3 required columns
    with intellisense, compile time validation, and no raw sql strings.
    Last edited by PlausiblyDamp; Feb 2nd, 2021 at 09:29 AM.

  18. #138
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by PlausiblyDamp View Post
    Or working with Linq and an ORM it could be as simple as
    Code:
    dim db as new AdventureWorksContext
    
    dim products = (from p in ctx.Products select p).ToList()
    dim cheapProducts = (from p in ctx.Products where p.ListPrice < 100 select p).ToList() 'creates a list of products in memory by querying the DB
    dim demo = (from p in ctx.Products select new with {.p.Name, p.ListPrice, p.Id}.ToList()  'Creates a list of objects by querying the db and only retrieving the 3 required columns
    Or alternatively (I prefer this format).

    Code:
    var products = ctx.Products.ToList(); // all products
    
    var cheapProducts = ctx.Products.Where(product => product.ListPrice < 100).ToList(); // cheap products
    
    var demo = products.Select(product => new {
      Name = product.Name,
      ListPrice = product.ListPrice,
      Id = product.Id
    }); // all products, but only query the name, listprice, and id

  19. #139
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,486

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by kfcSmitty View Post
    Or alternatively (I prefer this format).

    Code:
    var products = ctx.Products.ToList(); // all products
    
    var cheapProducts = ctx.Products.Where(product => product.ListPrice < 100).ToList(); // cheap products
    
    var demo = products.Select(product => new {
      Name = product.Name,
      ListPrice = product.ListPrice,
      Id = product.Id
    }); // all products, but only query the name, listprice, and id
    I much prefer the C# syntax as well.

  20. #140

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,520

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by PlausiblyDamp View Post
    Or working with Linq and an ORM it could be as simple as
    Code:
    dim db as new AdventureWorksContext
    
    dim products = (from p in ctx.Products select p).ToList()
    dim cheapProducts = (from p in ctx.Products where p.ListPrice < 100 select p).ToList() 'creates a list of products in memory by querying the DB
    dim demo = (from p in ctx.Products select new with {.p.Name, p.ListPrice, p.Id}.ToList()  'Creates a list of objects by querying the db and only retrieving the 3 required columns
    with intellisense, compile time validation, and no raw sql strings.
    Are you using Entity Framework there?
    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

    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

  21. #141
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,486

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Niya View Post
    Are you using Entity Framework there?
    It was more off the top of my head assuming I was using Entity Framework - would probably work though if you used VS to generate the context for you.

  22. #142

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,520

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by PlausiblyDamp View Post
    It was more off the top of my head assuming I was using Entity Framework - would probably work though if you used VS to generate the context for you.
    Ah. Ok.
    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

    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

  23. #143
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    I suppose that is another thing I like (and hate) about .NET -- entity framework.

    I don't need to create my database or tables if I don't want to. I can easily just create my classes

    Code:
    public class User {
      public int Id { get; set; }
      public string FirstName { get; set; }
      public string LastName { get; set; }
      public DateTime DateOfBirth { get; set; }
      public Address Address { get; set; }
    }
    
    public class Address {
      public int Id { get; set; }
      public string AddressLine1 { get; set; }
      public string AddressLine2 { get; set; }
      public string City { get; set; }
    }
    And then I need to set up the context:

    Code:
    public class DummyContext: DbContext {
      public DbSet<User> Users { get; set; }
      public DbSet<Address> Addresses { get; set; }
    }
    I can also set up relationships and other stuff, but a little too involved for this example. For a single one-to-one like I have above it will auto create the relationship.

    And then run "Update-Database" and it updates my local database. I can then query the data using LINQ easily with

    Code:
    using(var context = new DummyContext()) {
      var usersBornBefore1980 = context.Users.Where(b => b.DateOfBirth < new DateTime(1980, 1, 1));
    }
    It saves me having to do stuff like this (pseudocode because I haven't used ADO in a while)

    Code:
    var query = db.Query("SELECT * FROM Users WHERE DateOfBirth < '1980-01-01'");
    var usersBornBefore1980 = new List<User>();
    
    while(query.next()) {
      usersBornBefore1980.Add(new User {
        FirstName = query["FirstName"],
        LastName = query["LastName"],
    ...
      });
    }
    Now don't get me wrong.. I have a love/hate relationship with EF. Some of the queries can be suboptimal and we need to specify the query explicitly, but for the most part, it saves manually creating all of the objects and placing the data.
    Last edited by kfcSmitty; Feb 2nd, 2021 at 10:32 AM.

  24. #144
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,629

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    That may be the key point to all of this.

    I'm not thrilled with LINQ or EF. LINQ isn't ALWAYS slower, but it does appear to be usually slower. Techgnome reports seeing a LINQ statement that outperformed non-LINQ, but I think he said he couldn't remember the details. I've compared performance on a few simple LINQ statements and they aren't as performant.

    However, that doesn't matter. Most of what I write is LOB, which means there's a significant UI, and when it comes to the 'User' part of UI, the computer is always waiting around for the pink monkey to do something. Even the fastest typist is waaaayyyyy too slow for a computer. So, if LINQ is 30% slower on some simple task (I think that was roughly what I was finding), it doesn't make a bit of difference in most applications.

    It DOES make a difference in one particular area, and it's an area that Schmidt is particularly interested in: Libraries.

    Do what you want for your own code, but if you are writing a library, then write it to be as efficient as possible, because you don't know how sloppily it will be used. For that reason, I stripped all LINQ out of the libraries I have such that the code will run as tightly as possible.

    However, that invalidates a different argument that was made on the last page (all y'all are posting a bit fast to keep up) about compactness. People rarely care about that at all, but in the case of a library, it shouldn't even be on the list of concerns. One of my libraries could be made quite compact. A method loads a complicated model from a database. That code is straightforward, if complicated, and it works....but it isn't efficient to re-load these complicated models, no matter how straightforward, so there's a fair amount of extra code to speed things up. The model, once loaded, gets put into a series of different Dictionary objects to speed access. The extra code necessary to maintain the Dictionaries as the models change makes the overall library considerably more messy...but hundreds of times faster.

    So, forget about how compact the code is. That's nonsense.
    My usual boring signature: Nothing

  25. #145

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,520

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    I think the problem with LINQ is that it's one of those technologies where you can easily get carried away and use it for things you shouldn't. I love LINQ and I have found it extremely useful almost to the point where I hate not having it as an option. However, there are places I would never use it. The 2D engine in Demon Arena for example use lists, arrays and dictionaries in a lot of it's internal implementation. I avoided using LINQ almost entirely in the core parts of the engine because I wanted as much performance as I could get.
    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

    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

  26. #146
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Shaggy Hiker View Post
    So, forget about how compact the code is. That's nonsense.
    That's a ridiculous statement to make; it is nonsense in your particular use case, maybe. You also say "compactness" -- but it isn't about compactness, it is about the tradeoff of speed vs readability (IMO) and rapid development.

    If it is compact, I can easily write my examples more compact with the for loop, removing whitespace, shorter/less descriptive varibale names, etc.

    If I can accomplish the same task with 50% less code, and it only runs 30% slower than with that extra 50% of code, and even with my code only takes 20ms to run, why wouldn't I except in the specific scenario of developing libraries for others to use?

    I 100% agree that if you're developing something that is being given out to others, you should do everything you can in your code to ensure your code is not the bottleneck. Same with if you need extreme performance -- then obviously LINQ will not be the way to go.
    Last edited by kfcSmitty; Feb 2nd, 2021 at 11:53 AM.

  27. #147

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,520

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Shaggy Hiker View Post
    So, forget about how compact the code is. That's nonsense.
    I'm going to have to disagree here. I have a very strong preference for more compact code. There's nothing I hate more that reading some verbose monster I wrote 6 years ago and not understanding what it does. Of course no matter what language you write something in you cannot escape this but I do aim to make it as compact as I can where I can and I don't mind trading a bit of performance for it.

    This is probably just a matter of taste though. It's not really a hill I want to die on.
    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

    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

  28. #148

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,520

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    As for EF, I had a very brief experience with it and the problem I ran into was the abstraction level being too high. It was so high to the point that some simple tasks were very difficult to accomplish. There was one thing, which I cannot remember, that was just impossible to accomplish.

    However, I did find the idea of dealing with databases as normal objects in your application very appealing and highly productive. I decided to put EF on the back burner and give it some time to evolve. It was still fairly new when I tried it the first time. Despite my failure with it, I did enjoy using it very much for the things it did offer.

    I think I'll look into it again today and see where it's at. It was always a tech I was interested in.
    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

    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

  29. #149
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,486

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Niya View Post
    As for EF, I had a very brief experience with it and the problem I ran into was the abstraction level being too high. It was so high to the point that some simple tasks were very difficult to accomplish. There was one thing, which I cannot remember, that was just impossible to accomplish.

    However, I did find the idea of dealing with databases as normal objects in your application very appealing and highly productive. I decided to put EF on the back burner and give it some time to evolve. It was still fairly new when I tried it the first time. Despite my failure with it, I did enjoy using it very much for the things it did offer.

    I think I'll look into it again today and see where it's at. It was always a tech I was interested in.
    The later versions have improved a lot, the sql generation is certainly better although by no means perfect. The ability to integrate stored procs etc. with EF make a good compromise, use Linq when it suits but call into stored procs when you need to - still keeps a nice clean way of coding without dropping into low level ADO.Net code.

  30. #150

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,520

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by PlausiblyDamp View Post
    The later versions have improved a lot, the sql generation is certainly better although by no means perfect. The ability to integrate stored procs etc. with EF make a good compromise, use Linq when it suits but call into stored procs when you need to - still keeps a nice clean way of coding without dropping into low level ADO.Net code.
    That's good to hear. I've always had every intention of revisiting EF one day. I recognized it's potential the first time I used it. I really love the concept of ORM. I've always hated the amount of boilerplate involved when using ADO and ADO.Net directly. It takes too damn long to do some simple things.
    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

    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

  31. #151
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,629

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Niya View Post
    I'm going to have to disagree here. I have a very strong preference for more compact code. There's nothing I hate more that reading some verbose monster I wrote 6 years ago and not understanding what it does. Of course no matter what language you write something in you cannot escape this but I do aim to make it as compact as I can where I can and I don't mind trading a bit of performance for it.
    Did you read what I wrote, or stop at the sentence you quoted? Or possibly misunderstand what I was referring to? Was I not clear? Let me try to write it shorter:

    Some of the previous discussion seemed to be getting around to, "I can write the same thing in fewer lines." That's putting form ahead of function. The example I gave was where I wrote a more complex solution because the more compact solution had bad performance. I had already mentioned that there are times where performance doesn't matter, in which case you can do what you want. Where performance matters, then compactness shouldn't even be a factor.
    My usual boring signature: Nothing

  32. #152
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    33,495

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Shaggy Hiker View Post
    Did you read what I wrote, or stop at the sentence you quoted? Or possibly misunderstand what I was referring to? Was I not clear? Let me try to write it shorter:

    Some of the previous discussion seemed to be getting around to, "I can write the same thing in fewer lines." That's putting form ahead of function. The example I gave was where I wrote a more complex solution because the more compact solution had bad performance. I had already mentioned that there are times where performance doesn't matter, in which case you can do what you want. Where performance matters, then compactness shouldn't even be a factor.
    Hmmmm....I can attest to this. Couple of lifetimes ago, there was some code I had to delve into because it wasn't working. Turned out it was because the original developer had tried to use LINQ w/o fully understanding what they were doing and how delayed execution worked.This caused a problem a bit further down the line. I had to rewrite hte code to force instant execution of the same filter. It came at the cost of elegance, but it improved performance and reliability, which was more important.


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  33. #153
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by techgnome View Post
    Hmmmm....I can attest to this. Couple of lifetimes ago, there was some code I had to delve into because it wasn't working. Turned out it was because the original developer had tried to use LINQ w/o fully understanding what they were doing and how delayed execution worked.This caused a problem a bit further down the line. I had to rewrite hte code to force instant execution of the same filter. It came at the cost of elegance, but it improved performance and reliability, which was more important.


    -tg
    We also ran into issues initially with not specifically LINQ, but Entity Framework. By default it creates proxy objects when querying data.

    We were then trying to cache the data in memcache. Memcache doesn't complain if it fails to serialize something -- it just doesn't store it. Well because these proxy objects it was creating didn't have the [Serializable] attribute, it was silently failing, even though the objects it was proxying did have the attribute.
    Last edited by kfcSmitty; Feb 2nd, 2021 at 01:48 PM.

  34. #154
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Shaggy Hiker View Post
    Did you read what I wrote, or stop at the sentence you quoted? Or possibly misunderstand what I was referring to? Was I not clear? Let me try to write it shorter:

    Some of the previous discussion seemed to be getting around to, "I can write the same thing in fewer lines." That's putting form ahead of function. The example I gave was where I wrote a more complex solution because the more compact solution had bad performance. I had already mentioned that there are times where performance doesn't matter, in which case you can do what you want. Where performance matters, then compactness shouldn't even be a factor.
    Maybe I'm misunderstanding the previous discussion, or maybe you are.. not sure.

    From what I saw of the previous discussion, I posted LINQ statements saying how I like them in C#.

    People then started saying they wouldn't ever use that and would write more line of codes. Even saying we're lazy for liking the shorter syntax.

    So when Niya and myself have been explaining why we like it and benefits to it. No one, as far as I can see, has ever said it was extremely performant and that it should always be used vs more verbose code.

    However, your last line in your post

    So, forget about how compact the code is. That's nonsense.
    Seems to very bluntly state that anyone who cares about code compactness is spewing "nonsense" even though no one has said that compactness is the be-all-end-all.

    Code clarity will always come first for me. Period. If the user, or my testing, shows something running too slow, then I will optimize at that point. I will, however, not write longer, less clear code, to pre-optimize something that most likely will not need it.

  35. #155
    Hyperactive Member
    Join Date
    Aug 2020
    Posts
    447

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Delete duplicated post ...
    Last edited by SearchingDataOnly; Feb 2nd, 2021 at 02:35 PM.

  36. #156
    Frenzied Member
    Join Date
    Dec 2014
    Posts
    1,504

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    I will indulge you, I can recognize a bunch of different languages, some because I have experience coding, like Pascal, ADA and Java and multiple scripting languages.
    many times I have been studying c/c++ sources, but this was mostly in the past when there where little sources for VB6. I learned to understand, but not fully. it depends how important it is of course, more time I spent more I understand. But Im not an expert.
    But I think most programmers can understand other languages, at least a bit.

    Assembly, or should I say machine code, is what I have been dealing with, to change switches to bypass part of the code or inject new parts in-between, changing the string pool etc. so a bit. but again, it was for a project I did, was many years ago.

    but why?

  37. #157
    Hyperactive Member
    Join Date
    Aug 2020
    Posts
    447

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Niya View Post
    I think I know where you're going with this. The first page of this thread does show some direct comparisons between development in VB6 and Visual Studio 2019(VB.Net, C#, WPF etc.)

    However, you can't really think of it in such terms. It's not really about what someone can do in the one that they can't do in the other. It's more about the development experience. Anything you can do in VB.Net you can do in VB6 but the question is how much does the tool help you to bring your ideas into reality. I'll rehash a simple example I did once before. Take this piece of XAML code:-
    Code:
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <StackPanel.Resources>
                                <SolidColorBrush x:Key="color" Color="{Binding}"/>
                            </StackPanel.Resources>
    
                            <Rectangle Height="40" Width="40" Fill="{StaticResource color}"/>
    
                            <TextBlock Foreground="{StaticResource color}" VerticalAlignment="Center">How it looks as text</TextBlock>
                            <Button Margin="25,0,0,0" Width="70" VerticalAlignment="Center" Click="Button_Click">Remove</Button>
                        </StackPanel>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
    The above code modifies a ComboBox to do this:-


    Can that be done in VB6? Sure it can, but will it be that simple? I'd say probably not. Just placing a Button inside the ComboBox is a technical challenge and I'm sure if I spent a few hours I can figure out how to do it or I could wait for someone like Krool to show me how. But I really don't want to spend my time on such a simple UI detail and I don't want to have to wait on someone in a forum to answer my question on how to do it. I just want to get it done and move on. WPF's XAML layout engine makes it easy to accomplish things like that.
    Look at this:
    Code:
    Private Sub Form_Load()
    
        With mySpread
            .ColHeadersShow = False: .RowHeadersShow = False: .GridColor = vbWhite: .ScrollBars = ScrollBarsNone: .OperationMode = OperationModeSingle
            .MaxRows = 4: .MaxCols = 3: .RowHeight(-1) = 480: .ColWidth(1) = 480: .ColWidth(2) = 2400: .ColWidth(3) = 1200: .FontName = "Verdana"
                    
            .Row = 1:       .Col = 1:       .BackColor = vbRed:    .Col = 2:       .ForeColor = vbRed:
            .Row = 2:       .Col = 1:       .BackColor = vbBlue:    .Col = 2:       .ForeColor = vbBlue:
            .Row = 3:       .Col = 1:       .BackColor = vbGreen:  .Col = 2:       .ForeColor = vbGreen
            .Row = 4:       .Col = 1:       .BackColor = vbCyan:  .Col = 2:       .ForeColor = vbCyan
            
            .Row = -1:      .Col = 2:       .Text = "How it looks as text":  .TypeVAlign = 2
            .Row = -1:      .Col = 3:       .CellType = CellTypeButton:     .TypeButtonText = "Remove"
    
        End With
        
    End Sub
    Attached Images Attached Images  
    Last edited by SearchingDataOnly; Feb 2nd, 2021 at 02:36 PM.

  38. #158
    Hyperactive Member
    Join Date
    Aug 2020
    Posts
    447

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    The simpler code is as follows:

    Code:
    Private Sub Form_Load()
        Dim i As Long, nColor As Long
        
        With mySpread
            .ColHeadersShow = False: .RowHeadersShow = False: .GridColor = vbWhite: .ScrollBars = ScrollBarsNone: .OperationMode = OperationModeSingle
            .MaxRows = 4: .MaxCols = 3: .RowHeight(-1) = 480: .ColWidth(1) = 480: .ColWidth(2) = 2400: .ColWidth(3) = 1200: .FontName = "Verdana"
            
            For i = 1 To 4
                .Row = i:       nColor = Choose(i, vbRed, vbBlue, vbGreen, vbCyan)
                .Col = 1:       .BackColor = nColor:
                .Col = 2:       .ForeColor = nColor:        .Text = "How it looks as text"
                .Col = 3:       .CellType = CellTypeButton:     .TypeButtonText = "Remove"
            Next i
            
        End With
            
    End Sub
    Edit:
    Originally, I didn't want to participate in such a discussion, but some people really need to know more about other knowledge.

    In addition, the features that mySpread can achieve are 100 times more powerful than ComboBox.ItemTemplate.

    Also, I can easily add a function to mySpread: MyTemplateString = "<ComboBox.ItemTemplate>...</ComboBox.ItemTemplate>"
    Last edited by SearchingDataOnly; Feb 2nd, 2021 at 03:03 PM.

  39. #159
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by SearchingDataOnly View Post
    The simpler code is as follows:

    Code:
    
    
    I do have to admit.. that is pretty damn simple code!

  40. #160
    Hyperactive Member
    Join Date
    Aug 2020
    Posts
    447

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by kfcSmitty View Post
    I do have to admit.. that is pretty damn simple code!
    You are too impatient.

Page 4 of 20 FirstFirst 123456714 ... LastLast

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