|
Yea.. I had seen some library doing that last time I used C++....
I thought it pretty neat.
I tried it myself and it was great except for the abysmal compile time anytime I changed something..
|
|
|
|
|
yeah, but for the end user of your header it's great.
Real programmers use butterflies
|
|
|
|
|
Quote: why everyone doesn't just make C++ libs as pure HPP files is beyond me. The extra build complexity is not worth the little bit of extra code hiding you can get by using cpp files. With an HPP you just include the heckin thing.
There are a lot more reasons to not put implementations into header files than just hiding proprietary code: reducing dependencies, making code more readable and more maintainable, reducing build time.
You may not be able to appreciate any of this as long as you work on your own and your projects are small. But I assure you that it's well worth the effort for any project with a lifetime of more than 1 year, even if you're the only one maintaining it. And most certainly for any team project.
For example I currently work in plugin development, and our framework to help us create a plugin makes heavy use of templates, so it's header-only. However, these templates force the compiler to pull in pretty much the entire codebase as well as several large third party libraries such as boost, increasing the build time to more than a minute, whereas a simple plugin not using that framework can be built in a second.
It's so bad that I'm currently looking into replacing that framework with a different approach that minimizes dependencies (and therefore build-time). The key concept will be moving all the code that depends on third party libraries into cpp files and putting those into a pre-built library. Building the plugin will then no longer require pulling in hundreds of headers from third party libraries!
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
We'll have to disagree on the maintenance thing. CPP files are hateful. You have duplicate too much. Too many potentials for getting that wrong and it's annoying to have to flip back and forth between files if you forget a signature while making the CPP. You can have it.
Besides, HPPs make an easier to use library.
The only reasons I'd use CPP for that are if the implementation in the library is proprietary and I was building a static lib or if the build times were too long.
Real programmers use butterflies
|
|
|
|
|
Quote: CPP files are hateful. You have duplicate too much. Too many potentials for getting that wrong and it's annoying to have to flip back and forth between files if you forget a signature while making the CPP.
With the right tools none of these things ever become an issue. And the advantages of having clean and minimalistic headers easily outweighs the minimal overhead of maintaining additional files and maybe having to actually bind a library to your program rather than just header files.
But as I said earlier, you can only start to really appreciate the benefits of cpp files once the projects get bigger, so I guess we'll never share the same view on this. Let's just leave it at that.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Stefan_Lang wrote: I guess we'll never share the same view on this
I might, if I had the same requirements you did. I wouldn't like it, however.
I'm happy to agree to disagree though. However, you said something that particularly caught my interest:
Stefan_Lang wrote: With the right tools none of these things ever become an issue.
Okay so I use VS Code primarily for C++ development just because I like it better than Visual Studio for that.
Now, it's easy enough for me to open up another window to the right for my header file.
But what about the code duplication. You said you had tools for this? I'd love to know what you use.
Real programmers use butterflies
|
|
|
|
|
I haven't tried many tools, but VisualAssist for Visual Studio offers a function to change the signature of a function. This will change the function not only in the header and cpp file, it will also rename (if needed) any function calls in the rest of the code, and if you add a function argument, it will insert ToDo comments to help you locate code you need to adapt.
Not sure whether there's a version you can use with VSCode.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
P.S.: here's a description of the function I mentioned: Change Signature[^]
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Quote: and all the headers have to be included in a very particular order Don't feel bad. You tried. If any build order that satisfies the partial ordering determined by their #include directives doesn't work, they deserve not to be helped, but horsewhipped.
modified 2-Jul-21 18:01pm.
|
|
|
|
|
It could just be me. I'm rough around the edges using make and cmake is almost entirely new to me.
But when i've tried to yank all the source files out and assemble them myself, i can't get anywhere at all.
One of the problems is that you have to include the main header and then a secondary header this way
#include <freetype/ftbuilds2.h>
#include FREETYPE_H
or some such
It's a zoo
Real programmers use butterflies
|
|
|
|
|
I feel ya...
Sometimes, when something is too complicated for what it's worth, I also like to roll my own!
However, I am surprised the difficult part is the build process, how disappointing!
|
|
|
|
|
It's just that I don't have an author who can sit me down and walk me through the source tree.
If someone had a few hours to do that with me I could do it no problem.
The issue - or one of them is that the includes don't include prerequisite includes - they expect them to have already been included upstream so..
in one file you might have
#include <stdlib.h>
#include <math.h>
#include <string.h>
int do_something(float x,float y);
and then later on you have another include file that uses do_something() without ever explicitly including the first file. That only works because some file included both of them before. Does that make sense?
So basically I can't unwind which includes depend on what, much less figure out what all the defines are supposed to be without completely reverse engineering their make and cmake files.
And there's many of them, and it's just a maze.
Real programmers use butterflies
|
|
|
|
|
Ha yes that jog some memory... I did have similar problem with GNUstep long time ago....
Which reminds me, on a totally different, yet vaguely related topic, I really like how they handle the dependency in the new C# project file format in visual studio..
|
|
|
|
|
I haven't played with it yet. I've only been using VStudio a little here and there. I've been neck deep in C++ and I use VS Code for that.
Real programmers use butterflies
|
|
|
|
|
"If you build it, they will come..."
For/From an (Indie) software development perspective, does this sentiment even slightly hold true?
Assuming you have identified some need and have found a good/efficient way of providing a (software) solution that works well and is user friendly, how do you get people to:
0) Find it
1) Try/Evaluate it (for free)
2) Get sufficiently engaged in it (i.e. post on message boards / forum / read documentation)
3) Buy or license it
asking for a friend..
|
|
|
|
|
My perspective, from a somewhat different point of view:
When I create a new way I want things done I introduce it gently at first and then cut the cord and the old way is gone. I already learned years ago, that where I work, users want to do it they way they were doing it = even if it's stupid, irrational, and/or mistake-prone. I'm not overstating this.
So, pretty much I, my fearless leader, and our upcoming (welcome) third wheel make the decisions ourselves and that's how things are.
"Resistance is Futile"
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
As Jerry Pournelle used to write in the Chaos Manor column in Byte magazine (Yes I know I’m old!) -
‘Good enough is the enemy of better.’
If you can't laugh at yourself - ask me and I will do it for you.
|
|
|
|
|
I'd want more context for that quote.
I interpret it as meaning that a less-expensive product which is "good enough" will out-sell a "better" product which costs significantly more.
Just as MS-DOS outsold OpenVMS, and Ford outsells Porsche -- in numbers at least, if not dollars.
If so, then the quote also applies to "feature creep"; few will pay more for a product simply because it has more features if those features aren't required.
The result being that a developer who's trying to compete can't simply keep adding features in the hopes of gaining market share.
The quality (is job one) and price must remain competitive.
|
|
|
|
|
So let me throw this out there...
Hypothetically...
My software can do perhaps 10% of the things that my (closest/big) competitor can do, but I am offering it at 1% of the cost.
Assuming that the user base spans a sufficiently broad spectrum (not all of them need all of the features), if they currently have 10k users, would you expect my user base to be 100 or 1M?
|
|
|
|
|
I doubt you'd be pulling current customers away from them.
Would your mother buy a copy?
|
|
|
|
|
wasn't strictly speaking about pulling away, thinking about new customers given a choice...
No, she wouldn't. But my dad has asked for a key... probably just being polite
|
|
|
|
|
The bigger issue (in my opinion) is that if it is at least moderately successful, others will try to duplicate it and undercut you. You will have done a lot of market research and such for them at no cost. Feedback about what's good/bad/missing will be available for others to react to.
Your ability to respond to feedback and make updates available quickly will be critical in staying ahead of the competition.
Releasing a product doesn't mean you'll have time to relax.
|
|
|
|
|
The only place where success comes before work is in the dictionary
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I assume you're asking about software that would be released commercially. I also assume there's no budget for advertising, so it has to spread by word of mouth. Two common approaches are to offer a free version of the software that (a) expires after a trial period or (b) only provides a subset of the full functionality. Both approaches aim at getting users to pay for either a license or the extra features.
|
|
|
|
|
Your assumptions are correct...
I see the issue as not being able to sufficiently attract people in the first place. Yes, advertising is a big deal, but short of giving google some $100/mo to get clicks, low cost software cannot justify high cost advertising, especially for a niche app.
The Freemium model does partially work, but I have found that the free, time limited trial is often a better way to go.
|
|
|
|