-
Content Count
133 -
Joined
-
Last visited
-
Days Won
3
darnocian last won the day on August 19
darnocian had the most liked content!
Community Reputation
83 ExcellentRecent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
I've been experimenting with an integrated playground IDE plugin for the Sempare Template Engine ( https://github.com/sempare/sempare-delphi-template-engine or via GetIt). The template engine is available under Apache 2.0 and has been around for years, and has backward capability back to XE4. The playground plugin is similar to the standalone playground demo app that exists in the project. Anyways, I decided it was time to have a richer IDE experience. My initial development currently it supports: - highlighting (script tags, comments, numbers, strings) - toggling whitespace visibility - IDE Options Dialog allows you to customise options (overriding defaults which are IDE theme aware) - Supports prototyping templates against mock data (in json files) - Supports script tags <% %> or {{ }} - Real-time validation of templates and evaluation/preview - Preview as raw text or in a browser As I changed the license of the template engine to be Apache from GPL, this will be available initially to supporters of the project. More to follow... Any other ideas/improvement suggestions welcome. Here are some screenshots:
-
Sempare Template - How to get contextual data in a utility class method?
darnocian replied to Edwin Yip's topic in Delphi Third-Party
I stumbled across this thread again and thought I'd just add a reference to https://dev.to/sempare/accessing-data-from-the-sempare-template-engine-for-delphi-5dg8 It illustrates various approaches to accessing data from the template engine. In the thread above, we discussed static methods, but in the article you can easily see how you can access data from data stored in the context, or by creating a custom object with methods on it, which can then be called. -
TValue.ToString for TAlphaColor type returns a strange result.
darnocian replied to dmitrybv's topic in RTL and Delphi Object Pascal
AColorProp := LType.GetProperty('ColorProp'); Val := AColorProp.GetValue(ColorObj); //Memo1.Lines.Add('ColorObj.ColorProp.ToString = ' + ColorObj.ColorProp.ToString); Memo1.Lines.Add('ColorObj.ColorProp.ToString = ' + Cardinal(ColorObj.ColorProp).ToString); Memo1.Lines.Add('TValue.ToString = ' + Val.ToString); Should Val.ToString not be Val.AsType<TColorObj>.ToString ? I don’t think TValue.ToString is what you were expecting. It is more diagnostic in nature if you look at its implementation, as it supports all kinds of types. I suspect that what you’re seeing is simply an interpretation based on the contained value. However, in RTTI, these values are usually cast to their correct types—especially when passed to a TRttiMethod or similar, where FTypeInfo is considered appropriately. -
Execution time difference between 32b and 64b, using static arrays
darnocian replied to lg17's topic in General Help
I made a little FMX test app a few years back just to see how floating point differed in performance cross platform: https://github.com/darnocian/delphi-gausslegendre-pi-approximation-test It was nothing special and just a test using Extended / Double. The approximation function was implemented in https://github.com/darnocian/delphi-gausslegendre-pi-approximation-test/blob/master/gauss.legendre.pi.pas I havn't run the benchmark again recently, but at the time, it did highlight that cross platform, a review was required of how the underlying floating point stuff was being done in the various compilers as some were way out... -
I have witnessed similar behaviour actually with the MS memory manager. For one of my projects, I also switched to using the MS memory manager. I did benchmarks a while ago, but will look into publishing something in future.
-
I think the official term being referenced is 'string interning'.https://en.wikipedia.org/wiki/String_interning Scenarios where it may be useful is with JSON, results from dbs, or when custom collections containing strings from file or network. Depending on how the data is pulled in, you may have a spike in memory if all f the raw data is loaded, followed by the interning process which may normalise the structures. If the data is loaded incrementally, memory utilisation should correlate to the levels of duplication you know exists in the data. There is some overhead to the interning process in terms of constantly trying to deduplicate, so it depends on your scenario. If you keep the data in memory for a longish period of time, I think it can be useful to do this, especially if you are a ware that memory utilisation is a concern in your problem space. C# has a .Intern() method on string https://learn.microsoft.com/en-us/dotnet/api/system.string.intern?view=net-8.0. Similar in Java https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/String.html#intern() As Delphi strings are reference counted, you could say that having multiple variables assigned to the same string would be a form of interning. e.g. var str := 'hello world'; var str2 := str; var str3 := str; All of the above will reference the same data. Under the hood there should be a reference count (3). A non thread-safe approach to illustrate leveraging the above property by managing a TDictionary<string,string>: var GInternedStrings : TDictionary<string,string>; function Intern(const AString:string) : string; begin if not GInternedStrings.TryGetValue(AString, Result) then begin GInternedStrings.Add(AString, AString); Result := AString; end; end; initialization GInternedStrings := TDictionary<string,string>.Create; finalization GInternedStrings.Free; Here we see a lookup being done on the pool, and result being populated with a value from the pool if it exists. If no value exists, we simply add the value too the pool, and return the original. This could be used like: for var rec in records do begin rec.str := Intern(rec.str); end; Obviously, if you decide to go multi threaded, you would need to introduce some synchronisation, which will add some performance overhead due to locking and unlocking to keep the dictionary consistent. If you don't do anything multithreaded, you can get away with not having a sync object and could even just allocate a local pool in your loading procedure to localise the lifetime of the pool. Having the global pool will mean that you will have that memory 'permanently' allocated... so however you decide to manage the pool depends on your use case. Ideally, the functionality that loads data, such as TJSONValue.ParseJSONValue() or db query libraries would offer an option to do this. However, in many cases, I suspect it may be seen as an overhead in itself if the data is loaded into memory, processed and discarded. So the lifetime of the data in the app and how it is used is relevant to the effort of doing this all over.
-
Sempare Template Engine 1.8.0 and license change to Apache 2.0
darnocian replied to darnocian's topic in I made this
For those that are interested in a few lightweight tutorials, here are some short reads: Accesing a FireDAC dataset from the Sempare Template Engine for Delphi Accessing data from the Sempare Template Engine for Delphi Creating layouts using the Sempare Template Engine Configuring the Sempare Template Engine for Delphi Using the Sempare Template Engine for Delphi Using loops in the Sempare Template Engine for Delphi Functional templates with the Sempare Template Engine for Delphi Introducing the Sempare Template Engine Playground Wizard for the Delphi RAD Studio IDE -
Sempare Template Engine 1.8.0 and license change to Apache 2.0
darnocian replied to darnocian's topic in I made this
@Ian BranchThe new version 1.8 is now available on GetIt. -
Sempare Template Engine 1.8.0 and license change to Apache 2.0
darnocian replied to darnocian's topic in I made this
Yes. The request is in, but it takes a few days. -
The BEST template engine for generating webpages on the server side?
darnocian replied to Edwin Yip's topic in Tips / Blogs / Tutorials / Videos
Ok. I won't in future. 😉 -
The BEST template engine for generating webpages on the server side?
darnocian replied to Edwin Yip's topic in Tips / Blogs / Tutorials / Videos
Again, sorry for the cross post: The Sempare Template Engine is now available under the Apache 2.0 licensing. -
Sempare Template Engine 1.8.0 and license change to Apache 2.0
darnocian posted a topic in I made this
Hi, I am pleased to announce a new version of the Sempare Template Engine - v1.8.0. (https://github.com/sempare/sempare-delphi-template-engine) The Sempare Template (scripting) Engine for Delphi allows for flexible dynamic text generation. It can be used for generating email, html, reports, source code, xml, configuration, etc. Changes: NEW support calling methods on interfaces NEW support accessing properties on interfaces NEW simplified white space removal (https://github.com/sempare/sempare-delphi-template-engine/blob/main/docs/whitespace-removal.md) NEW License change to Apache 2.0 FIX to support issues under XE7 FIX AV when method method does not exist FIX improved error messaging on exceptions FIX regex threadsafety issue in lexer Most notably, license change has been from GPL to Apache 2.0. Commercial supporters are still appreciated for my time, continuous integration, support, etc. For those that don't know what this is all about, I gave a talk at Delphi Devdays 2024 this year. Here is a link to my talk: I'm hoping the Sempare Template Engine still remains one of the more feature rich, easy to use, and most pascal centric template engines out there for Delphi. Next focus in the development pipeline is native code generation from existing templates to allow you to get native speed without requiring you to make any changes (except including another source file that is auto generated from your templates). Sponsorship is appreciated. -
The BEST template engine for generating webpages on the server side?
darnocian replied to Edwin Yip's topic in Tips / Blogs / Tutorials / Videos
Hi all, I apologise for doing a double post, but some people don't see the posts everywhere. For any users, or anyone interested in the Sempare Template Engine, I would love to get some feedback from you to help with next steps in development on the project. The questionnaire is a bit general, as the objective is to guide the direction of this project and another I will be releasing soon as well. https://docs.google.com/forms/d/e/1FAIpQLScioIiDxvsWK01fMFqYr9aJ6KhCGeiw4UaU_esGuztEE7vYwA/viewform Thank you in advance. Regards, Conrad -
Hi all, For any users, or anyone interested in the template engine, I would love to get some feedback from you to help with next steps in development on the project. The questionnaire is a bit general, as the objective is to guide the direction of this project and another I will be releasing soon as well. https://docs.google.com/forms/d/e/1FAIpQLScioIiDxvsWK01fMFqYr9aJ6KhCGeiw4UaU_esGuztEE7vYwA/viewform Thank you in advance. Regards, Conrad
-
detecting events
darnocian replied to direktor05's topic in Algorithms, Data Structures and Class Design
your reference to 'debugview' makes it look like you are also after a logging framework. On getit, there are some options. Using a debugger is great for fault finding, but logging will help with a running app. Using a logging framework, you can decide when you want to enable/disable logging. If you have a console app, the poor man version is 'writeln' 😉