Skip to main content

Post 2: Hello World! Program

Hello World!

F4 IDE

The official F4 IDE is no longer maintained by the original creators but can be attained from the Xored website, or an updated open source copy is available on Github

The Windows version of the F4 IDE works fine for me, however I was unable to get the MacOS version to launch so working with this IDE on a Mac may prove to be a challenge.

If you are familiar with the Eclipse platform then F4 will look rather familiar. F4 is based on the Eclipse platform and functions relatively similar, just without a useful dark theme.

The default window configuration for F4 is almost identical to that of Eclipse and is fully customizable. The 'Fantom Explorer' on the left contains the file tree for all of your projects in your workspace. On the right, there is an 'Outline' view which shows the outline for the current Fantom Class file that you are working on including methods and functions. The 'Console' window and 'Error Log' window are at the bottom of the screen.
Click Image to Enlarge


Creating a New Project

Creating a new Fantom project in F4 is simple. Simply click 'File' > 'New' > 'Fantom Project' to create a new project. 
You can name the project what ever you chose and leave the rest of the settings default.

In the 'Fantom Explorer' window, you will now have a project file tree that contains everything in the project that you just created. 
The 'fan' folder is where you want to create new 'Fantom Class' files, which are saved with the extension .fan. This folder is similar to the 'src' folder in Eclipse but without the option for packages. 

Testing Your Code

When running .fan files in F4, make sure to select 'Fantom Class' from the pop-up window. If you select 'Fantom Testing' instead, you can right-click in the text editor window and select 'Run As' > '1 Fantom Class'.

Source Code


The way the classes are set up is very familiar to that of Java but with more simplification. Note here that Void is capitalized because Void is actually a class in Fantom. Methods are by default, public and the main() method does not need to be static nor does it need to take arguments like it does in Java. 

echo() works the same way as System.out.println() in Java or Console.WriteLine() in C# by printing what is within the parentheses and starting a new line following the print in the console.

    This:
    Will therefore print this:


General Syntax Rules

  • Fantom uses curly braces similarly to both Java and C#, the languages that it is based on.
  • A semicolon at the end of a line is optional.
  • Comments are made in Fandoc, which is Fantom's own version of Markdown.
    • ** is used for comments within a single line and can also be used to span multiple lines, similar to /* */ in Java.
    • This is also used for documentation within the F4 IDE in the same way you would use /** */ in Eclipse.


Comments

  1. Do you get the sense that the Fantom IDE is relatively maintained as a Github project, or is it just an archive for interested parties?

    ReplyDelete
    Replies
    1. It seems that Xored ended official updates for the IDE in 2017 so all of the updates that have come since have been through the Github project from a small, very dedicated community.

      Delete

Post a Comment

Popular posts from this blog

Post 5: Repeated Action Syntax

Loops While Loops While loops execute while the given conditional remains true. While loops use the same syntax as while loops in C# and Java.  The code will cease to execute once the given conditional is no longer true. For Loops For loops execute for a set, given length. A for loop will iterate through a range of given integers until the end of that range is reached. For loops are written the same was as in Java and C#.  For loops have the benefit of being able to keep track of how far something has looped through without the need for a separate variable by using the 'i', or however it may be named. For loops do not need to strictly follow hard coded numbers and could loop through the length of an array or size of a list or to any integer value. Iteration Iteration is a key function of lists in Fantom. By using the 'listName.each' method, you are able to iterate through the length of the list and execute code for each item in that list. This c...

Post 4: Conditional Statements

Conditionals Conditionals in Fantom are comprised of if-statements, if-else statements, and switch statements. If-statements If-statements in Fantom remain virtually the same to if-statements in it's parent languages, Java and C#. The if-statement takes some form of conditional and will only perform the block of code inside of it IF the condition stated is true. Every if-statement will be checked if performed in a sequence, however if-else statements will stop once the first true condition is met and perform the nested code. Else will only be performed if none of the previous conditionals have been satisfied. Switch Statements Switch statements remain very similar to Java and C# as well, however with some syntax differences. A switch condition is declared at the start and is compared to the list of case labels below it, executing code when a condition is met. If none of the conditionals are met, there is a default condition that works like the else of and if-statement....

Post 1: Background Information and Resources

Language Background Fantom is an object-oriented programming language designed to work in both the Java Runtime Environment and in the .NET Common Language Runtime while providing a more refined API that maintains much of the same functionality.  Fantom's syntax is relatively similar to that of Java and C# while refining certain aspects of the syntax for functionality and simplicity.  System.out.println("Hello world!"); becomes  echo("Hello world!") Fantom is designed to be portable between the Java and .NET VMs while also holding support for being compiled to JavaScript for browser use, making Fantom versatile.  Creators Fantom was created in 2005 by Brian Frank and Andy Frank and was originally named Fan. When the language began to gain some popularity, the name was changed to Fantom in order to address concerns about the ability to search for resources on a language named "Fan". The creators say that Fantom was created in orde...