Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: ooc bindings for sfml2 (ooc-sfml)  (Read 4852 times)

0 Members and 2 Guests are viewing this topic.

shamanas

  • Newbie
  • *
  • Posts: 6
    • View Profile
ooc bindings for sfml2 (ooc-sfml)
« on: December 28, 2010, 01:59:28 am »
Hello everybody :)
I just finished writing some ooc bindings for sfml2, so I thought I'd come and post a link for my github repo. But first, I am sure that very few of you have heard of ooc. Ooc ( which originally meant object orientated c but has been renamed to out of class ), is an awesome language with cool syntax ( I know it's subjective but anyways, how can you not like pure awesomeness ?  :P ). It is translated to C, which makes it very practical as writing bindings for C libraries is extremely easy. As you may have guessed by that last sequence, ooc-sfml is actually a binding for csfml and not for sfml itself. However, the fact that ooc is an object orientated langugage makes the usage of ooc-sfml closer to sfml than to csfml.

Links
------

ooc-sfml: http://www.github.com/shamanas/ooc-sfml
Ooc website: http://www.ooc-lang.org

Please let me know about any bugs/comments and post your feedback here

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
ooc bindings for sfml2 (ooc-sfml)
« Reply #1 on: December 28, 2010, 02:11:07 am »
First I thought it was Apple's Objective-C but OOC's syntax actually looks a bit cleaner and more C-like. I'll have to have a look at it later. Does it also try to follow smalltalks way of object oriented programming? You know with messaging and so on?
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

shamanas

  • Newbie
  • *
  • Posts: 6
    • View Profile
ooc bindings for sfml2 (ooc-sfml)
« Reply #2 on: December 28, 2010, 10:50:58 am »
Well I never programmed in smalltalk, but i just googled it for 2 seconds. Messages look like another way of calling member functions (or are there other differences?). I honestly do not know exactly where the ooc syntax/grammar was inspired from, although i do know that ooc's creator talks alot with the creator of io (http://www.iolanguage.org) and that these two langiuages are similar in many ways (decl-assign operator, object member syntax [no dots])

P.s: ooc's syntax is alot cleaner than objective-c's

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
ooc bindings for sfml2 (ooc-sfml)
« Reply #3 on: December 28, 2010, 12:04:19 pm »
Quote from: "shamanas"
Messages look like another way of calling member functions (or are there other differences?).
The main difference that I've understood by practicing Obj-C is that messages can be sent to anyone – even if they don't understand them – unlike methods. But I'm not sure about that – and Apple often use methods and messages for the same thing so...


Quote from: "shamanas"
ooc's syntax is alot cleaner than objective-c's
cleaner maybe, but not «a lot cleaner» – it's a quite different from what I've seen very quickly. In fact I looks more like Scala (in the Java way) than Obj-C to me.
SFML / OS X developer

shamanas

  • Newbie
  • *
  • Posts: 6
    • View Profile
ooc bindings for sfml2 (ooc-sfml)
« Reply #4 on: December 28, 2010, 01:32:52 pm »
Quote from: "Hiura"
Quote from: "shamanas"
Messages look like another way of calling member functions (or are there other differences?).
The main difference that I've understood by practicing Obj-C is that messages can be sent to anyone – even if they don't understand them – unlike methods. But I'm not sure about that – and Apple often use methods and messages for the same thing so...

So you mean you can just do someObject someMessage, even if the object has no message named someMessage? I don't quite get how this is helpful.


Quote from: "Hiura"
Quote from: "shamanas"
ooc's syntax is alot cleaner than objective-c's
cleaner maybe, but not «a lot cleaner» – it's a quite different from what I've seen very quickly. In fact I looks more like Scala (in the Java way) than Obj-C to me.

Yep it is true that Objective-C and ooc don't have very much in common. However, every time i've seen Obj-C code, i turned my head and closed my eyes in horror.
I mean, how can you say that
Code: [Select]

o := MyObject new(myString)


is not alot cleaner than

Code: [Select]

MyObject *o = [[MyObject alloc] initWithString: myString];


However, they share some common aspects, like the way you can do foreach'es (yep, I know it is done in many other languages this way too)
Code: [Select]

for(cat in cats) {
...
}


Also ooc supports function suffixes, wich are, i believe, an  obj-c feature (not sure about this). For example you can do taht in ooc:
Code: [Select]

MyClass : class {
    init : func ~withString (str : String) { // Do something ... }
    init : func ~withInt (num : Int) { // Do something ... }
}

Of course, when calling the funcion, you dont have to write the ~ part, wich is only here to help debugging and read the code. Always in this example, you could then do
Code: [Select]

obj1 := MyClass new("foo")
obj2 := MyClass new(42)

Note: new is actually not a keyword, but a static function wich is added by default to your class (it can be overwritten of course) and that calls init

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
ooc bindings for sfml2 (ooc-sfml)
« Reply #5 on: December 28, 2010, 01:50:32 pm »
The main thing with messaging in this kind of way is that you get a language with support for duck-typing, you decide the type of the class at runtime by what methods it support(It sounds like a duck, it walks like a duck, it looks like a duck, it must be a duck). More or less, the type is not what we are interested in but only what method it supports. We do not need to specify a type for variables, arguments and so on. Also mostly why it was used in all the Smalltalk children languages is because you can create a object who will forward the message to another object if itself do not understand the one it received. There's a lot of other neat tricks that I currently don't remember.

Ruby also uses it deep down in the core :P

I'm wondering, is OOC compiled or interpret?
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
ooc bindings for sfml2 (ooc-sfml)
« Reply #6 on: December 28, 2010, 02:02:10 pm »
Quote from: "shamanas"
So you mean you can just do someObject someMessage, even if the object has no message named someMessage? I don't quite get how this is helpful.

In OOC it wouldn't be usefull I think, as it's a static language (I mean, you can't add methods afterward to a class, can you ? ). And in Obj-C you'll get a crash if you send a message to an object which doesn't respond to it. At this point you may think : «what on Earth does the Obj-C designers thought when they add such feature?». Well, it's kind of tricky :

In obj-c you can add stuff to a class at runtime with «categories» for example (some doc).


Quote from: "shamanas"
Yep it is true that Objective-C and ooc don't have very much in common. However, every time i've seen Obj-C code, i turned my head and closed my eyes in horror.
When I started learning Obj-C I was also a little bit stunned but when you have large amount of code you're grateful to have such method name because you can read the code almost like English. But I agree : sometimes it's a little bit too heavy.
SFML / OS X developer

shamanas

  • Newbie
  • *
  • Posts: 6
    • View Profile
ooc bindings for sfml2 (ooc-sfml)
« Reply #7 on: December 28, 2010, 02:57:45 pm »
ooc (not OOC  :evil: :P ) is first translated to C and then compiled (thought id mentioned that?). And yes, it is a static language. However you could use first-class functions to change an object's methods during execution (but not add new ones)

shamanas

  • Newbie
  • *
  • Posts: 6
    • View Profile
ooc bindings for sfml2 (ooc-sfml)
« Reply #8 on: July 01, 2011, 10:45:56 am »
I am updating ooc-sfml to the latest commit of sfml2 :)
Just letting everyone know this project is revived.

 

anything