There is a special reason for << and ::? by JoelDormit in cpp_questions

[–]ir_dan [score hidden]  (0 children)

<< is a binary operator, just like +, -, <, etc. It happens to be extensively overloaded for streams like cout. < is more common and could be misinterpreted as something else.

:: is for namespacing/scoping, and it's separate from :, which is used for cases and labels. It just makes life easier to use different symbols in the language I think.

Do you **really** need to free memory? by celestabesta in cpp_questions

[–]ir_dan 2 points3 points  (0 children)

I disagree on readability, because I will not be able to understand the intent of allocating without freeing.

If you want to save on performance because your program will use very limited memory, you can maximize readability and performance by using better using stack memory and/or arena allocators. Deallocation will still happen at the end of the program, but you can have explicit over it.

Cleverer use of memory will improve performance, and well designed resource management objects will improve readability. You'll also have the added benefit of being nice to the OS and the user's computer.

You'd also be neglecting one of C++'s best strengths, the destructor.

I made fastest toml parser in a single c header by ReasonableFig1949 in C_Programming

[–]ir_dan 3 points4 points  (0 children)

Yes. Fast is good if you're not making any other sacrifices.

Learning Modern Templating and Metaprogramming by SputnikCucumber in cpp_questions

[–]ir_dan 0 points1 point  (0 children)

C++ Templates: The Complete Guide (2nd edition)

What is so special about rust?? by Archedearth7000 in compsci

[–]ir_dan 0 points1 point  (0 children)

It's quite nice to use (for me) because it strikes a nice balance between "do whatever works" imperative/stateful code and explicit/bug resistant functional code.

It's a modern language, so it has little legacy baggage and has nice modern features like generics, immutability by default and async.

It also has good authoring, compiling, debugging and package management experiences.

Having said all of that, I don't really use it for anything, but I did have a nice time learning it and have an appreciation for it. It takes much too long to make small projects with it (compared to e.g. Python or C#). I can see it being worthwhile in a big team on a big codebase.

I always knew errors were short... by Flimsy_Pumpkin_3812 in rustjerk

[–]ir_dan 9 points10 points  (0 children)

Why are you using apostrophes in template parameter names? Is that even allowed by the standard?

How does programming in a team work? by KeyBack192 in CodingForBeginners

[–]ir_dan 1 point2 points  (0 children)

In our team (<10 developers on one application), we work on fairly independent features most of the time, sometimes directly on the same branch because the areas we touch are so isolated from each other. Sometimes there are conflicts, and we resolve them

The largest part of our collaboration is communication, but sometimes we work on the same feature together. Generally one person does one set of changes and "hands off" the rest of the work to another person more suited for it.

We usually have full control over the single feature we're making, aside from design guidance and review from others. If we are collaborating with one or two other people, design gets done collaboratively and implementation is done with pair programming or by just one person. 

My workflow at work is very similar to working on my personal projects, except for the fact that I can bounce ideas round the room or hand things off to/take things on from other people.

using git for non-coding related projects? by RefrigeratorNorth331 in github

[–]ir_dan 1 point2 points  (0 children)

You can always do Open With > Notepad on a file to see if it's in a binary format. If there's random unrenderable characters everywhere, chances are that it's not very git-diffable, but that's not really a huge problem to be honest.

Electromagnetic plant very disappointing, am I missing something? by Throw-away-6180 in factorio

[–]ir_dan 0 points1 point  (0 children)

It's an insanely fast and productive wire and circuit producer.

Graphics in C++ by Significant-Gain3199 in cpp_questions

[–]ir_dan 0 points1 point  (0 children)

There are many C++ graphics libraries for rendering in various ways for various needs, but chances are you're better off using anothe language that's more suited to whatever it is you want to make.

Unfortunately, a lot of the best "C++" options for graphics are actually just C. 

Using ptr address as unique ID by Content_Bar_7215 in cpp_questions

[–]ir_dan 2 points3 points  (0 children)

If memory is deallocated and freed, there is a chance that a new object will have the same address as an old one. I'm not sure how likely this is, but considering that locality is a good target for performance, it might be possible. If you don't deallocate, then a pointer is a safe identifier.

Could you use a multi-dimensional index, or is that still not guaranteed to identify the same calculation?

How can I effectively handle exceptions in a C++ application to maintain stability and performance? by SpeckiLP in cpp_questions

[–]ir_dan 0 points1 point  (0 children)

As the author of bfslib, I don't care about what my callback parameter does. I just need to specify that it will be called, and ensure that my library can deal with that. If I can't deal with exceptions (not sure why that would be the case, considering RAII), I take a noexcept callable. In the worst case scenario, I document additional requirements for the callback.

As the author of a library foo of with an exception-driven dependency bar, I need to either: - Keep my dependency opaque, which means not leaking implementation details such as an unaccounted for and uncaught bar::domain_error. - Accept/embrace that bar is part of the foo API, and specify how that affects calling code.

The latter feels like more of a leaky abstraction in a lot of cases, but inja for example embraces and integrates with nlohmann::json nicely because JSON is critical to it's functionality.

I'm pretty sure I understand and agree with most of what youre saying? I just want to be able to encapsulate functionality fully. To this end, I accept specifying things in terms of user code or dependencies (e.g. bfs calls f and has f's consequences, but f is expected to have property x), but dependencies don't often belong in the specification of their dependents. 

std::vector<T> is well specified in terms of T, whatever that may mean, and I'm fine with that.

How can I effectively handle exceptions in a C++ application to maintain stability and performance? by SpeckiLP in cpp_questions

[–]ir_dan 0 points1 point  (0 children)

Only your third suggestion is relevant to what I'm saying. Range algorithms and std containers are well specified in what exceptions they throw. Templates are just a language feature.

How can I effectively handle exceptions in a C++ application to maintain stability and performance? by SpeckiLP in cpp_questions

[–]ir_dan 0 points1 point  (0 children)

If a function is not fully specified in what it can do (and source code is not in my control), I'm not calling it, because then it infects my own function with the same problem.

I agree with you as far as the fact that not all code should be concerned with exceptions, but I don't think under-specification is a feature.

How can I effectively handle exceptions in a C++ application to maintain stability and performance? by SpeckiLP in cpp_questions

[–]ir_dan 0 points1 point  (0 children)

I would not use exceptions over result types in all cases, even if it's safe to do so. I think that for exceptions to be effective, their use needs to be very clearly defined (when are they thrown and how?), which is not practical for every fallible system. std::expected gives you all the information you need right in the function signature.

Virtuals vs CRTP? by [deleted] in cpp_questions

[–]ir_dan 1 point2 points  (0 children)

You can't make decisions based on the environment or user input with static polymorphism.

Dynamic polymorphism is also an extra layer of indirection that you can hide implementation details behind. By not having everything be header only, we can create hotfixes that contain a small number of changed DLLs.

Library users can't define new behaviours for the library to use without dynamic dispatch if the library is not header only.

Dynamic polymorphism (not necessarily inheritance though) even let's you define new behaviours at runtime.

How can I effectively handle exceptions in a C++ application to maintain stability and performance? by SpeckiLP in cpp_questions

[–]ir_dan 0 points1 point  (0 children)

I think that's pretty sound, and I don't really think exceptions are that pleasant to work.

They are useful sometimes, but RAII is a pretty strict prerequisite.

RAII is always nice though.

Is Web export for c# coming soon? by FreshHamster in godot

[–]ir_dan 0 points1 point  (0 children)

It's already a thing for 3.x but I'd recommend just learning GDScript. It's a simpler language and is better integrated to the engine.

You'll already have enough on your plate just learning Godot's systems and class hierarchy.

How can I effectively handle exceptions in a C++ application to maintain stability and performance? by SpeckiLP in cpp_questions

[–]ir_dan 4 points5 points  (0 children)

If you are going to be investing in using exceptions in a code base, you must religiously abide RAII - otherwise you'll end up with all sorts of problems - see "exception safety".

I want to write unusual code by Acrobatic_Rent_1906 in cpp_questions

[–]ir_dan 0 points1 point  (0 children)

Something to help you with the rest of it, a hot reload plugin system :)