Ruby-Like Syntax in REALbasic (or RB has a C# 3.0 feature)

REALbasic, Software Development No Comments »

I came across this post the other day (Ruby-Like Syntax in C# 3.0) and it make me think of REALbasic. The author talks about using the new C# 3.0 extensions methods capability to simulate Ruby syntax.

In particular this Ruby example is given:

20.minutes.ago

Which returns the time from twenty minutes ago. It’s a nice, readable syntax (if you know english).

It’s cool that C# 3.0 will have this (when it ships), but REALbasic has had extension method capability for years. I believe Extension methods in REALbasic were added around the 5.0 release which was in 2003, if I recall correctly.

Anyway, to do this in REALbasic you would add two public methods to a module:

Function Minutes(Extends minutes As Integer) Return Double
   Return minutes*60
End Function
 
Function Ago(Extends seconds As Double) Return Date
   Dim now As New Date
   now.TotalSeconds = now.TotalSeconds - seconds
   Return now
End Function

That’s it! Now you can call this like so to show the time from twenty minutes ago in a MessageBox:

Dim twenty As Integer = 20
MsgBox twenty.Minutes.Ago.LongTime

This has a limitation that Ruby and C# 3.0 don’t have: it won’t work with an integer literal. So, 20.Minutes.Ago won’t actually work, but really how often would you actually do it that way? But as a bonus, unlike C# 3.0, you don’t need to include parenthesis with extension methods that don’t have any parameters.

So, to recap:

Ruby:

20.minutes.ago

C# 3.0:

20.Minutes().Ago()

REALbasic:

twenty.Minutes.Ago or twenty.minutes.ago

Java:

new Date(new Date().getTime() - 20 * 60 * 1000);

So rather than learning Ruby or waiting around for Orcas and C# 3.0, you can use this syntax today with REALbasic.

Virtualization and You

Software Business, Software Development 9 Comments »

Are you using virtualization tools? As a Micro-ISV, you should be. Virtualization is the ability to emulate computer hardware virtually, in software. This is called a Virtual Machine (VM). With Microsoft Virtual PC, Microsoft Virtual Server, VMware Server, VMware Fusion and VirtualBox, all available for free, there is no excuse to not be using them.

What’s the Difference?

Virtualization solutions are available for desktops and servers and they are both immensely useful. As a Micro-ISV, using virtualization will save you from buying a lots of hardware. Just get a decent box to use at as a server and put either Microsoft Virtual Server or VMware Server on it and you can now pretend you have a bunch of servers. This is great for testing, for hosting source control repositories and database servers.

The desktop solutions, usually have a nicer UI than the server products and are a bit easier to work with. I use them for managing different development and test environments from a single computer, which is a great time-saver.

Which Should You Use?

You should probably be using both. Some things I use virtualization for include:

  • Clean test environment for software
  • Development of patches to older software
  • Testing of new software, such as Visual Studio 2005
  • Testing with Windows Vista
  • Testing with Internet Explorer 7
  • Remote debugging
  • Testing Linux

Some of the things I use Virtual Server for include:

  • Team Foundation Server
  • Build machines
  • Unit test machines
  • Customer support VMs
  • Wiki server
  • Databases

This works great for me because not all of the above VMs are needed all the time so I can take them on and offline as needed. It’s a better use of hardware resources.

As long as you’re appropriately licensed, I also recommend setting up master VMs with each OS you use regularly. With a master vm, I can just make a copy of it and be up and running rather than installing the OS from scratch each time.

What’s the Catch?

Yes, there’s a catch. There’s always a catch. The first catch is that a VM will not generally run as fast as your native hardware, which makes sense because it is actually sharing your hardware. In most cases it is not noticeable, as long as you have enough RAM, which is easily the biggest obstacle to using VMs effectively. You really want at least 1GB of RAM, but I’d recommend you get at least 2GB. Another thing that can help with performance is to have a multi-core processor. The new Intel Core Duo chips are great for this, but older Pentium 4s can handle it as well. Just make sure you enable HyperThreading if you CPU supports it.

Another catch is to not try to run too many VMs on a single machine. The limit is really the amount of RAM you have, but it also depends on what each VM is doing. Hard drive access can also cause a bottleneck.

And one last thing to keep in mind. Although the VM software is usually free, Windows is not. If you intend to run Windows in your VMs, then you need to be appropriately licensed. If you have an MSDN subscription you’re probably all set for Windows licenses.

What Do I Use?

Primarily, I use Parallels Desktop as my virtualization solution within Mac OS X. Parallels Desktop works great on Mac OS X and runs Windows with aplomb. If you have an Intel Mac, you should look into Parallels Desktop (it’s also available for Windows and Linux).

I also use VMware Fusion Beta on Mac OS X for running Linux. Fusion, even in beta, runs Linux much better than Parallels does.

When I’m using Windows, I stick with Virtual PC and Virtual Server.

Advertising on RBDevZone

REALbasic, Software Business No Comments »

After a few months of planning, RBDevZone is now ready to accept text-based ads. I’ve been pretty pleased with how RBDevZone has progressed since its inception at the beginning of February. I also got the opportunity to talk with some people at REAL World about RBDevZone and they seem to think it is progressing nicely as well. Through yesterday, there have been over 190,000 hits, more than 47,000 page views and over 12,000 unique visits.

I think that shows there is some serious interest in professional REALbasic development.

To that end, I’ve decided that small text-based ads would be appropriate for the site. I’m going with a simple, affordable pricing model: $10 per month or $100 per year. And to entice you to try out an ad, I’m giving anyone two free months to run there ad at no cost whatsoever. If you have a REALbasic product or service to sell, give it try!

For more information, visit RBDevZone.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Login