[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 326
Thread images: 45

File: 1466969439648.png (286KB, 400x450px) Image search: [Google]
1466969439648.png
286KB, 400x450px
Previous Thread: >>60193215


What are you working on, /g/?

also mathematics is not a science
>>
>>60200231
>mathematics is not a science
t. SJW liberal arts major who couldn't handle any math classes
>>
You cant study deep space and black holes without math
checkm8 agnostics
>>
>there are people here who are writing obscure scripts and tools instead of writing apps for mobile devices
You realize you could get a job making $20/hour sitting on your fat NEET ass, right?
>>
>>60200249
>t. SJW liberal arts major who couldn't handle any math classes
Nobody who did more maths than the "mathematics for computer scientists" module in first year CS would say that mathematics is empirical
>>
File: smug_ran.jpg (632KB, 709x1063px) Image search: [Google]
smug_ran.jpg
632KB, 709x1063px
>>60200231
It doesn't really matter what you think; it's a fact that mathematics is a science.
https://en.wikipedia.org/wiki/Formal_science
Pathetic and retarded losers who don't agree with well-defined nomenclature that is widely-used by experts who are exponentially more intelligent than them (or indeed anyone with half a brain) need not apply (and need not reply to me).
>>
>>60200306
>$20/hour
is that your idea of good money?
>>
>>60200324
It's a respectable amount compared to being unemployed and tinkering with Linux
>>
>>60200317
i'm on to you, kitsune
>>
There are two rocks on a beach.
The human race has been wiped out in a nuclear war.
Are there still two rocks if there are no minds around to perceive them?
Twoness exists independently of consciousness. QED.
>>
>>60200313
>All sciences are empirical
See >>60200317
Math is a different type of science, in that it is primarily deductive instead of empiracle, but it's still a science
>>
File: 1492618231265.png (248KB, 1000x1200px) Image search: [Google]
1492618231265.png
248KB, 1000x1200px
>>60200341
Come at me faggot.
>>
holy shit there is not a single on-topic non-shitpost post in this entire thread
>>
>>60200404
shitposting is an science
>>
How would you construct data types or something like them in Prolog?
>>
> Each exchange operation on line 5 of HEAP-INCREASE-KEY typically requires three assignments. Show how to use the idea of the inner loop of INSERTIONSORT to reduce the three assignments down to just one assignment

anyone know what this is talking about?

heap_increase_key(A,i,key)
if key < A[i]: error
A[i] = key
while i > 1 and A[parent(i)] < A[i]:
swap A[i] with A[parent(i)
i = parent(i)
>>
Anime is shit
>>
>haskell cant do this
int hasklet = 5 + -2;
>>
>>60200640
in Haskell this is just
hasklet = 5 - 2
>>
>>60200231

I'm working on some javascript for my bff, RMS
>>
>>60200715
>bff
Boyfriend forever?
>>
>>60200734
big fat friend
>>
File: dlang_chan.jpg (139KB, 470x545px) Image search: [Google]
dlang_chan.jpg
139KB, 470x545px
Threadly reminder that dlang-chan is not dead, and she's super duper cute and fast! Say something nice about her, /dpt/!
>>
>>60200890
Whats the point of this?
To shitpost d?
Or reverse people into looking it up and using it?
either way its gonna get filtered.
>>
>>60200231
still trying to compile gcc 7 on windows. autotools is the worst build system ever.
>>
>>60200734

I wish
>>
>>60200915
Don't filter her, friend. I actually use D unlike the other shitposters.
>>
>>60200954
I do too, i just hate autists who spam their pastas like its some gift to us all.
>>
>>60200954
Are you a ghost?
>>
>>60200978
I do it because maybe some anon might actually try D. Is it likely? No, but if one person does do it, I'll be happy.
>>
>>60201003
Thats literally the worst way.
"Say something nice ___" shitposts makes me want to do the opposite.

Stop giving D more shitpost fuel and just let people find it on their own.
>>
                if i < len(d[c]):
if d[c][i + 1] == d[c][i] + 1:


why am I getting a "list index out of range" on the second condition ? there has to be a
d[c][i + 1]

since
i < len(d[c]
>>
>>60201048
There's another reason for me posting it, but I can't reveal why.
>>
rate my prime number checker


def main():
num1 = int(input('Enter a number: '))
while num1 != 0:
print(is_prime(num1))
num1 = int(input('\nEnter a number: '))

def is_prime(num1):
for i in range(2,num1):
if (num1 % i) == 0:
prime = False
print('divisible evenly by',i)
break
else:
prime = True
return prime
main()
>>
Are there any functions other than socket() and socketpair() that can create sockets?
>>
>>60201108
syscall
>>
>>60201107
>def
0/10 see me after class
>>
>>60201151
What you mean :-/
>>
>>60201157
he's just shitposting as most people here do.
ignore him.
>>
>>60201157
Learn a real language or you'll fail
>>
I'm a 2nd year IT student, I got an offer for an internship at Sabre. I'm pretty nervous about what to expect and where I might have gaps in knowledge. I've only done academic projects and feel comfortable writing code ant that level but not sure what to expect and what is expected of me. I thought exam for internship would provide some clues but that was mostly questions about "will this code compile and why not".
Anyone got any tips or things I should know?

Also, I didn't have a course about design patterns yet, is there a book you recommend for self-study? Internship is for Java but that seems like something that can be learned in any language.
>>
Why the fuck is my bash script not working? Bad part:

if [ "$stuScore" = "$profScore" ]
then
echo "$stuScore / $profScore Great! Continuing..."
else
echo "$stuScore / $profScore Incorrect. Exiting..."
exit
fi


When I run it:

1000 / 1000 Incorrect. Exiting...

What the fuck?
>>
>>60201204
idk bash but do you know what " does?
>>
Defend this, Java users.

String[] strings = new String[10];
Object[] objects = strings;
objects[0] = new Integer(7);
>>
>>60201227
No
>>
File: 1ZGjEDn.png (792KB, 1280x720px) Image search: [Google]
1ZGjEDn.png
792KB, 1280x720px
>>60201229
no one uses java so no one will defend this
>>
>>60201185
Lots of jobs in Python these days.
>>
>>60201270
Even more jobs in HTML
>>
>>60201263
https://www.tiobe.com/tiobe-index/

>1 1 Java 15.568%

https://pypl.github.io/PYPL.html

>1 Java 22.6 %

>>60201286
So learn Python and HTML, and you're set.
>>
>>60201308
I don't think you get what I meant
>>
>>60201326
You're right. You need to throw in CSS and JS too these days, preferably with a few frameworks.
>>
How can I get something to help me refactor code in Python? I want something like IntelliJ for Java.
>>
>>60201229
>>60201263
>>60201270
>>60201286
>>60201308
>>60201326
>>60201347
nice meta posts faggots
>>
File: explosive_brap.png (326KB, 678x506px) Image search: [Google]
explosive_brap.png
326KB, 678x506px
>>60201107
>checks i = num
>checks all 1 < i < num
Someone put this on the CS grad meme.
>>
>>60201419
You wouldn't need to check i <= num though
>>
>>60201419
Retard detected.
>>
File: ran_disgust.png (53KB, 204x288px) Image search: [Google]
ran_disgust.png
53KB, 204x288px
>>60201458
>calls others retarded
>doesn't know factors always come in pairs
>his code checks both of them
>his code also checks if num1 % num1 == 0
>yfw 7 isn't a prime according to his fucking code
Please tell me you're just fucking pretending.
>>
>>60201503
>yfw 7 isn't a prime according to his fucking code
7 is a prime according to his code.
>>
>>60201107
protip: you only need to check divisibility of numbers up to the square root of num1.

If a number n isn't prime, it has factors a and b such that n = a * b. At least one of a and b has to be less than sqrt(n), because otherwise their product would be larger than n.
>>
>>60201503
Autism.
>>
>>60201607
B-B-BUT THE SOURCE CODE IS THE DOCUMENTATION ANON
THAT'S WHY WE DON'T NEED TO WRITE USER MANUALS
>>
>>60201607
of course it's spaghetti, it's C
>>
>>60201607
pls no bulli C
>>
>>60201607
Unix programming is a quick and dirty form of CSP with pipes as channels and the kernel as the garbage collector. Threads with shared memory were a mistake.
>>
https://www.youtube.com/watch?v=02a723LsoFA

This is pretty much every post in /dpt/ in a nutshell
>>
>>60201255
might want to learn. it usually means strings. so you're comparing the word xxxx to the word yyyy
>>
Idris > Haskell > Scala > OCaml > F# > Rust > C++ > C > C# > Java > CL = Scheme = Clojure > Forth > Perl = PHP = Python = Ruby = JS > Go
>>
>>60201710
>>>/trash/
>>
>>60201710
Scala and F# should be somewhere near Perl
>>
>>60201710
>Rust better than sepples
nice shit taste
>>
>>60201710
Why is Lisp so low?
>>
Would a new language for the web have to be able to compile to Javascript, or do you think it would be possible to introduce a brand new language this far into the evolution of the web?
>>
>>60201100
that's not true. if i < len(d[c]) then the last entry of d[c] is d[c][i], and i+1 is out of range. this is because python arrays are zero indexed (like most languages), so for example an array of length 3 has indices 0, 1, 2. when i = 2, i + 1 = 3 and is out of range
>>
>>60201813
Make it compile to WASM
>>
>>60201813
Maybe it would be better to go the other way around and have the language be able to implement a fully featured Javascript implementation inside itself.
>>
>>60201229
an array of Object references can hold references to any object type, because Object is the base class of all object types

object-oriented type hierarchies are bullshit but this is an incredibly straightforward example of them, it will work in many languages
>>
>>60201813
The web should be able to implement other languages, really...
>>
>>60201710
>rust is better than c++
>scala is better than anything
>>
>>60201204
Post an example of where this happens. Your example lacks the values of both variables. It works fine if you assign them both to 1000.

>>60201227
Shell has but 1 type: string. Expansion of variables happens within double quotes, the double quotes are everywhere in bash because without them the value undergoes word splitting(e.g. 'foo bar' -> 'foo' 'bar'). You even have nested double quotes:

"$(cmd "${var}")"


Anyway they aren't the problem.
>>
>>60201812
Caution! The poster you are replying to has been infected by the "strong static typing" virus. It rots the brain, leaving the victim in a state of catatonia. The only form of communication they now possess is through grunts and phrases like "muh types." They will forever be unemployable, and will likely end up in a nursing home.
>>
>>60201922
I have to admit, it's easier to make mistakes on non-static typing languages.

Does it matter? dynamic FTW!
>>
>>60201813
>it would be possible to introduce a brand new language
Imagine one of the browser vendors suddenly coming up with it, that'd be a shitshow
>>
>>60201959
Dynamic only if it's a Lisp.
>>
>>60201916
Here's an example of what word splitting is and why quotes are needed.

~ $ ls -ld /tmp
drwxrwxrwt 9 root root 180 May 3 21:46 /tmp
~ $ args="-ld /tmp"
~ $ ls ${args}
drwxrwxrwt 9 root root 180 May 3 21:46 /tmp
~ $ ls "${args}"
ls: invalid option -- ' '
Try 'ls --help' for more information.


In the first case, they are expanded to ("-ld" "tmp"), in the second case it's equivalent to:

ls "-ld /tmp"
>>
>>60201813
>>60201829
>>60201885
>>60201994
You should really look into WebAssembly.
>>
>>60201994
Rust Scriptâ„¢ soon :^)
>>
>>60202026
Legit thanks for the education, /g/. I forgot this.
>>
>>60202020
>arrays can hold any lisp object
Can't imagine how slow lisp must be.
This is why dynamic programming sucks.
>>
>>60202063
>dynamic programming
That is something completely different.
>>
>>60202063
That's now how it works you idiot.
>>
>>60202063
Around 2-11 times slower than C++.
>>
Is wasm really gonna be a huge deal, a game changer?
>>
I'm a complete newfag to programming- business student learning python for fun over the summer. I'm working through that waterloo university intro to python and i need help on a really simple question, pic related. I can't figure out how to start- what's the input? i don't understand what input i'm basing the program off of.
>>
>>60202475
Maybe.
>>
>>60202505
Look up how to receive input in python.
>>
>>60202505
You are completely hopeless.
x = input("input some shit yo:")
write that and your input will be assigned to x. then you can use ord and chr and shit with x as if it were what is typed in
>>
>>60202505
learn a real language instead

NONE OF THE FOLLOWING
>python
>java
>ruby
>go
>javascript

recommended (all a different type of language):
>C
>Rust
>Haskell
>Prolog
>Scratch
>>
>>60202519
>>60202569
thanks fags, i'm a complete noob so apologies for the dumb question.
>>60202603
based on what i've read, python is a good choice for me as i'm not pursuing a career in programming but rather doing it for fun
>>
>>60202679
for absolute beginners
https://scratch.mit.edu/
>>
>>60202679
Then if you're doing it for fun, learn Common Lisp.
>>
>>60202714
>Common Lisp
Don't fall for this retarded meme
>>
>>60202603
>Said he was a business student
>Ask him to learn C
What do you expect him to do with it? Program financial data on an embedded system?
>>
>>60202738
You are a retarded meme.
>>
File: ainti depressants.jpg (42KB, 728x522px) Image search: [Google]
ainti depressants.jpg
42KB, 728x522px
>>60202705
what is this? i feel like an autist for having that on my screen in class
>>
>wake up
>it's 2017
>people can now compile C to work in a browser
you see kids, that's why everybody loves C
learn C and you'll never be hungry again
>>
>>60202771
You are the moron asking a self professed business student to learn C dipshit.
>>
>>60202788
I see your reading comprehension is nil.
>>
>>60202772
you are an autist
>>
>>60202800
Must be sad telling people on 4chan of all places of "real" languages.
>>
>>60202807
more or less.
in highschool i was pretty popular and kind of a class clown
in uni i have an apartment by myself and never hang out with anyone outside of class
>>
>>60202705
HAHAHAHAHAHHAHA
>>
>>60202816
You're getting so angry over text on the internet. How do you live day to day?
>>
i completed the problem, but i had to use 2 if statements because for whatever reason

if xxxxxxxx
else xxxxxx

wouldn't work
>>
>>60202505
a = input()
if len(a) == 1:
val = ord(a)
if a != 'Z':
print(chr(val+1))
else:
print(chr(ord('A')))


>I'm a complete newfag to programming

if you were not kidding, then that's just sad. even fizzbuzz looks hard compared to that.
>>
>>60202882
Use elif.
>>
>>60202864
I don't know. Do you get triggered everytime one mentions C being shit here? Does the word def trigger you so badly? How do you live day by day knowing people use python, java, ruby, go and javascript?
>>
>>60202907
I'm surprised you still haven't realized I never mentioned C in my posts. Thanks for the amusement.
>>
>>60202923
>>60202603
recommended (all a different type of language):
>C
>Rust
>Haskell
>Prolog
>Scratch
>>
>>60202934
he's not me
>>
>>60202934
I didn't reply to this, friendo. You just got buttmad for nothing!
>>
>>60202902
i went full retard. could've just put print('A') in the last bit
>>
if youd on't tell me the answer you're a pajeet

>Give an O.nlgk/-time algorithm to merge k sorted lists into one sorted list, where n is the total number of elements in all the input lists. (Hint: Use a minheap for k-way merging.

not homework, going through intro to algorithms myself
>>
>>60202967
>Not homework
Sure thing bud
>>
>>60202960
WEEEEEEEEEEEEEW LAAAAAAAAD
>>
Are there many programming jobs in Iceland?
>>
File: 1478996578360.jpg (10KB, 350x334px) Image search: [Google]
1478996578360.jpg
10KB, 350x334px
>>60202997
tfw it's really not but i can't expect dpt to believe me bc i'd think the same thing
>>
>>60203023
Probably
>>
>>60203026
dumb frogposter
>>
What's the best way to follow a programming book and not be constantly distracted by /g/
>>
File: stargazer.gif (924KB, 500x281px) Image search: [Google]
stargazer.gif
924KB, 500x281px
>>60203116
>>
>>60200231
learning cobol for this new job. every day is cooler than the last...but its in cobol so it is making my life hell.

pls help dpt.
>>
>>60203127
read a section, hit refresh, read another section
>>
>>60203127
Realize that if you don't, you will end up a CWC.
>>
>>60203144
post some code
>>
>>60203127
Put this in your hosts file:
boards.4chan.org 127.0.0.1
>>
>>60203144
Oh, it's you again.

Look kid, COBOL might seem like a golden ticket right now, but really it's a noose around your neck.
>>
>>60203144
F
>>
>>60203144
The best part about a COBOL job is never having to worry about job security. The bad part is coding in COBOL for your entire life.
>>
File: 1374707254344.jpg (20KB, 400x400px) Image search: [Google]
1374707254344.jpg
20KB, 400x400px
>when you implement much needed memoization and get close to tenfold speedup
Optimization, no matter how trivial, always feels so good.
>>
>>60203191
Memoization is trivial and can be done by the compiler for free in languages like Haskell
>>
>>60203144
job security son. there's nothing wrong with maintaining legacy code
>>
>>60203161
at this point I'm just complaining out of frustration. I'm not trying to annoy anyone I just need this release.

>>60203155
not at my office, but its all messing with the gui. using 2 gui technologies that both run off cobol because fuck the employees. in any other language it would be simple as heck, but in cobol creating an element and linking it to the database requires 4 programs to cooperate and about 9-8 files that all need to be coded.
>>
>>60203191
that's likely changing the time complexity of your program, not just a tenfold speedup
>>
>>60203208
And yet it's still slow as shit
>>
>>60203144
F
>>
>>60203215
>>60203189
the guy training me has been there for some years, and he told me today "i don't even know what I'm doing half the time"
>>
File: cobol.png (83KB, 575x636px) Image search: [Google]
cobol.png
83KB, 575x636px
heh
>>
>>60203208
I'm talking about deterministic function calls.
>>
>>60203026
>>60203134
dumb frogposter
you deserve death
>>
this code in k&r to count the occurences of digits in a text input is pajeet as fuck. it uses a switch with every digit included in the case for if it's a digit, not testing if c <= '9' && c >= '0'
>>
>>60203250
what is this?
>>
>>60200645
>>60200640's is mutable
>>
File: 1479352599652.jpg (7KB, 231x218px) Image search: [Google]
1479352599652.jpg
7KB, 231x218px
>>60203260
isn't that excessive?
>>
>>60203248
That cause the other half of the time he is considering suicide
>>
File: 1433713216515.jpg (14KB, 240x232px) Image search: [Google]
1433713216515.jpg
14KB, 240x232px
>>60203260
>>
>>60203285
Is it to teach you switch statements?
>>
File: 1387740906316.png (367KB, 800x800px) Image search: [Google]
1387740906316.png
367KB, 800x800px
>>60203260
>>
>>60203333
yeah but it's still shit. they should've done a better example instead of getting people to code like that after seeing it in a book, or at least point it out
>>
File: stallman.png (2MB, 1253x849px) Image search: [Google]
stallman.png
2MB, 1253x849px
>>60203327
>>60203373
>>60203304
it isnt far enough
ill make u pay

stupid robot losers
>>
>>60203423
You're right. Be glad you're not an idiot and noticed how it was bad.
>>
File: 1474748140503.png (67KB, 616x596px) Image search: [Google]
1474748140503.png
67KB, 616x596px
>>60203443
>>
>>60203461
grinned
>>
>>60203234
Well yes, hashtable lookup is around O(1), but how doesn't that constitute speedup?
>>
>>60203461 (upvote)
>>
File: 1492996529028.png (234KB, 600x599px) Image search: [Google]
1492996529028.png
234KB, 600x599px
>>60203491
because it's not a static tenfold increase, it depends on the input size
>>
r8 my code /g/

#include <stdint.h>

/**
* @param n n
* @return d on success, -1 on failure
*/
int64_t f(uint8_t n)
{
if (n <= 1) return n;
/* if n is greater than 92, fail */
if (n > 92) return -1;
n -= 2;

uint64_t a = 1, b = 1, c = 0, d = 1, e = 1, f = 0;

while (n) {
uint64_t g, h;
if (n & 1) {
g = a * d + b * e;
h = b * d + c * e;
f = b * e + c * f;
d = g;
e = h;
}
g = a * b + b * c;
a = a * a + b * b;
c = b * b + c * c;
b = g;
n >>= 1;
}

/* return d */
return d;
}
>>
What does this do?

if (!ptr && !!!*ptr) return NULL;
>>
>>60203767
if ptr isn't the null pointer, and the value pointed at by ptr is 0, return null
>>
>>60201229
That's the whole point of inheritance, that a reference to a base type may legally point to an instance of any of its subtypes, without casting or coercion. The Java type system defines all non-primitive types as being inherited from Object, so that Object may be used as a generic reference, similar to void pointers in C.
>>
>>60203673
too legible
>>
>>60203767
>!!!
Either the person doesn't understand what's actually going on, or is just fucking around.
One ! was sufficient.
>>
>>60203995
!!!!!
>>
How far should you go down the mathematics hole before there's diminishing returns for programming? Calculus?
>>
>>60204049
All the way
>>
>>60204049
...linear algebra?
>>
>>60204049
Mathematics like programming is a means to an end. Not the other way round. If you are involved in programming stuff like physics simulation clearly you need good mathematics and programming. Ask yourself what you want to do and then learn what you need. Don't learn blindly and then see what you can do.
>>
>>60203673
>>60203767
is this for an obfus contest?
>>
>>60204049
my college program goes up to probabilities/statistics
>>
>>60204083
>Don't learn blindly and then see what you can do.
wtf that's terrible advice, mediocre
> implying you will know what to do with your knowledge before having said knowledge
>>
>>60204092
No, I'm thinking of using it in interviews.
>>
>>60204049
Deep learning algorithms involve a lot of calculus among other things. Not that you're going to be doing anything important in that field on your own, anyways.
>>
>>60204118
Well then you should tack on a few
!!!!*&*&ptr
cases.
Also, make use of parantheses
>>
File: fish.png (33KB, 625x626px) Image search: [Google]
fish.png
33KB, 625x626px
Here's a (fish)
>>
>>60204049
you're going to need to know basic calculus if you're doing machine learning
>>
>>60204110
You learn what knowledge you need instead of learning and then trying to figure out what you can accomplish with said knowledge
>>
>>60204049
There is no limit.

Go far enough, and you will realize how broken every language really is.
>>
>>60204317
explain.
>>
doing this linear algebra homework uhg

then i gotta do some in prolog but it's late anon and im tired :(
>>
There are no men on /dpt/, only women pretending to be men
>>
>>60204049
Not addressing this question, but is somewhat related.
I've been doing a university course for "Modern Algebra" (Groups, rings, fields etc.), and it's been pretty interesting. How applicable is that to programming?
>>
>>60204400
nice dub dubs
>>
So I applied to a statistical programming job in my hometown, it pays 54k a year. Since I'm about to graduate is that pretty good or should I keep looking? I can live with my parents for a bit to save money for my own place.
>>
>>60204400
Explains why they can't program
>>
>>60204458
Degree?
>>
How do you feel about this:
https://www.youtube.com/watch?v=b-Cr0EWwaTk
>>
File: deck shuffling code.webm (3MB, 1866x872px) Image search: [Google]
deck shuffling code.webm
3MB, 1866x872px
R8 my horrible deck shuffling code

I'm going to guess there's a far easier way to randomize one table's data into another

someone already made me google deck shuffle algorithm, not sure how to do that in lua
>>
>>60204579
Computer science and math double major
>>
File: deck shuffle.png (6KB, 405x330px) Image search: [Google]
deck shuffle.png
6KB, 405x330px
>>60204669
three outputs from it
>>
>>60204458
that's pretty shitty pay. look for a job elsewhere and if nothing better comes up take that one but keep applying for other stuff
>>
>>60204462
She caught you sis. No need to keep pretending.
>>
>>60204317
That's the wrong perspective.
That computers aren't good at math is the issue.
>>
>>60204669
how long have you been working on this
>>
>>60204795
probably like 4-5 hours total on/off from today/yesterday

figuring out how to make it check itself so it didn't use the same slot or number twice was what took the longest

but that's because I made the mistake of trying to fill it faster too soon, basically had 2 version of the code running in succession to cut the fill time down
>>
>>60204669
>lua on Windows
I'm so sorry anon, you're retarded...
Also, look up the Fischer-Yates Shuffle.
>>
File: WBGdP6W.png (26KB, 531x342px) Image search: [Google]
WBGdP6W.png
26KB, 531x342px
how bad are my coding practices, on a scale of 1 to pajeet?
>>
>>60204669
Would it be better to simulate real shuffling eg.
>moving half the deck to the bottom and then interleaving the cards
or is unnatural psuedorandom shuffling fine?
>>
>>60204873
Jesus christ what the fuck is that washed up screenshot?
>>
>>60204844
I need lua for Love 2D

that is what I looked up

>>60204889
I just realized I could clone the data and move the stuff in the temporary deck all around with random numbers, but it would still require a lot of cycles or a lot of variable placeholder numbers for the random numbers
>>
I want to make a compiler for this:

https://github.com/silverwingedseraph/sbrain

It looks like it might be cool to compile, maybe with LLVM.
>>
File: 1474579995768.jpg (17KB, 286x380px) Image search: [Google]
1474579995768.jpg
17KB, 286x380px
When you are handling files, is it normal that you use environments' shell?

Like if your program is going to copy a file to another directory, are you going to use your language's environment/process library or are you just going to call
 mv here there/
?
>>
File: pp.png (72KB, 1366x768px) Image search: [Google]
pp.png
72KB, 1366x768px
Just did the initial steps for my ARM 64 bit operating system, initialized 4 cores, set up the memory management unit, interrupts, then I draw a dick on the screen using the framebuffer, feels gud
>>
File: le_monke_dance.webm (2MB, 854x480px) Image search: [Google]
le_monke_dance.webm
2MB, 854x480px
>>60204975
Good job!
>>
>>60204924
What I'm saying is that using Lua and LoveD on Windows is a nightmare (because Windows is a nightmare for development).

Also that code you wrote is terrible. Have you not yet been introduced to tables or for loops? Using all of Lua's features you could write it in about 10 lines.
>>
>>60204966

Unless you are using a shell scripting language, please do not do this. It makes your programs less portable, and quite possibly, more vulnerable.
>>
>>60205014
I am using tables and loops or sorts, but I if I try to loop a randomly generated number it just spits out the same thing unless I put it into a different function and make it wait 1.1 seconds on my desktop or 2.1 seconds for my phone to spit out a different number with the same variable.
>>
>>60204924
while (idx < 52)
{
int sel = rand() % 52;
if (old[sel])
{
new[idx++] = old[sel];
old[sel] = NULL;
}
}
>>
>>60204966
If the language has something ready to use and is simple to call like C's remove for removing files, why bother calling bash or whatever? Kills portability for no good reason.
>>
>>60205006
thank you babe
>>
>My lecturer is a Haskell programmer
>>
>>60205041
>quite possibly, more vulnerable.
You got my attention. Please elaborate.
>>
>My lecturer is an HTML programmer
>>
>>60204975
I don't know what anything you said means
>>
>>60205155
lol, basically did some low level hardware programming and wrote a small kernel for myself
>>
>>60205155
>I draw a dick.
Surely you understand this.
>>
>>60203864
Legit question, wouldn't the second expression in the if (!*ptr) only be considered true if the value isn't -1?
Considering that a 0 is interpreted as a false in an if and the only value that return a 0 in the bit by bit negation of a number is -1.
>>
>>60205043
Wait no, if I do that I run into the same problem of it repeating values, when I can't have it repeat the values, which means even if I did a whole self shuffle thing it needs the same checks and balances as before

>>60205046
if only I knew what any of that meant
>>
>>60205043
https://pastebin.com/h7ZrsZAu
>>
>>60205204
I just SOLVED your stupid deck shuffling problem.
you don't need ANY variables, just a random number and the index for the array you're copying values to.
>>
>>60205209
lol fuck, I forgot math.random can take a range.
https://pastebin.com/sf0ydipr
>>
File: test1.png (22KB, 257x545px) Image search: [Google]
test1.png
22KB, 257x545px
>>60205209
is that supposed to output the same thing everytime?

>>60205234
but I have 20 different possible values, that need to go into random places within 20 other possible values, and none of them can repeat

I don't know anything about programming btw, so thanks for the help
>>
>>60205303
>is that supposed to output the same thing everytime?
Yes? You need to call math.randomseed() if you want new a random sequence every start.
>>
>>60205337
well duh I guess, just gotta figure out what the hell that code means and how I can use it to shuffle a table's values
>>
>>60205364
https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
    for i = 1, #t do
table.insert(t, 1, table.remove(t, math.random(i, #t)))
end

The for loop performs the shuffle for each index of the table. The table.remove() pulls a value out of the list at the index given by math.random(1, #t). That call to random generates a random integer between i and the length of the table, meaning the rest of the array you haven't shuffled yet. The table.insert takes that value you pulled out of the remaining array and appends that value onto the beginning of the array keep the array the same length and shuffling it one index at a time.
>>
>>60205364
If you already have a defined table of values and want to perform a permutation you could do the following, iterate over every value in the table a do a math.random to get a valid index inside your table, then swap the value that is in that index with the value you are currently iterating.
>>
>>60205079

Unsanitized user input + any function that escapes to the shell = arbitrary command execution. It's a fairly common vulnerability, particularly in Perl programs, which like to abuse it.
>>
File: fork power outlet.jpg (17KB, 300x300px) Image search: [Google]
fork power outlet.jpg
17KB, 300x300px
What are some good books on programming patterns / anti-patterns?

Ideally aimed at beginners to intermediate programmers.
>>
>>60205364
Oh yeah, use math.randomseed(os.time()) before everything at the start of the program. It's not really the best, if you run it continuously you'll see you run into the same values a lot. Really you should use math.randomseed(socket.gettime()*1e6), but you would need to install luasocket. depending upon how you installed lua, whether you have a C compiler available, etc, that might be a pain...

Windows is a garbageOS
>>
>>60205736
gang of four
>>
>>60205896
How readable is it?
>>
File: Jon Tron.gif (2MB, 400x281px) Image search: [Google]
Jon Tron.gif
2MB, 400x281px
>>60205435
Yes...aha...I see


no but really I think I got it, thanks
>>
>>60205912
Well, if you know C++ and can learn Smalltalk, you should be able to read it fine.
>>
>>60205912
it's dull as shit
>>
How do I turn a project into a library. The main function just serves as a replacement for a gui but Im working on covering that and would like to add the rest of the project as a dynamic library.
Are there build options to do this.
>>
>>60206186
Have you tried googling?

Protip, include the language into your google search/forum posts.
>>
>>60206186

gcc -shared
>>
>>60206250
I did, but nothing turned up. Though I found It was buried in the configuration of my ide.
>>60206387
I really need to look into preprocessor commands
>>
Hey guys, I am literally a neet right now. I have so much time and vidya is starting to become boring. What should I work on for programming? Start a new project or join an already started project? pls help I need experience so I can get a job, been applying everywhere but I guess I am shit and no one wants to hire me
>>
>>60205046
ay that's quite pretty
>>
Web development is programming.
>>
>>60206186
add_library()
>>
I just added alpha blended colours to my collab draw app

Here's a room to test things out
http://www.drawy.io/r/z17jowu0bqmky2it
>>
>>60206557
If you have time, would you mind fixing something for me?
All free android music players suck because of one simple thing: when you tap on a song, it plays that song.
What is should do is call a action dispatcher, then depending on a user setting, perform the default action.
I don't write a lot of java, so I never found the time to write and test it out.
Preferably some music player on fdroid.
>>
>>60206936
>using Vanilla Music
>it can't handle disc numbers
>my double albums are a mess
This is the price of freedom I suppose. What's worse is that I could probably patch that, but I'm too lazy. Java sucks too.
>>
Guys I need a recursive solution to finding the average level of a Node in a binary search tree.

(Sum of all the levels of all the nodes) / (number of Nodes)

I have two functions that can give me the height of a Node, the other can give me the number of nodes in the table.

Yes this is one of babbies first programming classes, but i'm garbage at recursion so far and need some pointers
>>
>>60200368
What other science is not empirical?

Math is an extension of logic. Rational thinking is not the basis for math like it is for science.
>>
What are a few of the most famous things made with each programming languages, and what are some more basic, realistic things that I, as a newbie to programming, could potentially do with the language(s)?
>>
File: 1429667276968.png (162KB, 453x435px) Image search: [Google]
1429667276968.png
162KB, 453x435px
>>60200231
Anything which uses mathematical proofs is superior to empirical garbage.
>>
>>60207043
>Rational thinking
This is a non-valid word.
>is not the basis for math
The basis for empirical sciences is the scientific method. The basis for math is deduction.
>Math is an extension of logic.
It's the other way around actually.
>>
What's going on if I suddenly can't read certain words as if they're words? Just suddenly, for about 3-4 seconds. For instance if this happened to the word "suddenly" i'd be faced with the inability to infer the meaning of the word based on the letters, I'd only know that the word I wanted to be there has the meaning of suddenly. I then rationally realize that it's spelled as I usually spell suddenly but I'm very unsure of it and then google it just to confirm it's spelled correctly. Then a few moments after suddenly I can interpret the word to its meaning again.

Does this happen to anyone else from time to time? Should I see a doctor? It's not a major nuisance it just happens sometimes. It sounds similar to the symptoms of a stroke but it's certainly doesn't come with the massive consequences of a stroke.
>>
>>60207075
That wouldn't depend on the language really.
>>
Is C honestly better than Python? In my experience python exhibited more potential due to the quadratic algorithms being more capable of pushing boolean codes efficiently. Python also has a more soild internal structure and a more viable anagram frame than most other programing software. The boolean codes synch up 100x faster than C++ and guarantees a not so cluttered coding experience given the optimal setting.
>>
>>60207137
Something similar happened to me too, but I could still infer the meaning. The word "fight" just looked funny to me, I couldn't concentrate on it as a whole.
>>
>>60207152
>codes
Wrong thread.
>>>/g/wdg/
>>
File: yukari_arxiv.png (211KB, 372x1118px) Image search: [Google]
yukari_arxiv.png
211KB, 372x1118px
>>60207077
Well, it's certainly the case that most of the powerful physical theories (such as Fermi liquid theory or QCD) that describe general phenomena have no rigorous mathematical grounding while those that do (such as the free boson/fermion fields or theories of geometric quantization) have very limited scope. If you just want to calculate shit and make things work unnecessary mathematical formalism would only get in the way.
What's truly difficult is trying to strike the right balance of rigor with predictive power, and this is why theoretical physics is probably one of the most challenging subject one could study ever in the history of anything.
>>
>>60206977
//They're all passed as pointers because we wish to keep a global state for the whle traversal
void measureDepth(node* Node, int* depth, int* numberOfNodes int* depthAccumulation){
if(Node!=NULL){
*depth++; //every time we enter the loop we're at a new, higher, depth
*numberOfNodes++; //we're entering a new node for the first time
*depthAccumulation=*depthAccumulation+depth;
measureDepth(Node->Left,depth,numberOfNodes); //walk down the left subtree
measureDepth(Node->Right,depth,numberOfNodes); //walk down the right subtree
*depth--; //we're now moving up the tree again so we need to have our depth varaiable reflect that
}
}

int main(){
Node* Tree; //Lets pretend we have a binary tree called tree that's already built
int depth=0;
int numberOfNodes=0;
int accumulatedDepth=0;
measureDepth(Tree,&depth,&numberOfNodes,&accumulatedDepth); //& is "address of", it's like taking the reference of a variable in other languages
//We've now accumulated the depth for each node, we also have the number of nodes
double AverageDepth=(double)accumulatedDepth/(double)numberOfNodes;
//Convert it to integer if you want
}

Here's a simple untested example of a C implementation.

There's more ways to calculate the depth. And if you already know the number of nodes in the tree you don't need to track that either. If you have a special structure for your head node you would have to wrap the measureDepth call.

I'm sorry this isn't something I put a lot of effort into but I hope you get the idea.
>>
>>60207236
Oh man that's some horrible formatting. Also those inner measureDepth calls weren't correct:
https://pastebin.com/5ue7Eh3y
>>
File: 1458668770514.jpg (12KB, 236x265px) Image search: [Google]
1458668770514.jpg
12KB, 236x265px
>>60207171
>If you just want to calculate shit and make things work unnecessary mathematical formalism would only get in the way.
Which is what I mean by "garbage" (if they call it "science"). It should be called something else really if that's all what they're doing.
>What's truly difficult is trying to strike the right balance of rigor with predictive power, and this is why theoretical physics is probably one of the most challenging subject one could study ever in the history of anything.
I agree.
>>
>>60207140
Well, I wanted to get a general idea of the languages behind some of the most famous programs are.
I don't know what I'd do, but I'm new to programming and haven't even written any code.
>>
File: chen_class.png (92KB, 532x391px) Image search: [Google]
chen_class.png
92KB, 532x391px
>>60207270
>Which is what I mean by "garbage"
Ok whatever you say anon.
>>
>>60207279
>Well, I wanted to get a general idea of the languages behind some of the most famous programs are.
Why would you want to do that? Something being famous doesn't necessarily mean it's good way to learn.
>I don't know what I'd do
Automate the stuff you're interested in besides programming. Then as you learn more, hopefully you'll discover something interesting.
>code
"code" is something they discuss on "web "dev"" threads.
>>
File: Jimmies-Rustled.jpg (2MB, 2916x1257px) Image search: [Google]
Jimmies-Rustled.jpg
2MB, 2916x1257px
>>60202569
>you are completely hopeless.

Seeing people say this to new programmers really rustles my jimmies. Programming takes time and its basically an endless progression of learning. I guarantee there's some guy programming low level code for guided missile systems that would look are whatever you're making like you're a fucking newborn baby.
>>
File: 1458176971615.jpg (48KB, 600x390px) Image search: [Google]
1458176971615.jpg
48KB, 600x390px
>>60207318
Read the next few words.
>>
hi im a clueless idiot doing a university assignment in c# but i havent attended anything and the deadline is in 12 hours. Assignment is "Directions for play:
Players take turns rolling five dice and score for three-of-a-kind or better. If a player only has two-ofa-kind,
they may re-throw the remaining dice in an attempt to improve the remaining dice values. If
no matching numbers are rolled after two rolls, the player scores 0."

here is what i have so far (pic related):
https://pastebin.com/u16JE4DV

i still have to add a second player and a way to re-roll

please save the im a retard and i should drop out i already know i should
>>
>>60206462

This isn't a preprocessor command; it's a compiler flag.
>>
>>60207335
>in c#
Stopped reading right there.
>>
File: Yakumo.Ran.full.1823527.jpg (642KB, 775x1100px) Image search: [Google]
Yakumo.Ran.full.1823527.jpg
642KB, 775x1100px
>>60207332
Heh.


Nah.
>>
File: 1491238980736.png (56KB, 281x218px) Image search: [Google]
1491238980736.png
56KB, 281x218px
>>60207373
I can say with confidence that you are wrong.
>>
For the rock paper scissors game you have to check for every possibility of your choice and the computers choice right?
>>
>>60207449
Aw don't be all salty like that anon just because I don't wish to and indeed refuse to read about your rather amateurish opinions.
>>
>>60200231
I'm planning on learning lisp just because it will make me look cool.
>>
>>60207484
just like real life, you randomly throw an option and see what happens.
>>
>>60207681
So I will have a lot of if elif statements
>>
File: 1433345343941.jpg (22KB, 336x425px) Image search: [Google]
1433345343941.jpg
22KB, 336x425px
By hardcoding a function repeatedly into an algorithm, I achieved a speedup of ~15%. Python function calls are just that slow. But now my code is ugly as sin with the same code plastered everywhere.
>>
File: 1480574628504.jpg (274KB, 750x750px) Image search: [Google]
1480574628504.jpg
274KB, 750x750px
>>60207557
People always say that when I'm winning the argument.
>>
ne1 here actually use idris or have legit reasons it's the future

or nah
>>
>>60207691
you can use a 3x3 bool matrix.
rows = player's choice = i
columns = computer's choice = j
if the element i,j of the matrix is true, then the player won.
no if/else if/else used.
>>
>>60207707
Same happens in C. But I don't think python does inlining. So it's likely a massive issue in python.

I think a lot of people shy away from code duplication too much. Ignoring performance it has a lot of benefits. But if you're gaining 15% from removing the calls you're probably removing it in cases where you're making your code worse in terms of readability.
I really like Carmacks take on it:
http://number-none.com/blow/john_carmack_on_inlined_code.html
>>
>>60207769
Python is a language, it doesn't do anything. There's multiple implementations of Python.
>>
>>60207784
You're right I should have said 'the tools that support the python community'. Which is fairly obvious.
I don't know why /dpt/ pretend to be stupid to bring up pedantic arguments.
>>
>>60207809
We've run out of things to talk about
>>
File: out_c.png (4MB, 1920x1080px) Image search: [Google]
out_c.png
4MB, 1920x1080px
>>60200231
working on a mandelbrot fractal generator, it needs to be multithreaded atm
>>
>>60207846
We could talk about how cute and fast dlang-chan is!
>>
>>60207871
If you implement it in a shader instead you can have it be a live fractal Explorer without issue.
>>
>>60207919
I haven't the slightest idea how to do that
>>
>>60207769
>http://number-none.com/blow/john_carmack_on_inlined_code.html
>If a function is called from multiple places, see if it is possible to arrange for the work to be done in a single place, perhaps with flags, and inline that.
And if it's not possible?
>>
>>60207919
It's implemented in C if you want to know
>>
>>60207922
You'd have to learn a little bit of opengl. But I'm assuming it's a fairly straightforward translation from what you have to shader code. What you would implement is a fragment shader. It's a program that runs for every pixel where the object in opengl is drawn (for instance you could have drawn two triangles that covers your rectangular screen). I imagine what you're doing right now is exactly the same thing as that program but you're doing it for every pixel in an array that's sized to your resolution.

It's really nothing new.
https://www.shadertoy.com/view/4df3Rn
And multithreading this is certainly worthwhile for learning purposes.
Just wanted to suggest you it to you because it's usually more fun to have interactive results.
>>
>>60207933
Then it's not possible? The advice to take away here isn't for you to apply this as some kind of principle. It's tips to improve your code. If you actually can't follow the advice it's not appropriate for that situation.
>>
>>60207997
>opengl
or vulkan
>>
>>60208015
soab

How does the code thing work?
>>
>>60208015
>Failing basic brackets
>>
>>60208022
Probably shouldn't start there.
>>
>>60201771
Oh god that image is way too accurate.
>>
>>60208015
>(code)
>>
>>60208015
This would be a good joke is it were lisp.
>>
>>60201107
Not (code) edition

def main():
num1 = int(input('Enter a number: '))
mem = [1,2,3]
while num1 != 0:
chk, mem = (is_prime(num1, mem))
print(chk)
num1 = int(input('\nEnter a number: '))

def is_prime(num1, mem):
if num1 in mem:
return True
else:
if num1%2 == 0:
return False, mem
elif num1%3 == 0:
return False, mem
der = [i for i in range(4, num1//2)
if i%2 != 0 and i%3 != 0]
for i in der:
if num1%i == 0:
return False, mem
mem.append(num1)
return True, mem
main()
>>
>>60208021
>It's tips to improve your code
Skipping aside the anecdotes, it's really just trivial advice. It's only worthwhile to those who are adamant on prioritizing readability above all else. Or those people who turn everything into blocks of functions calling other functions. I fail to see why people fall all over this guy.
>>
>>60207997
Thanks anon, I'll look into that
>>
>>60208030
>>60208049
>>60208085
That's what I get for naively following what some anon said in the archives. Why don't they post some instructions?
>>
>>60208127
Did they remove the sticky?
>>
is there a program better than pgAdmin 3 or 4 for managing postgres databases?
>>
>>60208218
Not programming.
>>>/g/sqt/
>>
>>60208137
As far as i can tell it only links to a wiki on installing gentoo.
>>
>>60208222
fuck off
>>
>>60208231
Are you retarded by any chance? Can't you read?
see >>60200231
How is your stupid post related to what we discuss in this thread?
>>
>>60208257
go be a try-hard wannabe mod somewhere else
>>
>>60208230
Read the last sentence of the sticky
>>
>>60208286
I'm going to call it a conspiracy and say that wasn't there last time I checked...
>>
>>60208319
Why not just admit you didn't read it?
>>
>tfw autism so high different naming conventions between APIs trigger you
>>
>>60208098
Not sure you read and understand the article honestly. It's not a prioritisation of readability above all else since it doesn't have tradeoffs. It's simply improving readability.
The people who create tons of functions for everything is most people. If you open up practically any open source project you find examples of what he's talking about all over.
>I fail to see why people fall all over this guy
So you've only heard of Carmack being valued and think this is the biggest thing he has done?
>>
UI/UX designer here. I'm tired of being a wageslave so I'm planing to learn iOS programming and get self-employed by building my own apps/games. I have all the background I need to bring good apps to the market that have a good usability and a modern design.

Anyone doing something like this? Is it worth? From what I read it takes years to master a programming language. I have some basic skills though, for example I did some coding in framer.js (coffee script).
>>
>>60208554
>UI/UX designer here
>apps/games
>coding
>coffee script
>>>/g/wdg/
>>>/v/
>>
New thread:
>>60208700
>>60208700
>>60208700
>>
>>60200231
Why do autistic lolis like Scheme so much?
Thread posts: 326
Thread images: 45


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.