Jump to content

David Heffernan

Members
  • Content Count

    3499
  • Joined

  • Last visited

  • Days Won

    174

Posts posted by David Heffernan


  1. 15 hours ago, Rudy Velthuis said:

    RAII is for things that must be reversed, i.e. pointers that must be freed/deleted, screen cursors that must be returned to crArrow, files or ports or streams that must be closed again, etc.etc. But many objects in C++ are not used from a pointer or reference (except if they are supposed to be inheritance-polymorphic), they are used as stack (local frame) objects. That is the main automatic memory management. Actually RAII also builds on that principle: the reversals are done in the destructors of the stack-based RAII objects.

     

    And C++ has had from the beginning what Delphi got now too: limited scopes, i.e. variables that live only during the scope of a block, not just an entire function frame anymore. Together with mrecords with automatic destruction (you don't even really need automatic construction for that, IMO), that provides a simple way to do RAII too, one that does not involve interfaces and is probably far more lightweight and faster than the current smart pointers/guards/whatever using interfaces. But even with interfaces: an interface declared as inline variable must be released at the end of the block in which it was declared, not just at the end of the enclosing function anymore.

    I'm not sure what the purpose of this post is but it is pretty off topic. 


  2. 5 hours ago, Микола Петрівський said:

    Interesting observation: Android ART is written in C++ and core of Unity (game engine) is also written in C++. In both cases code with manual memory management is doing all hard work, and garbage collected code (Java and C#) sits on top of it. So authors of this codebases also were perfectly aware of problems related to mixing different memory management models, and have separated them on language borders. Delphi has to be good in both low level stuff and business logic, so it had to switch to simpler memory management model.

    Well, typical C++ code has automatic memory management too using the RAII principle. So that argument falls down I think. 

    • Like 1

  3. 1 hour ago, dummzeuch said:

    This was not about a video but about a blog post. But feel free to continue not reading anything I post. It's completely voluntary.

    I agree that most videos on programming are a waste of time.

     

    It's still my opinion that somebody who comments on a blog post should at least have read it. If you had, you would have noticed that I already mentioned RtlGetVersion and discarded it because it does not give me the information I wanted.

     

    Just in case you are interested nonetheless: I have just written another blog post crediting your hint. If you don't want to be credited with something that you apparently deem to be too trivial for your attention please let me know.

    I think that the point Angus was making was that he read the text, and did not follow the link.  The text seemed to be the first two paragraphs of the blog post, but without mentioning that there was more to be found by following the link.

     

    I have to say that I read the post two or three times wondering what it was that you were trying to tell us.  Since the text you did include was only part of the story, it would in my view, have been better not to have included any text and just referred us to the offsite link to your blog post.

     

    That's at least three people that were confused by the post.  Listen to our feedback or not. It's completely voluntary.  😉


  4. The C++ for loop, in its general form, is trivially translated into a while loop. So

     

    for (init; condition; iteration) statement

     

    becomes

     

    init;

    while (condition) {

      statement;

      iteration;

     

    It is well worth knowing this if you are in the business of translating pieces of code. 

     

    So in C++ the for loop is syntactic sugar on top of the while loop. 

     

    In Delphi also the classic for loop can also be trivially expressed as a while loop. This for loop is simpler than that of C++ but it's still just a while loop (condition tested before body executed) with implicit increment. 

     

    They Pascal repeat loop is like the C++ do loop. They key being that the condition is at the end of the body rather than the beginning. 

     

     

    • Like 2

  5. 23 hours ago, Mike Torrettinni said:

    That is definitely different that what I would... I try to open and close files as fast as possible, but maybe this is not such a bad idea. So, i lock the file and use it until I don't need it anymore. Which could actually work, because files are in 99% local files.

    Why are you so worried about reading from files. It's perfectly normal to open a file, read it, parse as you go, then close. In fact trying to do other than that is just going to create more complexity for you. To what benefit? 

     

    What is the problem here? What do you see going wrong with the most simple way to read files? 

     

    It looks like you are inventing a problem where none exists. 

    • Like 1

  6. 2 hours ago, Attila Kovacs said:

    Throw them an exception. Then they (your callers) will start checking by themselves and throwing an exception to its callers etc.. at the end you will have a solid app.

    That's not how you do exception handling. You don't need to catch and re-raise. You can just let them float up to wherever in the code knows how to deal with them with finality. 

    • Like 1

  7. 1 hour ago, Lars Fosdal said:

    Giving up their own compiler is completely different thing.

    Open source isn't giving up. It's allowing contributions from outside. Emba would still be in control. 

     

    The only open source project I have any involvement is Spring4d. Who do you think is the boss of that? It sure ain't me. And that's exactly how it should be.

     

    A good open source project has strong management and leadership, and those contributors that can fit in and add to the development effort are facilitated. You don't just hand control to random collaborators. 

     

    Stefan's point about open source collaborators is spot on. Good programmers aren't going to spend their time on open source projects unless it's rewarding and fun. I certainly could never see myself working with the OP here. 

    • Like 6

  8. 8 minutes ago, Remy Lebeau said:

    Borland tried that once before.  The CLX framework in Delphi 6 was a cross-platform version of the VCL.  Most of the interfaces remained the same, just the internal implementations changed.  That didn't work out so well for them, CLX had to be scrapped.

    CLX was actually alright. I built a cross platform app with it back in the day and lived for quite some time


  9. 31 minutes ago, Bill Meyer said:

    History shows that the US looking after its own interests has had us paying most of the costs of defense for Europe since WWII. 

    You are entitled to your own opinion, but not your own facts.

    Those aren't facts though. If you are going to make a claim, back it up with credible evidence. Just because 45 said it, doesn't make it true. 

×