Reputation
14,467
Top tag
Next privilege 15,000 Rep.
Protect questions
Badges
1 22 51
Newest
 Yearling
Impact
~433k people reached

Feb
1
comment What do other languages offer when it comes to infrastructure technology that could indicate its advantage over C in the future?
@supercat, time to copy a reference to one tree with N nodes is O(1) is each and every scheme in every language, because it is just one reference. Total overhead of collection is proportional to number of objects alive during each collection pass in collecting implementation and to number of reference copies in counting implementations, either of which can be less. A full counting implementation (perl, python) is typically slower than collector, but implementation that is able to omit many counting operations (C++, rust) may be slower or faster depending on particular case.
Feb
1
comment What do other languages offer when it comes to infrastructure technology that could indicate its advantage over C in the future?
@supercat, note that C++ does not do static verification, but rust does (that's where the "borrow" terminology comes from).
Feb
1
comment What do other languages offer when it comes to infrastructure technology that could indicate its advantage over C in the future?
@supercat, but that is the reference-counting overhead vs. the overhead of the mark+sweep, that the shared pointer don't have. And the reference counting updates can indeed be omitted in vast majority of cases, because most functions don't keep the reference beyond their return and all those can safely borrow plain old const & as the shared_ptr won't be deleted before they return, even if temporary (temporaries are deleted at the end of the statement).
Feb
1
comment What do other languages offer when it comes to infrastructure technology that could indicate its advantage over C in the future?
@supercat, shared_ptr to immutable objects can be equally well manipulated without any locking. They have copying overhead, but you can safely borrow dumb reference from a shared_ptr as long as you know the shared_ptr exists somewhere up the stack, and there is no other overhead.
Feb
1
comment What do other languages offer when it comes to infrastructure technology that could indicate its advantage over C in the future?
@supercat, shared objects in multi-threaded code are the problem. There is no easy way to handle them. That said, assigning a std::shared_ptr only needs a lock around the pointer, not the pointee. And that is exactly what you need anywhere else too. Java has atomic pointer writes, but that just adds overhead (ok, x86 has atomic stores; other platforms don't) to the 90% of cases where it isn't shared and the 90% of the rest where you have to lock the container anyway, because you are doing several operations on it. I prefer having to lock the pointer.
Jan
30
comment What do other languages offer when it comes to infrastructure technology that could indicate its advantage over C in the future?
@supercat, no, it can't. The hybrid RC+GC collector provides timely destruction unless you have cycle, but that is still much less than RAII.
Jan
30
comment What do other languages offer when it comes to infrastructure technology that could indicate its advantage over C in the future?
@supercat, yes, python has weak references and it has timely destruction. But having weak references does not mean they'll get properly used and if they don't you still hold on to a lot of memory you should have released. Nor that caches are properly limited and such.
Jan
25
comment Should we avoid language features that C++ has but Java doesn't to increase maintainability?
Note that C++ does not have finally blocks, but it has RAII, which is much better for most cases. And, again, different.
Jan
25
comment Should we avoid language features that C++ has but Java doesn't to increase maintainability?
Seasoned C++ veterans usually reject Google coding guidelines. Modern C++ is vastly better exactly because it uses those features. Yes, it makes it even more different.
Jan
25
reviewed Approve How does C++ handle multiple inheritance with a shared common ancestor?
Jan
13
revised C++ Virtual destructors used only when there are virtual functions
deleted 1 character in body
Jan
13
answered C++ Virtual destructors used only when there are virtual functions
Jan
8
comment How to design a function that takes a date and gives out a number between 1-6, always the same for all dates
How to approach this will significantly depend on the purpose, and you don't explain what it is.
Nov
20
comment Why do you need “self.” in Python to refer to instance variables?
Implicit member variable reference (without self., like Java) is fundamentally incompatible with the scoping rules and when you need to be explicit there, being implicit about the parameter does not make all that much sense any more.
Oct
7
awarded  Yearling
Sep
21
comment How to prevent changes to an internal API from breaking other projects?
How closely coupled are your projects? Does anybody have a right to touch any code? Does it all live in the same repository? Do the depenent projects always use latest revision of the dependencies?
Sep
3
awarded  Nice Answer
Aug
3
comment How do people get rid of conditional branches in Functional Programming?
@TimPote: Added explanation of what I mean by object-oriented. I also removed the mention Haskell lacks inheritance, because Rust also lacks class inheritance, yet it does have dynamic polymorphism. Yes, I equate OO with dynamic dispatch. I don't equate functional with static-dispatch though. That would make functional programming the opposite of object-oriented, but I explicitly state that most functional languages are also object-oriented. Functional means use of higher order functions and avoidance of side-effects.
Aug
3
revised How do people get rid of conditional branches in Functional Programming?
detail what I mean by object-oriented
Aug
3
comment How do people get rid of conditional branches in Functional Programming?
@TimPote: Java definitely dispatches on runtime value of the invocant (though not the other arguments). Haskell has a type-dispatch, but unless you use the ghc forall extension, it is completely compile-time.