/dpt/ - Daily Programming Thread

Old thread: What are you working on, Sup Forums?

c++ is the best language of all time

fuck opengl

C++ is bad because C++ has exceptions

rust is good but I want it to be great

Don't use them then, mongrel

How do I start the "xxxxxx..." line with a number?
>function startAutomatic(getSteamID64, xxxxxxxxxxx, callback)

I am trying to fix pic related

Then I can't use RAII.

Better yet, don't even use C++.

Was going to keep writing Haskell bindings to IG trading API but found out xenoblade chronicles 2 is coming out tomorrow so yeah, don't think that's going to happen for few days…

Exception safety != RAII

most languages dont let you put numbers at the start of an identifier

And use what?

So Im in a group with 2 others and we are supposed to write a paper on SSH for our network security class. We break it up into 3 parts and Im the middle of the third part. I get the first guys part and its written like a 10 year old having an in person conversation. Like its complete ass.

The paper only has to be 5 pages. Should I write the entire thing myself and just throw their contributions out and submit my version without their knowledge?

>Haskell
>Anything that actually does something instead of a mathematical jerkoff
m8

it has to be possible, the token in pic related (the module) always starts with a #

Reminder that `new` throws. What happens if you malloc an object with a destructor that gets called when it leaves the scope?

Do you have a peer review system in your class? If so, don't touch their contributions but reflect your thoughts in your peer review. If not, get the tard to sort his shit out, don't do it for him.

RAII works despite exceptions not because of them.

That's for you to figure out. It's a big world.

>ILLEGAL
why shouldn't i report you

unironically professional haskell programmer here, what's the problem

Reminder new throws if you run out of virtual memory. If you malloc an object with a destructor that gets called when it leaves the scope, resources are handled as you would expect

If almost everyone can learn programming for free, why is the salary relatively very high?

please dont bully me
this is my second project ever and my first in node

>why is the salary relatively very high
it isn't

>Java

> hurrrrr i'm going to diss C++ but won't provide an answer when asked for an alternative
troll

>not an argument

I already told him we need to use the RFCs for ssh and he just kinda blew me off. His shit is impossible to follow and out of order.

the parameter name, and its content are two different things.

>>not an argument

C++ is a general-purpose language. There are a million replacements but nothing as broad as C++ itself. Your alternative is specific to your application.

Because the best way to prove to an employer that you know something is through a degree which is basically that.

Taking someone who doesnt is a huge risk unless they have a shit ton of experience

What do you mean, is his writing-style bad or is his content/contribuation bad. If you dont like the content of his work, then re-write it.

It comes off contradictory when you recommend not using a language to others, and then saying language choice is specific to an individual

>There are a million replacements but nothing as broad as C++ itself. Your alternative is specific to your application.
Fucking THIS. C++ tries to do everything and ends up doing everything poorly. There are superior alternatives for almost every specific use case.

Both. Some of my favorite parts are "Lets talk about SSH and how it interacts with older versions of itself." and "OpenSSH is considered the safest SSH compared to the older versions of SSH but how?"

How would I write the contents of the parameter so that it isn't illegal?

>C++ tries to do everything and ends up doing everything poorly
What plethora of features do you believe C++ fails to implement? Feature-creep is a fair argument, but saying all features of C++ is poor is testament to your misunderstanding of performance

>and then saying language choice is specific to an individual
He said language choice is specific to the application, not that it's specific to your subjective whims (as it is often the case with people who use C++).

Fair enough I may have misread. Nonetheless, I fail to see how it is an argument against the use of C++

>saying all features of C++ is poor is testament to your misunderstanding of performance
This sentence is a testament to your meaningless subjectivist understanding of "performance".

Rust is mediocre but I truly want it to be great.

I see you cleverly dodged my first question with a quirky comment, why not do so?

rust is shit and it will never be great

So, I'm not allowed to dislike C++ unless I can tell you what to use instead without any context?

It's not about more features. It's about having the features cohere with the rest of the language.

>i fail to see how the existence of superior alternatives to C++ is an argument against the use of C++
Well, technically, it isn't. For all I know, you have a specific preference to use languages that make it harder to achieve your stated goal, because they satisfy your unstated Stockholm-syndrome-induced love for C++.

>So, I'm not allowed to dislike C++ unless I can tell you what to use instead without any context?
You're free to dislike what you want. In what way do existing features fail to cohere with the rest of the language?

>I see you cleverly dodged my first question
I don't know what your standards for "successes" are, but I consider C++ as a whole to be unusable, so I guess it fails at every single feature.

You see me as a undying adherent for C++, yet you didn't provide a single use-case where anything else is superior. Don't get me wrong, there are plenty, you seem more like the anti C++ bandwagon-rider here.

the contents of the parameter is whatever you pass into the function. If this is a string of some sorts, then that string can look like whatever you want, but the actual parameter name that you write in your function definition cannot start with a number.

it actually returns 5
>>the average of 4 and 5 is 4
>What did this poster mean by that post?

For languages without inheritance, what's the general solution? Interfaces? Isn't that technically inheritance too?

My standards for success are being able to build performant products and libraries with a language. If you're going to consider the entirety of C++ unusable, an incredibly popular and productive language, it sounds more like a programmer limitation than a language limitation.

oops second one meant for

Try not to look at it as a language having a
replacement for inheritance, but a new design philosophy in itself

Anyone know why this might occur?

I have an application that collects Kafka broker metrics that lives as three different deployments in a given Kubernetes cluster for three different teams. It collects the data, processes it, submits alerting info to zabbix and finally general metrics to graphite to power dashboards.

When a network blip happens and it gets disconnected, it will of course be unable to produce to graphite/zabbix and be unable to collect. That's fine, but once the network is available, collection and pushing to zabbix is good. However, graphite sending never recovers.

What's more odd is the way I push metrics to graphite is virtually the same as how py-zabbix pushes metrics. Open a basic TCP socket, send the batches, and close the socket afterward or for that batch if an exception is encountered. This will take place once another batch of metrics is needed to be sent (every 10s). But I can literally never produce metrics to graphite if a network blip occurs. If I kill & restart the service all is good, it acts like nothing happened.

I'm trying to deduce if this is a python, docker or graphite problem. So weird.

>yet you didn't provide a single use-case where anything else is superior
Any decent high-level language is superior to C++ whenever you can get away with using one.

Interfaces aren't inheritance in languages like Go. But you should prefer programming against interfaces to class hierarchies anyway.

High-level languages provide more abstractions. How do you define 'superior'?

I just re-write some parts(depending on time and motivation) myself. I usually send them the final version after giving the paper in, unless I know they won't like the fact I did it myself.
If you actually want to learn how to work in groups, don't do that.

>My standards for success are being able to build performant products and libraries with a language
That's not a standard for anything. Given enough time and effort, you can build "performant products" with almost any turd, no matter how poorly designed it is, as long as it supports some C-like core that gets compiled efficiently.

>If you're going to consider the entirety of C++ unusable, an incredibly popular and productive language, it sounds more like a programmer limitation than a language limitation.
If you're going to consider C++ a "productive" language, it sounds more like your limitation than mine.

May be worth confrontation, especially if you can get the other individual to join you. Failing that, just re-write it and reflect your thoughts in a peer-review if you can, if I was you.

use std::num::ParseIntError;

fn parse_and_sum(x : &str, y : &str) -> Result {
let parsed_x = x.parse::()?;
let parsed_y = y.parse::()?;

Ok(parsed_x + parsed_y)
}

fn main() {
let sum = parse_and_sum("12", "13").expect("Parse error.");
let will_fail = parse_and_sum("12", "Ass").expect("Parse error.");
}
You get quite a few methods and macros for manipulating your Results. It's possible to do pretty much the same thing as classic exception handling, just more explicit.

>If you're going to consider C++ a "productive" language, it sounds more like your limitation than mine.
A ubiquitous language that appears nearly everywhere, mainly in the most demanding applications sounds productive to me.
>That's not a standard for anything. Given enough time and effort, you can build "performant products" with almost any turd, no matter how poorly designed it is, as long as it supports some C-like core that gets compiled efficiently.
What're your standards?

>How do you define 'superior'?
More conducive to accomplishing the goals of the project. This usually involves things like correctness, security, timely delivery, maintainability, reusability etc., all of which C++ is sub par at compared to decent HLLs.

Sure it is faggot.

>A ubiquitous language that appears nearly everywhere
You mean like PHP, Javascript, Cobol etc.?

>mainly in the most demanding applications
What does it have to do with productivity? If you're programming "highly-demanding applications", it merely needs to be more productive than C. It doesn't matter if some other company could finish the same project with half the people in half the time and with twice as many features in the 2% of cases where performance trumps all other considerations.

monads could have prevented this

That program is invalid; you're causing undefined behaviour. Try writing a valid C++ program before trying to shit on it.

>you're causing undefined behaviour
Pretty sure that was his point.

>You mean like PHP, Javascript, Cobol etc.?
Yes...
C++ has plenty of high-level functionality. The idea that it's some clusterfuck of unproductivity is fallacy. Languages sit somewhere between performance and productivity. There is nothing wrong with the position where C++ stands on this spectrum, but it is not far away from full productivity.

Im trying to understand the reason behind this bullshit to avoid it in the future, care to explain?

...

updating a variable multiple times in a single statement has undefined order of evaluation

I don't see how it's a valid point. Will dereferencing (int*)(0) be a valid attack against C? The standard does not define such behaviour, so it seems pointless to use that as an argument

"If a side effect on a scalar object is unsequenced relative to a value computation using the value of the same scalar object, the behavior is undefined."
The standard does not provide instructions as how to handle such a situation. Thus, compilers will choose what happens. This is what undefined behaviour is. Put simply, literally anything can happen, including the program crashing, or even producing the output you expected!

>PHP, Javascript, Cobol etc. are productive
Well, okay, then. At least you're honest about your standards being based on market worship rather than anything to do with the innate quality of the language.

>The idea that it's some clusterfuck of unproductivity is fallacy.
The idea that the idea that it's some clusterfuck of unproductivity is a fallacy is a fallacy.

>Languages sit somewhere between performance and productivity
Only in the mind of a C++ programmer.

>There is nothing wrong with the position where C++ stands on this spectrum
Everything is wrong with it, because nothing about the performance C++ offers justifies its horrific design decisions.

> but it is not far away from full productivity.
It is lightyears from productivity, as you would've known if you hadn't wasted years of your life reading C++ minefield survival manuals.

Can someone offer me a smart way to do arrays in POSIX shell scripts without using spaces as delimiters and multiple pipes?

>I don't see how it's a valid point
I can see how a seemingly innocuous piece of code invoking undefined behavior could be a criticism. This isn't something like ++i + i++, which smells right away. Most people would expect the arguments to simply be evaluated left to right.

>The standard does not define such behaviour, so it seems pointless to use that as an argument
But that is exactly the point: perhaps it should have.

>The idea that the idea that it's some clusterfuck of unproductivity is a fallacy is a fallacy.
Do you have any C++ experience?

I now see your point. Yeah, I can't really argue against that. I suppose at first glance, everyone would expect left-to-right or right-to-left evaluation. That being said, I disagree with the other guy's prospect that an unexpected language quirk makes the entire thing 'shit'

>Do you have any C++ experience?
Yes. The problem with most C++ programmers is that they unironically believe that C++ is the be-all and end-all of programming languages, and that every shitty fizzbuzz they write needs the same level of performance as a HFT system, so they never bother learning anything else. Or if they do, they usually fail at it, because spending too long in a language like C++ is seriously crippling to the mind.

I'll stand right by your side and join you in saying that C++ is not the utter apex programming language, fittest for all tasks. Spending all the time using one language only and truly believing that it's perfect is of course a huge red flag. I hope I didn't come off like that, I simply defend the language when it's accused of being unusable.

>spending too long in a language like C++ is seriously crippling to the mind.
I have to disagree on this note, C++ is one of the better learning languages around.

Seeing how you are un-informed and yet have a strong opinion, you PERFECTLY fall under the category of uneducated Cniles that blindly hate on C++.

>I simply defend the language when it's accused of being unusable.
Whether it's "usable" or not is a matter of personal opinion. The more time I spend working with other languages, the less usable I find it when I come back to it. Interestingly, the reverse never happens. What isn't simply down to personal opinions is that there's nothing about the performance of C++ that justifies its sheer amount of incidental complexity. You could cut it down to a C with compile-time evaluation, compile-time reflection, a more expressive type system and some decent metaprogramming and get a language every bit as performant and even more powerful.

>spend all day learning about how a very specific compiler works, and how to work around edge cases
>master the C++ standard library
>become a language lawyer
>file GCC bug reports left and right
>meanwhile js pajeet has a $300k salary

>>meanwhile js pajeet has a $300k salary
Shhhh. Adults are talking about programming languages.

...

private businesses
>endless masses of shitty unmaintainable enterprise java

government
>short, clean, modular scala

explain this /dpt/

>government
>short, clean, modular

Hi, I'm trying to learn PHP here and am currently working on a basic website which will hold a database of a fictional library. I'm working on a functionality to edit a selected record, and I'm having a bit of a bit of a problem validating the use input upon form submission. I would like to automatically loop through the POST stream, validate each element according to its designated data type, and if validation fails (ie wrong data type, say I put a character in something that's supposed to be a float), I would like to store a message in a mulitidimensional array, something like $errors['title'][1], which afterwards will be checked and if empty, will allow form processing, and if not will be used to display the errors back (this I've got working).

I had a look at filter_input_array() but, I'm not sure how I could incorporate the error storage with that..

If this makes sense and anyone has a solution, would be great

The software written in the typical private business is an unholy abomination, because nobody gives a fuck.

>The software written in the typical private business is an unholy abomination, because nobody gives a fuck.
As opposed to the beautiful and superbly reliable software written in the public sector? Have you used any government websites lately?

hey guys, does pic related make any sense?

since i can't connect to databases in my computer directly through the browser...

the software written for government is written by intern who has never programmed before

>does pic related make any sense?
Such a pic can only make sense in

>Have you used any government websites lately?
Yes, they were a joy to use compared to the slow bloated ad-filled JS-riddled garbage that is most commercial websites.