Category:Objeck: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
No edit summary
Line 1: Line 1:
={{header|The Objeck Language}}=
={{header|The Objeck Language}}=


The Objeck computer language is an OO computing language that has ties with Java, Pascal and indirectly Ruby. In this language, all data types are treated as objects. This language contains all of the "basic" features of a general-purpose (Turing complete) programming language with an emphasis placed on OOP simplicity. The language consists of a compiler and virtual machine with associated garbage collector and JIT compiler. The compiler emits binary byte code that is executed by the runtime system. The runtime system has the ability to translate the byte code into IA-32 or AMD64 native machine code. The engineering goal is to have basic optimizations (peep hole) performed by the source code compiler and advanced optimizations performed by the JIT compiler.
The Objeck computer language is an object-oriented (OO) computing language that has ties with Java, Pascal and indirectly Ruby. In this language, all data types are treated as objects. This language contains all of the "basic" features of a general-purpose (Turing complete) programming language with an emphasis placed on OOP simplicity. The language consists of a compiler and virtual machine with associated garbage collector and JIT compiler. The compiler emits binary byte code that is executed by the runtime system. The runtime system has the ability to translate the byte code into IA-32 or AMD64 native machine code. The engineering goal is to have basic optimizations (peep hole) performed by the source code compiler and advanced optimizations performed by the JIT compiler.


Feel free to check out the [http://objeck-lang.svn.sourceforge.net/viewvc/objeck-lang/objeck-lang/docs/objeck_lang.pdf Introduction to Objeck] PDF document.
Feel free to check out the [http://objeck-lang.svn.sourceforge.net/viewvc/objeck-lang/objeck-lang/docs/objeck_lang.pdf Introduction to Objeck] PDF document.

Revision as of 08:29, 16 May 2010

The Objeck Language

The Objeck computer language is an object-oriented (OO) computing language that has ties with Java, Pascal and indirectly Ruby. In this language, all data types are treated as objects. This language contains all of the "basic" features of a general-purpose (Turing complete) programming language with an emphasis placed on OOP simplicity. The language consists of a compiler and virtual machine with associated garbage collector and JIT compiler. The compiler emits binary byte code that is executed by the runtime system. The runtime system has the ability to translate the byte code into IA-32 or AMD64 native machine code. The engineering goal is to have basic optimizations (peep hole) performed by the source code compiler and advanced optimizations performed by the JIT compiler.

Feel free to check out the Introduction to Objeck PDF document.

Examples

Hello World!

<lang objeck> bundle Default {

 class SayHello {
   function : Main(args : String[]), Nil {
     "Hello World!"->PrintLine();
   }
 }

} </lang>

Prime Numbers

<lang objeck> bundle Default {

 class FindPrime {
   function : Main(args : System.String[]), Nil {
     Run(1000000); 
   }
  function : native : Run(topCandidate : Int), Nil {
     candidate : Int := 2;
     while(candidate <= topCandidate) {
       trialDivisor : Int := 2;
       prime : Int := 1;
       
       found : Bool := true;
       while(trialDivisor * trialDivisor <= candidate & found) {
         if(candidate % trialDivisor = 0) {
           prime := 0;
           found := false;
         }
         else {
           trialDivisor := trialDivisor + 1;
         };
       };
       
       if(found) {
         candidate->PrintLine();
       };
       candidate := candidate + 1;
     };
   }
 }

} </lang>

Socket Client

<lang objeck> use Net; use IO;

bundle Default {

 class SocketTest {
   function : Main(args : System.String[]), Nil {
     address := "www.du.edu";
     socket := TCPSocket->New(address, 80);
     if(socket->IsOpen()) {
       get := "GET / HTTP/1.1\r\nHost: ";
       get->Append(address);
       get->Append("\r\n\r\n");
       socket->WriteString(get);
       line := socket->ReadString();
       while(line->GetSize() > 0) {  
         trim := line->Trim();
         start : Int;
         end : Int;
         for(i := 0; i < trim->GetSize(); i := i + 1;) {
           # find tag start
           if(trim->GetChar(i) = '<') {
             start := i;
           };
           # find tag end
           if(trim->GetChar(i) = '>') {
             end := i;
             len := i - start;
             # print tag
             if(len > 0) {
               tag := trim->SubString(start + 1, len - 1);
               if(tag->GetSize() > 0) {
                 if(tag->GetChar(0) <> '/') {
                   tag_end := 0;
                   while(tag_end < tag->GetSize() & 
                     tag->GetChar(tag_end) <> ' ') {
                     tag_end := tag_end + 1;
                   };
                   Console->GetInstance()->Print("start tag: |")->Print(tag->SubString(tag_end))->PrintLine("|");      
                 }
                 else {
                   tag_end := 1;
                   while(tag_end < tag->GetSize() & 
                     tag->GetChar(tag_end) <> ' ') {
                     tag_end := tag_end + 1;
                   };
                   Console->GetInstance()->Print("end tag: |")->Print(tag->SubString(1, tag_end - 1))->PrintLine("|");
                 };
               };                      
             };
           };
         };
         line := socket->ReadString();
       };
       socket->Close();
     }
     else {
       error := "unable to connect to: ";
       error->Append(address);
       error->PrintLine();
     };
   }
 }

} </lang>

Subcategories

This category has the following 3 subcategories, out of 3 total.

Pages in category "Objeck"

The following 200 pages are in this category, out of 331 total.

(previous page) (next page)
(previous page) (next page)