Categories
News

13 Reasons NOT to use Delphi

Over the years I’ve heard a lot of reasons or excuses people don’t use Delphi. I’ve collected the thirteen best reasons here.

1. Want to Write More Code – Delphi requires less code to accomplish the same task. If you want to write more code, don’t use Delphi. Especially helpful if writing more code gives you more sense of accomplishment, or you are paid based on lines of code written.

Number, 2, Digit, Figure, Cipher, Count, Numerary, Red

2. Larger Developer Teams – Who doesn’t love having lots of co-workers? If you use other tools and frameworks then you will need more developers, more developer tools, more frameworks, and more teams to support all the platforms. Makes for better office parties. Unfortunately, when you use Delphi you only need to write the app once for all the platforms, so one team and one code base for all the platforms. With Delphi, you just can’t justify hiring all those extra developers!

3. Like Fixing Bugs – All that code you had to write to implement the features on each platform? More code means more bugs! And more bugs means more job security for you and that huge team of testers. Gotta love bugs! Heck, you can even name some and keep them as pets! You know they will be around for a while.

4. More Meetings – Since each platform has its own code and own team you need more meetings to coordinate. You don’t want features to get out of sync between platforms! And then another round of meetings to coordinate bug fixes for each platform. Everyone knows meetings have the best snacks! Since Delphi lets you support all the platforms from one codebase then you can’t have all those planning meetings!

5. More Documentation – Each platform has a completely different app (despite all the meetings to keep them in sync) so now you need completely different documentation for each platform. We know how much you love writing code, so clearly you love writing end-user documentation too!

6. Larger Support Department – Each platform has its own version so you need to talk to a support tech that knows that version of the app. Who wants an Android version that behaves similar to the iOS version? Not to mention the desktop versions! 

7. Longer Compile Times – If it isn’t weren’t for long compiles developers would never get a break from their desk. We all know Delphi compiles super fast, which means you have less time to slack off.

'Are you stealing those LCDs?' 'Yeah, but I'm doing it while my code compiles.'
‘Are you stealing those LCDs?’ ‘Yeah, but I’m doing it while my code compiles.’
If Delphi can compile 1 million lines that quick, when will you slack off?

8. Slower Execution – If your executable runs slower the user feels safer and pretends that a lot of stuff is going on in the background. With Delphi’s native execution speed your programs are fast, so your users won’t believe it is doing anything. 

9. Separated Runtime – If your program depends on an external runtime library instead of having one executable on Windows, you can blame the runtime for any bugs. All those support calls just result in telling them to update or rollback the runtime libraries. You’ll be able to convince them it is all their fault that the program doesn’t work!

10. Putting Memory to Use – Great apps should use at least a full GB of memory just like small Electron utilities do. The great thing about Electron is it includes all of the Chrome browser features like Xbox 360 controller support. Why only use a few megabytes of memory for the same simple app? The more memory the better app. Electron puts all those CPU cores to use too!

11. In Deep Love With “DLL Hell” – You love sending your customer a dozen DLLs along with your EXE and you are having so much fun to debug over the phone, which DLL is not up-to-date and makes your app fail. Closely related to #9, but worth mentioning twice!

12. Unexpected Garbage Collection Pauses – Deterministic execution is boring! What fun is it to have your program behave the same every time it runs. Delphi doesn’t have any of those unexpected garbage collection pauses to mix things up. It gives you deterministic memory management either through ref-counting, an ownership / auto-free model, or whatever level of control you want. Why control when the memory is free when you can just wait for the garbage collector?

13. Would Rather “Re-Invent the Wheel” – Delphi comes with so many useful components and libraries and has a rich 3rd party ecosystem. This means there is usually some reusable code for any task you need. That means less opportunity to create something new.

Just in case it wasn’t obvious: This is a sarcastic list of bad reasons not to use Delphi. The reality is all the excuses are just reasons to use Delphi.

Carlos translated my post to Portuguese.

Categories
News Source Code

Unexpected Benefit of Inline Variables: Conditional Blocks

Inline variables is one of the cool new feature coming in 10.3. The obvious huge use case is loop control variables, but I just discovered another great use case while reviewing some code. 

procedure DoesSomething;
var
  var1, var2: Integer;
begin
  // use var1
  {$IFDEF Something}
  // use var1 & var2
  {$ENDIF Something}
end;

This is a pattern I see a lot, and it generates a hint on var2 being unused based on the current compiler directive status.

[dcc32 Hint] myUnit.pas(123): H2164 Variable 'var2' is declared but never used in 'DoesSomething'

Now there are a number of ways to deal with this with more compiler directives, which is what I’ve done in the past, but I never like adding more compiler directives. It makes the code way more complicated and harder to maintain. Now with Inline Variables I can simplify it, make it easier to maintain, and hande the hint! (all of which makes me so happy!)

procedure DoesSomething;
var
  var1: Integer;
begin
  // use var1
  {$IFDEF Something}
  var var2: Integer;
  // use var1 and var2
  {$ENDIF Something}
end;
Happy dance commencing in T-minus 10 seconds. 

What are some interesting ways you see inline variables benefiting you?

Categories
News

Arduino & Delphi Cosplay

Me with a Spartan Boba Fett, but I thought he was more of a Delphi Dude ?(FanX Salt Lake City - 2018)
Me with a Spartan Boba Fett. I thought he was more of a Delphi Dude (FanX Salt Lake City – 2018)

Cosplay (aka costume-play) takes the fun and imagination of childhood dress-up to extreme levels only justifiable by an adult! Not only is it expensive, and needs a large time commitment, but it is rarely comfortable.

Comic conventions are the usual place to find cosplay, but Halloween is also a good excuse for some cosplay fun. I’m a huge fan of creative cosplay and love getting my picture with cosplayers.

In writing this post I realized I am frequently attaching LEDs to my face.

The V character from Cyberpunk 2077. Cosplayer Maul. photo by eosAndy.
The V character from Cyberpunk 2077. Cosplayer Maul. photo by eosAndy. His cosplay is much better than mine.

This year I am putting together my Ultimate Cyberpunk cosplay. The first part is a jacket based on the main character from the game Cyberpunk 2077 by CD Projekt RED. Neuromancer, by William Gibson, inspired the Cyberpunk 2020 RPG by Mike Pondsmith. They both inspired this unreleased video game Cyberpunk 2077.

I’m a big fan of both the book and the original RPG and am looking forward to the video game. I combined elements from all three sources for my cosplay. The character V is more of a Street Samurai / Solo, while I wanted to go for more of a Decker / Netrunner (a little Shadowrun RPG influence in there too).

At this point the secret is out, I’m a huge nerd. I love Role Playing Games, and Cyberpunk & Shadowrun are my favorite genres.

I didn’t have my RGB Shades in time for Salt Lake FanX, so I justed glued some extra LEDs (NeoPixel 4×4 grids) to my face. They represent cybernetic enhancements, which is why I left the wires exposed. I used an Arduino MEGA 2560 by ELEGOO as the controller. It also controlled the string of NeoPixel lights in the collar. I attached a Bluetooth keyboard to one wrist and an Android Pixel phone to the other. The phone was decorative for now.

Later I got my RGB LED Shades which will become the key to my outfit for this Halloween. The RGB LED Shades use an Arduino Mini as the brains. I added an HC-06 Serial Bluetooth module to control the leds remotely.

After soldering the HC-06 onto my shades I can power them up and pair my Android phone with the HC-06 module. One note about my soldering is that if you look you will see that it is connected to two analog pins instead of digital pins. On most Arduinos the analog pins can double as digital pins (see the Pinout).

Android Bluetooth Pairing Dialog
Android Bluetooth Pairing Dialog

After that, a TBluetooth component is able to open a socket to the shades. Start the pairing with Bluetooth1.DiscoverDevices( 5000 ); In the DiscoveryEnd event handler the following code will open a socket to the HC-06 module (Thanks to Boian Mitov for the basis of this code):

var
  ADevice   : TBluetoothDevice;
  AService  : TBluetoothService;
begin
  for ADevice in ADeviceList do
  begin
    // HC-06 is the name of the bluetooth device
    if ADevice.DeviceName = 'HC-06' then 
    begin
      Bluetooth1.Pair( ADevice );
      for AService in ADevice.LastServiceList do
      begin
        // FSocket is a TBluetoothSocket with larger scope
        FSocket := ADevice.CreateClientSocket( 
            AService.UUID, False );
        If Assigned( FSocket ) then
        begin
          FSocket.Connect;
          Break;
        end;
      end;
      Break;
    end;
  end;
end;

Once the socket is open you can send characters with this code.

FSocket.SendData( TEncoding.UTF8.GetBytes( 'D' ));

It is so easy to work with Classic Serial Bluetooth in Delphi (or C++Builder) and the TBluetooth component. You even could send a whole string or other binary data. For this project a single character was all I needed to change modes on the shades. A single character is also easier to process on the Arduino side. (Technically Bluetooth Classic works on all platforms, but on iOS you need special approval from Apple on a per app basis.)

RGB Rio Shades
I’m wearing the Rio RGB Shades with the Delphi powered controller on my Android phone

I took my RGB Shades with me to Sao Paulo Brazil for the 10.3 Rio preview. Even though the Bluetooth worked before the conference, my phone couldn’t make the connection on stage. When I opened my phone’s Bluetooth connection window it was obvious that with 750+ people in attendance there were a few hundred Bluetooth devices broadcasting on the same wavelength.

David Millington kicking off the Keynote
David Millington kicking off the 10.3 Keynote

My next project involves Bluetooth LE with these RGB LED Steampunk Goggles.

Jim wearing LED Steampunk Goggles
RGB LED Steampunk Goggles

I built them a year ago from an AdaFruit kit. Later I added a Bluetooth LE Module to make them controllable. Unfortunately, my soldering didn’t hold up and I need to rebuild them. This makes them both my previous and next cosplay project.

RGB LED Goggles, a horse mask, and a Los Angeles Kings hockey jersey
RGB LED Goggles, a horse mask, and a Los Angeles Kings hockey jersey (don’t ask)

I’m considering salvaging the NeoPixels and rebuilding them with an ESP32 microcontroller. The ESP32 is a little larger than the original Trinket microcontroller. This is because it has integrated Bluetooth LE, WiFi, and more pins. I’d also like to get some 50% mirrors to create an infinite LED tunnel effect (I’ll post pictures when I get them – it is really amazing).

I met Star Lord!
I met Star Lord!

I’ve worked with the TBluetoothLE component before and it is even easier to work with than TBluetooth. So I’m really looking forward to this project.

On the Arduino side, you can use the Arduino IDE and flex your C programming skills. Or you can do like I usually do and use Visuino by Boian Mitov of Mitov Software. It provides a visual drag and drop interface for programming Arduino devices. It won the Embarcadero Cool App contest in April 2017 as Boian used Delphi to develop Visuino. Boian also recently added RGB LED Shades support to Visuino (along with unboxing and assembly videos.)

Visuino makes Arduino and LED RGB Shade development easy. It is an Embarcadero Cool App developed with Delphi!
Visuino makes Arduino and LED RGB Shade development easy. It is an Embarcadero Cool App developed with Delphi!

I think Boian is a great guy who makes some great technology. Most of it has a free version and the commercial prices are very reasonable too. He is always very helpful as well.

Boian and Jim at the 2017 SoCal CodeCamp in Los Angeles
Boian and Jim at the 2017 SoCal CodeCamp in Los Angeles

So what’s next (after the Bluetooth LE RGB Steampunk Goggles obviously)? I’m working on a design for an electronic physical polyhedral die with Bluetooth LE. So you roll a physical die of a single size and it can become any number of sides you need, all controlled via your phone. Did I mention how much of a nerd I am?

I love polyhedral dice
I love polyhedral dice
Categories
News

Where is the ActiveX Project Type for Delphi 10.1 Berlin?

In 10.1 Berlin the ActiveX project types are missing from the New Items Window under Delphi. They are there for C++Builder, but not for Delphi.

Missing AcitveX

This only happens if you use the shiney new Feature Installer that was introduced with 10.1 Berlin. So if you use the old offline ISO installer then it shows up fine.

[Update: This was just fixed in the installer. So if you download and install after today everything will work great!]

Turns out though, it is only a simple registry issue. Instead of explaining the details behind why, here is the quick and easy work around.

  1. Close RAD Studio or Delphi 10.1 Berlin.
  2. Open RegEdit
  3. Browse to “HKEY_CURRENT_USER\SOFTWARE\Embarcadero\BDS\18.0\Known IDE Packages\Delphi”
  4. Find the entry named “$(BDS)\Bin\delphicompro240.bpl” and change the value from “__(Untitled)” to “(Untitled)”. Here is a before screenshot:
    RegEdit
  5. And here is an after screenshot (notice the missing double underscore)
  6. Then restart your RAD Studio or Delphi 10.1 IDE and bask in all the ActiveX glory that you have restored!
    ActiveX Success
  7. Now you can create a new ActiveX Library or Type Library with your favorite programming language.

Interesting story, long ago a friend of mine worked for a software development company that used Visual Basic. He was in the “skunkworks” division that used Delphi to create all the ActiveX components that the Visual Basic developers used. There were 2 Delphi developers and about 50 VB developers. Whenever there was something that couldn’t be done in VB (which happened a lot) then they would make a new ActiveX in Delphi for them.

My friend showed him that they could actually out produce the VB developers with Delphi, but his boss was convinced that they were a VB development firm, and didn’t want to switch to the superior development tool. Unfortunately VB has died off, and all of those developers lost their jobs. My friend is glad he stuck with Delphi.

Categories
webinar

Hour of CodinGame with Object Pascal / Delphi

Hour of Code is upon us again. Take some time to learn about programming, or share what you know with others. In this blog post I show how the side CodinGame helps teach Delphi and also provide some resources for those wanting to learn programming.

A short overview to CodinGame for Hour of Code

CodinGame uses Free Pascal behind the scenes, which is based on Delphi. This means it is actually Object Pascal, which is an extension on Pascal. The code I’ve seen on CodinGame is mostly plain procedural Pascal, but since it is using an actual compiler, you should be able to use full Object Pascal. You will however be limited because Free Pascal doesn’t support some of the latest features Delphi does. Still a good learning resource and a lot of fun.

I’m planning to sit down with each of my kids, and probably my wife, on CodinGame this week! If you already know how to code then find someone you can share with too!

Resources for CodinGame and Hour of Code: 

Categories
Conferences

CodeRage C++

Tomorrow is the start of CodeRage 8 C++, which is a lot like regular CodeRage, but with an emphasis on C++Builder. This time there is a lot of coverage on the new iOS support, as well as the new REST Components and FireDAC data access.

It all starts with JT’s opening keynote at 6:00 AM Pacific Time, which may also be of interest to Delphi developers who want to get some glimmers of future plans, roadmaps and announcements. Actually most of the sessions will have content of interest to Delphi developers, especially if you’ve missed some of the more recent CodeRage conferences. But if you are a C++ developers, then be sure to make time for all the sessions!

CodeRage C++ - February 25-26, 2014

Categories
Commentary

The Delphi Object Pascal Language

What’s in a name? That which we call a rose
By any other name would smell as sweet;

The other day I noticed Github has a language choice for Pascal, but not Delphi. It turns out originally they had Delphi listed as a language, but some of the Delphi clones were getting marked as Delphi, so they renamed it to the more generic Pascal. Which immediately resulted in people requesting they rolled it back.

This brings up a good question though, “What is Delphi and what is Object Pascal?” Interestingly there were three implementations of Object Pascal that evolved from the original Pascal. The one we are all familiar with was designed at Borland as part of Turbo Pascal. Apple also designed one consulting with Nicholas Wirth. And there was the Think Pascal IDE with it’s own flavor.

The Borland flavor of Object Pascal evolved into the language we see in Delphi today, while the other two faded away. There actually exists a few other variations of Object Pascal, most all of which were inspired by the language that still lives in Delphi today.

Personally I think it is exciting to see so many other tools and languages in the Object Pascal and Pascal space. That is part of what made C & C++ so vibrant: All the other languages wanted to copy them (Java, JavaScript, C#, etc.)

So back to the question, “What is Delphi and what is Object Pascal.” Object Pascal is the language that powers Delphi. Object Pascal can exist without Delphi, but part of what defines Delphi is it’s Object Pascal language. Just in the same way C++Builder isn’t the only implementation of C++, but part of C++Builder is the C++ language. So Delphi and C++Builder are each the whole package: Language + IDE + Compiler + Debugger + Libraries + Tools. You could say they are the definitive implementation of those languages.

Could we see Delphi with a different language? That would be interesting. At one end of the spectrum there was Delphi for PHP (which evolved into HTML5 Builder.) It was Delphi’s Rapid Application Development concept combined with the PHP language. And then Delphi Prism which used the Oxygene language variant of Object Pascal combined with Visual Studio and .NET.

In my opinion, Delphi is a specific version of Object Pascal, if for no other reason than because it has a fabulous runtime library and framework. Using Object Pascal without TStringList and all the other useful types, function and libraries that Delphi comes with wouldn’t be much fun.

Categories
Commentary

Hidden features in the Delphi Object Pascal language

A list of hidden features in Delphi Object Pascal that are great, obscure, best avoided or remarkable.

This was copied from Stack Overflow’s question of the same name which is closed and flagged for deletion. Licensed under cc by-sa 3.0 with attribution required. I’ve made a few changes, updates and some copy editing. Original question by Johan and others on May 19 2011 at 18:34. Post inspired by Jeroen W. Pluimers’ post.

Categories
webinar

Oh Yeah, the Ouya!

The Ouya is an Android powered game console / set-top box that you can pick up for $99. Not only is it a cheap game console, but it is also an affordable Android platform designed to drive big screen TVs. Easily turn a TV into a wall mounted dashboard or living picture frame.

Once the ADB driver is installed, You can develop for and deploy to it with Delphi XE5 just like any other Android device.

This video is from our Making the Connection: Programming Devices and Gadgets with RAD Studio webinar. Check out the on-demand replay and download the full source code too.

The Ouya has an SDK that goes beyond what I showed above. I’ll be revisiting it with more updates in the future.

Categories
Brain Computer Interface devices gadgets webinar

Connecting Delphi to my Brain with the Emotiv EPOC

Emotiv EPOC NeuroheadsetThe Emotiv EPOC might seem more Sci-Fi than practical technology. It is designed to pick up on brain waves through its 14 brain wave sensors (plus 2 reference receivers) and convert them into a usable signal for your computer. For head tracking it also includes a head mounted gyroscope.

The sensor input comes in 4 different categories:

  • Head rotation: The gyroscope returns acceleration information about the movement of your head.
  • Facial Expressions: Referred to as the Expressiv Suite, it processes the signals to detect facial expressions in real time. This includes winks, smiles, and eye movement.
  • Emotions: The Affectiv Suite provides real time emotional feedback including frustration, distraction, etc.
  • Direct Thought Control: The Cognitiv Suite lets you define trained brain patterns that you associate with different outcomes. When you repeat the brain pattern the system responds appropriately.

If you want to play with the Emotiv EPOC it is $500 for the developer set. The normal consumer set only works with official licensed software. It comes with a nice control panel that lets you play with the different inputs.

Thanks to the work of Simon J. Stuart (aka LaKraven) the SDK has a full Delphi translation. I have a short demo using the gyroscope. The brain access systems were giving me a handshake error, but that may be a commentary on my brain power.

My next objective is to unlock the brain interface and combine that with the Parrot AR.Drone api so I can fly the quadricopter with my mind.

That was part of the 11 demos in our Devices and Gadgets webinar. You can access the full replay on demand, which includes access to most all the drivers, wrappers, apis and source code. The only missing source code is to Allen Bauer‘s bluetooth infrared velocity screen system. He’ll have a blog post about that one.