4 ms·
I think the goal in general should be to minimize conceptual depth and maximize predictability for the problem domain you are trying to address. I dislike the
by munchbunny 8y ago
I think the goal in general should be to minimize conceptual depth and maximize predictability for the problem domain you are trying to address.
I dislike the C style for several reasons:
> FILE * test_file = fopen(“/tmp/test.txt”, “w+”);
First, you have to understand the implications of it being a pointer, which includes the little warning light in your head about ownership and allocation/deallocation. Then you have to remember that "w+" translates to "write in append mode". The fact that it's a string means you know it by memorization. But also there are warning lights in your head about text encoding... just standard things you're trained to be vigilant about. Where you can avoid triggering those reactions, I think it's worth trying.
These days we have the help of IDE's as memory aids, so for things like "w+" I prefer enums so that a tap of the auto-complete button shows you "write mode" and "append mode" options.
I suppose if I were to have any marginally controversial opinion on this topic, it's that I believe we should be embracing IDE's as "portable stack overflows" and designing languages with IDE assistance in mind.
- setr 8y ago>First, you have to understand the implications of it being a pointer, which includes the little warning light in your head about ownership and allocation/deallocation Thats a semantic issue, not a syntax/style one. If your language has pointer semantics, you’d need to a way to access it with either proposed styles, and the same warning light should appear regardless. The w+ example is much more relevant, as it could be expressed more clearly and well-defined (eg enum with full name). But all you could do with the pointer syntax is say FILE POINTER test_file, and gain nothing, because the “*” syntax isn’t at fault here