Currently Being Moderated
13

How big is your source code?

Posted by Richard Monson-Haefel on Jun 12, 2008 9:33:17 AM

Maurizioi Storani wrote an excellent blog post about his first impressions using JavaFX's new GUI API (javafx.gui)  titled "[JavaFX (James Weaver)|http://mauriziostorani.wordpress.com/2008/06/10/java-fx-james-weaver/]". That post shows a simple example of JavaFX code using the new javafx.gui library. Out of curiosity I asked Doug McCrae, a Curl engineer, to write up the same exact program in Curl. It turns out that Curl code looks a bit shorter than the JavaFX code.   Anyway I thought it would be fun to see if other bloggers would be willing to post the code for their favorite RIA technology. It's a pretty short program and very GUI centric, but its a fun to compare solutions all the same.

 

If you have never used Curl before you'll find that running the Curl application is easy. Copy and past code below into a text file and save it as "helloGoodbye.dcurl" to your desktop. Then download and install the Curl RTE. Once the RTE is installed, run the Curl application by simply double clicking on it.  It will look almost exactly the same as the JavaFX code that Maurizioi created. 

 

 

 

 


{curl 6.0, 7.0 applet}
 
{value
   def content = {Frame}
 
   {View title = "Hello, Goodbye",
       width = 400px, height = 300px,
       visibility = "normal",
       background = "#DDF",
       {on WindowClose do
           {exit}
       },
       {VBox
           margin = 6px, font-size = 36px,
           halign = "center",
           width = {make-elastic},
           {vcenter content},
           {HBox spacing = 6px,
               {CommandButton label = "Hello",
                   {on Action do
                       {content.add "You say hello...", replace? = true}
                   }
               },
               {CommandButton label = "Goodbye",
                   {on Action do
                       {content.add "and I say goodbye", replace? = true}
                   }
               }
           }
       }
   }
}
 

 

 

 

I don't recommend running the code I posted on Maurizioi blog because the commenting feature removed all the white space so it doesn't work. Also the one attached is even shorter than the one posted to Maurizioi's blog.

 

 

Note: Code has been modified since original post to take out errors introduced by formatting and also to make the code more readable.

 

 

Attachments:


Add a comment Leave a comment on this blog post.
Jun 12, 2008 5:06 PM Christopher Barber Christopher Barber    says:

Of course, this example does not demonstrate Curl's text markup capabilities. Let's say you wan to show 'hello' and 'goodbye' in bold. All you have to do is to change those string literals to:

 


{text You say {bold hello}...}

 

and

 


{text and I say {bold goodbye}}

 

Doing this in most other programming languages is onerous.

Jun 12, 2008 10:35 PM Guest Ed O'Connor  says:

Here's a script in REBOL (a 500 KB cross-platform language) that does the same job:

(hopefully the formatting doesn't get mangled)

 



REBOL title: "Hello, Goodbye"
layout [
   across 
   t: text 300 font-size 36 center "" return 
   btn "Hello"   t/text: "You say hello..."  show t 
   btn "Goodbye" t/text: "and I say goodbye" show t]

view center-face

If you're curious, more information can be found here: http://www.rebol.com/docs.html

Jun 12, 2008 5:02 PM Guest Ed O'Connor  says in response to Ed O'Connor:

Well, it did mangle it slightly. If you pretend the text isn't stricken out, it's fine.

Jun 12, 2008 7:27 PM Richard Monson-Haefel Richard Monson-Haefel    says in response to Ed O'Connor:

Wow. That's pretty cool. very short - I'll have to download the REBOL compliler/runtime and give it a try. Did you intend for there to be strike-throughs on code?  I'm guessing not.

Jun 12, 2008 9:08 PM Guest Ed O'Connor  says in response to Richard Monson-Haefel:

No, there aren't supposed to be strike-throughs-- somehow the commenting feature added those in there.

 

If you'd like to see the code for a very simple image viewer utility in REBOL which is roughly the same number of lines as the 'do-little' example above, see this page on my site: http://www.flippingsweet.com/viewer.html

Jun 12, 2008 10:36 PM Richard Monson-Haefel Richard Monson-Haefel    says in response to Ed O'Connor:

I tried to fix the code listing for you ... let me know if its worse than before.

Jun 13, 2008 11:52 AM Guest Ed O'Connor  says in response to Richard Monson-Haefel:

Thanks, that's pretty close. Here's the code and some screen-grabs:

http://www.flippingsweet.com/hello.html

Jun 13, 2008 3:52 PM Christopher Barber Christopher Barber    says in response to Ed O'Connor:

Looks good. Presumably there is some easy way in REBOL to set both the height and width of the view, set its background color, and center the buttons? The text does not look smooth in your screen shot, is REBOL not doing antialiasing?

Jun 14, 2008 12:09 PM Guest Ed O'Connor  says in response to Christopher Barber:

REBOL is not doing anti-aliasing there. Perhaps in the newer version, REBOL 3 (which is only in alpha or beta release right now).

You are correct; there are lots of options to set all manner of colors and dimensions-- you can construct a fairly robust interface (although no editable table element yet).

 

I should mention that the reason my sample code is so short is that I am using VID, which is a domain-specific language within REBOL to easily layout interface elements (that's what the layout function does). If I used the direct /View controls, my code would have been much more verbose, roughly in line with the Curl or Java FX example.

Jun 14, 2008 6:43 PM Guest Jerry Tsai  says:

REBOL supports anti-aliasing, but it's not activated in REBOL 2.x VID. For REBOL 3.0 VID, check it out here http://www.rebol.net/wiki/VID_Tutorial.

 

BTW, I was the translator of Traditional Chinese Edition of RMH's EJB book.

Jun 15, 2008 5:09 AM Guest Henrik Mikael Kristensen  says in response to Christopher Barber:

For REBOL 3 there will also be a rich text scheme, not entirely different from CURLs. By default, rich text is enabled everywhere in the UI.

 

Some examples can be found here:

 

http://rebol.net/wiki/Richtext

Jun 15, 2008 8:52 AM Guest Ed O'Connor  says:

Looks like some of the rebol community has tuned-in to this conversation. FWIW, for all matters REBOL, esp. for REBOL 3, their comments should be viewed as more authoritative than mine. I'm not a business-user, not a programmer/coder.

Aug 18, 2009 10:34 AM Guest reboltutorial  says in response to Richard Monson-Haefel:

Yeah Rebol is cool even if you program in other languages for a living see

http://reboltutorial.com/testimonies/

This is how to bind Rebol Form with Database:

http://reboltutorial.com/blog/binding-text-database/