[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 1759830500140666.png (94 KB, 1822x2051)
94 KB
94 KB PNG
If I just decide on a subset, does it become the best language? The complaints I mainly hear are:
> it's hard and unsafe
Git gud

>it's super bloated by boomers maintaining backward compatibility
Fair, but is it not solved by just agreeing on a subset? "Too many features" is a weird reason to toss a language.
>>
>>106846664
stick to the guidelines and you're golden.
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
>>
>>106846664
its telling that you didnt work with cpp for a long time. not a single senior cpp dev would want to stick with cpp if there was some better alternative. but there is none right now.
when people are usually talking about the "bad aspects" of cpp, they usually dont mean what people like you at best do with cpp - nor are they are talking about some fresh application they started, alone or with a small team, where they can easily decide on things like style, subset, features etc.
its usually people who are working on huge monoliths written in different styles of cpp over decades where some stuff has dozens of levels of inheritance for some fucking reason, where some retard decided to basically write half the business logic via templating at some point etc.

but starting a small private project with cpp is just nice, pick whatever you want, do whatever the fuck you want and nobody is stopping.
>>
>>106846664
The subset that I decide on is C.
>>
>>106846664
Only dumb people think that you have to use the whole language. Like I hate exceptions and I wouldnt allow them in any project or you have to catch them on the lowest level.
>>
>>106846817
>I hate exceptions
why?
>>
>>106846704
>I like, for no benefit, spending x10 more time or medium and x100 on complex tasks, but at least it adds x2 to x10 more bugs and vulns
>>
>>106846827
he is probably mentally challenged
>>
>>106846984
sounds like a (you) issue
>>
>>106847019
>if you want to use tools, like a hammer, then it's a (you) issue. build all things without them, because!
retard
>>
>>106846827
Because it creates hidden side effects and makes your interfaces opaque. Throwing exception is sphagetthi code. If you have large codabases with millions of lines of code exceptions makes it very hard to maintain.
>>
>>106846664
>it's super bloated by boomers maintaining backward compatibility
The problem isn't features that you don't use, it's that the existence of those features and the ABI prevent new features from being implemented in a sensible way which is why everything is so retarded and overly complicated.
>>
>>106846664
a good subset of C++ is called C#
>>
>>106847188
>Throwing exception is sphagetthi code.
lol ok retard
enjoy writting
if (do_foo()) then return 1;
and then same in caller, on each call.

if (std::cout << "poster is gay, ") return 1;
if (std::cout << "lol ") return 1;
if (std::cout << "LAMAO ") return 1;

but oh wait your function was suposed to return an int! what now? tuple with ok,int like a rust-tranny?

ok cool.
now what about
draw( get_screen(), best_player_nr(1).find_pos(world_name()), style_color());
each of the functions there can fail
what about

cout << "Hey you " << (poster().get_id()==106847188 ? "big" : "medium") << " faggot"
each op<< and each function can fail there
good luck you big retard
>>
Only on a one person project. Otherwise, welcome to hell.
>>
>>106846664
its a fine language until you have to use code someone else wrote then figuring out their style will make you angry even worse if you adapt others style
>>
>>106847398
>can't use code tags
>misunderstand what he's saying.
exceptions are untyped garbage. at any level in your call stack, can one magically show up. they're shit. this is why newer languages try to discourage using stack unwinding shitcode as control flow and if you forced checked exceptions, lol, lmao, enjoy your fuck huge function decls.
>>
>>106848837
>exceptions are untyped garbage
what?
>at any level in your call stack, can one magically show up
yeah. and you can't change that by choosing not to use them. others' code may throw, even stdlib.
>discourage using stack unwinding shitcode as control flow
you're not supposed to use exceptions for control flow anyway
>>
>>106848988
>>exceptions are untyped garbage
>what?
did I stutter, PLTlet?
>yeah. and you can't change that by choosing not to use them. others' code may throw, even stdlib.
thus the problem. combine that with the fact that in badly designed languages like C++, failing in a constructor is only possible with exceptions. usually have to write a bunch of shitty factory patterns like you're a java jeet just to handle that.
>you're not supposed to use exceptions for control flow anyway
then what use case do they have? Google turned them off ages ago for a reason anyway. they're just bad.
>>
>>106846704
C with vectors, references and namespaces? Is this the final redpill?
>>
>>106849116
it really is, i personally just use C++ over pure C because it has some convenient features such as vectors, actual strings, some pointer things, etc, other than that i use it like C
>>
>>106846664
>you can't take out header files
>you can't take out build system fuckery
>you can't take long compile times
>you can't take out inconsistent naming conventions
>you can't make the standard library good
>you can't take out most footguns

the improvements you can achieve by using a subset are minimal at best
>>
>>106849060
>did I stutter, PLTlet?
no. you also make no sense.
>usually have to write a bunch of shitty factory patterns like you're a java jeet just to handle that.
no, you don't have to do that. that's something you chose to do. it seems like you try to use C++ like it's some different language. why even bother with C++ then?
>Google turned them off ages ago for a reason anyway
the reason is, by their own admission, that their code is dogshit, and would get wrecked by exceptions. that's not a problem with exceptions, but with their trash code.
>>
>>106849180
the only real problem i agree with is header files, header files are kinda silly
>>
>>106849116
Without references please.
>>
>>106849199
references are good though.
>>
>>106849240
>call f(2)
>suddenly 2 is not 2 anymore
utterly brain damaged
>>
>>106848837
>exceptions are untyped
???

catch (const freddy_mercury_the_faggot & you) { ... }
catch (const some_faggot & you) { ... }
catch (const std::exception & ex) { ... }
catch(...) { abort_with_meme("retard"); }

theory(">>106848837 is some poo and has no idea about coding").confirm(true)
>>
>>106846664
>Git gud
You won't
>is it not solved by just agreeing on a subset?
As long as you work alone and never interact with or use anybody else's code, sure. Brand new novice programmers really like to present this as an option.
>>
>>106846664
>If I just decide on a subset, does it become the best language?
there is no such thing as a "best language".

>The complaints I mainly hear are
Here's another list of complaints:
- Outright malicious standard with insane shit like strict pointer aliasing requiring you to configure your compiler just for baseline
- Two (technically 3) type systems, one of which is turing complete, means you're writing two languages at once (three if you include C macros, and you will need them)
- Speaking of the second language, it's constructed in an extremely ridiculous way and is very annoying to read and write. Also it's impossible to debug
- Said second language also has very strange limitations, some of which have been addressed in the last 2 or 3 standard revisions. However thanks to absolutely horrid design, you *will* encounter annoying limitations and awkward boilerplate just to use them. You still can't arbitrarily allocate/reallocate memory using constexpr and embed it into the program, for instance. You have to work around by using constexpr std::array and you MUST be able to pre-compute the size of the array, you can't delay it. This basically kneecaps your ability to offload things to compile-time
- Unstandardized ABI means interfacing requires extensive boilerplate that you can't even generate internally because the metaprogramming is so fucking bad
- You can't even get the mangled symbol-name in a standard way
- No standard way to allocate additional memory on the stack
- Still no ability to iterate over structure members at compile-time, meaning serdes will be a royal pain in the ass
- Template parameter deduction is complete ass
- auto&& is privileged in such a way it can hijack a visitor, even when an explicit qualifier-matched case is available, making std variant fucking useless
And many, many more!

If you're doing something complex, especially if you're working with people or pulling in dependencies, you will not stick with a subset of a language.
>>
>>106849270
can't pass 2 by non-const reference.
>>
>>106848837
you use statuses where appropriate and exceptions everywhere else. as it turns out, there is usually not that much places in programs where checking for status is meaningful.

also, it's better use the following pattern instead of status code:

bool MyFunc(int& result);

if (!MyFunc(result)) {
//error
}
>>
>>106849270
That's not how references work.
>>
>>106849294
checked cast != strongly typed, retarded faggot. holy shit.
>>
>>106849374
use std::optional in situations like that. returning by reference makes code hard to read.
>>
>>106849374
What's the usecase of exceptions?
If you don't handle them the program crashes, it produces a coredump, and I need to look at the coredump anyways, so any information conveyed by the exception crash is fundamentally useless.
If you DO handle them, you already set up the logic for potential failure and possibly recovery, why wouldn't you just do the same work to sanitize your shit instead of having a bunch of disorganized jumps?
>>
>>106846704
C is not a subset of C++, there are some subtle differences (and C is better)
>>
>>106849423
You catch them in your main loop, and display an error to the user, or log it to a file for a dev to look at later. The only time you let it take down the whole process is for short lived programs like a command line utility.
>>
>>106849396
Don't forget it turns the entire codebase into a minefield, as "object of class Thing holds a Thing unless it was moved from" is no longer true when you allow types to be constructed without data for the purpose of return by parameter, so now EVERYTHING doubles as an optional.
>>
>>106849393
what is this idiot trying to say, that option to capture "virtually" (as pointer/ref to base class if you prefer) is la bad? because...???
if you really need to capture a more child class, then add capture for the child first
there is no scenario where this is an issue, especially in real and not shit code

what a brainlet.
>>
>>106847398
>draw( get_screen(), best_player_nr(1).find_pos(world_name()), style_color());
draw_result = get_screen().zip(best_player_nr(1).zip(world_name()).and_then(|(bp, wn)| bp.find_pos(wn))).zip(style_color()).and_then(|(scr, bpp, sc)| draw(scr, bpp, sc))

Used rust-style syntax for brevity
>>
>>106849675
If it's not an intractable problem, then why not just check the inputs so no exception occurs in the first place? Take for instance, we try to load a file that does not exist. We can avoid the exception entirely by just checking if the file actually exists first.
>>
>>106850056
>checking if the file actually exists first.
that's a TOCTOU risk thougheverbeit.
>>
>>106846664
It has zero bloat, everything is there for a reason. Just don't use what you don't need, some stuff covers very niche scenarios that you may never need to use in your life.

>>106849180
Skill issue.
>>
>>106847398
We need explicit error propagation, consider this:
Try {
Linear SocketHandle client

client := Propagate net.Accept()
Propagate HandleClient(client)
}
Catch e: ErrorCode {
WriteLN('Client handling failed: ', e)
}


This:
Try {
Linear SocketHandle client

Propagate {
client := net.Accept()
HandleClient(client)
}
}
Catch e: ErrorCode {
WriteLN('Client handling failed: ', e)
}


And this:
Try Propagate {
Linear SocketHandle client

client := net.Accept()
HandleClient(client)
}
Catch e: ErrorCode {
WriteLN('Client handling failed: ', e)
}

All this should work with sum types, no stack unrolling or setjump-longjump required.
>>
>>106850067
I guess that's true depending on how you're checking it. Generally I try to open a file and check if the handle is valid. If somebody is still pulling some trickery off at that point, I don't think exceptions are going to help me mitigate that.
>>
>>106847398
that would indicate a code smell and whoever wrote such shit code full of singularities requiring such extensive sanitization needs to be put into a mandatory training program.
>now what about
>draw( get_screen(), best_player_nr(1).find_pos(world_name()), style_color());
this is unambiguously shitcode for multiple reasons, and suggests that this employee does need to spend more time learning and practicing before they can contribute to any of our codebases.
>>
File: useful_subset_of_cpp.png (48 KB, 926x1024)
48 KB
48 KB PNG
>>106846664
>If I just decide on a subset, does it become the best language?
yeah. already exists, too
>>
>>106849154
>some convenient features such as vectors
seems real cool until you have to program on bare metal and realize all this shit is unforgivable bloat
>>
>>106850533
C++ has tools for that.
They're shit tools and you have to work very hard to abuse them into working for that task, but it does have the tools.
>>
>>106850056
You can avoid the exception, but you can't avoid the error. Sometimes the only useful thing that can be done with an error is to propagate it up the call stack. Eg if some necessary file doesn't exist, telling the user it doesn't exist is often all you can do.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.