/dpt/ - Daily Programming Thread

This is /dpt/, the best subreddit of Jow Forums

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

/!\ ** Read this before asking questions ** /!\

catb.org/~esr/faqs/smart-questions.html


What are you working on?

Attached: timetocode.webm (1152x648, 2M)

Other urls found in this thread:

github.com/awesomekling/serenity
youtube.com/watch?v=hE52D-zbX3g
learnpythonthehardway.org/
twitter.com/NSFWRedditGif

First for C

>tfw fucking around with X509 and I have no idea what i'm doing

What is the best way to do async IO in C?

Any advice for a uni student balancing school assignments and doing side projects? I tried scheduling my days, but I it didn't really help.
I'm hoping there are others like me who were successful at it and could chime in on with some advice.

stupid umaru thread

Last thread:

Attached: 1547986820417.gif (600x500, 573K)

Just made a splitter for user-driven widget resize and hooked it up in my file manager. I'm pretty happy with how it turned out.
Today I'm moving out of the cottage where I've built this OS over the last 6 months so I thought I'd make a little demo video about it.

Attached: widget-splitter.webm (1024x768, 423K)

posix?

idk, I just try to do it when I have time. Some periods are hard because when I'm done with school I'm done focusing for the day.
Luckily, most programming assignments are not that difficult, so I can finish them quickly then do my own stuff. It's usually when I have a course in maths or similar it gets tricky.

That's some sexy folding right there.

>windows 95

Attached: cat-looking-disgusted.webm (275x154, 240K)

More info on your OS?

Will Crystal ascend meme status?

Kino

Attached: 1552401752441.jpg (344x500, 27K)

Thanks anons.

It's a 32-bit Unix-like with a GUI heavily inspired by late 90s productivity software. Sources here: github.com/awesomekling/serenity
I also just made a little intro video about it, here: youtube.com/watch?v=hE52D-zbX3g

Attached: 90sgo.gif (400x300, 2.9M)

do I learn C or no

Yes, but don't use it, except if you can't use something else.

have you learned anything else but C before C?

Attached: 1530831431752.jpg (690x588, 79K)

Carry on my wayward son.

Working on a neural network project, this is my code so far. Any tips and tricks?
int main() {
puts("Tranining neural netowrk");
return 0;
}

puts can fail. You should check the return value. You don't want your neural network to crash because of something so simple.

So I'm trying to figure out data structures in the Linux kernel, working with 4.9 right now but I've stumbled onto an issue.
I'm getting an Unknown Symbols error when I try to load a kernel module using idr. Specifically I've narrowed it down to idr_alloc() because commenting it out the module loads fine. I've declared the header file for idr so at this point I'm lost on what to do to get this to work, since the old method for allocating something and getting an ID seems to be deprecated.

Attached: VirtualBox_2019-03-30_12-25-18.png (567x32, 7K)

Awesome stuff! Thanks for sharing

Make a tensor library in opencl first

So I wrote a project on my own and now I wanna license it out under the GPL. From my understanding the easiest way to do so is to stick the three-four paragraphs of "this code is licensed under the GPL blah blah" at the beginning of each and every source file, right? As a method that doesn't rely on e.g. github displaying your project's license, or external stuff like that. Or if I just include a license.txt in the git repo containing the text of GPLv3, would that be clear enough?

Also, anyone have something like I dunno a sed command or something handy for pasting in the GPL header if that's the best way? I've got a couple dozen files and don't wanna do it by hand

No tips but I just want to say that it's nice to see people actually doing serious development here, and not just having language wars.
Keep at it user!

text file processor that auto links and creates static html for deployment in massive cloud scale

A tool to grind through recovered data blocks from corrupted 7zip archives looking for audio files and recovering them. Client discovered that something was fucky in their file upload process so all of their call recording backups are bonked.

>tfw only the WMA files that make up 2% of the recoverable data had metadata with call ID

C++ and programming dumbo here. I'm trying to poll the input of a joystick and return the button value to the command line using SDL2 framework but when I try

if (windowEvent.type == SDL_JOYBUTTONDOWN)
{
std::cout

Attached: 10554520.jpg.png (429x410, 6K)

if you do
(int) windowEvent.jbutton.button
do you have the same problem? Maybe button is interpreted as a char.

holy FUCk all i needed to do was add
MODULE_LICENSE("GPL");

what the hell

That seems to have worked, thanks bruh.

What is the best syntax for importing?

Is suckless stuff good C?

>brittany not in latest stack LTS
>hindent not in latest stack LTS
Which Haskell code formatter is actually maintained nowadays?

No, they don't check return values.

Any languages other than java I should look into if I'm trying to develop android apps for personal use? (not games)

Remind me again my fellow hardcore C++ brogrammers why we hate web developers. I forgot xD

Kotlin

because they make more money and the hard part of their job is getting 300+ different libraries and packaging systems to work instead of solving programming problems

I don't hate web developers. I hate what the web has become.

Linux protects its GPL APIs by making you declare your software is GPL before you can use them

Hell no. Reading st source code is like being tortured

I only got to this issue while trying to use idr, but using slab, module, list, random, etc doesn't give the error? That doesn't make sense to me. It would throw warning about no license but compile and load just fine.

How would someone go about using Ruby to create a program that can divide a line of text from a txt file into several individual strings, add a new piece of text to the line, repeat the process for several more lines of text in the txt, and then input the new seperated text into an output txt?

In basic terms, take thing that says
"A B C"
"D E F"
make all six characters different strings, and then
output
"A B C G"
"D E F H"
in a document

Attached: 1488253433715.jpg (359x305, 51K)

learnpythonthehardway.org/

>Ruby

its the same thing man, manipulating strings in languages like ruby,python,js is a joke

>C doesn't have as many features as sepples
#include

#define foreach(arr, val, i, max, body) for(i = 0; i < max; i++){val = arr[i]; body;}

int main() {
int arr[3] = {42, 13, 7};
int val, i;
foreach(arr, val, i, 3, {
printf("%d\n", val);
});
}

An incredibly basic for loop that just opens a file, changes each line and then writes the file.

But then what does it do when it runs out of text? Wouldn't I need a while loop so it knows when to stop then?

You may think this is neat, but it is junk. Most of these "conveniences" end up creating convoluted bullshit. Everyone would instantly understand a for (i = ...), but this macro is 1) new 2) bugprone

uhhh you check for end of file
is this a homework assignment?

I'm having an existential crisis over whether I should be using C or C++.

I've been using both languages extensively for 12 or so years now, for exactly the same problems. I don't program in an OOP style, and C++ is so bloated that I feel sick just thinking about it, though it has some nice features here and there.

My #1 concern is performance, to be honest, and what has kept me from adopting C++ fully, despite knowing the language well, and despite it being the first programming language I've ever learned, is my concern with how things like exceptions and stuff like that (which I never use), affect my program just because of implementation quirks and overhead relating to them.

Just fuck my shit up, senpai.

I would trade C++ for C with no hesitation: It is the simplest way of keeping all the complexity of C++ away.

There are only two features in C++ that add overhead if you do not use them. These are exceptions and RTTI. The only overhead added when these are not used are binary size, otherwise performance and codegen is identical. These can also be disabled with compiler flags.

until you need the complexity of c++ and you come crawling back because doing the same thing in c would be a giant waste of time

What crisis? If your code is simpler or more performant with one or the other, then the decision is easy. If there's a feature you want to use in c++, then benchmark whether it's actually a performance issue.

Why is it called TCP/IP but UDP is just UDP? UDP also has an IP header, no?

yeah

is c the loomis of /dpt/?

I would go for C++, despite the language being huge it does have some useful features. Unlike C which is too minimal for its own good, and makes you deal with c-strings. Besides your compiled binary won't have the parts of C++ you don't use.

Attached: 1549138099513.png (673x1539, 1006K)

Why isn't undefined behaviour a compile error?

but how do I write quality code?

Attached: 1485620779544.png (298x274, 59K)

noice

Stop posting and watching anime first.

Some of it cannot be determined at compile time.

Understand how the compiler generates assembly code, and try to find out how to improve that assembly with your source code.
Experiment with it.

Or just write Assembly.

portability?

writing quality code isn't about trying to clean-room engineer the Clang compiler.

The notion of quality code is defined ahead of time by the project lead or by company standards, using a combination of qualitative and quantitative metrics.

In most companies, i.e. the ones who do not make embedded software, readability and maintainability tend to be the highest priority.
Code is a human readable format, but many humans go above and beyond in making obfuscated code, sometimes even on purpose.
At such companies, the goal is to write code that can be easily understood and easily modified with predictable enhancements.

Read Clean Code by Dr. Bob

I am in the same boat as you. For me, my goal eventually is to write my own compiler. And writing a c compiler is so much easier than a c++ compiler.

I would want as much of my code to be compiled with my own compiler.

My question is, why hasn't someone wrote libraries in c which provide the features of c++? Why do we all need to re-write the same things?

I broke recaptcha by sending it off to some third world country and injecting it into the target website.

Now, how do I make money from this?

>why hasn't someone wrote libraries in c which provide the features of c++
because features don't work that way?

language features that is
unless your language is already super expressive, but then you risk suboptimal code

make a free ad-serving file hosting service using a ton of free tier accounts from services like dropbox which require you to fill out a captcha to create an account

No, but functions do.

An example I can give is in the realm of ops.
One person might say that a certain shell script used to set up Kubernetes master or slave nodes is "quality" because it is simple and it works for what he wrote it for.
Another might say that it misses corner cases and other use cases, and that it would be better to use something like Ansible to guarantee that even a set of nodes would be in their desired states.

What are some enlightenments you have experienced?

Time is weird
source: acid

no? you can't write C functions that use lambdas without an unofficial GCC extension
even if they add lambdas, this is just one example

The majority of automation in this day and age assumes the information being entered is either all true or all false, and makes hard assumption based on those dogmas

Finish assignments first, because they're going to have the most material impact on your university success in the near future.
Then you just meter out the rest of your free time as you see fit. Sometimes you'll have the energy for sideprojects, sometimes a nap is a better idea.

It gets harder if your side stuff has commitments or stakeholders or customers though.

C++ generates better and more optimized code than C

Anyone know a good book about complex (evolving) patterns? Not necessarily programming patterns, but patterns in general.

Attached: 1420616475299.jpg (640x480, 74K)

never.

You don't need lambdas.

I suck at sed so just making a bash loop to cat/append the license comment header and the src file into a new one and copying it over would work.
for src_file in $SRC_FILES; do cat license_header > src_file.license && cat src_file >> src_file.license && mv src_file.license src_file; done

>The only overhead added when these are not used are binary size
The std libraries use them though, right?

To be honest, the more I think about it, the more I doubt I'd ever use more than what's available to me in C, if I were to go back to C++. It's a nice language and all, but there are reasons why I stopped using things like exceptions (and by extension, anything to do with constructors, classes in general, overloading, and so on.

There's only one thing I can think of that C++ has over C, and that's not needing to typedef structs (seriously, what is up with that shit? We're on C17 now, and that's still a thing...) Other than that, the only thing I miss in C, is a proper preprocessor, and that's not fixed by C++ (and no, templates don't count as proper meta programming).

And yet I always get stuck thinking about this before every new project... What the fuck is wrong with me?

Elaborate

I was looking into ansible in order to move away from CloudFormation templates. Are there any significant limitations that you've experienced with it as opposed to traditional shell scripting?

Ok. But this is what I dont understand. Anything is possible in C. So how much more code would you need to do a lamda in c?

Why is she among those niggers

That's 100 % bullshit. Noise has been a concept for literally hundreds of years in statistics, and it is certainly taken seriously nowadays with a million different methods to avoid overfitting or underfitting or to choose models and hyperparameters.

Always fix performance issues even when people say it isn't a problem. It will always become a problem.

"anything is possible" includes writing a C++ compiler in C

Wow

You're fucking retarded