/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread: Fuck off mod, we had 5 /dpt/s since the other thread was created. Nobody wanted to post in a shitpost thread.

Attached: 1530582440062.png (1280x720, 1M)

first for Java
>deal with it

>What are you working on, Jow Forums?
Writing a GUI program with OpenGL, without relying on bloated nonsense like GTK or Qt.
It's an image viewer.

Attached: 1554334256061.jpg (704x1024, 59K)

very based thread

Did you mean
>DealFactoryFactory.createDealFactory().createDeal().dealWith(ItSingleton.getIt());
?

In php
$time_start = microtime(true);
for ($i=1; $i

Hi C****o

Wut

I'm working on a botnet that makes IoT airconditioners flood discord tranny lair basements with natural gas.

Attached: 1532239878708.gif (800x468, 682K)

lewd

how much math do you need to know to become an employed and well paid programmer?

serious question frens

Attached: D4WkkrtUIAAOsUX.jpg (1200x900, 299K)

Depends. Programming is a pretty broad field.

All of it

implement a recursive function that checks if a given number is prime or not

I don't think you should use any sleep function for anything requiring precise time resolution. Your process resumes when it's scheduled, at a time at minimum what you asked for.

I'm working on research right now. It's a program that uses Intel SGX to do some end-to-end data sharing. It's all been low-level C programming. With some whiskey to hand I'm enjoying myself. Sucks a lot to debug it, though.

You should definitely know every thing up to basic abstract algebra and differential equations. Knowing some algebraic topology wouldn't hurt, though.

thanks frens, gonna go ahead and make sure i know my shit then

Attached: 1554251678014.jpg (640x854, 67K)

I'd say that you don't need to know any specific field. You don't need to know differential equations unless you're in engineering, or shit like abstract algebra. The important thing is that you're a good mathematical thinker. Exposure to a lot of algorithms and types of math is the most important thing.

If my hand were forced on a specific field, I would say number theory is most useful. It has the most direct application to computer hardware.

An addendum, read (and actually work through, even if you're a brainlet) something like Introduction to Algorithms by CLRS or TAOCP. It will make you smarter.

These people are giving you meme answers. How much math you need depends on your job. If you’re doing web dev, probably you need to know only basic shit. If you're doing numerical computations for CERN you’ll need a lot more. I work in low level kernel driver shit and my math is mainly fucking with bytes and hex conversions. Linear Algebra is a big help across the field, as is probability. In general the more math the better but it’s really not necessary for a lot of shit.

wow that was hard

Attached: 1341267438538547.png (354x387, 22K)

Great now make it actually efficient instead of code monkeying it up

it's tail recursive so should get optimized

>recursive
>efficient

No wonder everyone complains about being unemployed on here... What is the largest factor a number could have?

i see. thank you.

sqrt

>What is the largest factor a number could have?
smallest prime < ∞

2?

what sort of number

Any fucking number, what is the largest factor that any number with regards to itself.

Jesus maybe /sci/ is right

forgot all of the negatives too, I only just started programming again a couple months ago

Attached: 1341267438538547.png (504x205, 24K)

>any fucking number
not all numbers have factors

that third test should be abs shit

I'm a beginner in programming. I've worked IT most my career, started at a helpdesk, got certs, very first was Network+ then Security+ then Linux, etc. But I'm tired of being the fucking network admin. I don't want to set up fucking servers, routers, switches or PBX's anymore. So I'm gonna get into programming, albiet late.

Stupid questions follow. What should I start with? C seems to be the most popular and works at a lower level, managing memory for example. Or should I do python or Java or something? And what do I need to program? I know Vim and Emacs, use Vim alot for bash scripts and configuring cisco's bullshit. But what about IDE's? VS code? Jetbrain? Netbeans? I'd appreciate any help from you /dpt/

Attached: 1527595696053.png (981x814, 773K)

This is a joke right? You’re making fun of me? You guys aren’t this stupid right?
What is theoretically the largest factor any number could have, as in what is the limit on the factor of a number?

Project Euler 9 in F#.
Quite elegant if I may say so myself.
It outputs the correct answer twice (hence the last map) because it doesn't do the minimum number of iterations, but I like how short the code turned out so sue me.

let pairs = List.allPairs [1..1000] [1..1000]

let check (a, b) =
let c = 1000 - a - b
if (a * a + b * b) = c * c then true
else false

let euler9 =
List.filter check pairs
|> List.map (fun (a, b) -> a * b * (1000 - a - b))

>What is theoretically the largest factor any number could have, as in what is the limit on the factor of a number?
The largest factor for a given number N is N, because N * 1 = N, QED.
Prime factor, on the other hand...

>assuming multiplication is defined for every number

Here's your stupid prime checker thing

#include

int isPrime(int n) {
union {
float f;
int32_t i;
} u = {n};
u.i = (u.i >> 1) + 0x1f800000;
for (int i = 2; i

If you know what I mean then fuck off. I bet you think the code posted solves it O(n) anyways

>

Whoops, should be u.f

they asked for recursive, even though its fucking retarded to use for checking primes

Relax senpai, I was just teasing. I also didn't want to give the solution away completely.

Ultrafinitists pls go

I’m sorry, I’m high strung at the moment and this thread has put me on the edge, I didn’t mean to lash out at you user-kun.

Plz help, I'm new and dumb

I'm working on a college group project right now. Of the 56 commits to our GitHub I've made 34. The next highest contributor has made 9. Are these people taking me for a ride?

Attached: twrppesp20211.png (1061x800, 1.04M)

kek

What do you need help with user, I got the time and if I don't talk to someone I'm going to melt into a bubble of mtn dew and depression.

But who has the most logic contributions? I commonly see half a dozen commits in a row saying "fix" or "forgot thing" that contribute nothing then one "did the needful" commit that's all the work.

import primeChecker
primeChecker.check(37)

module primeChecker

check(int n) {
return True
}

it passes the tests

using namespace std;

It's still me. I wrote almost everything. I'm about 4 years older than everyone else on my team so I'm not super surprised they have me taking the lead on this. It's just really burning me out.

C or Perl, or even Python... *yuck* are all fine for as long as you pick up other technologies along the way.

Since you write shell scripts already you could start with more shell scripts, awk, the parts of sed nobody uses... Maybe a little SQL, whatever.

A good idea for C would be to try compiling some open source projects and installing from source. DON'T DO THIS IN PRODUCTION! Use the package manager as usual, but learn how the process of building from source works. You don't need to be fully proficient in C to try that.

Builds won't always go smoothly BTW... There is a reason I say "try", some projects build easier than others for all sorts of reasons. Welcome to the club!

use ur editor of preference. if u want something new(no need as u use emacs/vim), unironically use notepad++. start whatever language interests you, or had interested you. some differ in syntax; some are simpler, some are not; don't go with the simpler mindset as it tends to ignore a lot of stuff. think of anything that you think you could realise as a program, then figure out how to do it in whatever lang, preferably the one u picked beforehand. if picking a language is hard, start with a more ambigious grouping, like "programming" languages that are web-oriented, "desktop" oriented, etc. then you could just google or ask here again, 'good languages for x' x standing for somewhat specific area for what you want. it's kinda stupid because you can make anything in any language that is turing complete but some are easier for certain things, some not. just pick some shit and don't ponder for months on what to start, you'll just lose time

BASED

Depends on what your goal is. If you want to stay in IT/sysadmin, I'd recommend learning python or something.
If you want to switch to software engineering, I would recommend learning C at some point, so you might as well start with it.

As for what you need, there are two kinds of languages
Interpreted languages:
You need to download the interpreter, create and save a script file, and make the interpreter run your script, i.e. "python.exe my_script.py"
Compiled languages:
You need to download the compiler, create and save a source code file, make the compiler compile your code into an executable, and then run the executable.

Most languages come with IDEs, whose primary function it is to combine a bunch of tools into one easy to use graphical interface + code editor.
For example, if you want to write C you would want a text editor, a compiler, a linker, makefiles, a debugger, a disassembler, etc.
It's a lot to manage on your own and very tedious having to switch back and forth every time you want to make a minor change, so an IDE handles that for you.

To be honest C's tooling isn't the best, so having to manually fiddle with those things can be pretty discouraging at first.
Maybe you're better off downloading Visual Studio (for C#), where basically all you have to do is write code and hit F5.

I'm being dumb right now but what determines if some platform can run a newer c++ revisions, like 17? Is it simply the compiler support for it?

Yes.

you're still checking every value from start-1 to 0 for divisibility meaning the algorithm scales poorly for higher numbers

the bare minimum optimization you can do is starting at sqrt(start)

Did no one like my solution? Isn't the code very cute? Where are my (You)s?

it's pretty straightforward
not really contrived or hacky enough to get attention on Jow Forums
plus i hate how you calculate C twice for every pair

Fair enough.

>plus i hate how you calculate C twice for every pair
The map at the end only runs twice in total. It could be removed if "then true" was replaced with "then printfn "%A" (a * b * c)", which would output the answer but not return it. I should probably add a |> List.head at the end, so that only one instance of the answer is returned.

its recursion, it will seg fault on large numbers unless the compiler saves you, optimizing it is a bit pointless

t. seething loopcel

Attached: you.jpg (800x450, 44K)

Thanks Fren, I'm just looking to see what language to begin with, probably the most asked question on this board for people looking to weasel our way into your jobs. Plus know what IDE would be recommended, I'd rather not spend time learning something like VS code when there are better options out there based on the experience of seasoned dev's, saves time. And any recommeneded books would be nice, though I could just pirate a whole bunch and start reading.

I'd like to do dev shit, hopefully not codemonkey status. I'll give C a try, and I could always dual with python or Perl. Guess I'll see which I like more. And thanks man, I already use linux, have a functional Arch desktop I post on desktop threads, so maybe I'll try compiling some of the packages from the source code.

I appreciate the input. I suppose I could just use Clang or GCC with Vim to compile the source I write. Then if I truely need it I'll look at full bloat IDE's when I'm more experienced. From the recommendations I think I'll start with Perl, I like the syntax, and then move to C, maybe get to mess with embedded systems. I don't plan on wasting my time, I'm not getting younger and when I started Networking I wasted alot of time trying to perfect my book memorization instead of just going around configuring Cisco routers with Vlans, using Netcat or nmap, and fucking with macs'. Practice is the only way to learn ya know.

Sys Admin is tedious, boring, and pay is pretty shit. Plus I can't make cool stuff, besides networking my house. So I'm looking to leave it. Thanks for the tips mang. I don't know dick about IDE's, and that sounds like a pain in the ass. But is there an alternative to VS? I've heard it's bloated and not to mention developed my Microsoft. If possible an open source IDE or atleast something running on Linux would be cool. If not I can throw Win7 on an old desktop for it.

Thanks frens

I like Elixir.
I just wish it wasn't tied to a shitty VM.

Attached: -MWyJCb1.png (512x512, 114K)

t. coping stacklet

If your writing python you can use vim. Memes aside vim can be used to do everything on your machine and it's only ever crashed on me twice. If I can't write something in vim then I'm not happy.

Taul recursion (or, generally, tail calls) doesn't grow stack

It's a shame that most languages don't actually make that optimisation.

I would like to become a gnu/linux wizard, not just an ordinary guy. I’m talking system calls, kernel hacking and the whole shebang - like a formal study of GNU/Linux.

Where I’m lost is resources. Is ‘The Advanced Unix Programming Environment’ enough? Any .edu course links or lectures would be great.

IDEs don't matter at the start. Not to mention that most of the time what you use depends on where you work and what you work on, so VS for C# and sometimes C++, IntelliJ for Java, etc.
>hopefully not codemonkey status
well it'll take dedication and preferably not getting into webshit straight away with no motivation to further improve past the knowledge your regular pajeet already has

I think that's only with -O2+, but I could be wrong

generic programming was a mistake

have fun

when can we have /dpt/ on /sci/?

>w-when can we have a /sci/ programming thread, I keep getting bullied here and I want actual intellectual discussions!!

>/sci/
no, we need a new /prog/.

Attached: prog.jpg (473x496, 105K)

text board would be nice

do you mean /prog/ from double chan? because it was never that active, is that still the final frontier?

Nah. Sometimes you want to post an image which is relevant to your posts, e.g. writing some kind of graphical program.
Also, how would we post our cute anime grils?

Attached: 1550139553146.jpg (710x779, 93K)

Jow Forums used to have a /prog/, but it was never on the front page. You just had to know that it was there.

No, the /prog/ from Jow Forums, progrider then tinychan. It's dead though.

shit, what was it like user? can’t believe i never bothered to check

Google sleep sort.
Aside from that you didn't miss much. 80% of posts were "hax my anus", literally just that.

How do I get better at programming I learnt stuff in uni but i felt real behind when I did an internship at a start up.

Is the styling in K&R for C optimal?
Still looks pretty ugly, but I started python so maybe I'm biased.

when they start wearing programming socks, but they're faggots so they don't

you program

hax my anus

I finished my java course, any cool things to do you recommend me?

K.N King is the modern K&R, I’ve read.

ya'll niggas don't even smoke crack

Currently learning programming for the first time, and decided to start with C. I wrote a very basic program to determine if two integer values are evenly divisible by each other using only stdio.h, and was wondering if any Jow Forumsentoomen wanted to give me some feedback on how I can improve this. My little division by zero check felt fucking weird to do, but it works. There has to be a better way of doing this though kek. Plz no bully.

#include

int main(void) {
int n1, n2, r, r2;

printf("Enter first integer value: \n");
scanf("%i", &n1);

printf("Enter second integer value: \n");
scanf("%i", &n2);
if(n1 == 0 || n1 == 0) {
printf("Division by zero is undefined.\n");
return 0;
}

r = n1 % n2;
r2 = n2 % n1;

if(r == 0 && r2 == 0){
printf("%i and %i are evenly divisible by each other.\n", n1, n2);
}
else {
printf("%i and %i are not evenly divisible by each other.\n", n1, n2);
}

return 0;
}

Attached: 1555223722743.jpg (1280x720, 500K)