Sunday, October 05, 2008

Lazarus 0.9.26

It's released, check the Release Notes. As a side note, I've found an interesting website called Fórum Lazarus e Freepascal with a bulletin board in portuguese.

Thursday, March 06, 2008

It's all about freedom

Sometimes a line from a movie transcends the silver screen and becomes a proverb. In Star Wars Episode IV - A New Hope (1977), when the Galactic Empire captures Princess Leia Organa, they tortured her in order to get the location of Rebel Alliance's secret base. Admiral Tarkin then says: "Princess Leia, before your execution, you will join me at a ceremony that will make this battle station operational. No star system will dare oppose the Emperor now." Her answer is now a legendary movie quote:
"The more you tighten your grip, Tarkin, the more star systems will slip through your fingers." (Princess Leia Organa)
This quote has been used, since then, as a proverb about freedom. When a government (or company) implements policies to supress or reduce freedom, people and customers start to circumvent these policies. There's a lot of webpages using this proverb in different contexts. A few examples:

Hollander Space uses the quote in an article about the "indecency test" used by FCC in order to fine broadcasters. He mentions a civil suit filed by four television networks (Fox, CBS, NBC and ABC) at the Court of Appeals for the Second Circuit in New York, where the Court decided against the government.

Bad Coffee uses it in an article about the leaking of the seventh book of Harry Potter's saga (Harry Potter and the Deathly Hallows), despite of extreme security measures taken by the publisher.

Michael Lambert, in his blog called Ponderings of an Itinerate Programmer, mentions Leia's words in his post about the fight between consumers and two "evil empires": RIAA and MPAA. Both entities are suing consumers with charges of movie and music piracy over the Internet. Jeff Kirvin also uses the very same quote in another article on the subject. This quote is considered an "obligatory quote" at Slashdot when RIAA and MPAA are mentioned.

An article on Storm Pilot website uses the quote as an advice for IT professionals when dealing with customers. The goal is to hide the excitement of a new prospect and the desperation for money: do NOT call the customer every day about a proposal you made.

Microsoft is also compared to the Galactic Empire using this quote. Danifer ran an article about Windows Vista and complained about Microsoft Mail: I’m extremely disappointed with Microsoft’s attempt to rule the email world by programming an application that refuses to play nicely with others. I’m reminded of Princess Leia’s quote from Star Wars “The more you tighten your grip, Tarkin, the more star systems will slip through your fingers.” The author migrated to Thunderbird, from Mozilla.

John T. Kennedy wrote a piece about online gambling ban and said: "The good news about this law is that the online gambling market isn’t going away. Entrepreneurs are not going to abandon the vast profits that have already been demonstrated. Internet markets are going to route around such legal obstacles. This law, if it is enforced, will spur efficient black markets like nothing ever has." John used the quote in a comment posted later.

Even an article about Russia used Leia's words. Ben and Alice comment a story about the Russian ban of Georgian and Moldovan wine and food imports, published by Moscow Times back in 2006. They quote Princess Leia just after quoting the original article: "The Kremlin is consciously and systematically carrying out a policy of isolating itself across the former Soviet Union. The more pressure it puts on former Soviet republics, the more it hurries them into the arms of the West".

This is one of my favorite movie quotes. When you "tighten the grip", reducing the freedom of the people, the inevitable outcome is a failure. As soon as people get less freedom, they start to "slip through your fingers": if it's a country, many will try to escape; if it's a company, customers will look for competitors; if it's a market, the goods will be delivered by smugglers.

It's all about freedom.

Monday, January 28, 2008

Native widgets vs GUI toolkits

When developing cross-platform applications we have a basic decision to make: use a wrapper like wxWidgets (C/C++) or Lazarus/LCL (Pascal) or use a GUI toolkit like FLTK (C/C++) or fpGUI (Pascal). The wrapper relies in the underlying API of the host desktop environment (Win32, Mac OS X, GTK+, X11, Motif, etc) in order to draw its widgets; the toolkit draws the widgets by itself, emulating the native GUI.

There is a very interesting thread about this topic on Lazarus mailing list.

Tuesday, November 13, 2007

Living alone

(This is an English homework).

Back in the early 90's I lived alone. Well, actually I had my sister as flatmate, but she had her own bedroom and was never at home, as she spent most of her time at her boyfriend's place. Nevertheless, it was a good way to assess the pros and cons of living alone. After two years of experience it's even possible to write a few lines on the subject.

It's obvious that the main advantage is the liberty. You can bring in your friends, your girlfriend (or boyfriend if you prefer), have a party any day without having to ask your parents. You can do whatever you please as long as you do not disturb your neighbours. On the other hand, this also means that you need to do all the house keeping: if you leave a glass in the sink, it will stay there forever unless you wash it. Some people claim that only after living alone they realize that the fridge does not get filled magically, the clothes don't get washed by themselves and the bills need to be actually paid.

As a result, you are forced to be very independent. After living alone, even a few blocks from your parent's home (and it was my case), it's easier to break the bonds and move to another city, another state, another country. Nevertheless, precisely because all kids eventually grow and this departure is inevitable, the parents should delegate tasks for the children since they are very young, as a preparation for the adulthood. The mother that crawls after her kids picking dirty clothes from the floor is raising spoiled children.

It could be argued that one may feel very lonely living alone. This is partly true as most of the time you are at home there's nobody else to talk with. However, if you work full-time and study, this may be a bless as you probably arrive home late at night and usually all you want is go to the bed. But in spite of this, it's up to you to have a healthy social life. Some prefer to hang out with friends, others prefer to watch a movie home alone. Nowadays the Internet can be a great way to stay in touch with friends and relatives.

There's a trend called Boomerang Generation, that refers to the young adults that choose to move back home with their parents after a brief period of living on their own, usually college, or to never move out in the first place. Other countries have adopted similar slang to represent this domestic phenomenon. In Italy, the term mammon, or "mama's boys" is used, while the Japanese refer to them as parasaito shinguru, or "parasite singles". In UK, they are known as KIPPERS (Kids In Parents' Pockets Eroding Retirement Savings).

To conclude, it's clear that living alone is a good thing for most young adults. Eventually every children will leave the security of the family home to start their own lives. Although both kids and parents are sure to worry, it's important to realize that this is just another passage in the growing-up process.

Tuesday, July 31, 2007

Back from the dead

After a few months without updates, the porting project is back. Now we are going to port our Point-Of-Sale (POS) module to Lazarus, to avoid Wine's problems with serial communication. We will use the ACBr component set. The other modules will remain coded in Delphi (running under Wine on Linux).

Wednesday, September 13, 2006

Why Delphi Win32 is important

Delphi Win32 is important because of Linux.

Right now it is one of the best options for cross-platform development. Kylix is dead (correct me if I am wrong); Lazarus is not ready yet (but it's on the way); Mono is not good enough yet (and is doomed to play catch with Microsoft .NET). Other portable options (Java/GTK/QT/etc) don't have a nice RAD environment like Delphi.

On the other hand, WINE has evolved (in the last years) enough to run most Win32 applications written in Delphi 7 or less. If the developer avoids certain problematic components, it runs 100% fine. Faster than Java, more complete than Mono, easier to code than GTK / QT / whatever. Been there, done that.

Many software solutions these days are web applications - cross-platform by design. For the few cases where you can't run in a browser, a Delphi Win32 application running under Wine is an excellent solution. This way you can please both markets easily.

Wednesday, September 06, 2006

ACBr and Wine

We are replacing our custom-made ECF (Emissor de Cupom Fiscal) component. The new versions will use ACBr. In other news, the software now runs almost perfectly under Wine. There's no speed issues - it's faster under Wine than it would be if it was written in .NET or Java.

Monday, June 19, 2006

Porting status

The porting is officially paused.

In the last few months, a number of changes were made to the main project (written in Delphi) in order to help the porting to Lazarus - mostly the replacement of problematic components. These changes, helped by recent versions of Wine, improved immensely the emulation under Linux. Right now the software runs smoothly under Wine for 99% of the user profiles.

Wednesday, March 22, 2006

StrToDateDef, RoundTo and BoolToStr

Delphi has 2 functions not present in FPC:
function StrToDateDef(const S: string; const Default: TDateTime): TDateTime;
function RoundTo(const AValue: Double; const ADigit: TRoundToRange): Double;

The first one tries to convert String to TDateTime, and if the conversion fails, the result is the value informed at the Default parameter. The second one does banker's rounding to a given precision, informed in power of ten. To round to cents, you need to pass -2, as 10 ^ -2 is 1/100.

There's another function that is present but has different behaviour. It's BoolToStr:
//--- Delphi's BoolToStr
function BoolToStr(B: Boolean; UseBoolStrs: Boolean = False): string;
If UseBoolStrs is false (the default), it returns '-1' for true and
'0' for false. If UseBoolStrs is true, it returns the strings 'TRUE'
and 'FALSE'. In Free Pascal it's like this:

//--- in objpas/sysutils/sysstr.inc
function BoolToStr(B: Boolean): string;
begin
If B then
Result:='TRUE'
else
Result:='FALSE';
end;

So a call to BoolStr(true) would return '-1' in Delphi and 'TRUE' in FPC. I don't know if it was pointed before, and I agree that returning 'TRUE' makes a lot of sense, but when porting an application this may lead to trouble. A simple "fix" would be add an extra boolean parameter, with the default value of true:
//--- in objpas/sysutils/sysstr.inc
function BoolToStr(B: Boolean; TF: Boolean = true): string;
begin
If TF then
begin
If B then
Result:='TRUE'
else
Result:='FALSE';
end
else
begin
If B then
Result:='-1'
else
Result:='0';
end;
end;

Of course, some may oppose to this change, as it would be a hack made just in order to keep Delphi compatibility.

Wednesday, March 15, 2006

MDI, qtintf70.dll, launcher... all gone

Several changes has been made in the last few weeks. I also managed to actually convert and open the entire project on Lazarus - as expected, it's not compiling yet. The major changes are:
  • No more MDI: all remaining MDI Forms are now converted to SDI;
  • No more qtintf70.dll dependency: after a complete cleaning, no more QT Units are being used. There were a couple QTypes that were missed in the automated CLX - VCL conversion;
  • No more Launcher: the old launcher checks if there's a newer version in a given web server, and using Indy it downloads it; after that it runs the application. Now the own client app does that (using Synapse), calling an external program only if there IS a new version (the external program, already a Lazarus application, only swaps the downloaded file with the file that were being run).
Now I'll focus in the conversion, in order to actually get the project compiled. I know that get it compiled and get it working are two very different things, but hey, I own the damn company. There's no deadline: it's ready when it's ready!

Sunday, March 05, 2006

Lazarus 0.9.12

This release is based on FPC 2.0.2 and the binary packages now contain many standard packages: RunTimeTypeInfoControls, Printer4Lazarus, CGILaz, CGILazIDE, MemDSLaz, SDFLaz, TurboPowerIPro, JPEGForLazarus, FPCUnitTestRunner, FPCUnitIDE and ProjTemplates.

Here are the full announcement and the download page. Enjoy!

Thursday, January 26, 2006

Converting a MDI form to SDI

In the Form itself:
  1. Change FormStyle property to fsNormal;
  2. Change Visible property to False;
  3. Remove the line "Action := caFree;" from OnClose event;
  4. Change property Position to poDesktopCenter or something else (optional);
  5. Override CreateParams to add extra funcionality, like make it have a button on taskbar or make it become indepent from the main form (optional);

In the caller Forms:
  1. Change "Application.CreateForm(FormClass,FormName)" to FormName.Show;

In the Project Options, tab "Forms":
  1. Move the Form from "Available" list to "Auto-create" list (if needed);
That's it.

Tuesday, January 17, 2006

MDI x SDI

My project has several MDI forms. Right now I'm studying the conversion of all MDI forms to SDI, not only because Lazarus does not support MDI, but also for usability issues. I've read several sources basically stating that MDI is harmful - and for what I see in daily basis, I agree. Here I quote Joel Spolsky (from the www.joelonsoftware.com site):

Here are the usability problems people have with MDI:

* They accidentally minimize a child window, e.g. by double clicking it's title bar, and don't know what they've done. Then they think the other windows are lost.

* They get into a state where the child windows are not even visible because the main window is too small or scrolled away, and don't know what they've done. Then they think the window is lost, and choosing it from the Window list does nothing.

* They close the app when they meant to close a child window because the X's icons are so close.

There are a whole range of other pathologies. Programmers are very logical people and understand MDI quickly. Most end users just don't get it and usability on these apps is terrible.

Joel Spolsky
Wednesday, January 16, 2002

What can I say? He's damn right: been there, done that. Porting my project to Lazarus will be a hell of a excuse to get rid of MDI for good.

Wednesday, January 04, 2006

FPC 2.0.2 and postgresql3dyn

The Win32 binary installation of FPC 2.0.2 does not have the postgresql3dyn unit. This unit is not needed in order to compile Lazarus itself, but it IS needed by sqldb. Once Lazarus needs the FPC sources for some features, and most people have them, it's easy to solve this problem.

Considering the FPC binaries AND sources are in C:\FPC\2.0.2:

1. mkdir C:\FPC\2.0.2\units\i386-win32\postgres
2. cd C:\FPC\2.0.2\packages\base\postgres
3. make
4. copy units\i386-win32\* C:\FPC\2.0.2\units\i386-win32\postgres

Thanks giantm from #lazarus-ide channel for the help. If the step 3 does not work, probably the Delphi's make is being called instead of GNU's - if Delphi was installed BEFORE Lazarus, its bin directory is in Windows PATH environment variable. To solve it, I renamed make.exe from Delphi to make_delphi.exe; other way to do the same is using:

3. C:\FPC\2.0.2\bin\i386-win32\make.exe

As usual, YMMV.

Thursday, December 29, 2005

From CLX to VCL

Back in 2002, when the project was being designed, it was meant to be cross-platform (well, at least Windows and Linux on i386). The choice was Delphi/Kylix; instead of VCL, we used CLX from day one. This was bad - because Kylix is dead by now - but also good, because we were forced to code in a cleaner way - no Windows API calls, very few third-party components, etc.

Coding for both Delphi and Kylix was an {$IFDEF} nightmare. Most coding was being done in Delphi, under Windows, and everytime we fired up Kylix to compile a Linux version, a lot of changes were needed. Then, early this year, some customers started to try the win32 program under Wine, getting very good results. With little effort we made it work 100% under Wine, and it became clear that it was easier to run the application under Wine than code for Kylix.

The CLX is very buggy (and slow); a couple months ago we started to port to VCL. We also evaluated the possibility of porting directly from CLX to Lazarus, but our studies have shown it would be a huge step. So we decided to port to VCL first. A tool was used for this task: Convert Files, by Dennys dos Santos Sobrinho. As expected, the conversion did not worked in the first try; a lot of changes were needed and we could not afford to mantain a branch just for this task. So we decided to gradually reduce the gap, by removing obstacles at each official release.

It was a major refactoring task - a lot of code was rewritten, third-party components were replaced with standard ones (new code was needed to accomplish the missing features), points of conflict of method signatures between CLX and VCL were concentrated in fewer places, xpm icons were replaced by bmp, png or ico files, etc. Every week we tried the conversion process with the current codebase; the gap was becoming small.

And today, at last, we managed to get a working VCL port! It's a lot faster (at least 3 x), a lot of CLX bugs are gone (mouse scroll works now, form focus is not crazy anymore, etc) and with XP Manifest the project got a nicer look under Windows. Of course the entire project needs some revision to fix minor visual glitches, but overall it's working. We plan to issue an official VCL release in a couple weeks.

Monday, December 26, 2005

Installing Lazarus on [K] Ubuntu 5.10

1. Download the Free Pascal Compiler:
http://www.freepascal.org/down/i386/linux.html
http://www.freepascal.org/down/source/sources.html

2. Execute install script for FPC (use all defaults, installs to /usr/local)

3. Untar (tar -xvzf) the sources into /usr/local/src

4. Install (with "sudo apt-get install"):
build-essential
subversion
libglib1.2-dev
libgnome-dev
libgdk-pixbuf-dev

5. Get Lazarus with Subversion (SVN)
svn co http://svn.freepascal.org/svn/lazarus/trunk lazarus
(from now on, change to lazarus directory and run "svn update")

6. Build (use only "make" to build with GTK1 widgetset)
make LCL_PLATFORM=gtk2

That's it. YMMV, of course.

Monday, December 19, 2005

Indy or Synapse?

After trying Indy 4 Lazarus without success, I was told (thanks again, jesusrmx) to try Synapse's HTTP functions (from the HttpSend unit). I've been using Synapse for serial communication, but I was not aware of its HTTP features. I was gladly surprised: it's almost as easy as TIdHTTP and is officially supported on Lazarus.

Now I'll finally port the "Auto Updater" from my project. The preliminary tests were excellent, and as soon as I finish it, there will be another post here.

Friday, December 16, 2005

More on Auto Update

The Auto Update feature uses Indy's TIdHTTP. There's an effort to port Indy for Lazarus, but the Sourceforge file is a bit outdated (almost two years old). So I started to search for alternatives, just in case. I've found LNet (LightWeight Networking Library), written by Ales Katona. In the next days I'll try them all and decide which one the project will use.

Update: after some chatting on #lazarus-ide, I managed to download a newer version of indy4lazarus. I'll test it soon and post here the results.

Monday, December 12, 2005

Auto update

The RNGE system has an auto update feature. An application launcher checks the Version Info data from each EXE against the configurations files on the server; if the versions are different, the launcher downloads the version from the server and overwrites the version on the client.

However this depends on Windows API in order to get the Version Info from the binaries, therefore a crossplatform solution is needed. Joran and fpcfan from #lazarus-ide channel (at Freenode) gave me the idea of using a POSIX compliant command-line argument: --version.

Saturday, December 10, 2005

OnPrepareCanvas

The 200 kloc project I'm porting uses only a few third-party CLX components on Delphi 7. The most used by far are TAdvStringGrid (Advanced String Grid) and Synapse (serial communication). The latter is already ported to Lazarus, so I focused on the standard TStringGrid from LCL.

In my code, the event OnGetCellColor (from TAdvStringGrid) is used to change the look of the Cell depending on some conditions. The AlternateColor property solved part of my problems, but I needed to check the Cell's content before it's drawn. Then, after a few searches, I've found OnPrepareCanvas. A simple code to put negative numbers in red looks like this:

procedure TForm1.StringGrid1PrepareCanvas(sender: TObject;
Col, Row: Integer; aState: TGridDrawState);
begin
if not (gdfixed in aState) then
if Pos('-',StringGrid1.Cells[Col,Row]) = 0 then begin
StringGrid1.Canvas.Font.Color := clBlue;
end else begin
StringGrid1.Canvas.Font.Color := clRed;
end;
end;
The standard TStringGrid from LCL has all I need: the project is one step closer to be ported. Thanks Jesus Reyes Aguilar for the great work!