44 ms·
Show HN: Introducting C+
- deleted 14y ago[deleted]
- codewright 14y agoHow is this different from Obj-C? Seems mostly like syntax sugar on top of what already exists in C. The call and call_with are intriguing though. Please change the name to something searchable and easily remembered before it's too late.
- orangeduck 14y agoWell Objective C is a separate language entirely. This is just a library for GNU99 C. Point about name noted, open to suggestions :)
- codewright 14y ago"Bluegoose C runtime" What are the performance implications of these features? How do they compare with similar C++ functionality, especially things they do at compile-time? Can I have a pretty graph? What trade-offs were made? Can they be improved? Are certain aspects or semantics optional? Do you pay the price of linking this library simply by linking it, or do you "only pay for what you use"? Is it safe? Type-safe? If not, what's required to make them safe? If you don't answer these questions, somebody like me will who's ignorant of how this is supposed to work will produce their own data. That's not good, you understand how it's supposed to be used.
- orangeduck 14y agoThat's a lot of questions. I will do my best to answer them but note I am not trying to sell a language here. I'm just a student and wanted to show an interesting project I'd been playing with. The performance implications are much like vtable lookup in C++. Generic functions are essentially overloaded and their function pointer looked up at runtime. The main tradeoff over C++ is that rich types don't play well when allocated on the stack as destructors cannot be automatically called on frame exit. The added semantics are not optional, but you can still program in standard C while avoiding the defined keywords and functions and the interaction should not be troublesome at all. There is no price for linking the library. It is not type-safe and employs runtime type checking where inserted by the user - but also this allows for duck typing and more generic code so perhaps it is not a bad thing all round. I hope that helps. Any more questions feel free to drop me an e-mail.
- chm 14y agoWhat about "C&"? C and Short and easily searchable.
- jspthrowaway 14y ago> Well Objective C is a separate language entirely. Not quite; Objective-C is a superset of C. You can write pure C and compile it as Objective-C all day long. This is an important point because people think their C knowledge doesn't translate to Objective-C, mainly because people say things like "it's entirely different". At its core, it really isn't -- the superset syntax becomes straight C underneath.
- jballanc 14y agoBeyond that, even, you can write Objective-C in pure C99. The brackets, class definitions, and all the rest is a sort of syntactic sugar that converts directly to a handful of straight C functions (you can find them all here: https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html https://developer.apple.com/library/mac/#documentation/Cocoa...)
- skrebbel 14y ago"Mediterranean C". Fits, because it's more comfortable, more laid-back, less worrying-about-the-future C programming (si si, we typecheck mañana!).
- inoop 14y agoOn the other hand, this language appears to be working.
- nthitz 14y agoYou probably could have chosen a less confusing name..
- dysoco 14y agoI dislike the way you declare variables, I'd rather prefer the classic: "int x = 5;" but with some syntactic sugar for Stack/Heap. It's interesting anyways, I love the simplicity of C but agree that it's a bit "outdated", and I dislike the radical change of Go.
- agentS 14y agohttp://blog.golang.org/2010/07/gos-declaration-syntax.html http://blog.golang.org/2010/07/gos-declaration-syntax.html
- stcredzero 14y ago> ...I dislike the radical change of Go. Funny, but the common criticism in the days when Go was first released was that it was not radical enough.
- eungyu 14y agoA+ for clever use of typedef void star
- areorui 14y agoWtf
- 3rd3 14y agoPlease elaborate.
- robomartin 14y agoPlease don't
- effinjames 14y agoHypocrites
- sverige 14y agoIf only you had been around during my first interview when I told the recruiter that I knew C, C+, and C++.
- meta 14y agoCool idea. I am confused by the implication of this code var prices = new(Table, String, Int); put(prices, $(String, "Apple"), $(Int, 12)); Stack objects are created with "$" so these are on the stack and then placed into the Table? So if this was in a function and the function returned, the Table (lets assume it was global) would now be pointing to destroyed stack variables? Is that the correct interpretation? Is this all done with header files and the preprocessor? It looks like that is the case - if so, I am impressed at the dances you got it to do ;) Also, have you read http://www.amazon.com/Interfaces-Implementations-Techniques-Creating-Reusable/dp/0201498413/ http://www.amazon.com/Interfaces-Implementations-Techniques-... which does some "Object Orientation" in C tricks?
- MetallicCloud 14y agoI'm just guessing here, but I assume the variables are created on the stack, then copied into the table object, rather than references being passed to the table. So when the function would end, the original variables would be destroyed, but the copies would remain.
- orangeduck 14y agoThis is correct. "Table" is a datatype which copies the values into the table, while "Dict" is a data type that holds references to the objects. The same semantics hold for "Array" and "List". Although not perfect this was probably the best way I could have designed such structures. There is some info in the header files as to how to use them.
- crudbug 14y agoNeat!
- shadowmint 14y agoHad a play with it; few oddities, but this is pretty cool. The use of the $ function is totally not portable though, which is a bit of a pity. Doesn't compile on a mac either; bunch of warning about pointer size that are being treated as errors by -Werror Still, nice work~!
- aeroevan 14y agoI think that's actually an issue with 64bit pointers :/
- orangeduck 14y agoYeah using $ was pretty cheeky. I use a few other GCC specific features such as nested functions, which is why I specify that the standard is GNU99 rather than C99. If you have any errors on mac please post a bug report as I don't have a machine to test on! Thanks.
- eigenrick 14y agoWorks on my Mac (with gcc 4.7 :) )
- codgercoder 14y agobad name
- ryanashcraft 14y agoI was working a similar project a few months ago. Wish I hade more time to complete. Mine was a bit more of a ripoff of Obj-C than anything. https://github.com/ryanashcraft/Classified-C https://github.com/ryanashcraft/Classified-C
- jamesaguilar 14y agoIMO, any new language that has inclusion as a mechanism for modules is not just at a developmental dead end, it's over the curb at the end of that dead end and in the retention pond beyond. The parser and compiler should only need to examine each source file once.
- skrebbel 14y agoThis isn't a new language. It's a C library. ps. Of course that does not invalidate your point, which I fully agree with. It's just on the wrong thread.
- huhtenberg 14y agoHow's your comment even remotely related to the submission?
- troymc 14y agoA resume that said the applicant had programmed with C, C+ and C++ used to be a tell. Not any more, I guess.
- philbarr 14y agoMy local bookstore had a sign in the software development section saying "C, C+, C++". I can't point and laugh anymore :(.
- nsp 14y ago0
- prtamil 14y agoEvery Smart guys is trying to bring Lisp's functionality in C Syntax. But i'm stupid , i directly use Lisp. Even its hard and that's why i'm stupid.
- Meai 14y agoI have two things that would make me very happy in C: Overloadable operators and constructors/destructors. I have not been able to come up with a way to do that yet, but maybe if I change the entire way I write C like you did with the syntax changes, it might actually work. I'm going to have to think about that!
- dietrichepp 14y agoOut of curiosity, what's wrong with C++? You can always -fno-rtti -fno-exceptions disable everything, then avoid classes and templates.
- huhtenberg 14y agoSome form of templating would be nice too. Something to replace multi-line macros.
- nnq 14y agoit always annoys me when people can't properly write about what they've done. For example, the description says, with reference to C: "I've turned it into something of a dynamic and powerful functional language which it might have once been" ...is his wording wrong or what? ...'cause C has never been a "powerful functional language"
- rytis 14y agonot everyone is good at writing and expressing themselves in written language. quite a lot of good engineers actually struggle with this. definitely no need to be "annoyed", may be try helping him out?
- nnq 14y agoI don't mean literary style or PR magic or anything, just using the words right so what comes out is exactly what you mean, not something that means something different but you have to use the context to understand what he probably thought about when writing that... If one can express his thought in a programming language, one can also use basic grammar like tenses and modes to say what he means... all this "words don't matter" attitude is what eventually ends up spreading and making wonderful pieces of software engineering unusable because of broken docs...
- Nursie 14y agoPerhaps 'it might once have become' would make more sense there, in that it was a development the author thought could have happened in the past but did not?
- IsTom 14y ago> What I don't enjoy in Haskell is writing small detailed algorithms in a functional style. You can hop around this easily using the ST monad. It's less elegant than usual Haskell and often less elegant than languages where mutation is 'native', but it does its job.
- michaelfeathers 14y ago> What I don't enjoy in Haskell is writing small detailed algorithms in a functional style. Wow. That's my favorite part.
- taken 14y agohow about adding a macro var(name, type, value) -> var name = $(type, value)?