/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1534036011579.png (1280x720, 705K)

wait that's not a girl

first for Go is a nice language

if err != nil {
return err
}

do go fags not realize that this is basically an exception?

5th for haskell tiddie monsters

LOL GO CAN'T INTO FIRST

Attached: 1552109170956.png (850x1200, 938K)

It can only go uo 1 level in the call stack, unlike real exceptions.

What do you think about exceptions vs error codes?

truncating numbers
its not fun

exceptions are not explicit

harmful to control flow predictability
more expressive
sum types with sufficiently expressive generics are the best of both worlds

how do I learn how to photoshop programming book into anime scenes?

I don't understand. How can a pattern of workflow like throwing exceptions be seen as a competing alternative to a collection of error codes representing potential problems encountered? Does "error codes" refer to something I'm not aware of?

But you can't trade in fractional shares. Unless the broker supports that. Or it's a mutual fund.

More programming languages should have coroutines and/or continuations built-in.

This. With appropriate syntactic sugar (e.g. do-notation) there is almost zero overhead when writing code.

std::expected will save the world

I think it's such bloat... why not just a pointer or std::optional?

good to see C++ is finally catching up to early 90s Haskell

the best thing you can do with sepples is to ignore all this std shit and roll your own implementation of everything

It's actually bad and sad. If you rolling your own shit (and you are not google, ea or some other gorrillion corp) you are not writing C++, you are using some weird shitty dialect which will most definitely fail

best thing you can do is write C and call into it from a good higher-level language, probably a lisp-like or ml-like

> C++ catching up to Haskell

C++ TIOBE Index: 4
Haskell TIOBE Index: 43

Continue to weep functional fags. C++ will continue to be one of most practical and robust solutions to real world performance critical programming problems for a long time. If you think you know better than the thousands and thousands of professionals in the industry who keep deciding to use it, you are delusional.

Attached: stroustrup-draper-award-banner.jpg (750x330, 147K)

it's what cniles do and it works for them
std apis are fucking abysmal.

shit like this is what's keeping me away from C++
nice, retard
I would not EVER want to work with you

I don't think he meant that as an insult. C++ indeed got expected from Haskell. And that's a good thing unironically

Attached: herr_sutter.jpg (765x659, 131K)

How do I get started programming? What language should I learn and what's the best way to go about learning it?

more like charles diaper

Most also do.

>you are not writing C++, you are using some weird shitty dialect which work fine for you, but if you ever have to bring anyone into the project you'll have to teach them from square 1
FTFY.

depends on what you want to program and why

stop posting this abysmal paper

>muh TIOBE
reminder that Java is #1 there even though it's garbage

Sucking a bookmaker dry. And it's fucking nerve wrecking.

>stop posting a paper that refutes my posts

Start with C
It is fun and you'll learn some concepts. Move on later once you have the basics.

the deterministic exceptions proposal has absolutely nothing to do with haskell, and is also a terrible design on its own terms

>charles barper

It was intended as a backhanded insult though it was unfair of me to level it at C++ in particular, because it applies to most other mainstream languages too. C++ is far from the only one that refuses to advance to the point of being less than two decades behind the state of the art in programming language design.

I feel like the better I get at C, the less I need the fancy stuff from C++

In most cases C combined with a higher-level language will give you what you need a lot more easily than C++ will.

You don't understand C++, then.

probably because you were shit at c++.

Nonsense.

>you're doing it wrong!
Pathetic.

>What are you working on, Jow Forums?
Decided to give haskell book a break to do exercises on exercism.
It's a nice change of pace.

>pic

Any functional language is a good start. You will become a better programmer for it. Haskell is a classic, but not good if you want to start doing real things soon. Maybe try elixir if you want something simpler.

Attached: c programming.png (1705x179, 22K)

The only people who recommend C++ are those who have never learned any other programming language, either through inability or stubbornness. Demand for C++ continues to shrink. There is no future in it. They only continue to spam it as a recommendation because misery loves company. Pick Java, or C#, or Python, or JavaScript, or Go, or Scala. You'll have a brighter future than if you pick C++.

I'm writing a wayland compositor in scheme. Currently adding workspaces and designing some generic interfaces for handling floating and dynamically tiled windows.

Attached: resetwm.png (1629x973, 858K)

std::unexpected

when?

I wrote a loader that loads png files on multiple threads. so far I can load, decode and put into vram 200mb pngs in 0.795s.

however when I replace the number of my max number of threads with a macro it slows down to 1.1s. why is that?

Attached: 1548456684474.jpg (540x540, 20K)

Spinning up a bunch of threads isn't hard, but engineering something that scales well with multiple cores isn't so trivial.

you dont understand:

when I write: 4 in my loops -> fast

when I do: #define THREADS 4 and replace all hard coded 4s in my code with THREADS -> slow

You did something retarded then. Brainlets should stop trying to write multithreaded code; they will make a mess that is hard to clean up.

I notice nobody mentioned python or java, is there any reason why? I've heard they're both very good to learn for jobs and are easy for beginners to pick up, but of course I don't know.

Could actually be your testing methodology.
Easy to fuck up timing if you rolled your own profiling tools.

which tool or set of tools should I learn in order to develop cross-platform mobile apps?
>React Native
>Ionic
>Dart + Flutter

React Native is the one that has more jobs where I live. Ionic is a solid 2nd but positions asking it also asks PHP, little to no positions for Dart + Flutter -- I've read somehere Dart + Flutter is the best if you want same performance as native

Hard to say. It isn't expected.

>when I replace the number of my max number of threads with a macro it slows down to 1.1s
This sounds weird. Are you sure you're testing the same thing?

I use the built in tools of visual studio

exactly the same. probably has something to do with the debug symbols

I second the C vote. Learning C can be a pain but the possibility of struggling at the beginning is totally worth it because it actually teaches you about how a programming language works, rather than the functions it has.

>scheme
can you do this with windows?

Attached: picture lang.png (926x926, 292K)

What programming related youtube video should I watch while eating?

That's the thing, they're easy for beginners to pick up, but with python especially if you haven't got a good idea of the under workings of the language, it's easy to shoot yourself in the foot. Java is also a good one to learn, but if you're gonna do that, then just do C since the syntax is so similar, and C has a lot less features to get hung up on. Most are saying C because it makes sure you get the basics down well first. Just like learning algebra before calculus.

Yeah ok, that makes sense. Do y'all have any recommendations on getting started with c? Resources like videos or books I should check out?

You don't need to know how low level languages work when you're learning to program. Learn a modern "easy" language first like Java or Python so you can actually start making things, then when you get comfortable you can branch out to whatever kind of programming interests you.

Not yet, but once the tiling interfaces are in place it should be too hard to implement. I'll add 'autistic geometric series layout' to my TODO list.

*shouldn't

Your thoughts on Donald E. Knuth?

Attached: the man, the myth, the legend.jpg (750x500, 256K)

bamf but he talks very strangely

>the cuck

Old people just talk that way. He doesn't seem to have dementia or anything, so he's fine.

old guy but seems he take no shit from anybod y .

he talks like most people write, but he writes like no one can; life is all 'bout them tradeoffs

C

Learn F#

You can make plenty of things in C. Learning how pointers and memory management work is valuable. I wouldn't even call C particularly low level. You're giving bad advice to be honest.

React is complete shit, I don't understand why it got so popular, the framework goes against every good coding practice known.

webdevs

post the actual code

a question for the rustfags here (if there are any)

say you have a trait T, with implementations T1 and T2; and you have a struct P like this:
struct P {
t: T
}


and, in runtime, you wanted to switch which one you wanted to use (via command line args, for example). so you would have something like this, on main:
let p : P = match cmd_arg {
"t1" => P::new(T1::new()),
"t2" => P::new(T2::new())
}


however, the above code doesn't work. it fails to compile, with "the size for values of type `dyn T` cannot be known at compilation time". any ideas of how to do this?

Attached: 1456726383290.png (515x518, 298K)

...

I was asked to create a survey that generates a PDF report once it's completed.
This is what I got so far.
However, some of the later survey questions have more complicated answers than yes or no and I can't figure out how to make it display a choice of answers rather than a text box.
Also I don't know how to add a question mark at the end of the Template Tokens.

Attached: 1552787145120.png (748x876, 73K)

HOLY FUCK
I JUST realised that "The Mythical Man-Month" isn't titled "The Mythical Man Moth".

Please tell me I'm not the only one

Attached: 1549769966453.png (500x679, 71K)

maybe i/o performance is limiting you? 200 mb in 0.7s seems like pretty decent performance for spinning rust.

you need to use trait objects. Probably Box is what you want

Don't worry user, we're all dyslexic branlets here.

How nice of you to share your diary with us.

What's the issue, survey or PDF generation?
PHP can do both trivially, what roundabout way are you using?

You are the only one user. You hear the calling of the moths. Fulfill the prophecy. Achieve your destiny. Become the legendary man-moth.

put t in a ox so that the size of P stays the same

survey.
I was asked to do it using Docupilot.

The fuck, man?
I could do it in less than an hour with PHP. What retards are you working for?

You keep posting this shit, and no one helps you because you arnt giving any fucking useful information, I don't even know what you are using to do this, what the problem is, ate you trying to turn this into some annoying pasta?

Working through the C programming language and Kubernetes in Action. It's like time machine in my head.

I'm using Docupilot.
The problem is that I don't know how to use Template Tokens to make a survey list.

I've got a problem I'm struggling with, any sort of psuedocode would help.

Basically, I've got a 2d array which contains a closed path - a closed path in this case is any vertical/horizontal jump from X, through a bunch of non zero numbers, back to X.

So for example, for the one on the left, we start at X, then go up to 25, then right to 125, then down to 175, then left to X and then stop.

In this process, we assign +/- to another 2d array which has the same size/dimensions as the one illustrated.

I'm having problems assigning the +/- properly according to this rule. X has to start with a +, then it alternates with - and + until the path is completed.

been stuck on this shit all day any help would be appreciated

Attached: help.png (644x244, 8K)

struct Foo {
const std::string &str;
};

int main() {
Foo foo{"hello"};
std::cout prints an empty string
umm sepples????

If it’s good code and your new friend is good, it’s fine and pretty fast. Teaching unskilled people to work with bad abstractions is harder and less rewarding

>const std::string &str;
nani

Rent Free.

make sure you don't fuck up input handling like literally every other wayland compositor
SIGIO is your friend

that's a reference to a temporary dummy
you invoked ub