-
Content Count
1264 -
Joined
-
Last visited
-
Days Won
26
Posts posted by David Schwartz
-
-
What you want is a circular buffer that points to buffers in a memory pool if they're all the same size, or pools of different sizes if they vary. The pool pre-allocates (static) buffers that are re-used, so no fragmentation occurs.
Memory fragmention is not your biggest issue, it's atomic reads and writes, or test-and-sets to avoid corruption and gridlock from race conditions.
-
Have you looked at TMS WEB Core? You can write your code in Dephi and it transpiles it into JS. You can use pretty much any 3rd-party JS lib. I use HTTP for I/O, but you could use JS just as easily. And the language has been extended to support async requests in-line.
-
Anything like that in just Delphi?
-
On 8/7/2024 at 8:32 AM, Frickler said:You mean Simula. Modula had no classes.
Btw. Anonymous functions have been a feature of programming languages since Lisp in 1958. That was really a long time ago.
Yup, you're right about Simula vs. Modula.
I learned LISP in college. I found it to be a very strange language, but it helped me really understand recursive programming. It probably did support a lot of things, including anonymous functions, but we didn't get that far in the class. I wouldn't hold it up as an exemplar for much of anything other than an interesting experiment at the time. It was an interpreter that took very few resources and let you create programs by defining rabbit holes to go down. Unlike most other languages, iteration was much harder to do than recursion. But I guess it was a good learning tool for a few things, given what was available at the time.
-
I'd like to build something that can be trained to recognize a deck of playing cards or flash cards, both upright and upside-down.
Why? Because it's far easier and cheaper to be able to use a set of existing cards to do this as opposed to printing up a set with barcodes on them that the computer can read.
Copyright issues aside, it's really expensive to print a set of playing cards. You need to print them by the 1000s if not 10,000s and then you have to sell them. It's not a quick process. Or print unique barcodes / QR codes / NFC tags and stick them on all of the cards. This is the "age of AI" so why not just be able to use a deck of cards and train the software to recognize each one?
Once trained and incorporated into an app, you could hold up a card in front of the video camera and it would recognize it and as one of the cards it was trained on, say as an index into the list of cards, and be able to process it via the index from that point forward.
I'm looking at a relatively limited set of cards, up to 100 or so, with images of varying complexity, and recognize each one with a high degree of accuracy.
This is just pattern recognition, not any kind of generative aspect.
What's the best way to go about something like this in Delphi?
-
What comes to mind for me is a simple publish/subscribe model with a lightweight notification mechanism like MQTT. It would keep the overhead miminal and could easily be kept out-of-band relative to the actual data channels.
-
On 7/27/2024 at 7:27 AM, dummzeuch said:No, you are wrong. Even anonymous methods were in Java first.
Nope, as Remy pointed out, they weren't actually supported until Java 7 or 8. I remember reading a bunch of stuff back when Java 8 was released about how difficult it was for them to get the anonymous methods working, and they weren't even supported as "first class objects". They were improved in the next version and the syntax was simplified significantly. I was at some tech event shortly after Java 8 was released, and I happened to talk with the SW Dev Mgr who coordinated a rather large team of Java devs at a local company, and asked him what version of Java they were using. He admitted they has finally just switched over to Java 6 about 6 months earlier, and it took them a couple of years to do that. I asked what their plans were to migrate to Java 8. He said the architecture of their overall system was unable to handle it, and they had started on a mission to completely rebuild the system from scratch that could track newer Java releases.
I played with Java for about a week and quickly got disgusted with it. I don't know who thought it would be a Good Idea to put Configuration Management stuff into a programming language, but I think it was a truly insane idea. That was what the aforementioned manager was referring to, because their system got boxed-in and the architecture calcified because of so much of that and how inflexible it was. Even Delphi does a better job at that than Java does!
Delphi has supported lambdas and closures as "first class objects" since they were first introduced, or maybe the following update. (I wasn't paying much attention at the time.)
-
On 7/27/2024 at 6:19 AM, Lajos Juhász said:do not forget that multi-line strings completely broke the IDE. For D13 they will have to change the code in the IDE to support them.
I'm still using D10.4.2, and it has trouble dealing with inline vars that have been in C++ since it was released in 1985.
-
On 7/29/2024 at 10:16 PM, chkaufmann said:Clipper and I think Smalltalk had anonymous methods as well. And this at the time when Java was not even born.
Christian
IIRC, Smalltalk was the first language that popularized the notion of 'classes' and OOP, although classes were first implemented in Modula which never really got much traction.
Both Modula and Smalltalk were way ahead of their time.
-
On 7/26/2024 at 4:08 AM, timfrost said:I cannot believe how complex this discussion has become! All to avoid having a tiny unit with four boolean variables defined in the interface, along with a GetLogLevel function which can be called when needed ...
Delphi is a few decades behind contemporary language features today. The last several language additions have been around since the 90's. I'm not sure how far into the 2000's they are yet. I think I'll be long dead before they catch up with the more popular language features that most languages already support today in 2024.
I mean ... hey ... the only thing added in D12 was multi-line string literals. WOOT! WOOT!
I'm not moving off of D10.4.2 until they start focusing on real language improvements. Given how many emails I'm getting lately trying to urge people to get back onto maintenance plans, I'm guessing the user base is shrinking ... maybe because nobody wants to use a language that's still stuck in the 90's when most contemporary languages are still evolving quite steadily.
I think Delphi introduced anonymous methods and closures before Java did. But since then, Java has updated them with nearly every release, and they look nothing like they did initially. I can't think of anything that has changed with Delphi's syntax.
-
1
-
-
I've had to deal with several variations of that over time. Are there web-hooks in place that call the system to hand over each JSON packet? Or are they just dumped in chunks into a file, accessible by something like FTP? Or do you have to poll a system periodically for new data that has accumulated?
60k records per day isn't that big of a deal. And text is quite easy to compress, especially if there's a limited lexicon involved.
Then there's the backing store, where it really depends on the total lifetime of that data, what the half-life of searches is (so you know when you can flush it out to secondary storage with low likelihood of needing the majority of it), and tuning the DB to optimize the queries that come in. In America, certain types of records need to be kept for a legally-defined minimum length of time, like 7 years for corporate and financial records. Most of it isn't ever looked at, but it needs to be kept online and backed-up in case of audits or lawsuits. Just figure out how to compress the crap out of it and stash it away so it's easy to retrieve when needed.
The point is, your job is to make sure the recent data is quickly accessible, while the older data is on slower more massive drives but still accessible in a reasonable amount of time. (A subpoena for data might give a month or more to provide it, which should be plenty of time to deal with slower backing stores, or even mag tapes.) Do NOT try to make 100% of it accessible "instantly". The client might have some temporal requirements, but make sure they're reasonable.
-
1
-
-
21 hours ago, JonRobertson said:23 hours ago, David Schwartz said:This wide disparity between forms that are used for interacting with DBs that have DB-aware controls on them vs. those that don't -- because you're not using DB -- has always perplexed me with Delphi.
Just with Delphi? Do you use other languages with frameworks that provide a cleaner solution?
I've only used Delphi. Prior to that I spent most of 15+ years doing embedded systems programming, and they never used DBs for performance reasons. It was pretty low-level C and C++. Frameworks were fairly primitive back then. And there were lots of Delphi apps I worked on that were essentially embedded systems, like stand-alone kiosks, that had content created externally and manually installed -- no DBs were used here either.
-
On 6/17/2024 at 5:54 AM, JonRobertson said:That sounds like much more code than necessary to me.
I have a base form with a TDataSet field named StateDataSet and a virtual method called UpdateUIState...
Yeah, it often is.
What if you're not using DB-aware controls? The OP didn't sound like he was.
As I said, the DB-aware controls add a lot of buffering and logic to simplify this.
If you just have any random form that's got edits and grids and checkboxes and whatnot on it, and they are NOT DB-aware controls, then what do you do?
Like, say, you have a form that displays data returned from an HTTP GET request as a JSON packet that consists of an array of objects, and you want to scroll through the objects as if they're records in a table?
I'm genuinely curious. This wide disparity between forms that are used for interacting with DBs that have DB-aware controls on them vs. those that don't -- because you're not using DB -- has always perplexed me with Delphi. I've seen at least a half-dozen different solutions used over the years for the latter case, none of which were particularly elegant. Sometimes I asked the developer why he didn't just use an in-memory table and DB-aware controls, and the excuse was usually that it "added too much overhead to the app". OTOH, there have been numerous situations where I got rid of a bunch of code that did this and replaced it with an in-memory table and DB-aware controls, and the performance actually improved.
-
On 6/15/2024 at 2:08 AM, Uwe Raabe said:Reading the code despite of its irritating formatting reveals the problem:
WorkOrdersSelectedRow := WorkOrdersGrid.Selection.Top; if FWorkOrderManager.GetWorkOrderDataByIndex(WorkOrdersSelectedRow - 1, Data) then // evaluates file index FileIndex := ARow - 1; if (FileIndex < 0) or (FileIndex >= TWorkOrderData.FILE_DATA_SIZE) then Exit;
FileIndex will not be initialized when the if clause fails.
BTW, it also irritates that the compiler is charged guilty first.
Look for the code that causes FileIndex to be set, and then look above it for something that might cause that line to not execute.
You're lucky in this case that these are three lines in a row. Sometimes several of these kinds of initializations are set at the top of a proc and the warning isn't issued until much farther down in the body of the proc.
-
I've generally found it's easier to make one form to ADD a NEW item, and another to VIEW / EDIT the item (either object instances or DB records). But it can depend what's in the form.
I've often tried using one for all three, but I often end up with so much code that does one thing for Adding and another for Viewing / Editing that it's just too much of a headache.
One way around that is to Insert a new record with default values, then open it in Edit mode. But the problem with that is if the user Cancels out of the form, then you have to be sure to delete the added record. If there's a possibility that someone might issue a query that attempts to access that record, then you'll need a field that maintains a state flag saying it's temporary. If something throws an exception and blows out of the Edit process but doesn't delete the temp item, that can create all sorts of headaches.
The areas that cause trouble are fields that are references to chunks of data from elsewhere, fields that contain indices that point to items in a lookup table, along with field validation read errors, among others.
To address some of these disparities, adding a new record can require data fields that are flagged as "required" but their data hasn't been selected yet by the user. You have to treat those fields as "required but empty" which is technically an error condition. So you have to put code around that to guard it from throwing an error while tabbing into or out of such a field, because for NEW records it's NOT an error. See my point?
Using DB-aware fields figures out a lot of this stuff. But to make it work, you need to add field validations to check this stuff when they click Post on a NEW form. But wait ... those field validation routines now have to figure out if it's Add or View or Edit as well and take appropriate action. So you end up simply shifting that logic from one place to another place. It would be nice to bury it inside of a class, making the objects self-validating, but that's a whole nuther can of worms!
Using one form for Adding and another one for Viewing / Editing eliminates all of that selection logic and is a lot easier to maintain. It's also simpler than dealing with inserting a temp object / record first then Editing it because you don't have to deal with deleting the temp if the user cancels the edits or an exception is raised.
BTW, the difference between View and Edit is that View sets all of the fields to read-only, and going into Edit mode turns off all of the ones that the user can edit (ie, applies permissions). A copy of the data needs to be kept when you go into Edit mode so you can compare which fields changed and only update them, or restore the field values if they Cancel the Edit after making some changes. Again, DB-Aware controls can do this automatically, but using lists of objects this way may not provide the same logic.
-
3 hours ago, PawelPepe said:Thank you for your comment. I have to say I don't know what you wanna tell me...
Are you working for TMS Team? I almost bought it reading your post 😛
But no - I am not gonna spend so much money for it. I was looking for freee stuff not because I think paying for code is bad - but because I don't have money! Simple.
I am sure TMS did great job and it works fine.
As I said, the trial version is free, but it only runs inside of the IDE.
I'll use free code samples to build proof-of-concept prototypes. Not for production code.
But production libs that are free to run inside of the IDE are usually quite adequate for proof-of-concept prototypes, and that also means I can usually reuse much of the code I wrote to work with them.
-
TMS Cloud Pack is the best I know of. (There are a few varieties of it.) There's a free trial that works when running inside of the IDE if it's just for your own use.
Only you can place a value on your own time. Far too many programmers undervalue their time and refuse to pay for stuff that costs less than a day's earnings, some less than one hour's earnings.
Also, if you're building a solution that's going to put money into your pocket (by selling to clients), then why should someone pay you for something of value if you don't see the value in the work others do? You pay people to prepare food for you; you pay for electricity delivered to your house; you pay for water, sewer, and garbage collection; you pay for clothes that people make; you pay for food that people farm; you pay for music, for movies, for popcorn; you even pay $1 or more for a bottle of water where the bottle costs more than the water inside of it; but you won't pay for software that people write?
Let's say it took someone a week to build each of the interfaces in TMS VCL Cloud Pack -- it's probably more than a month, with all of the testing, support, and other stuff they've got invested, none of which you're going to provide by rolling your own -- and you don't think it's worth it to save yourself a month or more of your time by paying $200 USD or so to have a solution ready-to-go in 5 minutes? Do you only earn $200 per month? Is that how LITTLE you value your time -- that you'd "spend" 200 hours of your time in order to "save" $200? That works out to a whopping $1 per hour that you value your programming skills at.
This whole notion of "software should be free" baffles the hell out of me. It's like when the CEO of Spotify said recently, "Very little effort goes into making music." Then he raised his subscription rate. Yeah, like that took him a few thousand hours to do. It will actually put a few hundred million dollars into his pocket, while not adding a penny of income to the artists who he's hardly paying for the "very little effort" they put into their artistry.
I paid for a college degree in Math and Computer Science. I've spent 40+ years honing my skills, and untold thousands of dollars on tools, hardware, and services. I charge a lot for my time as a software developer, because I believe I deserve it. If someone would rather hire someone from India at $2/hr that's fine by me. You get what you pay for. But I've ALWAYS found it FAR CHEAPER to pay for software that has hundreds if not thousands of hours of work behind it than trying to do it myself from scratch. People PAY ME TO BUILD STUFF FOR THEM! Why would I want to charge them for the time it takes me to re-invent something from scratch that I can buy that's already working, debugged, and production-ready? Spending $200 for a software library that probably has over 1000 hours of work put into it is a SCREAMING DEAL in my mind. (Would it surprise you to learn that I have a TMS ALL-ACCESS PASS license?)
BTW, did you write your own Delphi compiler and IDE?
-
2
-
-
-
On 6/11/2024 at 1:38 PM, Ali Dehban said:A new Delphi plug-in for automatically implementing the client side of a Rest API is now available in beta version.
Repository: https://github.com/AliDehbansiahkarbon/OpenAPIClientWizard
Demo video: https://www.youtube.com/watch?v=7B7nSHIsV64
This looks awesome, long awaited option for Delphi. What Delphi versions does this support?
-
1
-
-
Whenever I'm tempted to do this, I look very hard at the likelihood that the code I'm dealing with could be moved into a class. If it's only used once, right there, then I may just leave it as-is. But maybe with a bit more abstraction it could be more useful.
That said, it's not something I ever think of doing very often because it's a form of encapsulation that's mostly used in classes.
-
In ChatGPT4, have you tried setting the 'temperature' setting to zero? That's supposedly a setting to moderate how much / little it exercises its own "creativity".
-
On 4/25/2024 at 10:20 PM, Rollo62 said:
Still I'm more fond of the Windows ecosystem, the Macos ecosystem is more and more a no-go, for several lock-in syndrom reasons.
Sooner or later, I think the Linux ecosystem will be the solution out of both booby traps, but unfortunately still is not ready yet for Delphi devvelopers.
This is exactly why I've chosen to go with TMS WEB Core as it runs in pretty much any web browser. It does not lock you into any particular hardware or OS version. If you need something specific, you can get a cheap machine and use it to build a REST service that the web app can call directly, or indirectly through your app's main service.
There's also Crossover, which is a WINE-based containerized solution for running a Windows app in other environments that looks and runs as a native app. It's ok for one-offs, but publishers will need to see if its cost justifies the results.
-
There's also the problem that XCode upgrades may be required that cannot be installed without upgrading the OS.
I stopped upgrading my MacOS a while back b/c it seemed like each time it would lock me out of apps that cost me a lot to update themselves to continue using -- if that was even an option. I have a 2014 Mac MIni running Mojave b/c there are several 32-bit apps that I use but can't update, and the next OS doesn't support any 32-bit apps.
I have another one (2018) that's running Catalina and I won't update it either b/c of other things that break and will be expensive to update -- no free updates for these things. This is the machine I use to do my Delphi work on, inside of a VirtualBox VM, and now I can't even upgrade that to the latest version, although they seem to be supporting older versions pretty well.
And with the switch to M-series chips, there's a BUNCH of apps I can no longer upgrade b/c they ALL require the latest version of the OS to run.
XCode updates all seem to be tied to a specific version of the OS, and they don't maintain backward compatibility for older versions when they add new features to it.
Which is why I'm mainly interested in working with TMS WEB Core to build web apps that run inside of web browsers and are not dependent on hardware or OS issues.
-
That looks pretty slick.
how to recognize cards drawn from a deck?
in General Help
Posted
I have no problem with licensing libraries, unlike a lot of programmers today. I draw the line at royalties on a per-use basis, however.
A quick glance at this library tells me it's designed to be trained from a bunch of samples in order to classify and/or recognize unseen examples based on common features extracted from the samples.
I only have a single example of each card. If you hold up the Ace of Spades, there's only one of them and it should not be confused by whether it's red or black, or a Club, Diamond, or Heart. I want to train it on all of the cards in the deck so it recognizes any given card from that deck that's held up to the camera.
Noise might be present in terms of variances in color tint and hue, brightness, contrast, and orientation, but the same details are unchanged and not fuzzy nor ambiguous.