Thursday, May 15, 2014

XE6–Links for the presentation

On today’s presentation I promised listeners a bunch of links so that they didn’t have to write them down. Here they are:
By the way, RAD Studio XE6 was well excepted. People really liked not only the focus on stability (although that was the favorite by far) but also the new additions – tethering, BaaS and support for advertising and in-app purchases.
image
Photo was taken during the PhotoWall demo and is blurry, as I was more focused on describing the simplicity of app tethering than on taking the shot. Sorry!
BTW2, the app tethering is way way cool! Check it out!

Monday, May 12, 2014

Adding Borders to Pictures

Besides being a programmer, I like taking pretty pictures (and working with wood, but that’s another story). And from time to time I like to print some pictures and hang them on a wall.

Because framing pictures is expensive and, frankly, most of them don’t deserve it, I like to print a “virtual frame” – a thin black border followed by a wide white border – around each photo. Until recently, I was adding them in some stupid program I found on the Internet (it doesn’t deserve to be named), but I was always having problems because you had to specify border width in pixels – and if I wanted to set the same border (for example, a 1,5 mm black border followed by a 20 mm white border) for a set of pictures in a different resolutions, I had to calculate pixel sizes for each photo, which was a pain.

So I sat down and wrote a border-adding program. It allows you to specify border sizes in “real” measures, it can process one picture or a folder full of them and it can add a suffix to processed pictures (plus it will skip files containing this suffix if they are found in the source folder) and that’s about it. It is small, simple, solves a real problem and – what I found the most impressing – I wrote it in a single working day. Truth to be told, I needed about a month of work – an hour here, 15 minutes there – but all together I needed less than eight hours. That is the power of Delphi!

If you have a need for such tool, go ahead and download it from my Dropbox. You can also get the source, which is released to a public domain (i.e., do with it whatever you want). It depends on few external libraries, which are all released with an open source license: JCL, JVCL, GpDelphiUnits, OmniXML. At the moment the GUI is written in VCL, because I really didn’t want to spend too much time on this project and I know VCL by heart, but if somebody wants to go ahead and rewrite it in FireMonkey, I certainly won’t stand in his/her way.

image

image

Friday, May 09, 2014

XE6 Launch in Slovenia

Join me in Ljubljana on May 15th when I’ll be showing all the goodies that came with recently released RAD Studio XE6.

Register here.

Saturday, April 12, 2014

Safe-casting Pointers

You cannot safe-cast a pointer. This will fail:

ptr as TProject

You can only cast pointers the unsafe way:

TProject(ptr)

That is, unless you use this neat trick:

TObject(ptr) as TProject

This will also catch programming errors, specifically a pointer that doesn’t point to an object.

Monday, April 07, 2014

Short tips: PNGImage

If you have problems processing PNG images because you are using DevExpress components, add this to the beginning of your program’s uses list:

  dxGDIPlusClasses,
Vcl.Imaging.PNGImage,

DevExpress registers PNG handler with doesn’t behave exactly the same as Delphi’s built-in TGraphics descendants. With this addition, PNGImage.RegisterFileFormat will be called after dxGDIPlusClasses.RegisterFileFormat and will overwrite DevExpress’ PNG handler.

Thursday, March 13, 2014

IOmniPipeline termination bug

There was a nasty race condition in the IOmniPipeline termination code which could result in access violations. It has been fixed in the SVN so please update to the latest version if you are using Parallel.Pipeline, Parallel.BackgroundWorker, or Parallel.ForkJoin.

Great thanks go to Dean from DeNovo Software who narrowed down the problem and make sure I can repeat it on my machine.

Friday, February 28, 2014

RAD Studio XE5, C++, iOS etc … in Slovenia

This Tuesday (March 4th) Embarcadero and Marand are organizing a RAD Studio XE5 presentation in Ljubljana. We’ll be showing great features that were implemented in RAD Studio in the past few years – from 64-bit Windows compilation, Unicode support and styling to multiplatform development, LiveBindings and FireDAC. For the first time in Slovenia we’ll be presenting the new REST library and C++ support for iOS.

Presentation will be given in Slovenian language. Register here.

Friday, February 07, 2014

Worst. Interface. Ever.

As seen on Blogger:

image

I have just written a reply and clicked “Sign out”. For the third time since the Google changed the Blogger UI!

I don’t care that the “Publish” button is highlighted. “Sign out” is just placed in perfect position to click on when you are typing a response.

Fix this, Google!

Thursday, January 09, 2014

OmniThreadLibrary 3.03b – Small version change, big update!

Yesterday I noticed a big nasty bug in the OmniThreadLibrary which was present in for a long long time. If a thread priority was not explicitly specified (by calling SetPriority OTL function or SetThreadPriority Windows API), a thread was started with idle priority (instead of normal).

How comes nobody has noticed that? Well, it looks like the Windows thread scheduler is really great and nicely schedules threads even in such case. Still, this is something that has to be fixed and I have immediately released new version.

If you’re using OTL, please download the newest version or update from the SVN.

New features

  • Added SetPriority function to the IOmniTaskConfig.
  • Added indexed writers ([number] and [name]) to both TOmniValue and TOmniValueContainer.

Bug fixes

  • Thread priority is set correctly (to 'normal') if it is not explicitly specified.
  • Corrected swapped content of 'Schedule Observed'/'Schedule Unobserved' methods in the 11_ThreadPool test (tnx to [semele]).
  • Locked<T>.Free can be called if Locked<T> owns its Value.

Friday, December 13, 2013

It’s that time of the year …

… when you can get “Parallel Programming with OmniThreadLibraryand three “High-Level Multithreading with OmniThreadLibrary” for a reduced price!

Go to https://leanpub.com/omnithreadlibrary and buy the “The Book + Webinars” package for mere $29.99!

By the way, now you can buy a site-wide license – buy the book and give it to anybody in your organisation for mere $250! Plus you get all three webinars in the deal.

Monday, December 09, 2013

Smart Mobile Studio 2.0 beta 1

I know we promised it for November so here it is – Smart Mobile Studio 2.0 beta 1, released on November 39th ;)

I know some were waiting anxiously for this release so joke aside – we are sorry that we couldn’t release it in November but you know how it goes – there is always one more showstopper problem :( We know that this beta is not yet perfect (and we’ll release another one before the product is finalized) but as we do want your feedback we have exposed it for the public consumption.

A list of changes since the last released version is available here.

In case you were not actively following Smart since the last release, I would like to recommend few interesting articles on our site:

And remember – Smart targets everything from microcontrollers (Espruino) to mobile devices (in-browser, PhoneGap, Cordova), desktop (in-browser) to servers (NodeJS).

Saturday, December 07, 2013

SapMM

This is a guest post, written by Anton Alisov, software PM and developer from Ivanovo city, Russia.

I’m posting it here because I want to increase visibility of this new memory manager which featured quite well on my recent test (guest posted at Eric’s blog). I’m perfectly aware that my test was superficial and I intend to do a better test with more memory managers in the following weeks.

Arnaud Buchez already posted a overview of the memory manager on his blog.

And now I’ll give word to my colleague Anton.


We were waiting for the robust and scalable memory manager for Delphi for the long time. Our best choice - FastMM - did not scale well under multithreaded use in memory intensive applications. Memory manager with
a new design was required. We have tested many scalable managers such as TopMM, ScaleMM and other. Some of them are quite robust, but not supported currently by its developers (TopMM), some are not yet ready
for production. So, we decided to develop our own memory manager to have more control over it. We believe, one doesn't have to be big to be efficient. Meet a new player - SapMM - Simple As Possible Memory Manager.

SapMM is robust, production quality memory manager, developed by software guru Alexei Nedoria from Ivanovo city, Russia. SapMM was designed for use in memory intensive multithreaded applications with the
scalability in the first place. In single threaded use SapMM is only a bit (up to 40% on certain scenarios) slower than FastMM (on some scenarios SapMM is faster than FastMM even in single threaded use), but
the real power of SapMM shows in multihreaded applications. SapMM scales very well and in a vast majority of scenarios is much faster than FastMM in multithreaded use.

SapMM is used in production 24/7 system since June 2013. Currently SapMM was well tested only with Delphi XE and XE3, small code changes may be required in order to use it with other versions of Delphi. Currently SapMM supports only 32-bit mode and cannot be used in 64-bit applications. You can grab SapMM sources and do some tests yourself: https://code.google.com/p/sapmm/

Monday, November 25, 2013

Embarcadero Academy – Android Programming

Next Tuesday (December 3rd) we’ll continue the Embarcadero Academy line of presentations for Slovenian developers. This time I’ll cover programming for Android devices in Delphi XE5.

Register here.

Predavanje bo v slovenskem jeziku.

Sunday, November 17, 2013

ITDevCon 2013 Slides, Code and Photos

ITDevCon 2013 has finished and as always it was a beautiful (but wearying) experience. I’m still trying to pull myself together.

My session slides and code are now available on this blog – just click on the Presentations link on the right.

Some snapshots from the conference (take with the crappy camera on the Sony Xperia P phone):

01_
Opening session

02_
Last preparations …

03_
Smart Mobile Studio everywhere

04_
Three fifths of the Smart Mobile Studio team

05_
Christian during the “LLVM” presentation

06_
Stefan Glienke talking about Spring4D

07_
The Spring4D session was packed

08_
Christian preparing for the “Microcontrollers and Pascal” session

Wednesday, October 23, 2013

ITDevCon 2013–Lots of hard choices

Yellow – sessions I’d like to attend.

Green – sessions I really want to attend.

Red – sessions I have to attend.

Can somebody please invent a time machine before November 14th?

image

Monday, October 21, 2013

OmniThreadLibrary 3.03a

OmniThreadLibrary 3.03a has just been released. This is purely a bugfix release which fixes ugly problem in the ForEach abstraction. If the code has called ForEach with empty input set (for example, ForEach(0, –1)), the program would block infinitely.

OTL 3.03a is available via SVN or as a ZIP archive.

ITDevCon 2013

image

The ITDevCon conference is almost there (register while you still can!). As four times before, the organizer has invited an impressive list of speakers which will be giving 19 presentations (if I counted correctly), divided in three parallel tracks over two days. The conference will occur on 14th and 15th in the beautiful city of Verona.

On the first day of the conference I’ll be presenting two Delphi-related sessions. In the Using attributes and RTTI to automate programming tasks talk, I’ll introduce a concept of attributes in Delphi and present few different practical uses for this interesting but underused language concept.

In my second session of the day, Continuous Integration, delivery and deployment, I’ll talk about continuous integration and its cousins, continuous delivery and continuous deployment. In the session I’ll present few different software tools that support those concepts and I’ll also speak about practical experiences with continuous integration in the field.

On the second day of the conference, both my sessions will revolve around the Smart Mobile Studio. [BTW, four SMS developers will be visiting – and presenting at the conference. This year’s ITDevCon is a great place to discuss JavaScript programming with Pascal!] In the Smart Mobile Studio today session I'll present new release of Smart Mobile Studio 2.0, which should be released soon after the ITDevCon. SMS 2.0 will support new targets (Node.JS, Espruino, Web Workers), contain new components and libraries (grid, new game framework) and new data connectors (DataSnap) so I’ll have problems showing everything new inside the one hour time frame.

In my second session of the day, From Zero to Hero in 60 minutes, I'll try to write a very simple client/server mobile application in one hour. The client side will run in a browser, the server side in Node.JS, and both will be written in Pascal without adding a single line of JavaScript. Participants will be welcome to test the application while it is being developed.

I hope I’ll see you in Verona so we can talk about Delphi, Pascal, and everything related and unrelated!

Tuesday, October 15, 2013

OmniThreadLibrary 3.03–quick fix

Yesterday’s 3.03 version was somehow corrupted (in a way that it doesn’t compile). I have no idea what I did wrong as I did recompile test apps before committing and they did compile. Anyhow, if you’re one of the first 85 downloaders, please download the corrected version or implement a very simple fix. In the OtlParallel unit on the line 1663 a class prefix is missing. Just type it in and everything will work.

class procedure Parallel.ApplyConfig(const taskConfig: IOmniTaskConfig; ...

The management apologizes for the inconvenience. ;)

EDIT 2013-10-16: It has been brought to my attention that both the original 3.03 and yesterday's fix were missing the XE5 packages. This has been now fixed. You can download missing packages from here.

Monday, October 14, 2013

OmniThreadLibrary 3.03

OmniThreadLibrary 3.03 has just been released. It is available via SVN or as a ZIP archive.

What is OmniThreadLibrary?

OmniThreadLibrary is simple to use threading library for Delphi. It's main "selling" points (besides the price, of course are power, simplicity, and openess. With just few lines of code, you can set up multiple threads, send messages between them, process Windows messages and more. OmniThreadLibrary doesn't limit you in any way - if it is not powerfull enough for you, you can ignore any part of its "smartness" and replace it with your own code. If you don't like working with threads - no problem! You can use high-level primitives like parallel for, futures and pipelines to introduce parallelism into your application.

OmniThreadLibrary is an open source project. It lives in the Google Code and is licensed under the BSD license.

At the moment, OmniThreadLibrary supports Delphi 2007, 2009, 2010, XE, XE2, XE3, XE4, and XE5 on the Win32 and Win64 platforms. Currently, there are no plans to support older Delphi compilers and .NET. XE2+
support is limited to Windows targets. Firemonkey is currently not supported.

Where can I get more information?

Home page: http://www.omnithreadlibrary.com/
Web discussion forum: http://otl.17slon.com/forum/
Downloads: http://code.google.com/p/omnithreadlibrary/downloads/list
Issue tracker: http://code.google.com/p/omnithreadlibrary/issues/list
SVN checkout instructions: http://code.google.com/p/omnithreadlibrary/source/checkout
Author's blog: http://thedelphigeek.com
Author's home page: http://www.glagolite.si/delphi/
Documentation wiki: http://otl.17slon.com/book/
Documentation book: http://http://leanpub.com/omnithreadlibrary

Changes since version 3.02

New features
Bug fixes
  • Fixed XE2/XE3 package compilation.
  • TOmniBaseBounded(Queue|Stack) internally aligns allocated memory to required CAS granularity (8 bytes on 32-bit platforms, 16 bytes on 64-bit platforms) (tnx to [Alexander Alexeev]).
  • TOmniBaseBoundedQueue's ring buffers are internally aligned to 2*SizeOf(pointer) (tnx to [Alex Egorov]).
  • Prevent memory leak if (Queue|Stack).Initialize is called more than once (tnx to [h.hasenack]).
  • Fixed memory leaks in `forEach output` and `checkVat` examples(tnx to [Steve Maughan]).
  • Fixed TOmniTaskGroup.TerminateAll.
  • Simple pipeline stage handles exceptions in the executor function.
  • Compiles when 'Typed @ operator' is enabled (tnx to [arioch]).
  • Removed optimization which caused ForEach to behave differently on uniprocessor computers.
New demos
  • 54_LockManager: Demonstrates the new lock manager (IOmniLockManager<K>).

Friday, October 11, 2013

TStreamAdapter.Seek – Apology

Sometimes you write a blog post that you wish you wouldn’t. Maybe you don’t, but I certainly did. Yesterday I wrote about TStreamAdapter.Seek Broken For Large Files I completely incorrectly stated that “the bug was not fixed in XE4/XE5”.

The reason for my mistake was that although I verified the problem in the XE2, I didn’t write any test code for it (we already had a failing application so I didn’t have to – or so I thought) and I only checked the RTL for changes. I found out that the TStreamAdapter.Seek didn’t change from XE2 to XE4/5 and assumed the worst.

Well, the good guys at Embarcadero did fix the problem in the meantime – but in a different place. They have added a new Seek overload to the TStream class and this new Seek (which is implemented as an inline function) acts as an intermediary between the TStreamAdapter and the correct TStream.Seek method. This solution is much better than our quick fix as it also fixes all other code in the world which mistakenly calls the wrong Seek overload.

function Seek(Offset: Longint; Origin: Word): Longint; overload; virtual;
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; overload; virtual
;
function Seek(const Offset: Int64; Origin: Word): Int64; overload; deprecated; inline
;

function TStream.Seek(const Offset: Int64; Origin: Word):
Int64;
begin
Result := Seek(Offset,
TSeekOrigin(Origin));
end
;

Thanks to the Arioch’s prompt in the original post I did write a test code today and when I finally tested it on the XE5, it run just fine! Imagine my shame. :(


What have I learned today? That looking at the source code is not enough, especially if you want to complain. Always write a test case (and then run it!).


I deeply apology to Embarcadero programmers (especially to the guy who fixed the original error) and to you, my readers.


And now, if you’ll excuse me, I’ll pull a cover over my head and gently weep.