If have login problems remove cookies and clear browser cache.



Post Reply 
 
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ether lession #1: Compiling your code
09-06-2021, 03:59 AM (This post was last modified: 09-06-2021 04:41 AM by JoseskVolpe.)
Post: #1
Question Ether lession #1: Compiling your code
Introduction
Now that you're here, i'm sure you have finished, and not given up, to lession #0 about pseudocodes. ¡That's great! I hope you've choosen to do the 5th activity and join our n*de programming class party hehehe :-D
Pretty soon, you'll begin making your first game :3
But first, you need to know what programming logics is and how to communicate with your phone, or any other kind of machine that requires code
If you didn't check the last lession about pseudocodes, ¿why not check it before? It's better to crack your head on easier stuff first than doing harder ones directly, get confused what you should do and then give up because you "didn't had much instructions". Click here, sit, chill, read it and to do the activity to pin in your big head how a machine understand another instruction they should do and what kind of stuff you should think before starting making a code. Remember to do the 5th activity to join our fun party.

¡Anyways, you'll begin coding now! You'll see while it can be stressful and hard on beginning, it'll be fun x3
¡Especially doing that undressed!

On this lession, you'll learn how to write a simple code in Ether language and compile it in ex build tool for Alchemy OS (Package already included after installing Alchemy OS)

After we code something, that's not enough, the machine still doesn't exactly understand your code, they need to translate it to their original language. We call the machine's traditional language "Machine language", wich can be read and executed by the machine as an Assembly code.
We call our code "High-level language"
Assembly, as a low-level language, is much more overcomplicated and involves a set of CPU instructions to do a simple instruction we could look and read easily from a high-level language. A high-level language can be any language we can easily use like C, Ether, Hecl, Java etc.
Compiling can be made automatically by the machine by using compilers, but we have to know how do we ask the compiler to compile our code.
[Image: kQYLUdt.png]
Some of you guys might remember when i told you guys to "compile a demo" and gave you some .zip files, and inside them were .java files...
In Java, .java files are identified as high-level Java code, wich we can easily look inside and modify. When we compile it, we get a .class file, wich can be packed (automatically by J2ME SDK Mobile) inside a .jar file, that the phone's operating system will extract into the system to be executed by the Java Virtual Machine.
In a nutshell, a .java file is high-level code, .class is compiled code (low-level Java Assembly), and .jar is a package for installation.
Equivalent to the language we're going to use, we're going to create a ".e" file, create a program by using a high-level language - Ether - and compile it as a executable to a Assembly language. We could also package our program as a ".pkg" file ready for installation, but we're not going to do it in our lessions.

Before you begin
¡I told you to install Alchemy OS (J2ME), we'll need that for this lession. If you didn't, quick, install it already (JAD)!
Alternatives: IMPORTANT: Install Alchemy OS by JSR75 or Siemens API if possible, avoid RMS or it'll be more complicated to share your code

*If you're using a candybar numpad or QWERTY phone, i optionally recommend that you use editext package to write your codes instead the default edit package: How to install editext package in Alchemy OS
*If you're either using Android J2ME Loader or any touchscreen device, use default edit package
*If you're using a QWERTY phone, you can also use J2MEdit (J2ME)

As our goal is to learn programming logics right now, i'll let you use any other tool and programming language to do this and the next Ether activities. But we're going to use Ether language from the Alchemy OS.

Writing a code
First the obvious. Create a file.
Open your file manager, press "Menu" and select "New file". Ether code files are identified with ".e" extension in Alchemy OS, so name it anything and end it with ".e".
We're going to make a simple "Hello World" code, so i'll call it "Hello.e"
Open it, by either just pressing it or if you installed editext, use "editext" command on Terminal
Quote:editext Hello.e

Let's begin our code very simple. Copy and paste that (or just download it on attachments and move to /home):
Quote:use "io"

def main(args: [String]){
println("Hello world OwO")
println("Welcome to the party x3")
}

¿What each line do?
I'll explain more about them soon, but let me explain in few words
"use" command is a importer, it imports system or user libraries inside the code and make you able to use custom finished methods/functions, variables and definitions. It's importing "io.eh" header from libcore, a system library from Alchemy OS

"def main()" is a method called by the system when the program is executed. Inside it there's "println" commands, wich are methods imported from io.eh and display messages to the user on a terminal.

Compiling
Open your terminal. Make sure you're on the same path as your code file (/home on my case). if you aren't, type in:
Quote:cd /path/to/the/directory/your/file/is

[Image: BSxAaeF.jpeg]
Type in your terminal
Quote:ex YourFile.e -o OutputFile
In this case, i'm using
Quote:ex Hello.e -o Hello
It'll compile your Ether file (Hello.e on my case) and make a executable file with the name you inserted.
If you made any mistake in your code, the compiler will alert you what's wrong and you must correct it

¡Now, to execute your file!
[Image: KC6dAdJ.jpg]
Type in terminal:
Quote:./OutputFile
In this case, i'm using
Quote:./Hello
This will open your executable file in the terminal and display all printable messages there. Notice every message that was inside println() commands are being displayed
¡If you can see them, congrats, everything went fine!

Activity
  • Make your own code displaying many messages by using pritnln(String), printf(String) and print(String) command and compile it. Post here the difference between each of the 3 commands and what they do

Attachments
Because Dedomil currently does not allow to upload .e file formats, i'm zipping it. Extract it
.zip  Hello.zip (Size: 243 bytes / Downloads: 15)

[size=xx-small]Signature[/size]
[URL=https://www.exophase.com/user/JoseskVolpe/][IMG]https://card.exophase.com/2/0/45687.png?1612237163[/IMG][/URL]

[align=justify][size=x-small][b]OwO ¿¿¿What is this??? *wags tail*
Take my beret plz 7w7 ~[/b][/size][/align]
Find all posts by this user
Quote this message in a reply
09-08-2021, 08:37 AM
Post: #2
RE: Ether lession #1: Compiling your code
1) The `println("String")` Prints The Raw String With New Line in Terminal/Shell.
2) The `print("String")` Cannot Format Anything, it Simply Takes a String And Print it.
3) In `printf("String")` You Can Use Symbols & Also Variables..

If I am Wrong Please Tell Me..

I Will Share my Code Tomorrow as I am Busy in Studies. xD
Visit this user's website Find all posts by this user
Quote this message in a reply
09-08-2021, 10:25 AM
Post: #3
RE: Ether lession #1: Compiling your code
Is it a must we use the "use "io" "
Find all posts by this user
Quote this message in a reply
09-08-2021, 07:11 PM
Post: #4
RE: Ether lession #1: Compiling your code
(09-08-2021 10:25 AM)star cash Wrote:  Is it a must we use the "use "io" "

Yes :-)
Visit this user's website Find all posts by this user
Quote this message in a reply
09-08-2021, 08:38 PM (This post was last modified: 09-08-2021 08:40 PM by star cash.)
Post: #5
RE: Ether lession #1: Compiling your code
(09-08-2021 07:11 PM)CodeWithAadi Wrote:  
(09-08-2021 10:25 AM)star cash Wrote:  Is it a must we use the "use "io" "

Yes :-)

Ok :-)......what is the use....?

Ok "use" is use to import the Code you want to use.....right?
Find all posts by this user
Quote this message in a reply
09-09-2021, 08:14 AM
Post: #6
RE: Ether lession #1: Compiling your code
(09-08-2021 08:38 PM)star cash Wrote:  
(09-08-2021 07:11 PM)CodeWithAadi Wrote:  
(09-08-2021 10:25 AM)star cash Wrote:  Is it a must we use the "use "io" "

Yes :-)

Ok :-)......what is the use....?

Ok "use" is use to import the Code you want to use.....right?

It is API/Library for development you can use other libs like math, ui, etc..

Each library has its own function you can visit docs page for more help!
Visit this user's website Find all posts by this user
Quote this message in a reply
09-09-2021, 09:04 AM
Post: #7
RE: Ether lession #1: Compiling your code
(09-09-2021 08:14 AM)CodeWithAadi Wrote:  
(09-08-2021 08:38 PM)star cash Wrote:  
(09-08-2021 07:11 PM)CodeWithAadi Wrote:  
(09-08-2021 10:25 AM)star cash Wrote:  Is it a must we use the "use "io" "

Yes :-)

Ok :-)......what is the use....?

Ok "use" is use to import the Code you want to use.....right?

It is API/Library for development you can use other libs like math, ui, etc..

Each library has its own function you can visit docs page for more help!

Ok... Can you show me the docs page?
Find all posts by this user
Quote this message in a reply
09-09-2021, 09:06 AM
Post: #8
RE: Ether lession #1: Compiling your code
http://alchemy-os.sourceforge.net/docs.php
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)