News for hackers. Stuff that matters.
Re:Pointer Free Programming and the Future of Nim by delinka on Thursday October 19, 2017 @09:44PM (#15512991)
Creating objects in “empty” states is lazy programming. The point of references is to guarantee an object exists. But don’t pretend an object exists just to satisfy the reference. Rethink your code to take advantage of the guarantee.
Re:Pointer Free Programming and the Future of Nim by quotemstr on Friday October 20, 2017 @12:47AM (#15513599)
You've illustrated why I'm against the kind of simplistic programming maxims you'll find in "Effective X" books. It's easy to brand certain syntactic constructs as "bad", but unless you teach people good taste (which is fiendishly difficult to learn), all you do by telling people to avoid certain easily-recognizable syntactic patterns is to get them to come up with new horrors.
Re:Pointer Free Programming and the Future of Nim by leni536 on Friday October 20, 2017 @03:29AM (#15514092)
> You've illustrated why I'm against the kind of simplistic programming maxims you'll find in "Effective X" books.

Another thing you won't find in this book is the C++ Gospel, the One True Path to perfect C++ software. Each of the Items in this book provides guidance on how to develop better designs, how to avoid common problems, or how to achieve greater efficiency, but none of the Items is universally applicable. ...

If you follow all the guidelines all the time, you are unlikely to fall into the most common traps surrounding C++, but guidelines, by their nature, have exceptions. That's why each Item has an explanation. The explanations are the most important part of the book.

Scott Meyers - Effective C++

The problem is not "Effective X" books. The problems is people treating these rules in these books as dogma.

Re:Pointer Free Programming and the Future of Nim by jstimpfle on Friday October 20, 2017 @03:42AM (#15514147)
Not following a dogma pretty consistently in a single code base (or part of a very large codebase) very quickly leads to inconsistent code and bikeshed style of decision making.
Re:Pointer Free Programming and the Future of Nim by marcosdumay on Friday October 20, 2017 @10:00AM (#15515795)
That, or it could lead to well architected code that changes according to its requirements. YMMV.

The one thing that does never work is blindly following dogma.

Re:Pointer Free Programming and the Future of Nim by quotemstr on Friday October 20, 2017 @07:57AM (#15515040)
> The problem is not "Effective X" books. The problems is people treating these rules in these books as dogma.

You put a bunch of stuff in a book and people are going to copy the stuff from the book into their programs. Bits of front-matter don't matter. Consider the GoF book and the havoc that mindless repetition of design patterns creates.

Re:Pointer Free Programming and the Future of Nim by marcosdumay on Friday October 20, 2017 @09:58AM (#15515778)
Still the problem is the people working mindlessly, not the books.

The alternative would be to not ever improve our knowledge.

Re:Pointer Free Programming and the Future of Nim by notduncansmith on Friday October 20, 2017 @01:09AM (#15513648)
As GP said, rethink the code, from as far out as you need to. Granted, much code has been written under the explicit constraint of not doing this. In that case, do the nasty thing and then if it matters that much to you, find somewhere else to work that cares a similar amount about producing maintainable software.
Re:Pointer Free Programming and the Future of Nim by jstimpfle on Friday October 20, 2017 @03:51AM (#15514184)
Just a reminder that there are many people who prefer not to think in objects.

Rant: Personally since working on my game engine in C, my architecture has become so much simpler, I can easily avoid unnecessecary allocations. My code is much more coherent. Aspect-oriented - which is not at all OO spirit, since OO encourages (trying) to bundle things in self-contained packages.

Yes, that seems hard to believe, since there is so much bad C code out there. With allocations, strings, file system operations etc. all over the place, just as in typical OO code. (Of course some things are really hard to do in C vs C++. The point is forcing myself to have a good architecture and avoid having to make many meaningless decisions).

Re:Pointer Free Programming and the Future of Nim by quotemstr on Friday October 20, 2017 @07:59AM (#15515051)
The game engine people have the right idea with their entity-component-system [1] model. Essentially, it models the program as a big relational database instead of a graph of objects. It can work pretty well.

[1] https://en.wikipedia.org/wiki/Entity%E2%80%93component%E2%80...

Re:Pointer Free Programming and the Future of Nim by plesn on Friday October 20, 2017 @04:28AM (#15514314)
Could you provide more precisions / examples of this C code-style ?
Re:Pointer Free Programming and the Future of Nim by jstimpfle on Friday October 20, 2017 @10:51AM (#15516220)
I wrote a huge ranty reply, but deleted it because it leads OT. Basically, read up on the link to ECS in the sibling comment. Also, definitely check out "Data-oriented design". There's a talk by Mike Acton on Youtube. "Where there's one, there's many" is a pretty basic but super important insight.

I consider this to be important to code maintainability at least as much as to performance.