Hacker News new | past | comments | ask | show | jobs | submit | more PSeitz's comments login

Garbage collector is actually something you'd want, if it caused no performance hit.


Meh. I might have a huge Stockholm syndrome with manual resource management since I've basically started coding with C and used GC-free languages for most of my life since them but I never really understood why people liked GCs so much outside of scripting languages where convenience trumps correctness and you just litter your resources around instead of tracking them properly.

Are people using GC languages really often thinking "uh, I don't know when I won't be needing this resource anymore, thankfully the GC will figure that out for me"? Because I certainly never do. Either the resource is scoped and I expect it to be destroyed at the end of a certain block RAII-style, or it's some longer-lived resource (connection handle, object in a videogame, Window object in a GUI) that I'm going to store in some container and destroy when I no longer need it. If I have multiple references and a complex dependency graph I might use a reference counted container which is effectively a very simplistic GC but it's the exception and not the rule and it's still completely transparent and easy to reason about.

I never, ever, feel like I'm missing a GC when I'm coding in Rust or C++. In C I miss destructors and RAII but that's it. I just don't understand why they're so popular, at best they save you a few lines of cleanup code in your destructors, at worse they make your code behave sub-optimally and non-deterministically because you don't know when your objects are going to be destroyed and your destructors are going to run. Then if you need to write critical code you have to carefully step around the GC to be sure that your perf will be deterministic.

I genuinely don't get GCs.


From a Java programmer's perspective: I agree that a majority of your could would function just as well with RAII-style deallocations. That said, it's not too rare to throw objects around in queues or hashmaps and the garbage collector can save you from sloppy code turning into memory leaks.

Also consider, GC can "solve" a number of other issues. malloc() and free() aren't always cheap to do in the critical path especially when you have heap fragmentation. There are solutions without GCs, but compacting generational GCs combat both of these things without requiring you to even be aware of them. I'm not claiming they're always the best solutions but hopefully I've explained their motivations.


I'm guessing you've never written heavily concurrent code.

C/C++/Rust are totally fine when you have a single thread. It's concurrency and parallelism where object ownership and who gets to destroy what and when becomes a real problem unless you have GC.


> I'm guessing you've never written heavily concurrent code.

Guess again.

> C/C++/Rust are totally fine when you have a single thread. It's concurrency and parallelism where object ownership and who gets to destroy what and when becomes a real problem unless you have GC.

Given that one of Rust's main shticks is concurrency and parallelism it's an odd thing to say. You can always use an Arc<> if you want reference counting between threads which is sort-of GC but opt-in and perfectly deterministic.


There's more to it than that. Having a garbage collector can be faster even, but would you take a faster program if it cost you memory footprint or predictability? It just depends on what you're doing.


The performance comparisons between gc and non-gc languages show otherwise. Also, memory consumption eventually costs cpu cycles.


I'm not really disagreeing with you, performance comparisons between gc and non-gc languages DO tend show otherwise, but consider this: a common GC strategy in C++ is arena allocation. Faster allocations and deallocations but more memory overhead. It's still C++ but a little faster in the right situation.


Depending on the GC and what the particular definition of "performance" is for your use case (Memory usage? Throughput? Latency? ...), they don't cause a hit. It depends.

For instance, if you never hit the GC memory limit in D, it's faster than manually managing memory since you never free it.


Some article about development a approach is not news. Also, hackernews is largely composed of non-news information, else I wouldn't be here ;)


That was just an example. Instead of picking nits, focus on the real point being made, namely that if you miss some insight or perspective that later causes you to make bad decisions later on, you won't know that if you'd up more, you wouldn't be in the situation you're in.


I use a state machine for text

https://github.com/BurntSushi/fst


But it does work in Tokyo, maybe it's the people


I'm specifically talking about NYC.

It's definitely the people.


Internet availability is not a problem. Just check cable availability and your up and running with 100Mbits+ in a few days.


And Germans really like to complain.


you always need at least compiler/interpreter to execute your code... unless write bytecode in your editor


Yes, but you don't need a compiler/editor, you can separate those.


If your editor is your compiler, then something is seriously wrong.


Seems to me, that apple bosses want to put their name on every patent created in their division.


I heard that about Atom around 12 months ago.


Atom had many more performance issues. VSCode is not on par with Sublime but very close.


This document is from before the election, it's invalid now.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: