News for hackers. Stuff that matters.
Re:Baby's First Garbage Collector by city41 on Sunday December 08, 2013 @04:55PM (#6871603)
I don't know of any language that has pointers and a GC. Are there any? C# lets you use pointers but only if you tell the GC to not move your object and promise to behave.
Re:Baby's First Garbage Collector by wsc981 on Sunday December 08, 2013 @05:36PM (#6871782)
> "I don't know of any language that has pointers and a GC. Are there any?"

Objective-C used to have a garbage collector, though (at least with regards to iOS) Apple removed this capability with the introduction or ARC. On the following URL is some discussion on the Objective-C garbage collector: http://cocoasamurai.blogspot.nl/2010/12/objective-c-memory-m...

Re:Baby's First Garbage Collector by masklinn on Monday December 09, 2013 @04:33AM (#6873531)
iOS never got the GC, only the desktop version got it, and afaik it was deprecated rather than removed entirely.
Re:Baby's First Garbage Collector by pornel on Monday December 09, 2013 @05:36AM (#6873690)
It's been removed entirely in Xcode 5.1.
Re:Baby's First Garbage Collector by betterunix on Sunday December 08, 2013 @06:49PM (#6872073)
Re:Baby's First Garbage Collector by pjmlp on Monday December 09, 2013 @02:54AM (#6873282)
> I don't know of any language that has pointers and a GC. Are there any? C# lets you use pointers but only if you tell the GC to not move your object and promise to behave

Oberon, Oberon-2 allows you to use no-GC pointers via the SYSTEM package.

Active Oberon additionally adds syntax support for untraced pointers.

Modula-3 has unsafe modules which allow you to use untraced pointers.

D has unsafe pointers in system blocks.

Ada and C++11 have support for optional GC defined on the language standard. However so far, there isn't any compiler vendor that really offers them.

In Java you can do a bit of dirty pointer tricks via the com.sun.unsafe package, but it is Oracle's VM specific. Although there are plans to make it part of the official library after Java 8.

Re:Baby's First Garbage Collector by octo_t on Sunday December 08, 2013 @04:58PM (#6871617)
Optional GC[1] in a language like C++, and Rust has pointers with task-local GC

[1] - http://en.wikipedia.org/wiki/Boehm_GC

Re:Baby's First Garbage Collector by jballanc on Sunday December 08, 2013 @05:07PM (#6871651)
The Boehm–Demers–Weiser garbage collector is a fairly famous implementation of a GC for vanilla C, pointers and all: http://en.wikipedia.org/wiki/Boehm_garbage_collector
Re:Baby's First Garbage Collector by city41 on Sunday December 08, 2013 @05:12PM (#6871671)
Yeah I'm aware of optional GCs. What I meant was languages that ship with a GC as standard and also have pointers. In the case of Boehm, since you choose to bring it in yourself, it's up to you to make sure you don't abuse it.
Re:Baby's First Garbage Collector by jballanc on Sunday December 08, 2013 @05:46PM (#6871815)
Well, pretty much any language with a GC can abuse the GC, regardless of whether it's optional or designed in from the start. It just happens to be a lot harder to abuse a GC than to forget to free/delete something.
Re:Baby's First Garbage Collector by Scaevolus on Sunday December 08, 2013 @05:24PM (#6871721)
You can have a GC without compaction.

Go has a GC and pointers, including internal pointers (e.g. to a field of a struct). Its GC started out fully conservative, then precise for the heap and conservative for the stack, and future versions will be fully precise.

Re:Baby's First Garbage Collector by bitwize on Monday December 09, 2013 @07:23AM (#6873969)
Various Lisp dialects over the years have supported the use of locatives, or pointer-like objects.

In general, objects which can be moved or copied around by the runtime behind the programmer's back cannot have indefinite-extent hardware-address pointers taken directly into them. This includes objects managed by most halfway-decent garbage collectors (which tend to be implemented as stop-and-copy, not mark-and-sweep), but also includes such things as drawing surfaces in SDL and DirectDraw. Many runtimes take the C# approach -- provide a memory locking operation that fixes the object in memory while you do some pointer stuff on it and a dual unlocking operation that releases the object so it can be kicked around by the runtime again.

Re:Baby's First Garbage Collector by cwzwarich on Sunday December 08, 2013 @05:29PM (#6871745)
Some languages in the Wirth family have pointers and GC, e.g. Modula-3. It has a module-level notion of safety, so that modules using potentially unsafe pointer manipulation are marked as unsafe and break runtime safety guarantees. It also doesn't guarantee that all pointers will be roots for GC.
Re:Baby's First Garbage Collector by nicky0 on Sunday December 08, 2013 @05:36PM (#6871781)
Objective-C has pointers and a GC.