6 ms·
Ooc - modern object oriented c
- henryw 17y agoi 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 17y agoC# isn't modern? Do you know C#?
- nddrylliog 17y agoI 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 17y agoWhat 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 17y agoAlright - 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 17y agoIf 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 17y agoYou'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 17y agoNo 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.
- uriel 17y agoI would expect a modern language to be like Limbo: http://limbo.cat-v.org http://limbo.cat-v.org
- ilyak 17y agoBy putting c# in the same league as c++ and this ooc, you've automatically tagged yourself as clueless.
- steiger 17y agoAnd why is that? Many parallels can be made with C++/C/C#. I wouldn`t go that far and call it clueless.
- ilyak 17y agoWhen someone lists "C/C++/C#" (not "Java/C#" or "C/C++/D" or "C/ObjC/C++") this typically means two things: - He's judging language proximity by their name instead of their traits. - He doesn't know other languages (often: his experience is limited to MS platform). If someone isn't judging languages by name and have broad sight, he would recognize that C# falls into entirely different bucket (bytecode virtual machine, mandatory garbage collection, managed execution, inseparable class library) than any of C, D, C++, ObjC, ooc.
- joss82 17y agoFor 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 17y agoHmm 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 http://ooc-lang.org/docs/memory/no-gc.html
- joss82 17y agoThanks 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 17y agoprintln() 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.
- imok20 17y agoIt'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 17y agoPlease do =) We're open about its design, all contributors are welcome, all the code is BSD licensed on GitHub. Join the fun!
- bensummers 17y agoYet 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 17y agoThat's a good point. I'll write some docs on that now. Stay tuned.
- rw 17y agoThis 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 17y agoI'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 17y agoD still has a few tricks up its sleeves, don't worry ;). But nice language. It's pretty!
- Derferman 17y agoI would love to see some benchmarks against c and c++.
- nddrylliog 17y agoDone 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 http://goog-perftools.sourceforge.net/doc/tcmalloc.html is looking good)
- scott_s 17y agoThat 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 17y agoIt'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.
- shimonamit 17y agoExcuse 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 17y agoActually, 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 17y agoThat 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 17y agoJust curious - what did you expect? And a name change isn't excluded, do you have any cool language name idea?
- scott_s 17y agoBackwards 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 17y ago
- StrawberryFrog 17y agoThe 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 17y agoThat'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/ http://docs.ooc-lang.org/ from this git repo http://github.com/nddrylliog/ooc-docs 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 17y ago>> 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 17y agoAnd 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.
- xenonite 17y agointeresting. will it be possible to use libs like QT and CUDA?
- nddrylliog 17y agoQT 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/qtjambi-generator.html http://qt.nokia.com/doc/qtjambi-4.4/html/com/trolltech/qt/qt... 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!
- varjag 17y agoI think it's a prank set up by Ruby users, but don't see it anywhere in the text.
- chipsy 17y agoAt 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 17y agoSeems to fit the pattern "ooc is to C as Scala is to Java."
- dtf 17y agoLooks very cool. Any thoughts on adding closures?
- nddrylliog 17y agoIndeed =) It will be implemented very simply, as in the latest Vala release (in fact they should even be compatible).
- dtf 17y agoNow I'm really salivating. Good work!
- berntb 17y agoObjective C && ooc == ? Could it be a precompiler generating Objective C, while using the GC in Apples' frameworks?
- nestlequ1k 17y agooooc
- cesare 17y agoI would like to take a look at this project, but the link to the source on github is broken.
- truiu 17y agoThe link on the download page seems to be broken. The correct one is on the community page: http://github.com/nddrylliog/ooc/ http://github.com/nddrylliog/ooc/
- hxa7241 17y ago> it thrives to be I think you mean: "it strives to be"
- omouse 17y agoMaybe he has a Lisp?!
- discojesus 17y agoor it's all part of some grand scheme...
- nddrylliog 17y agoGroup 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 =)
- Davertron 17y agoYou also have "syntaxic" in a number of places when you want "syntactic" :) Looks very cool!
- bbb 17y agoMinor 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 17y agoThere 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 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.
- bbb 17y agoThe 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 17y agoCompiled to plain C, hence fast and super compatible... In the beginning, there was cfront... ;)
- bbb 17y agoTrue, but it wasn't exactly Ruby/Python/IO inspired. ;-)
- nddrylliog 17y agoI've added the optional {} after the empty TimeT cover =) Is it clearer now? I'm really glad to see that it scratches an itch for many people out there. As always, suggestions are welcome.
- bbb 17y agoUh, no. I guess I picked the wrong declaration; I meant Tm. There is a bracket/scope opened after 'struct tm' that, as far as I can tell, is never closed.
- swolchok 17y ago"Compiled to plain C, hence fast" is not actually a great argument. See e.g. lua-jit, which IIRC just generates subroutine-threaded code. (In other words, it "merely" takes a series of lua opcodes generates C code that is a series of calls to the functions that implement these opcodes.)
- Raphael_Amiard 17y agoI'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/ 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 17y agoClosures 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 17y ago> 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 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 !
- jcw 17y agoThis looks great. Let's all hope bloat and feature creep don't turn it into C++ in a few years.
- lzimm 17y ago/* 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 17y agoIf it's message passing, then yeah it's a good thing, but apparently it's just a syntax thing so not too exciting.
- natemartin 17y agoLooks 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?