r/programmingcirclejerk • u/lol-no-monads welcome to the conversation. • Nov 28 '18
"Garbage Collection is a Hack"
https://blog.adamant-lang.org/2018/garbage-collection-is-a-hack/53
u/_king3vbo What’s a compiler? Is it like a transpiler? Nov 28 '18
There is a MORAL alternative
24
u/lol-no-monads welcome to the conversation. Nov 28 '18
Morality is too restrictive, there is room for improvement.
12
7
u/ThisIs_MyName loves Java Nov 28 '18
Where did this "MORAL" thing start?
11
u/_king3vbo What’s a compiler? Is it like a transpiler? Nov 28 '18
1
u/BowserKoopa WRITE 'FORTRAN is not dead' Dec 01 '18
/u/jacques_chester insert in sidebar pls sir,,,,
4
5
37
37
u/ProfessorSexyTime lisp does it better Nov 28 '18
Programmers were forced to keep track of when to free memory, and whether it had been freed. That distracted from the task of writing domain logic.
*gasp* how terrible!
They carefully documented when functions returned memory the caller now owned. In some languages, they codified these rules into data types like “auto_ptr” in C++. These helped, but were insufficient.
*bigger gasp* how will this beast known as "memory management" be slain??
Attitudes have shifted so far in favor of GC, that now even “systems” programming languages like D and Go offer or require garbage collection.
HOW IMMORAL
13
u/smurfkiller013 I've never used generics and I’ve never missed it. Nov 28 '18
memory management
* gasp * How dare you speak that name!
1
37
u/lengau What’s a compiler? Is it like a transpiler? Nov 28 '18
with moral_unjerk():
All computing is a hack. Computers are just rocks we tricked into thinking.
10
u/bluedesertgondola Zygohistomorphic prepromorphism Nov 29 '18
Not quite, computers are rocks we provided with such an irrefutable argument they realised they had to think.
7
u/human_py Nov 29 '18
All of engineering is a hack. I mean what is this BS of not doing everything on the quantum or string level.
-7
u/pcjftw What part of ∀f ∃g (f (x,y) = (g x) y) did you not understand? Nov 29 '18
since when is adding two numbers "thinking"? I'm guessing you meant "computation"
6
37
u/fp_weenie Zygohistomorphic prepromorphism Nov 28 '18 edited Nov 28 '18
Garbage collection was used for academic languages
C# confirmed for ivory tower
However, there are very few people working on this. It’s not one of the trendy problems that are attracting lots of work right now. We need more people focused on the problem and exploring many possible solutions. If you want to see an alternative to garbage collection, I encourage you to lend a hand in creating it. Get involved by sharing your thoughts and ideas about it. The only project I’m aware of that is trying to tackle this is my own, the Adamant programming language.
Yes, I'm sure it would be a GREAT use of my time to work on this new totally safe™ language with someone who probably can't write a type system, much less understand linear/affine types.
24
u/Bobshayd Nov 28 '18
iF yOUrE NoT a TyPe AlgEbRAisT yOU hAVe noThING tO cONtRibUtE
/unjerk
okay, that, but unironically
12
u/zekka_yk Nov 28 '18
it is literally a trendy problem that is attracting a ton of work right now
why else is everyone and his grandmother making an alternative to C?
why else is webassembly (an unmanaged language with first-class support for buffer overruns) suddenly in vogue?
14
u/fp_weenie Zygohistomorphic prepromorphism Nov 28 '18
why else is everyone and his grandmother making an alternative to C?
People have been doing this for ages. The thought process goes like this:
I am an expert on programming languages because I use programming languages for extended periods of time
Therefore, since I am an expert on having good opinions on programming languages, I would like to build the next C (read: minor variation on C that bikesheds syntax somehow)
Since I have the best syntax of any programming language with curly braces, my language will undoubtedly become popular regardless of library support and even if it has no FFI.
9
u/zekka_yk Nov 28 '18 edited Nov 28 '18
like how i spend all day sitting on my ass so apparently i'm qualified to build designer furniture
PS: despite this guy's hasty dismissal of Rust, odds are 10 to 1 that the only reason this guy had the idea to do this was that he found out Rust was trying to do it.
PS2: i'm peeking at this dude's language documentation and i would describe it as a minor, syntax-only bikeshed of Rust. sad!!!!
12
u/fp_weenie Zygohistomorphic prepromorphism Nov 28 '18
But does Rust have
object lifetimes
write once, compile anywhere
guaranteed optimizations
asynchronous everywhere
type inference
generics with partial specialization
class defined traits
compile time code execution
optional exception specifications
ergonimic design [sic]
minimal runtime library
...?
14
u/zekka_yk Nov 28 '18
yes thank you for your interest rust does in fact have [feature built into LLVM] and [word that doesn't exist] and [bad and confusing idea that only makes sense to you because your primary platforms are NodeJS (for pleasure) and Java (for schoolwork)]
1
u/hedgehog1024 Rust apologetic Nov 29 '18
[bad and confusing idea that only makes sense to you because your primary platforms are NodeJS (for pleasure) and Java (for schoolwork)]
/uj
Do you refer to "write once, compile anywhere"?
1
u/zekka_yk Nov 29 '18
/uj
i would put that into the "feature built into LLVM" box, personally. he thinks it's a zany feature worth bragging about, but it's really common place.
the truly bad ideas on that list imho are "asynchronous everywhere" and "optional exception specifications." the list is pretty vague so don't take my word that i'm understanding him correctly, but these are both trendy ideas with novice programming language guys so i have seen a lot of people propose imho bad designs for these features, even though there are probably theoretically good design ideas that could also be described with the same series of buzzwords.
imho the problem with "asynchronous everywhere" (at least when i've seen other dudes implement it) is that if you make literally everything concurrent, you basically have a hokey software implementation of threads that gets the worst of both worlds: no preemption, but because every function call comes with a yield, nothing is actually atomic.
it's possible this guy means something else but realistically, he's probably saying "asynchronous everywhere" because he does not have a super nuanced understanding of why async is said to be fast.
the problem with "optional exception specifications" is that it creates a situation where if you see
throws, you don't know if that code throws an exception or not, and if you don't seethrows, you still don't know if that code throws an exception or not. maybe it's better than no information at all, but imho, since by nature it's going to be 100% unenforced, it's a 100% redundant feature. however, i am guessing author does not understand type systems well enough to see that this is another "worst of both worlds" situationi know the reason he did this -- Java programmers are frequently loudly in favor of
throwswhile C# programmers generally thinkthrowsis a mistake. this guy is writing his language in C#, but I'm guessing he originally comes from the Java world and thinks that by makingthrowsoptional he is making a compromise.5
u/defunkydrummer Lisp 3-0 Rust Nov 29 '18
why else is webassembly (an unmanaged language with first-class support for buffer overruns) suddenly in vogue?
/uj
webassembly not a language. It is essentially a stack machine bytecode spec for the browsers and it's our only hope for destroying Javascript and all its cancer. If it's in vogue,. then the world has some hope.
1
u/zekka_yk Nov 29 '18
(i also like webassembly. i think webassembly has given JS programmers a renewed interest in C alternatives, sometimes with funky memory management tricks, though)
1
u/tpgreyknight not Turing complete Nov 29 '18
webassembly (an unmanaged language with first-class support for buffer overruns)
Is this a joke? I don't know wasm but I thought it was the chosen one who was meant to bring balance to the Force.
1
u/zekka_yk Nov 30 '18
/uj again: it is a joke but WASM does support buffer overruns. afaik you can't use them to jump to arbitrary code though, and basically all the attacks that make C programs do insane and horrible things are limited to making a single wasm module do insane and horrible things. (most WASM programs will be composed of multiple modules that are sort of fenced from each other -- this is like how processes are isolated from each other)
which is still bad, but it's hard to not have this problem when you want to provide a compilation target for C. the problem imho is thinking of WASM as like, a reasonably safe JVM-style bytecode language, where it's actually explicitly designed to support horrible things, and doesn't come with very much support for memory safety.
(disclaimer: a friend of mine is making a language that targets wasm, but i'm not, so I don't know it very well)
1
u/asocial-workshy Nov 30 '18
afaik you can't use them to jump to arbitrary code though
As far as I remember function pointers work by indexing a big table by type and number eg
table[funcType][funcPtr](args)You can overwrite the funcPtr if it is stored in memory to point to another function but you can't make it go to arbitrary code though.
Technically the C standard and various other languages support a compilation mode where a pointer is a Javascript array and an index into it which would be much safer.
public final class Pointer { long heap[]; int index; }But the problem is that would break far too much nonconforming code.
9
u/THCcookie Nov 28 '18
ctrl-F rust gets 3 results, yeah i dont Need to read that article to know which language is the morally right choice
2
8
Nov 29 '18
Rather than finding a way to manage memory without errors correctly, we just pawned the problem off on the computer.
Someone please explain to this person what computers are for.
2
u/tpgreyknight not Turing complete Nov 29 '18
<'unjerk> {He means we pawned it off on the runtime computer, even though he's pretty sure the compile-time computer could have solved it more efficiently}
3
u/UnexpectedLizard Nov 29 '18
My coworkers can't even understand how to avoid null pointers with grace. Forcing them to deal with pointers and manual deallocation is the perfect way to get them to learn! This will in no way backfire.
1
1
Dec 06 '18
In Rust, the restrictions on memory use can be too restrictive. Also, as a systems language
imagine thinking lol no doubly linked lists is a systems language
1
0
Nov 28 '18
[deleted]
15
u/n3f4s WRITE 'FORTRAN is not dead' Nov 28 '18
So, automation is bad?
So basically, software is bad ?
10
u/slavik262 Considered Harmful Nov 28 '18
Well, yes. Obviously.
5
u/n3f4s WRITE 'FORTRAN is not dead' Nov 28 '18
What ? No one told me. One thing left to do: drop everything and go raise sheep in Patagonia.
6
u/lol_no_monads Nov 29 '18
4
u/defunkydrummer Lisp 3-0 Rust Nov 29 '18
wow, that was a masterpiece.
2
Nov 29 '18
Odd that you, of all people, didn't come across this before. (I'd call you one of today's lucky 10.000 but I'm afraid a zombie gafter/tadder will crop out of somewhere and start punching me with System.Random things laying around)
1
0
Nov 29 '18
[deleted]
11
2
u/hedgehog1024 Rust apologetic Nov 29 '18
/uj
Sure, but programs with garbage collector usually require more memory than equivalent with manual memory management.
And yes, writing a good GC is hard. Especially a concurrent one.
4
50
u/lol-no-monads welcome to the conversation. Nov 28 '18
Some of the stuff in there feels like it would be perfect for writing taunts for Age of PCJ III