News for hackers. Stuff that matters.
Re:Ways to Avoid Complexity in Modern C++ [pdf] by vvanders on Monday December 07, 2015 @12:35PM (#10690997)
When you give me a language that I can specify explicit memory layout and support for generics we can talk.

Otherwise C++ is going to continue filling the space for large, performance sensitive applications.

Re:Ways to Avoid Complexity in Modern C++ [pdf] by krylon on Monday December 07, 2015 @02:27PM (#10691982)
No flame-bait here, but if you are seriously looking for that, how about Ada?

Realistically, I don't see C++ going away for a looong time (if ever), simply because of the huge amounts of code written in it. But if one were looking for an alternative that matches C++ both in performance and control over memory layout, Ada is where I would start. It has generics, you can do OOP, it avoids many of the syntactic pitfalls of C++... As a bonus, the language standard and the rationale are available for free.

Re:Ways to Avoid Complexity in Modern C++ [pdf] by supernintendo on Monday December 07, 2015 @03:34PM (#10692483)
I can think of a few reasons to avoid Ada. For one, resources and community for this language are basically nonexistent compared to C++. The history of the language is obscured in proprietary implementations which has led it down the same road as Pascal in terms of longevity. Ada has "bad parts" in the same way that C++ does, although this is mitigated by SPARK.

Concurrency / tasking in Ada is simple and beautiful, however. One of the most compelling features of the language, especially coming from C++.

Re:Ways to Avoid Complexity in Modern C++ [pdf] by tjr on Monday December 07, 2015 @03:40PM (#10692523)
I have observed a strong trend in avionics software development to move away from Ada towards C++. I have not yet heard a concrete reason why. I might guess that it's easier to hire people with some existing C++ experience than with Ada experience, but understanding the programming language is pretty inconsequential compared to understanding the product domain.
Re:Ways to Avoid Complexity in Modern C++ [pdf] by marvy on Monday December 07, 2015 @03:34PM (#10692484)
How much does Ada rely on garbage collection?
Re:Ways to Avoid Complexity in Modern C++ [pdf] by Solarsail on Monday December 07, 2015 @04:36PM (#10692895)
Doesn't have one. Reference counting is available as a (what looks like third-party) library: http://www.adacore.com/adaanswers/gems/gem-97-reference-coun...

I guess you could say that is even less reliance on GC than C++ has, with smart pointers being part of the standard.

Re:Ways to Avoid Complexity in Modern C++ [pdf] by adrianm on Monday December 07, 2015 @03:19PM (#10692378)
Common Lisp's foreign function interface (either implementation specific or cross-platform a la CFFI) allows for the explicit definition of how a foreign structure should be laid out in memory.

Even if I'm not using Lisp for the end product, whose SLA may not permit a runtime with garbage collection, I always find it invaluable to define low-level structures with a Lisp whose machine code compiler is available at runtime for experimental interactive development.

A free and open source Lisp that you might enjoy experimenting with is SBCL, available from http://www.sbcl.org.

Load up the REPL, and follow the manual available here http://sbcl.org/manual/index.html#Foreign-Function-Interface.

SBCL also allows you to interactively augment the machine code compiler, install new intrinsics, and disassemble any function interactively.

Even if you never use it for production code directly, it might become an invaluable tool in your low level development process.

Re:Ways to Avoid Complexity in Modern C++ [pdf] by chncdcksn on Monday December 07, 2015 @12:59PM (#10691195)
Does Rust fit into those specifications? I understand library support is probably not quite there yet, but I was under the impression it could fill the role of C/C++.
Re:Ways to Avoid Complexity in Modern C++ [pdf] by vvanders on Monday December 07, 2015 @01:02PM (#10691216)
They get close but I think there's a few restrictions(rightly so from a safety perspective) that keep untyped arena allocators and in-place loading from working(see FlatBuffers for a fantastic library for in-place loading).

Edit(since I can't reply yet to child):

By in-place loading I don't mean placement new(which untyped arena covers). Usually in-place loading means constructing an object(usually just by reinterpret_cast<T*>(data)) over a block of memory read in from disk/network such that all data members "line up" with data as it was serialized.

This also includes the ability to mutate the in-place data but have initialized to some sane values. 99% of the time this is paired with either some sort of preprocessor(usually written in the same compiler as the reader to guarantee data matching).

Quite a few games use this technique to allocate levels/fixed entities such that once you've pulled them disk you just need to do some trivial pointer fixup and away you go. There's some pretty incredible speed increases(100-200x) but obviously it's incredibly fragile and complex to get right.

Flatbuffers does a good job of trading off fragility for usability by encoding offsets in the placement data. Reading data is slightly slower due to needing to calculate the offset into the data but on the plus side it doesn't depend on compiler specific layouts :).

Re:Ways to Avoid Complexity in Modern C++ [pdf] by steveklabnik on Monday December 07, 2015 @01:49PM (#10691648)
By "in-place loading" do you mean placement new?

And while Rust does have restrictions for safety, unsafe should give you the power to do anything equivalent C or C++ can do. Of course, many idioms are different, especially for safe Rust.

Re:Ways to Avoid Complexity in Modern C++ [pdf] by steveklabnik on Monday December 07, 2015 @03:39PM (#10692518)

  > Edit(since I can't reply yet to child):
HN #protip: if you click on comment link itself, it will let you comment earlier.

Ah, I see. This isn't my area of specialty, but it _sounds_ like what Cap'n Proto does? Anyway, it doesn't sound impossible, though it might not be the most ergonomic. I'll check out that library, thanks.

Re:Ways to Avoid Complexity in Modern C++ [pdf] by vvanders on Monday December 07, 2015 @03:49PM (#10692582)
Learn something new every day!

Yeah, Cap'n Proto is very similar, FlatBuffers has the advantage in that it compiles against almost all versions of Visual Studio where Cap'n Proto unfortunately decided to use some C++14 features.

FWIW I think I've seen some ports of FlatBuffers into Rust since it's much easier to handle due to the offsets and translation on return value. The former(matching compiler layout) was the part that I was mentioning that seems like something a bit gnarlier than rust would like.

Re:Ways to Avoid Complexity in Modern C++ [pdf] by steveklabnik on Monday December 07, 2015 @04:46PM (#10692970)
Gotcha. Yeah, so the Rust Capn' Proto does compile-time codegen to write out all the structures, so the grossness is hidden away, or at least, you don't have to deal with writing it out. I believe it's basically the same as the C++ version.
Re:Ways to Avoid Complexity in Modern C++ [pdf] by pif on Monday December 07, 2015 @12:47PM (#10691101)
Yes, support for generics. _Full_ support for generics. And RAII!
Re:Ways to Avoid Complexity in Modern C++ [pdf] by Ace17 on Monday December 07, 2015 @01:12PM (#10691304)
The D programming language anyone?
Re:Ways to Avoid Complexity in Modern C++ [pdf] by CyberDildonics on Monday December 07, 2015 @01:44PM (#10691589)
If D manages to get garbage collection out of their standard library and there is a one click IDE with step through debugging and code completion, then D could be a major contender. Right now it has a few big barriers that prevent it from taking significant market share on C++.
Re:Ways to Avoid Complexity in Modern C++ [pdf] by WalterBright on Monday December 07, 2015 @01:52PM (#10691672)
D has full generics, explicit memory layout, and RAII.
Re:Ways to Avoid Complexity in Modern C++ [pdf] by vvanders on Monday December 07, 2015 @02:04PM (#10691778)
From what I've seen of D(I haven't used it in detail) there isn't enough materially different(like say Rust) to warrant the loss of libraries and IDE integrations available to C++.
Re:Ways to Avoid Complexity in Modern C++ [pdf] by Ace17 on Monday December 07, 2015 @03:18PM (#10692368)
Amongst the parts of Phobos having an equivalent in the C++ standard library (algorithm, string, etc.), which ones still require garbage collection?
Re:Ways to Avoid Complexity in Modern C++ [pdf] by WalterBright on Monday December 07, 2015 @04:05PM (#10692694)
Only one of the algorithms in Phobos still uses the GC.
Re:Ways to Avoid Complexity in Modern C++ [pdf] by usefulcat on Monday December 07, 2015 @01:21PM (#10691374)
Also, library support.
Re:Ways to Avoid Complexity in Modern C++ [pdf] by potbelly83 on Monday December 07, 2015 @01:34PM (#10691488)
Free Pascal?