News for hackers. Stuff that matters.
Re:The C++ Programming Language (4th Edition) by minamea on Saturday May 11, 2013 @10:34PM (#5692893)
I think that's true, but it's also sad. I've looked at D and it's criticism seems reasonable to me: it actually seems to have more features than C++.

I really hope Go catches on more and fixes some of the (imho) bad things about it (like lack of generic programming). And then C++ won't be the only option anymore.

Re:The C++ Programming Language (4th Edition) by fauigerzigerk on Sunday May 12, 2013 @02:39AM (#5693388)
Go is nice but it's a replacement for Java or Python not for C++. I'm working on an in-memory analytics engine, something that has only become affordable in recent years because memory prices have fallen so much.

In-memory computing is a very important trend and garbage collected languages just don't work. You can't have the system stall for seconds or even tens of seconds unless it's purely a batch workload.

I have to admit that I haven't really researched what can be done in Go to keep in-memory data off-heap so the garbage collector doesn't see it. I have done that research for Java and it's unworkable. It's either slow or extremely unproductive to work with or both.

Re:The C++ Programming Language (4th Edition) by minamea on Sunday May 12, 2013 @03:25AM (#5693489)
Are garbage collection pauses really a concern? You're still running atop a multitasking operating system with all kinds of pauses.
Re:The C++ Programming Language (4th Edition) by fauigerzigerk on Sunday May 12, 2013 @04:07AM (#5693557)
Garbage collection pauses are a huge concern with larger heap sizes. Depending on the application it may be OK to make a user wait for a second or two, but not for 30 seconds. Multitasking doesn't cause that kind of lag usually.

It's even more problematic for some types of trading systems or stream processing of sensor data, etc.

All the trends are working against garbage collection right now. Memory sizes are growing and we're moving away from batch processing for many workloads.

Re:The C++ Programming Language (4th Edition) by berkut on Sunday May 12, 2013 @06:00AM (#5693766)
Most definitely - on a modern multitasking operating system your "all types of pauses" is generally only synchronous IO issues to disk or network - as long as you've got spare CPU available to your process/threads and you're sensible with your memory allocation.
Re:The C++ Programming Language (4th Edition) by derefr on Sunday May 12, 2013 @03:59AM (#5693544)
> garbage collected languages just don't work. You can't have the system stall for seconds or even tens of seconds unless it's purely a batch workload.

What about languages like Erlang and Rust where each actor/object/process has its own heap, GCed individually?

Re:The C++ Programming Language (4th Edition) by fauigerzigerk on Sunday May 12, 2013 @04:25AM (#5693597)
I have zero experience with Erlang, but judging by the benchmarks it is a very slow language for algorithmic stuff.

Rust should work. It's the right approach I think. I haven't used it yet, but I really hope it gains popularity and becomes a real alternative to C++.

Re:The C++ Programming Language (4th Edition) by pjmlp on Sunday May 12, 2013 @08:17AM (#5694002)
> In-memory computing is a very important trend and garbage collected languages just don't work. You can't have the system stall for seconds or even tens of seconds unless it's purely a batch workload.

Nice omission of pauseless GC algorithms there.

Re:The C++ Programming Language (4th Edition) by beagle3 on Sunday May 12, 2013 @03:07PM (#5695441)
As someone who had tried to work with available GCs in Java, GP is spot on; it doesn't matter that algorithms exist - production JVMs still pause (or at least did 2 years ago when I looked into it)
Re:The C++ Programming Language (4th Edition) by fauigerzigerk on Sunday May 12, 2013 @09:34AM (#5694158)
Can you point me to a reasonably mature and efficient implementation of such an algorithm for Go or Java? I only know the Azul one which costs thousands of dollars per server per year.
Re:The C++ Programming Language (4th Edition) by pjmlp on Sunday May 12, 2013 @10:04AM (#5694246)
You just mentioned one for Java, the fact that it is commercial is irrelevant.
Re:The C++ Programming Language (4th Edition) by fauigerzigerk on Sunday May 12, 2013 @11:18AM (#5694542)
Irrelevant for what? This was a debate about whether or not Go can replace C++, remember? So the fact that there is no such implementation for Go has to be relevant.

It is also very relevant for me that there is no Java implementation of a pauseless garbage collector that is even remotely viable for my business model or the business model of 99% of all startups out there.

If all you want to say is that it is possible to solve this problem for garbage collected languages, then we can agree. Unfortunately there is no viable solution available right now.

Re:The C++ Programming Language (4th Edition) by pjmlp on Sunday May 12, 2013 @01:40PM (#5695068)
> Irrelevant for what? This was a debate about whether or not Go can replace C++, remember? So the fact that there is no such implementation for Go has to be relevant.

Well, surely with so many top notch brains Google can come up with a way to improve Go's runtime if they care about the issue.

> It is also very relevant for me that there is no Java implementation of a pauseless garbage collector that is even remotely viable for my business model or the business model of 99% of all startups out there.

Do you mean viable, as free of charge?

> If all you want to say is that it is possible to solve this problem for garbage collected languages, then we can agree. Unfortunately there is no viable solution available right now.

Yes, that is my main point.

Re:The C++ Programming Language (4th Edition) by fauigerzigerk on Sunday May 12, 2013 @02:43PM (#5695332)
"Do you mean viable, as free of charge?"

No, but it would have to be a fraction not a multiple of my per server profit margin. Azul's target market is clearly hedge funds and the like. They don't even quote a price on their website.

To be not only viable but also beneficial, the Azul license plus the additional DRAM cost of Java itself would have to be less than it costs me to use C++ instead of Java.

Re:The C++ Programming Language (4th Edition) by pjmlp on Sunday May 12, 2013 @04:19PM (#5695677)
Faire enough.
Re:The C++ Programming Language (4th Edition) by WalterBright on Saturday May 11, 2013 @11:01PM (#5692948)
I don't really understand your post. You criticized D for having more features than C++, and Go for having fewer.
Re:The C++ Programming Language (4th Edition) by minamea on Saturday May 11, 2013 @11:46PM (#5693064)
That's exactly how I feel, I guess. D seems to have a lot more features (import, public import, and static import?) and I'm no expert but I feel some aren't all that necessary/add enough value. Go has fewer than C++, which I think is really good, except for some few ones that I wish were there. Only generic programming/templates off the top of my head actually.
Re:The C++ Programming Language (4th Edition) by zura on Sunday May 12, 2013 @03:23AM (#5693488)
And exceptions, or any other way to better handle error conditions, rather than that "if hell".
Re:The C++ Programming Language (4th Edition) by minamea on Sunday May 12, 2013 @03:36AM (#5693512)
See I don't know about that. Maybe exceptions was one of the features that was good to be left out. I think maybe the comma ok idiom forces the programmer to more actively check for errors and recover from them, and there is no need to do things like RIIA. Maybe also the code is clearer to read, because you can see "if not ok then do_this()" and know that this is error checking/recovery code, instead of looking up the call stack to see where the exception that was thrown in one place is being handled.
Re:The C++ Programming Language (4th Edition) by jamesaguilar on Sunday May 12, 2013 @01:42PM (#5695074)
I feel like panic/recover give me 90% of what I need from exceptions.
Re:The C++ Programming Language (4th Edition) by zura on Sunday May 12, 2013 @05:57PM (#5696032)
If only D had Rust like reference counted embedded smart pointers... [for a deterministic memory management].

I think that would be much easy to add than C++esque `smart pointers as library`.

Re:The C++ Programming Language (4th Edition) by jamesaguilar on Sunday May 12, 2013 @02:16AM (#5693355)
Go <what I want> C++ D
Re:The C++ Programming Language (4th Edition) by parbo on Sunday May 12, 2013 @03:57AM (#5693542)
Have you tried Rust?
Re:The C++ Programming Language (4th Edition) by jamesaguilar on Sunday May 12, 2013 @01:39PM (#5695065)
Read some code thanks to your comment. I think I will try it.
Re:The C++ Programming Language (4th Edition) by dorolow on Saturday May 11, 2013 @11:05PM (#5692956)
I haven't looked at D in a while, but I recall it having two competing standard libraries.

I'm pinning all my hopes and dreams on Rust, but as a frequent (ab)user of Boost.Coroutine and gevent I certainly wouldn't mind if Go gained a bit more traction.

Re:The C++ Programming Language (4th Edition) by pcwalton on Saturday May 11, 2013 @11:22PM (#5693000)
D doesn't have two competing libraries anymore. There's just one, Phobos.

Regarding Rust, Rust has lightweight green threads just like Go does. (Go's scheduler is currently more mature though.)

Re:The C++ Programming Language (4th Edition) by dorolow on Sunday May 12, 2013 @02:20AM (#5693359)
Regarding D, that's good! I always thought D was very cool, but the two libraries thing kept me away till now. Maybe I'll have to check it out again.

It seems like Rust never ceases to impress.

Re:The C++ Programming Language (4th Edition) by zura on Sunday May 12, 2013 @03:28AM (#5693496)
No language with a nondeterministic memory management will ever be able to be an alternative of C++.
Re:The C++ Programming Language (4th Edition) by Someone on Sunday May 12, 2013 @04:13AM (#5693576)
There isn't anything nondeterministic about garbage collection systems; it is just that it is hard to predict how much time they will take for a call.

However, the same can be said about classical C style memory management. An alloc can be almost immediate or take lots of time because it has to request a fresh memory block from the OS. Similarly, a free can or cannot take time to coalesce blocks.

Yes, the differences are much smaller there, certainly historically, but garbage collectors have improved, and I am not sure that C-style allocators can stay predictable in long-running programs. Let's say you have a terabyte of RAM, and want to run a multi-threaded server in it 'forever'. Chances are that your garbage-collected system will be more stable and use less memory because it can compact memory. A C style allocator would need quite a few heuristics (or maybe, even contain some machine learning code that builds a model of memory allocation patterns) to prevent memory fragmentation. Such features would make their timing less predictable.

Because of that, I think we may at some time see an OS with built-in garbage-collection become mainstream.

Re:The C++ Programming Language (4th Edition) by zura on Sunday May 12, 2013 @06:05PM (#5696050)
> it is just that it is hard to predict how much time they will take for a call.

The problem is not how much but when - you never know when GC fires and interrupts your running code. That is a nondeterminism.

Re:The C++ Programming Language (4th Edition) by Someone on Monday May 13, 2013 @01:44AM (#5697364)
If it interrupts your running code, it only can happen at moments when you allocate memory, just like with malloc. You cannot predict when malloc calls brk(), either.

Also, most OS-es are non-deterministic, anyways. You cannot predict whether your code lives in cache/main memory, or on disk. In some systems, your data even might have to be brought in by a tape robot without your code being aware of it. As soon as a garbage collector manages to get its interruptions to be about equal to delays caused by caching and virtual memory, I doubt many people will care.

Re:The C++ Programming Language (4th Edition) by zura on Monday May 13, 2013 @06:44AM (#5698003)
I'm not talking about interruptions on allocations, but deallocations.

You never know when GC fires - starts harvesting for memory locations that need to be freed and frees them.

Re:The C++ Programming Language (4th Edition) by Someone on Tuesday May 14, 2013 @07:55AM (#5704262)
With Gargage collection, there are ni deallocations.

Also, garbage collection does not "harvest for memory locations that need to be freed and frees them.". Garbage collection does not collect garbage, it collects used space.

Re:The C++ Programming Language (4th Edition) by zura on Wednesday May 15, 2013 @04:16AM (#5710777)
I think you're misinformed.

Here are some more details if you're interested:

http://en.wikipedia.org/wiki/Garbage_collection_(computer_sc...

Re:The C++ Programming Language (4th Edition) by pjmlp on Sunday May 12, 2013 @08:20AM (#5694009)
Are you sure you know what the language runtime does with your delete or how long a new takes?
Re:The C++ Programming Language (4th Edition) by zura on Sunday May 12, 2013 @10:11AM (#5694279)
I think we already had some conversation about this topic:

https://news.ycombinator.com/item?id=5503066

HN is small ;)

Re:The C++ Programming Language (4th Edition) by pjmlp on Sunday May 12, 2013 @01:37PM (#5695059)
Most likely. :)
Re:The C++ Programming Language (4th Edition) by zura on Sunday May 12, 2013 @05:47PM (#5695997)
Just followed that thread again, and I think we're on the same side :)

I mean, when I say that I prefer deterministic memory management, that includes an automatic reference counting - smart pointers - which are now part of C++11.

On that thread, under my "deterministic", you assumed only "manual" as it seems.

Re:The C++ Programming Language (4th Edition) by pjmlp on Monday May 13, 2013 @02:06AM (#5697405)
Oh, great! :)