/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

gist.github.com/anonymous/c4344a67d179c5e96bea70f5a4d76b32
noesisengine.com/
twitter.com/NSFWRedditImage

what's the easiest language to learn to become employable?

gist.github.com/anonymous/c4344a67d179c5e96bea70f5a4d76b32

So I just got this to work all the way, but now the issue I'm running into is that when it's under 20 guests, the number of servers returns 0 instead of 1. Should I use a floor function for that?

guys amazon wouldn't accept a hole in the ground as my mailing address pls help

>what's the easiest language to learn to become employable?
Javascript and Python

What's the best language to learn for shitposting on Sup Forums?
Haskell.

You don’t even need to learn programming to become employable.

Not everyone was born into a protected class, user.

prolly english or chinese

Is there ever a reason to use struct assignment instead of memcpy?

When dividing 2 integers, the / operator performs integer division.
When you need fractional amounts, store the result as a float and cast as follows
numberOfServers = (float) GuestNumber / guestsperserver;

i'm a code artisan

A E S T H E T I C

My IDE has support for Vim bindings. Is it a meme or worth taking the time to get used to?

use vimtutor

easier to read
easier to write
harder to break
compiler can still optimize it to be as fast or faster than memcpy

19:05 gcc args.c
19:05 ./a.out
0
19:05 ./a.out 3
3
19:05 ./a.out 5
5
19:05 cat args.c
#include

int main(int argc, char* argv[]){
int x;
if (argc == 2){
sscanf(argv[1], "%d", &x);
}
printf("%d\n", x);
return 0;
}
19:05

what's the point of atoi?

The only vim emulator kind of worth using is evil-mode for emacs. Everything else is generally trash that is missing most of the keybindings you would use on a daily basis.

to convert a string to an integer

so this is what it feels like, to poo, without the loo

There is Visual Studio Code and there is Visual Studio Community (among other versions, of course). What is the difference between them and is it important for a programming newbie?

Why is it so fucking difficult to compile my shitty C++ program using a shitty external library. Fuck CMake fuck C++

pajeet poos in code

back to css

Employed Haskell programmer here

Haskell

Why not Agda?

>CMake
found your problem.
the hand-craft makefile (not autogenerated ones from ganoo autotools) is the best build system ever made.

how do i create an array of ArrayDeques in java?

Because you didn't setup your system.
You need to learn how to compile stuff.

How much less energy consumption does a raspberry pi require than say a macbook for simple tasks, such as if I want to constantly fetch statistics from the net with my bot?

thats not orthogonal to sscanf though

you are one of my favourite posters behind akari poster

VSCode is basically just a text-editor (imo it's a good one) that's heavily extensible, but can't compile your programs, at least not out of the box.

VSCommunity is an IDE, meaning in addition to the amenities of VSCode, you can build and run projects.

>is it important for a programming newbie
If you're on Windows, save yourself the headache and use an IDE

no u

GNU build tools are cash. I'm forced to use CMake because the Wt library uses it

I know. I've been tracking down where the include files are located since I was stupid and installed the library from the repo instead of building from source

from googling around a bit, raspberry pi peaks at 4W and macbooks peak at ~30W

when do i stop feeling like a badass hacker every time i start tossing around pointers in c/c++, and recognize myself for the smug brainlet i truly am

>I'm literally retarded
we know

Make a self-balancing binary search tree in C with dynamic memory that works with all possible inputs and operations, without using a reference.

Do that and you are justified in feeling like a badass hacker.

ArrayDeque[] Queues = new ArrayDeque[AlphabetLength];
Queues = {A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z};

send help, netbeans and stack overflow isn't telling me how to do this

community is just the free version of the regular visual studio ide, which is the big heavy-duty tool with 80000 bloated features you'll never use, and 4 or 5 that are really cool helpful, providing you play along and let it manhandle your build

code is a lightweight, open-source text editor styled after visual studio. it can do some ide-like things with third-party plugins, which is nice, but those a. are third-party and not necessarily reliable, b. tend to still require you to follow the not-really-but-really-official ms-approved build setup, which defeats half the purpose of this sort of thing

let big daddy vs baby you, and then just switch to vim when you actually know what you're doing

ArrayList a = new ArrayList();
them a.add(new ArrayDeque()) in a loop.

Thoughts/opinions on this book:

>web semantic class
Shit is so boring. I wish every day I could find, pass interview and keep a job in any shit language instead of pretending to be useful with this.

nm got it

More difficult than you think

wouldn't work for this situation anyways. thanks though

Knuth's books all have a similar feeling to me. Also, I don't think that book covers topics in the best order. Discrete Mathematics and Its Applications is what I used in school and it was fine.

quantum mechanics is the future so don't waste your time. learn linear algebra instead

if posting on Sup Forums required government-issued ID and verification that the poster is both 18 or older and has an IQ over 99, would this thread have the same number of contributors?

Not the same number, no.

What is your opinion on Kotlin?

it's good for android

When you can use C++ without using any raw pointers anywhere because unique_ptr and shared_ptr are more suitable for 95% of your needs.

How in the fuck does Eclipse use more memory than fucking VS?

Finally made a functioning game of blackjack in python
it's barebones, and doesnt properly list face cards, instead counting them as their value, so I can end up having two different "ten of clubs." and aces are listed as elevens of whatever suit.
Still though, the numbers are correct and it works.
Took me a while but I'm proud of myself.

Way to go, user. Have a (You) :3

Congrats, user

Do your programs work on ARM, /dpt/?

Yes, why wouldn't they?

Eclipse was written in Java, that's why

console or GUI? if GUI im jelly.

You might have been one of those people who only use asm.

How do you calculate average/best/worst cases for algorithms?

I ended up doing multiple inheritence today :(

#include

class Point {
public:
int x{0}, y{0}, z{0};
Point(int a, int b, int c = 0) : x{a}, y{b}, z{c} {};
friend std::ostream& operator

so was Netbeans and IntelliJ, both are excellent IDEs and have a much lower memory footprint than Eclipse. Just because some program has some shitty code it doesn't mean that the language is the culprit.

>You might have been one of those people who only use asm.
No, I enjoy getting things actually done

#Blackjack
import sys
import random
A, J, Q, K = 11, 10, 10, 10
spades = [A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K]
clubs = [A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K]
diamonds = [A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K]
hearts = [A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K]


deck = [spades, clubs, diamonds, hearts]
psuits = range(len(deck))
for suit in deck:
random.shuffle(suit)
player_cards = []
dealer_cards = []
player_score = 0
dealer_score = 0
player_nums = []
dealer_nums = []

def deal(recip, indiv):
csuit = random.choice(psuits)
if csuit == 0:
plscore = deck[csuit].pop()
indiv.append(plscore)
interim = str(plscore)
recip.append(interim + " of spades")
elif csuit == 1:
plscore = deck[csuit].pop()
indiv.append(plscore)
interim = str(plscore)
recip.append(interim + " of clubs")
elif csuit == 2:
plscore = deck[csuit].pop()
indiv.append(plscore)
interim = str(plscore)
recip.append(interim + " of diamonds")
elif csuit == 3:
plscore = deck[csuit].pop()
indiv.append(plscore)
interim = str(plscore)
recip.append(interim + " of hearts")
deal(player_cards, player_nums)
deal(dealer_cards, dealer_nums)
deal(player_cards, player_nums)
deal(dealer_cards, dealer_nums)

I'll post my code so you all can laugh at how inefficient it is.
unfortunately its too big to be posted all at once, so i have to fragment it.
just console. I'm not good enough to make stuff in a GUI yet.

I implemented Linear Conflict into the priority function of my program that solves sliding puzzles today and my program can finally solve 15-puzzles with greater than 50 moves in a reasonable amount of time.

It still completely halts on puzzles with very high number of moves (60+) so I tried learning IDA* and how to use a pattern database but I got stuck.
Do any of you know how to implement IDA* correctly? I know it's supposed to be way faster than A* for 15-puzzles yet my version is slow as shit

player_score = player_score + int(player_cards[0][0:2]) + int(player_cards[1][0:2])
dealer_score = dealer_score + int(dealer_cards[0][0:2]) + int(dealer_cards[1][0:2])
if dealer_score > 21 and A in dealer_nums:
dealer_score -= 10
if player_score > 21 and A in player_nums:
player_score -= 10
showdown = False
cardnumber = 2
dealcardnumber = 2
while not showdown:
if player_score > 21 and A in player_nums:
player_score -= 10
A = 1
elif player_score > 21:
print("You bust with a hand of " + str(player_cards) + "and a score of " + str(player_score) + " You lose.")
break
hors = input("You have " + str(player_cards) + " dealer has a " + dealer_cards[0] + " will you hit or stay?")
if hors == "hit":
deal(player_cards, player_nums)
player_score = player_score + int(player_cards[cardnumber][0:2])
print("you draw " + player_cards[cardnumber])
cardnumber += 1
elif hors == "stay":
if dealer_score < 16:
while dealer_score < 16:
deal(dealer_cards, dealer_nums)
dealer_score = dealer_score + int(dealer_cards[dealcardnumber][0:2])
if int(dealer_cards[dealcardnumber][0:2]) == A and dealer_score >= 11:
dealer_score -= 10
print("dealer draws " + dealer_cards[dealcardnumber])
dealcardnumber += 1
if dealer_score > 16 and dealer_score 21 and A in dealer_nums:
A = 1
elif dealer_score > 21:
print("dealer busts with " + str(dealer_cards) + "! You win.")
sys.exit()
else:
showdown = True
else:
showdown = True
else:
print("try again")

Scripting a porn batch downloading engine for a dude who torrents all of them as soon as they are released. Remove fetch sessions, download either from a stream or a real file, meta data removal as much as I can (though most is done recontainering it...) , and then sort it to another directory and instant torrent creation.

else:
print("Showdown! player has " + str(player_cards) + ", dealer has "+ str(dealer_cards))
print(player_score)
print(dealer_score)
if player_score > 21:
print("You bust with a hand of " + str(player_cards) + "and a score of " + str(player_score) + " You lose.")
if player_score dealer_score:
print("you win")
elif player_score == dealer_score:
print("it's a draw")
elif dealer_score > 21:
print("dealer busts with " + str(dealer_cards) + "! You win.")
else:
print("You lose")
this isnt your regular average everyday pajeet code
this is advanced pajeet code

Typically how to AAA game devs go about developing engine tool GUIs? Looking at Frostbite and Bungie's engine tools they looks similar to something you'd get in WPF, which is C#. But I imagine their engines are written in C++. I'm just confused how they're probably using XAML/WPF for GUI and C++ for backend and how that all connects?

So I can do node->value in C but can I do node->anothernode->value?

Python pays good and is really easy to learn.

What the actual fuck is this shit?

You're not supposed to run Agda code, only typecheck it.

going from java to c# what are the big things i need to change with my brain

ive been doing embedded java for 2 years now and im watching c# shit and it seems so close to java stuff right now that im starting to get things mixed out between them

Remember not to use C# or any .NET technologies.

delegates (first-class function types) exist. look them up, and also the "event" keyword

you can define your own value types if you use struct {} instead of class {}. this has its own inherent uses; on top of that, they're better and more performant for smaller, short-lifetime objects

yield return is a really nice feature

What's the point of using sscanf over atoi if you're not error checking?

atoi is for dirt nasty, fast conversions.

strtol and friends are for robust error checking.

sscanf is a slow, jack of all trades, with somewhat okay error checking.

t. jobless NEET

If only.

Yes. This is valid.

C++ or Rust for new projects?

this

Pick whatever you want. Rust isn't mature enough for something serious IMO, but if you're curious there's no harm in working with it.

...

java

if youre using Indeed to find a job than your skill level isnt high enough to actually apply for any senior level positions

if youre ACTUALLY a senior level programmer than you would be getting at minimum 5 offers from recruiters every week via linkedin

There's tens of thousands of smaller companies hiring C# developers. Programmers working for the top 15 are still a minority overall.

Also, C# might not be popular in the US, but it is popular in the UK and Europe.

>it hurts

somebody or some small team builds the tool
some other guy or some other small team builds the GUI
then somebody or some team connects the two

Trying to expand my knowledge on python. I just written a syntax cheat sheet for the language and I'm not sure what to do next.

Are there any projects I can do to get used to python?

>Are there any projects I can do to get used to python?

Literally anything you want

Someone please post the /dpt/ roll v4.1+

C# can interface to C and C++, so it's certainly possible to write most of your game as a library and invoke what you need from a C# application.

There's plenty of people using noesisengine.com/ though, which is effectively WPF for C++.

>syntax cheat sheet
>python
Is this your first time programming?

Something like this?

some guy in another board said

>i've been developing software for a cc/contactless company

what's a contactless company?

Not really. I have some experience in Java and a general knowlege in web based stuff.

I looked up a video on how to learn python quickly and they went over the syntax. Thats why I made this cheat sheet sort of thing.

>cc/contactless
credit card and contactless payment

What would you recommended for someone that is doesn't know the first thing about programing?

What language should I try to learn first?

After I choose one, how should I go about learning it?
Should I just find a guide study it completely try to replicate what I read or should I do it step by step?

I'm really lost