|
In (very) special cases: Sure. In those cases, you might as well go to assembly language.
I learned 30+ years ago that trying to outsmart an optimizing compiler is futile. In my student days, we thought it crazy to write an OS in a "high" level language - but Unix did succeed, and performance was not an issue. So we abandoned assembly. Not entirely; there are cases for assembly because that is the only possible way to get access to certain hardware functions. But going assembly for performance reasons has no place in the third millennium.
Today, the same goes for memory. It is almost as difficult to outsmart automatic memory management by "clever" use of malloc/free as to outsmart a compiler - in particular because you have no insight in actual memory fragmentation. The risk of memory leaks is much larger; too many programmers do not master their own memory use as well as they believe (or, they are not enforcing the programming discipline as they should).
Again: There are (very) extreme cases where the cost of garbage collection is unacceptable. Usually, memory fragmentation is then unacceptable as well. So you manage your objects e.g. in a static array, dimensioned for a worst case. (I was programming one such C solution - malloc was not accepted by our coding standards. C++ new would have been rejected as well, so the case for C++ was not very strong.)
Analogy: When I talk with extreme HiFi buffs, I must admit that 24 bit samples at 96 kHz does have its place, in a professional studio where a sound recording may go through many generations of various processing, mixing etc. for an end result of unknown sample width and frequency. But that is is the studio. It doesn't mean that the music I listen to on my stereo benefits from being in 96/24 format.
Similarly: If you write a physical level driver for a 10 Gbps network interface, you probably cannot tolerate GC delays. But for 99.999% of all code written, GC without memory leaks is a lot better than dubious "private" memory management.
|
|
|
|
|
Special cases or not, there's no way I'd go to assembler and give up all the things that an OO language like C++ provides. And the special cases I'm thinking of aren't a question of trying to outsmart anything.
One of them, in serious production code, was morphing an object to a sibling class in the inheritance hierarchy by changing its vptr . The objects' memory came from a pool of blocks, not the heap, so objects from both classes fit into the same block. No deep copying, no worries about stale pointers to the object, just abracadabra, and its behavior is now what's needed.
|
|
|
|
|
Your example is no different that code I saw implemented, where the sort order, leveraged the same code by the program MOVING the appropriate "Branch If >=" vs "Branch If <=" to X bytes forward on the execution pointer.
I remember reading that code over and over. Utterly confused. I had NEVER SEEN a move to a relative offset from the SP (Stack Pointer). It was already coded for the the ASCENDING sort, if they are overwriting that address, if it is ascending, it made no sense (ah, but the code broke when he was wrong on the pointer location, LOL)...
Anyways, I would EITHER shoot or beat a programmer for that kind of optimization. The C solution, of using a pointer to a function() that returned the appropriate sorting value induced HUGE functionality benefits, cleaner code and tons more flexibility. Almost pure elegance, IMO.
The code has 3 consumers. The Current Developer, The Compiler, and the Next Developer. The last one being the most important!
|
|
|
|
|
I also like the "pointer to the comparison function" design.
The fourth consumer of code is the customer, and our customers were demanding when it came to performance. The scenario in question occurred with sufficient frequency that no one objected to the design. The code in question called a MorphTo function, which was a giveaway as to what was going on.
|
|
|
|
|
Quote: I learned 30+ years ago that trying to outsmart an optimizing compiler is futile.
Indoctrination. Processors have been built to prove this point for a long time. Cache penalties, pipeline penalties, millions of addressing modes... Just take a true RISC processor and you are rid of most of that. Now a child can be just as good as the compiler, leaving only the thing that compilers are notoriously bad at and that's choosing the algorithm.
trønderen wrote: But for 99.999% of all code written, GC without memory leaks is a lot better than dubious "private" memory management.
Maybe, but developers who run into such a problem and know nothing about memory management are helpless 100% of the time.
Watching 'team leaders', 'architects' and who knows what other titles they had given themselves camp around a server and trying magical chanting and sacrificing virgins to fix a memory overflow is a sad sight. But I was able to motivate them with lots of good natured humor, which they took as biting sarcasm.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
It's like the ongoing dispute between Nikon and Canon users as to which is best.
They are both excellent cameras it's just a matter of preference...but Nikon is way better.
|
|
|
|
|
You realize this thread is not about cameras?
Sorry - just messing with you!
Get me coffee and no one gets hurt!
|
|
|
|
|
|
|
Nikon is unusable.
Pentax is the only true path.
|
|
|
|
|
Nay brother let me lead you to the true path of enlightenment. Nikon shall set you free and with your purchase of a new lens you shall receive the blessing of the shutter gods.
|
|
|
|
|
Uuuhhh...
I have no lenses younger than about twenty years -- and some closer to seventy.
My latest camera purchase is a Kodak Vigilant Six-20 (circa 1940).
Lately I've been playing with a 4x5 monorail camera from the '60s.
I say again, Nikon is unusable -- except maybe by wrong-handed practitioners (like my brother).
Having said that, Nikon does make good point-and-shoot cameras, my wife is on her third.
|
|
|
|
|
I give...
|
|
|
|
|
PIEBALDconsult wrote: I have no lenses younger than about twenty years -- and some closer to seventy. I held on to silver photography quite long; we had entered the third millennium before I got my first digital SLR, and went from lenses of the 1980s to lenses of the early 2000s.
I had one major surprise: The 20 years newer lenses had dramatically improved anti-reflex coating. With my old lenses, I always had to be careful with backlight, or the picture would be completely washed out. With newer lenses, you can more or less point the camera directly at the sun! (But not for long, or it will burn your sensor!)
Lenses you buy today have another great improvement: If you in the 1980s showed up with a 600 mm f/6.7 lens, weight 430 grams, about 12 cm long, people would have refused to believe it. My most recent buy is even more than a 600 mm lens, it is a 4x zoom, 150-600 mm. Or ... It is not, it is a 75-300 mm MFT lens. But if you dig up lens test result from the 1980s and earlier, comparing resolution, contrast and sharpness to modern lenses, you may be in for a surprise.
There is one area where I sort of miss an old quality: Mechanical. Affordable lenses, sold to photo amateurs like me, have a touch and feeling reflecting the use of plastics. They feel plastic. Not solid, not smooth, the way the old metal stuff felt. (And that is a major reason why they are as lightweight as they are.) I know that I could go for professional lenses at triple the cost, but I am not that active as a photographer.
|
|
|
|
|
Yeah, my few auto-focus lenses -- even from the 90s -- are very plastic and cheap-feeling. Near-impossible to use manual-focus.
I very much prefer my solid-feeling lenses prior to those.
What a lot of today's practitioners don't realize is that increased mass increases inertia which improves stability by reducing shake.
The 28-210 zoom I've used since the '80s is 778g and a joy to use.
I also didn't buy a DSLR until 2016 -- when Pentax (Ricoh) released the K-1 (full-frame, dontcha know).
Once I bought the K-1, I began buying more vintage lenses, mostly Super-Takumars which are as old as I am.
|
|
|
|
|
PIEBALDconsult wrote: The 28-210 zoom I've used since the '80s is 778g and a joy to use. That was late 1980s, wasn't it? I don't remember anything close to that being available in 1980. Or is my memory wrong? What make / model was it?
Old memory from the 1970s: Vivitar announced its Series 1, the 70-210 mm as the first one going to market. A notice in "Fotografi", the major Norwegian amateur photography magazine, reported that the computers doing the lens calculations was expected to complete by the end of April that year(!) (If my memory is correct, it was done on a PDP-11.)
My first SLR had a Nikon 43-86mm zoom, well know for its terrible (lack of) sharpness at the edges. The Vivitar Series 1 was by many considered the first major breakthrough in high quality yet affordable zoom lenses. 3X was impressive by that time, 7.5X for a full-format lens was far out of sight.
|
|
|
|
|
I bought it in 1985 and it's a marvelous work of engineering.
"
The need for one lens able to do everything, or at least as much as possible, was an influence on lens design in the last quarter century. The Kino Precision Kiron 28-210mm f/4-5.6 (Japan) of 1985 was the first very large ratio focal length zoom lens for still cameras (most 35mm SLRs). The fourteen element/eleven group Kiron was first 35mm SLR zoom lens to extend from standard wide angle to long telephoto (sometimes referred to as "superzoom"),[191] able to replace 28, 35, 50, 85, 105, 135 and 200mm prime lenses, albeit restricted to a small variable maximum aperture to keep size, weight and cost within reason (129×75 mm, 840 g, 72mm filter, US$359 list).[192][193][194]
" -- History of photographic lens design - Wikipedia[^]
|
|
|
|
|
What's a 'camera'?
Isn't that what smartphones are for?
How else to instantly upload to that other essential invention ... social media? 
|
|
|
|
|
The problem with smartphones is that they suck out the subject's soul. 
|
|
|
|
|
Leo56 wrote: What's a 'camera'?
Isn't that what smartphones are for? Obligatory Geek and Poke[^]
|
|
|
|
|
Hmmph! https://www.flickr.com/photos/awrose/103252765/in/pool-camerawiki ain't it pretty?
Story - 35 yrs ago - guy had done some beautiful work and was very proud that the grain was so fine.
I said so? I get that smooth out of Tri-X all the time. He goes uh - OH! you're the one with THAT camera!
|
|
|
|
|
Beautiful camera!
I love looking at old photos taken with those types of cameras.
|
|
|
|
|
Ah yes, one of far too many "need to spend time with thats". ( And the F-1, A-1... the D2s ( which are 5-7s, the Gundlach is a 4-5 ) and the Bronica - which I got paid for using _almost_ what I paid for it. )
|
|
|
|
|
I am very much two-faced about grains. On the one hand, those super-smooth tones from old 4*5" films (or even larger), when the emulsion was stuffed with silver, and not a trace of grain, can be a pleasure to study for their tonal qualities alone.
Then, in significant parts of modern B&W photography, graininess is used as an artistic expression, not unlike the 'dottiness' of some impressionist painters. In journalism and sports photography, graininess and hard, 'graphics style' contrast has been a style of expression for at least 50 years. Even in some landscape photography, grains can add structure to a surface that would otherwise be boring (e.g. a misty landscape).
My photography books fill two meters of shelf space. In them, I can "in no time" find a hundred photos, from internationally recognized photographers, that would have lost some of their qualities if they were absolutely grain-less and with a smooth, 'natural' tone scale. Fair enough for 'scientific style' documentary photos, but if you want your photo to tell a story, you may need something beyond a simple and boring 'This is exactly how it looks'. It may be true, but So what?
Who said "A picture shouldn't show something, it should be something"? In the process of making it "be" something, grains can be a great tool.
|
|
|
|
|
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|