Live data from Hacker News

Cello – A library that brings higher level programming to C

libcello.org

41–50 of 158 posts

Re: Cello – A library that brings higher level programming to C

#41

Earlier quoted context omitted.

slow compile times, complex language, sanity

Compile times aren't that slow, and the language is barely less complex than this insane hack. In fact C++'s complexity allows libraries to make their use a lot simpler. Consider string concatenation in C++ and C. Which is really simpler? The main reason I can think not to use C++ is that C has a simple stable ABI so you can easily use C libraries from many languages and compilers. But you can always wrap C++ librari…

C++ libraries often add new semantics to the language, and that is not so obviously a benefit. Recently I explored Kiwi project (constraint solver). It is easy to use if you solve specific cases, e.g.:

  Variable x, y, z;
  solver.add(x = x - y);
But if you need it in meta-way (and I always do, I rarely write non-meta code), you have to unwind all the sources[-in-headers] to find out what Expression is, how does one construct one, write dynamic expression builder, etc. Sources do consist mostly of one-line helper methods/getters/constructors that are nested and intercalled 10-15 times per operation. LPSolve was much simpler in API, since you don't mess with variables and add constraints directly as matrix values.

  double row[size+1] = { };

  /* ...fill row... */
  add_constraint(solver, row);

  /* ...fill row... */
  add_constraint(solver, row);
In the end of the day, both libraries involve identical usage pattern, but for C++ I have to create a convenience unwrapper. This 'convenience' swamp is SO popular in C++. Once you say "++", you have to deal with it all the time, unless you write something really dumb and straightforward. Not to mention most libraries have huge header-only parts due to template obsession. Qt, yeah. It takes forever to compile 20 modules on reasonably priced laptop even with fine-tuned prefix header and -j9.

From the employment point of view, C++ is a nightmare. No one really knows it, and everyone thinks he does. Experienced developers can't tell what explicit constructor is, are confused with move semantics, blink hopelessly on "what is RVO". You actually employ python programmers for sky prices, while all they know is easiest part of C++/stl magic, which is effectively beginner-grade python with low-level bugs and UBs.

>wrap C++ libraries in a C API

Together with "ecosystem" such as std::cool_ptr>. That's a concern.

When I want nice bridgeable object model above C, I use Objective-C or simple embedded language with proper features. Personally, I'm really tired of C++ everywhere.

Re: Cello – A library that brings higher level programming to C

#42
post #40

Earlier quoted context omitted.

I wonder if the Iron fans realize that they are doing more harm than good the way they go about this. It reminds me of the perl zealot days.

The Iron fans are doing a bit of harm but that Perl zealotism is one of the things that made it wildly popular in its day. And unlike Perl, Iron development is structured, not "organic" a la Larry Wall/Perl. I'm not an Iron zealot but I do believe that there rarely is such a thing as bad publicity :)

Seen much perl lately?

Re: Cello – A library that brings higher level programming to C

#43

Earlier quoted context omitted.

Why did you find that crazy? They are 2 fully separate languages that have both evolved after the latter (C++) was first introduced.

I wouldn't call them "fully separate". Mixed C/C++ codebases are still fairly common, which works as long as the interface between them is in C.

They have separate ISO standards. IMO, this makes them fully separate.

C - ISO/IEC 9899:2011

C++ - ISO/IEC 14882:2014

Re: Cello – A library that brings higher level programming to C

#44

Earlier quoted context omitted.

Why not just write another language, that compiles to machine code, but doesn't totally enforce type safety. Call it Iron.

And make sure Iron has a small group of annoying, hardcore fans who relentlessly disrupts any thread about C or indeed programming in general with their ham fisted advocacy.

Iron Fist

Re: Cello – A library that brings higher level programming to C

#45

Earlier quoted context omitted.

C++ isn't strictly a superset of C! Which I always found crazy. Some C will not compile for C++.

Can you provide C code that will not compile with c++ compiler?

Besides the various "bad old programming idioms" that do not compile under C++, there are a few genuinely useful features that have only just been added to C++ more than 15 years after they appeared in C, like hexadecimal floating-point literals (in practice, many compilers supported these, but they were not formally part of the language). Designated struct initializers are another C feature that I would love to have in C++.

Re: Cello – A library that brings higher level programming to C

#47
post #43

Earlier quoted context omitted.

I wouldn't call them "fully separate". Mixed C/C++ codebases are still fairly common, which works as long as the interface between them is in C.

They have separate ISO standards. IMO, this makes them fully separate. C - ISO/IEC 9899:2011 C++ - ISO/IEC 14882:2014

But the standards have made some effort at avoiding gratuitous incompatibility, and have even introduced changes to reflect changes in the other standard.

Also, much C code is still valid C++. Sure, you can write code that isn't, but I would guess (pulls a number out of nowhere) that 90% of the valid C code is also valid C++.

That makes them languages that have separate standards, but not completely independent standards, that share a whole lot of source code. That's something less than fully separate in my book.

Re: Cello – A library that brings higher level programming to C

#48

Earlier quoted context omitted.

Why did you find that crazy? They are 2 fully separate languages that have both evolved after the latter (C++) was first introduced.

For people who aren't professionally familiar with C or C++ it's an easy mistake to make considering how often things refer to "C/C++" like they are a single skill. Example: https://sjobs.brassring.com/TGWebHost/jobdetails.aspx?jobId=...

When people use the term "C/C++", I assume that they don't know either language well.

Re: Cello – A library that brings higher level programming to C

#49
post #35

Earlier quoted context omitted.

Why would you say that "Cello isn't really C"?

It's arguable that extensive use of macros and faux-dynamic-typing violate the ideology of C that makes it simple and predictable.

I'd remove the “faux”. Cello is dynamically typed.

Re: Cello – A library that brings higher level programming to C

#50
post #24

Earlier quoted context omitted.

What do you love about C and hate about C++?

I'm not the parent, but C has a certain simple elegance: everything's an int; those things which aren't ints (e.g. compound structures like structs and arrays) are represented using pointers and offsets, so in a sense they're also ints; except for floats, but meh. In C++, everything is an int; except for objects; and templates; and lambdas; and classes; and exceptions; and all the other things which keep getting chuc…

"everything's an int"

I don't understand this. Floating point values aren't ints. I suppose strings are integers because they're made up of 8-bit chars (which are basically ints), but I don't understand how that is advantageous or helpful.

Post reply on HN