

Ooc - modern object oriented c - ptomato
http://ooc-lang.org/

======
nddrylliog
Group answer so I don't blow up my HackerNews quota:

thrives/strives : yeah! thanks a lot, fixed now

wrong url in downloads: all fixed, thanks for reporting.

guess vs inferred: replaced.

why some things are prefix and some infix: that's the magic of covers. In "hi
world" println(), it's the method String.println() which is called. In
println("hi world"), it's a different function, e.g. println(String) which is
called.

prank by ruby users: actually there seems to be a lot of interest from the
ruby community =) maybe they're realizing you can have nice syntax without a
VM.

Objective C && ooc: that's been mentioned on #ooc-lang, it would be very
interesting for iPhone development, definitely something to explore =)

sorry about the delay, I've got more traffic than I can handle right now =)

EDIT 1: fixed syntaxic/syntactic. Damn me and my French background ;) thanks
for reporting

EDIT 2: I _love_ the comparison "ooc is to C as Scala is to Java." Seems very
fit =)

~~~
bbb
Minor question: what's the RSS feed for the blog?

Safari lists two:

    
    
      feed://ooc-lang.org/feed.php
    

and

    
    
      feed://ooc-lang.org/feed.php?mode=list&ns=
    

The former one appears to be empty and the latter one doesn't appear to
include blog posts (or at least it includes a lot of other stuff; I'm not
sure). It would be nice to have a regular RSS just for the blog for us non-
Twitter-aficionados.

~~~
nddrylliog
There is one actually, (and now I must reveal the ugly blog hack I made to
integrate wordpress with DokuWiki), <http://ooc-
lang.org/blogbackend/?feed=rss2>

It should probably be linked on the website. Lemme fix that.

EDIT: Added link to rss and atom feeds on the blog.

------
chipsy
At first I wanted to say "bah humbug" but it really does seem to hit a sweet
spot:

-Common modern features(implicit typing, generics, GC, iterator syntax)

-Source-to-source C, so it is compatible with just about everything

-Doesn't attempt to reinvent libraries

-Doesn't attempt to reinvent the build system

-Doesn't diverge strongly on syntax(apart from supporting the new features)

These are the kind of things that make a language easy to pick up and start
using :)

~~~
jimbokun
Seems to fit the pattern "ooc is to C as Scala is to Java."

------
imok20
It's beautiful. I think I'm in love!

It's a wonderful framework giving me a graceful syntax and some nifty tools. I
may just get involved!

~~~
nddrylliog
Please do =) We're open about its design, all contributors are welcome, all
the code is BSD licensed on GitHub. Join the fun!

------
StrawberryFrog
The documentation has issues, e.gs.

 _"But remember, the compiler is your friend. He guessed that's what you
wanted to return."_

Yuk, a compiler is not a cuddly teddy bear, and I really don't want a compiler
to "guess", I want it to be very predictable in its behaviour.

 _add: func(a, b : Int)_

Previous function example specifies a return type, why doesn't this one?

 _The strange little dots_

Oh please.

No explanation of why some things seem to be prefix, e.g. _"Hi, softer world
=)" println()_ and some are infix, e.g. _add(1, 2)_

~~~
nddrylliog
That's why it's called a "tour", not a reference documentation ;) Reference
docs are being written, and are updated here <http://docs.ooc-lang.org/> from
this git repo <http://github.com/nddrylliog/ooc-docs> If you want to help
you're welcome.

> A compiler is not a cuddly teddy bear

Why, shouldn't it? I always found gcc so cold and all. Friendly compilers
surely aren't so bad. I could do a -hardass flag if you wanted.

> Previous function example speicifes a return type, why doesn't this one?

Wohow, my bad. Fixed in the doc.

> The strange little dots

Actually they _are_ strange, because they're unexpected. It's a bit of the
syntax that would probably most appeal to perl hackers, and is totally
optional.

EDIT: Realized the return type was missing in add: func definition. :/ sorry.

~~~
StrawberryFrog
>> Previous function example speicifes a return type, why doesn't this one?

> Because the function doesn't return anything (e.g. is void), I guess.

Have another look at it. Does "add" look to you in this context at all like a
function that returns void?

 _printf("1 + 2 = %d\n", add(1, 2))_

~~~
nddrylliog
And now I feel very dumb.

You were right :/ It's all fixed now, thanks a lot for reporting.

(At first I thought that you thought that return type specification was non-
optional, e.g. that it lacked "-> Void")

About the other issues: are you really bothered by them? (e.g. the familiarity
of the writing, etc.) I thought it'd be less boring, but I didn't mean it to
annoying.

EDIT: fixed the "strange little dots" and "compiler is your friend" parts.

~~~
StrawberryFrog
Striking the right tone is hard, and you can't please everyone. Personally, I
like a slightly conversational tone, but it's easy to got to far with it, and
it just becomes a waste of words. You're writing to please the reader, not the
writer ( see <http://news.ycombinator.org/item?id=875094> ).

E.g. "Foreaches. Foreaches is like.. a regular For that gave up alcohol,
decided to shave daily, and bought a new suit. It's prettier, and more
effective. "

I've been programming in C# for years, I know foreach. It's a workhorse
feature that I use daily. There are similar constructs in Ruby and PHP and
others.

------
lzimm
/*

Vector3f: class { x, y, z : Float }

vec := Vector3f new() vec x = 3.14 vec y = 6.18 vec z = 42.0 // hey,
Java/C/C++/C# guys: look! no dots =)

*/

Uhh, are "no dots" supposed to be a good thing?

~~~
omouse
If it's message passing, then yeah it's a good thing, but apparently it's just
a syntax thing so not too exciting.

------
Raphael_Amiard
I'm sad that i don't see any references to first class functions and closures.
But that may be because they're not implemented yet.

Also, any thoughts about all that "immutability by default" rumble ? Is ooc
too close to c to give that a thought ? Simplify the use of immutable data
structures would be very cool, and very possible since ooc has a gc.

Actually, i was thinking about a "competitor" for this nice language, and the
closest thing to it that i found was BOO : <http://boo.codehaus.org/>. Boo has
a syntax that is just as nice, comparable set of features + closures, very
nice type inference, and very good interaction with native code. It runs on
.Net, but i think the interop with c is really very flawless for once. You can
even manipulate pointer data. And it has the nicest macros i've seen yet in a
non lisp language (i've not seen a lot except lisps tho).

~~~
nddrylliog
Closures are planned, indeed.

About immutability, it's really a hard call for me to do here. C is very much
about in-place data modification (as far as I know). Working with immutable
objects seems to be a very different approach.

What do you mean with "simplify the use of immutable data structures" ? Like a
good support for const?

Thanks for the feedback, I'll definitely look deeper into Boo to steal.. huh
get inspiration from it ;)

~~~
Raphael_Amiard
> About immutability, it's really a hard call for me to do here. C is very
> much about in-place data modification (as far as I know). Working with
> immutable objects seems to be a very different approach.

Yeah i know what you mean. But anyway this is a whole other topic, and it
could be programmed by third parties. The important part would be more about
enforcing a transitive const keyword, and some other nice things like that.I
think what the d people are doing at the moment is very interesting :
<http://www.digitalmars.com/d/2.0/accu-functional.pdf>

Another question i had is, do you plan to provide any meta-programming
facilities (macros) ? Boo is very interresting in this regard, i can only
recommend you look into it.

Oh and one last thing, how does ooc fare performance wise compared to plain c
at the moment ?

Also i've been toying a bit with ooc and it's very nice to code in. I will
probably follow its evolution with a great lot of interrest. Thanks for your
work and dedication !

------
bensummers
Yet another interesting looking new language -- but not on the JVM for once.

The site doesn't explain how C and C++ libraries can be used, especially with
respect to GC. There doesn't seem to be a destructor/finalizer to wire up to a
'legacy' free(), so wrapper classes might be tricky.

~~~
nddrylliog
That's a good point. I'll write some docs on that now. Stay tuned.

------
bbb
The second to last example looks like it is incomplete:

    
    
        include time // equivalent to #include <time.h> in C
     
        TimeT: cover from time_t
        Tm: cover from struct tm {
           tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year, tm_wday, tm_Tm*
     
        main: func {
          timestamp := time() // timestamp is now a TimeT
          t := localtime(timestamp&) // t is now a Tm*
          printf("It's %dh%d.", t@ tm_hour, t@ tm_min)
        }
    

I would have expected a closing } in the definition of the TimeT cover.

Generally speaking, ooc looks really promising. Compiled to plain C, hence
fast and super compatible, and with syntactical treats borrowed from Python
and Ruby. I wanted this for a looong time. :-)

~~~
jcl
_Compiled to plain C, hence fast and super compatible..._

In the beginning, there was _cfront_... ;)

~~~
bbb
True, but it wasn't exactly Ruby/Python/IO inspired. ;-)

------
natemartin
Looks really interesting!

The one thing I was missing, coming from an objective-c background, is named
parameters in method calls. Definitely one of my favorite parts of
objective-c.

Any thoughts on adding anything like that?

------
hxa7241
> it thrives to be

I think you mean: "it _strives_ to be"

~~~
omouse
Maybe he has a Lisp?!

~~~
discojesus
or it's all part of some grand scheme...

------
varjag
I think it's a prank set up by Ruby users, but don't see it anywhere in the
text.

------
rw
This looks a _lot_ less syntactically confusing than D. Specifically, by
describing it as "here's how to shorten the C you already want to write".

~~~
nddrylliog
I'm part of the crowd who thinks it's too bad that D didn't get that far, that
it was encumbered by licence issues and a syntax sometimes more complete than
what you need.

I'm trying to stay minimal with ooc's syntax. From 0.3 on, it's heavily Io-
inspired (Steve Dekorte and I are regularly discussing syntax matters.) and
with operator overloading, generics, etc. you get a very expressive language
at little cost.

In the end, it's just a bunch of new idioms to learn =)

~~~
steveklabnik
D still has a few tricks up its sleeves, don't worry ;).

But nice language. It's pretty!

------
Derferman
I would love to see some benchmarks against c and c++.

~~~
nddrylliog
Done and done, but it's not such a good idea.

ooc translates to C, and as someone mentioned, it's often the C you would
write yourself.

What you would really be benchmark here is Garbage collector vs vanilla
malloc/free. And whether one or the other is fastest depends greatly on your
scenario (and on your malloc implementation, e.g. <http://goog-
perftools.sourceforge.net/doc/tcmalloc.html> is looking good)

~~~
scott_s
That your compiler produces C doesn't imply anything about performance. When
you introduce general abstractions, you also make it harder to perform certain
optimizations. It's still worthwhile, and potentially informative, to write an
idiomatic OOC program, an optimized OOC program, and compare their performance
to both an idiomatic C program and an optimized C program. (Solving the same
problem, of course.)

Your statement "it's often the C you would write yourself" is a claim that you
can support with numbers.

~~~
nddrylliog
It's very difficult to determine what is "idiomatic", and how far to go.

For example, in ooc you often have to choose between classes and covers. When
you don't need inheritance, covers is often enough, + you get to work on the
stack rather than all on the heap (in that respect, ooc offers more
flexibility than Java, and a little less than C++)

What would also be interesting is offering abstractions for parallelism in
ooc, etc. and then differences in benchmarks would show for "idiomatic"
implementations. (Very much like Haskell idiomatic solutions are sometimes
faster than C ones.)

The challenge that programmers are presented with nowadays is much more than
just rewriting a few tight loops in assembler ;) Concurrency and parallelism
are the most important challenges for us now, imho.

~~~
scott_s
Hey, you're the designer and implementer. You need to explore what idiomatic
OOC codes looks like. If you pick up enough users, they'll evolve it for you,
but you need to start it.

If you're interested in abstractions for concurrency and parallelism, I
suggest you look at both Cilk and Apple's block extension for C (used in
conjunction with Grand Central Dispatch). There are many others, of course,
but those perhaps are the easiest fit into your language.

------
joss82
For me it looks like a compilable python (with more complex syntax, of course)
but with all the libraries of C.

The garbage collector without gc_free() means less control and memory leaks in
complex programs (my biggest issue with python). I guess one could use
malloc() and free() if they really want to (since C headers can be imported).

The hello world example is confusing though.

~~~
nddrylliog
Hmm what is confusing in the hello world example?

And yeah, you can totally use malloc/free.

Either globally (e.g. just change the definitions of gc_malloc/gc_realloc etc.
to be extern(malloc), extern(realloc), etc.) or locally for a specific class,
e.g. overriding the "alloc" method of a class or writing your "new: static
func() {}" yourself instead of relying on auto-new generation from "init:
func() {}" methods.

We need more documentation =) Stay tuned.

EDIT: Added some docs here <http://ooc-lang.org/docs/memory/no-gc.html>

~~~
joss82
Thanks for the docs, what a quick and effective feedback !

Let's have a look at the "hello world" :

"Hello world!" println()

It is simple and short but makes no sense to me because the print function
takes no argument and doesn't seem linked to the string "Hello world!" it
prints.

When a function manipulate data, shouldn't it be passed as argument ? I would
understand better:

println("Hello world!")

But maybe it's because it's not the first time I read code.

EDIT : OK, I just read your group post. Thanks.

~~~
0x44
println() isn't a function, it's a method/message passed to the "Hello world!"
string object. The lack of syntax highlighting that (the strange dots) makes
it difficult to notice.

------
dtf
Looks very cool. Any thoughts on adding closures?

~~~
nddrylliog
Indeed =) It will be implemented very simply, as in the latest Vala release
(in fact they should even be compatible).

~~~
dtf
Now I'm really salivating. Good work!

------
shimonamit
Excuse the superficial review, but it looks like JSON, not C. Why the name
association with C, apart from the fact that you can include C libs? Vala or D
look much closer to C.

~~~
nddrylliog
Actually, the syntax has evolved much since ooc 0.1 (which was then closer to
C).

The main implementation is still a source-to-source translator to C99 so the
name association is still justified.

Plus, if you don't like "ooc = object oriented C", you have plenty of choice.
My personal favorite is "only on caturday". But YMMV.

~~~
scott_s
That you compile (not translate) down to C is an implementation detail. I
think you've deviated enough from C that a name change might help people's
first impression - I had very different expectations because of the name.

~~~
nddrylliog
Just curious - what did you expect?

And a name change isn't excluded, do you have any cool language name idea?

~~~
scott_s
Backwards compatible with C with object-orientation. When you include the name
of another language in your own name, I assume you're either a subset or a
superset of that language.

I have no real suggestions, but it's worth noting that some popular languages
have names with no relationship to the language (Java, Python, Ruby). I think
perhaps the most important criteria are that it's a single syllable, easy to
say, easy to type and doesn't have unfortunate associations.

~~~
nddrylliog
I'm not sure what you mean with "Backwards compatible with C". You can easily
use ooc code from C, and C code from ooc. What more do you want?

ooc is indeed not a superset of C syntactically. Objective-C is there for
that, and its syntax is (imho) a mess.

You can mix and match C and ooc code at will =)

~~~
scott_s
Please don't confuse this with an issue of what I _want_. It's just what I
think the name implies.

"Backwards compatible" implies, to me, that if I take out the new features
from the language, I'm left with legal code in the original language. This is
markedly different than being able to _call_ one language from another. I can
call Fortran code from C, and I would never characterize Fortran and C as
"backwards compatible."

One is about source code compatibility. The other is about object code
compatibility.

------
henryw
i was going to say that there's already c++ or c#, but the language looks
really cool. i guess the keyword there is "modern".

~~~
ighost
C# isn't modern? Do you know C#?

~~~
nddrylliog
I don't consider C# a modern language.

C# is a good proprietary ripoff of Java, with a few things done right. Java
itself was a wrong interpretation of Smalltalk with C++-like syntax to attract
the masses and, they randomly crossed every feature they thought was
"complicated".

What's modern about it? Except that they add bloat with each new version. The
original C# wasn't so bad. Just my 2 cents =)

EDIT: Stay calm. The above is obviously an over-statement. I don't really care
about C#. Relax. Breathe. Write some Python. Feeling better now?

~~~
shrughes
What would you expect a "modern" language to be like?

Your opinion about C# is flat-out asinine. The original C# had less type
safety. And it lacked anonymous delegates. And it required you to write out
all your types. If you actually used C#, you would not decide that you'd
rather use C# 1 instead of C# 3 unless you were deliberately being irrational.

~~~
nddrylliog
Alright - before it becomes a troll =)

I have no definitive opinion on C#. I don't use it, don't really care about
it, and yeah the fact that bloats comes with successive versions doesn't mean
there weren't improvements as well.

In fact, bloat is often the price to pay for completeness/usefulness, and as I
see it, C# is both quite complete and very useful (makes up for a lot of jobs
now).

I'd expect a modern language to be either very minimalistic like Io, or very
expressive like Scala, or very straight-forward like Python.

But I guess this is a point that would gain to be elaborated in a blog post or
something - we're too limited here in the comment to say much of value.

~~~
scott_s
If you're ignorant of C#, then you probably shouldn't make declarations about
it. Your definition of "modern," while reasonable, is not a commonly accepted
one, so be careful about using it without defining it.

~~~
nddrylliog
You're right, now that I'm a public person, I must be careful what I declare.
(Damn you, scope)

No seriously - who cares what I say? ;)

~~~
ighost
No one cares what you say until you start flaming something you know nothing
about. Then some people develop a need to set the record straight.

------
jcw
This looks great. Let's all hope bloat and feature creep don't turn it into
C++ in a few years.

------
cesare
I would like to take a look at this project, but the link to the source on
github is broken.

~~~
truiu
The link on the download page seems to be broken. The correct one is on the
community page: <http://github.com/nddrylliog/ooc/>

------
xenonite
interesting.

will it be possible to use libs like QT and CUDA?

~~~
nddrylliog
QT is C++ and CUDA is C so yeah, it would be quite straightforward =)

An ooc user has been looking into adapting
[http://qt.nokia.com/doc/qtjambi-4.4/html/com/trolltech/qt/qt...](http://qt.nokia.com/doc/qtjambi-4.4/html/com/trolltech/qt/qtjambi-
generator.html) to generate ooc QT bindings. If you're interested, join us on
our IRC Channel #ooc-lang at Freenode

I'd be very interested in seeing some CUDA/ooc work!

------
berntb
Objective C && ooc == ?

Could it be a precompiler generating Objective C, while using the GC in
Apples' frameworks?

~~~
nestlequ1k
oooc

