Writeln ( True); Magic;Writeln ( True);
… output this:?
TRUE FALSE
Simple!
Writeln ( True); Magic;Writeln ( True);
TRUE FALSE
case a of
0: Writeln(0);
else
Writeln('else');
Writeln(a);
end;
This code indeed compiles and works exactly as the following fragment.case a of
0: Writeln(0);
else begin
Writeln('else');
Writeln(a);
end;
end;
I personally would never drop begin/end inside a case/else statement, but at least someone must disagree. I found such example in a very (VERY!) old code (it was written for Delphi 2) and I was quite surprised that it compiles at all.case a of
0: Writeln(0);
else
Writeln('else');
Writeln(a);
end;
I guess this makes more sense (but just an itsy bitsy teenie weenie bit more).Slides and code for the Spring4D conference are now published on the conference page.
Slides and code for my two sessions – Design patterns with Spring4D and Interception and dynamic proxy – are also available on my presentations page.
TLThere were, however, other interesting results that my simple benchmark pointed out. More on that in a moment, but first…; DR Yes, allocating from the top is slower. No, the difference is not big and in most cases you’ll not even notice it.
While writing Design Patterns with Delphi, I spent quite some time researching existing literature on design patterns implementation in Delphi, design patterns in other languages, other types of patterns, design principles and so on …
In case you would like to dig deeper than the book takes you, here is my reading list.

“Bee there Orr Bee A Rectangular Thyng
”
- The Band With Rocks In *
Slovenian company BASS is looking for a Delphi developer (on-site in Celje, Slovenia).
(I’m not affiliated with them; they just asked me to spread a word around. If you have any questions, contact them directly.)
Hurrah, hurray, my third book is here! It’s called Hands-On Design Patterns with Delphi and (just like my first book) I wrote it for Packt Publishing. (The second book was self-published and I expect the fourth one to be, too.)
As the name says, “Design Patterns with Delphi” deals with design patterns. It is a bit different from most of design pattern books and websites you will find on the Internet. Case in point A: There are no UML diagrams. I don‘t speak UML. Tried to learn it few times but for some reason the whole concept doesn‘t agree with me. If you like diagrams, don’t fear though. Any book on design patterns - and most websites covering that topic - will gladly show how any design pattern can be diagrammed. That, however, is not important and should not govern your decision to buy the book.
More important is case in point B: This book speaks Delphi. All the examples are written in Delphi and language features are used to the full. I also covered few less known Delphi idioms in separate sections. You’ll still be able to follow the discussion even though you may program in a different Pascal dialect.
There’s also case in point C: Examples make sense. I deeply dislike classical design pattern examples of the “And then we want to write this program for different toolkits and it should also be able to draw circles, not only squares” kind. Euch! I tried to find a good example for each design pattern. Admittedly, I ended with few examples that draw triangles and squares on screen (mostly because some patterns were designed specifically for solving such problems), but most of them are of a more practical nature.
This book covers all three classical design pattern categories - Creational patterns, Structural patterns, and Behavioral patterns. It also discusses patterns from the newer Concurrency patterns category. At the end I threw in some borderline-pattern(ish) topics and ended with a discussion of few patterns that cannot be strictly classified as “design” patterns.
In this book you’ll find:
I hope you will like this book and learn a lot from it. I know I did during the nine months I spent writing it. And if you find any bug in the code, let me know so I can correct it in the second release!
New OmniThreadLibrary is out! Get it while it’s hot!
Version 3.07.7 is mostly a bugfix release. It fixes a stupid mistake introduced in version 3.07.6 plus some other minor bugs.
You can get it now on git, download the ZIP archive, install it with Delphinus or with GetIt.
For more information, visit OmniThreadLibrary home page or write your question on the forum.
On December, 6th I’ll be showing all that is new and shiny in 10.3 Rio to anyone that happens to pass by!
Join me in Ljubljana at 9:30 in the “standard” venue … just don’t forget to register first.
Today I was porting some legacy code and noticed a weird warning:
Weird warning, I thought. Obviously the loop variable can be passed as a var parameter as the code compiles. Why a warning and not an error, then?
When writing libraries you sometimes want to provide users (that is, programmers) with a flexible API. If a specific part of your library can be used in different ways, you may want to provide multiple overloaded methods accepting different combinations of parameters.
For example, IOmniPipeline interface from OmniThreadLibrary implements three overloaded Stage functions.
function Stage(pipelineStage: TPipelineSimpleStageDelegate;
taskConfig: IOmniTaskConfig = nil): IOmniPipeline; overload;
function Stage(pipelineStage: TPipelineStageDelegate;
taskConfig: IOmniTaskConfig = nil): IOmniPipeline; overload;
function Stage(pipelineStage: TPipelineStageDelegateEx;
taskConfig: IOmniTaskConfig = nil): IOmniPipeline; overload;
Delphi’s own System.Threading is even worse. In class TParallel, for example, there are 32 overloads of the &For class function. Thirty two! Not only it is hard to select appropriate function; it is also hard to decode something useful from the code completion tip. Check the image below – can you tell which overloaded version I’m trying to call? Me neither!
Because of all that, it is usually good to minimize number of overloaded methods. We can do some work by adding default parameters, but sometimes this doesn’t help. Today I’d like to present an alternative solution – configuration records and operator overloading. To simplify things, I’ll present a mostly made-up problem. You can download it from github.
Delphi High Performance is, as the name says, a book about writing Delphi applications that perform well. That does not mean writing multithreaded applications - and I say this many times in the book. To write high performance applications you need to known much more. The book therefore starts with the basics - with the algorithms, how we can classify them, how they behave and how can we pull the most from the built-in Delphi data structures. Then it moves to profilers because you should never guess what the slowest part of the code is. Always measure!"This is the best Delphi book (for me personally) I've read since 'Delphi in a Nutshell'. It is 'must buy' for our department and mandatory that everyone reads it."
This post contains just a bunch of links to online resources that I mentioned on the today’s presentation.
In two days I’ll present RAD Studio 10.2 Tokyo in Ljubljana.
Click here for more information and to register.
This update brings only few small changes. The biggest of them is support for the Delphi 10.2 Tokyo.
You can get it as a zipped download, git checkout, via Delphinus, and via GetIt.
For more information on OmniThreadLibrary, go to www.omnithreadlibrary.com.
Forward declaration is not really a new concept. It was already present in the original Wirth Pascal where it allowed the programmer to do one thing and one thing only – call procedure A from procedure B and procedure B from procedure A. Remember – in ye olde times of good old Pascal we had no interfaces, no classes, no units … just procedures and functions.
Because the code tells more than thousand words, here’s an example (still perfectly valid in modern Object Pascal).
procedure ProcA; forward;
procedure ProcB;
begin
ProcA;
end;
procedure ProcA;
begin
ProcB;
end;
New year, new release ;) You can get it as a zipped download, git checkout, via Delphinus, and via GetIt.
For more information on OmniThreadLibrary, go to www.omnithreadlibrary.com.
It is almost time for a new release! If you’d like to see what 3.07 will contain – or if you just want to test it before it is out – click here.
[If you are a serious OTL user - and especially if you are using pre-Seattle Delphi - please test your program(s) with the beta release. Thanks!]
I have started work on OTL 4.0 which will (fingers crossed) fully support cross-platorm work. Yup, it will work on all platforms that Delphi can compile for! Multiplatform support was implemented by Sean B. Durkin so if OTL/Mobile is something you were waiting for a long time, go to OmniThreadLibrary-For-Mobile Google+ community and express your gratitude.
This post contains just a bunch of links that I refered to in my two-part (live) presentation on version control management with RAD Studio and Git.
This is an announcement for the next Slovenian “Embarcadero Academy” session. As it is intended for Slovenian Delphi programmers, the rest of this post is in the Slovenian language.
This year I’ll be presenting two sessions at CodeRage XI.
On Wednesday, I’ll be exploring the topic of debugging in RAD Studio. I’ll show how advanced options in breakpoint properties work and drop some debugging tips & tricks here and there. Join me in room 1 at 7 am PST / 10 am EST / 16.00 CET.
On Thursday I’ll be demoing new enhancements in FastMM. If you are writing multithreaded code, then this session will be targeted to you! Join me in room 1 at 10 am PST / 1 pm EST / 19.00 CET.
As I’m pretty sure many Delphi programmers will be working on their CodeRage XI videos this weekend ;) , I decided to repost a link to my year old post Recording Webinars – My Workflow. Maybe it will be of some use to you.
Another week, another critical update …
There was a logical error – also known as “my own stupidity” – built into OTL 3.06 which prevented programs that used OtlCommon to be started on Windows XP. This is now fixed.
There’s also a tiny addition to OtlSync included in this release.
There was a nasty bug in DSiWin32 unit included with the 3.06 release so I had no other option than to quickly issue a fix. If you have downloaded version 3.06 then please update to 3.06.1 as with 3.06 you could experience weird crashes during program startup. I’m really sorry for that :(
There’s also a tiny addition to TOmniValue included in this release.
Hi, guys! After a looong time, a new version of OmniThreadLibrary was released! It is available as a zipped download, git checkout, via Delphinus and (really soon) via GetIt.
Following stuff was added/changed/fixed since the 3.05 release:
For the last year and some, Sean B. Durkin has been working on the mobile port of the OmniThreadLibrary. There was lots to be done, as OTL was never designed to be a portable library – after all, it was created in Delphi 2007 times.
Recently I merged his latest commits into the mobile OmniThreadLibrary branch. This version is (by his words) functionally complete (although it may be missing some very recent OTL features) but is very much untested. So Sean is asking everybody that is interested in multithreading on OS/X, iOS, and Android to help him find bugs and to make OTL even more awesome!
Please report any findings to his OmniThreadLibrary-For-Mobile-DevelopmentProject on Google+. I am currently working on other aspects of the OTL and didn’t I put much energy into checking his work.
In case you are wondering which of the many github (and even bitbucket) omnixml repos is the official one (as www.omnixml.com is still pointing to the old googlecode storage), this is it: https://github.com/mremec/omnixml.
www.omnixml.com should be pointing to the correct repository “real soon now” ;)
In case you are already using RAD Studio Berlin 10.1 or are merely looking into it, these links and notes may help you.
YouTube videos
Next week (Wednesday 25th) I’ll be presenting the new and shiny 10.1 release in Ljubljana.
For more info click here.
Next Wednesday (9th) I’ll be holding a presentation in Ljubljana. Topic: defensive programming, maintaining a clean code, and debugging tips and tricks. Presentation will be applicable to both Delphi and C++Builder programmers.
As usual, I’ll be presenting in Slovenian language.
Recently, I had to find bottlenecks in one of our applications that does all sorts of things related to DVB and is handling real-time reading and sending of data streams over IP with bitrates up to 80 Mb/s (in our lab; in real life maybe even more). Our customer created a configuration which essentially brought the app to the crawl and I had to fix it.
It quickly turned out that although the program was not able to handle the load, the CPU was not very busy. The busiest core was only using about 30% CPU. So I suspected the thread contention problems in FastMM, switched it for SapMM and indeed - the problem went away. CPU load went up and application could again handle the load.
Crisis averted, I took time to find the real problem - excessive get/freemem calls in this program. As far as I could tell, there existed no tool to find that so in a true DIY manner I created my own ;)
The materials for my “Connect your applications with REST” workshop are now available online (in Slovenian language).
Below you can find all the interesting DELPHI- and REST-related links I have collected during the preparation of this workshop.