[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: 330
Thread images: 41

File: 1470090763294.png (88KB, 713x667px) Image search: [Google]
1470090763294.png
88KB, 713x667px
Previous: >>57361528

What are you working on, /g/?
>>
>>57369870
First for C#
>>
>>57369908
Second for C#
>>
Third for C#
>>
>/dpt/ - Daily Pajeet Thread
>>
File: rT6sJLb.png (24KB, 346x379px) Image search: [Google]
rT6sJLb.png
24KB, 346x379px
I've got a bash script that works if i run it with ./script.sh but doesnt work if i run it as sh script.sh

i'm trying to make a shortcut to the script but the only way i know how is sh /destionation/script.sh. Can i make a similar shortcut using ./ instead of sh?
>>
File: durga.png (1MB, 1273x717px) Image search: [Google]
durga.png
1MB, 1273x717px
>>57369925
>>
>>57369908
>>57369915
>>57369919
What does this mean?

First for C++. Amidoinitrite?
>>
File: durgadurga poohammuh loohad.webm (199KB, 1898x972px) Image search: [Google]
durgadurga poohammuh loohad.webm
199KB, 1898x972px
>>57369940
>>
>>57369948
No.

I'm genuinely curious; are you very new to 4chan, or doing some good 'ole trolling?
>>
>>57369965
Neither. I just can't keep up with you kids and all your newfangled memes.
>>
>>57369870
write a function that prints out this structer - 

+ ---- + ---- +
| | |
| | |
| | |
| | |
+ ---- + ---- +
| | |
| | |
| | |
| | |
+ ---- + ---- +

1 def box():
2 print('+', '-' * 4, '+', '-' * 4, '+')
3
4 def verticle():
5 line = ('| | |')
6 print(line)
7 print(line)
8 print(line)
9 print(line)
10
11 def do_twice(f, n):
12 f()
13 n()
14 f()
15 n()
16 f()
17
18 do_twice(box, verticle)


i don't know if i actually did it write but on checking the answer his code is much more OOP then mine.
>>
>>57369993
>newfangled memes
It's literally been an internet thing since the 90's.

The practice of not only getting a "FIRST" post, but also attributing it to something you value is more recent, but certainly at least to the early 2000's.

So maybe you're neither young/new or trolling, but you're at the very least not very observant.
>>
>>57369965
lol itrollu
>>
>>57370030
>but you're at the very least not very observant.
Can't really argue with this, i guess.
>>
File: 3x8fUrh.png (15KB, 722x656px) Image search: [Google]
3x8fUrh.png
15KB, 722x656px
>>57370013
i remember that assignement. I made a version where you could decide how many boxes you wanted and it would draw them for you.

# -*- coding: utf-8 -*-
while True:
import sys
y = int(input('How many horizontal boxes do you want? (Max 15!): '))

if y > 15:
print 'Too many you fucking retard!'
sys.exit('ss')

x = int(input('How many vertical boxes do you want?: '))
print
print



if y == '':
print 'You didnt write anything'
sys.exit('ss')

def do_twice(g):
g(x)
g(x)

def do_four(g):
do_twice(g),
do_twice(g)

if y > 1:
def first_tak(y):
print (('x' + ' -'*4 + ' ')*(y) + 'x')

if y == 1:
def first_tak(y):
print ('x' + ' -'*4 + ' x')

if y <= 0:
def first_tak(y):
print ''

if x <= 0:
def first_vagg(x):
print ''

if x >= 1:
def first_vagg(x):
print (('|' + ' '*9)*(int(y)+1))
print (('|' + ' '*9)*(int(y)+1))
print (('|' + ' '*9)*(int(y)+1))
print (('|' + ' '*9)*(int(y)+1))

def second_vagg():
do_twice(first_vagg),

def hel_vagg():
do_four(first_vagg)

def fler_vagg(x,y):
for a in range(0,x):
first_tak(y)
print (('|' + ' '*9)*(int(y)+1))
print (('|' + ' '*9)*(int(y)+1))
print (('|' + ' '*9)*(int(y)+1))
print (('|' + ' '*9)*(int(y)+1))


def full_rektangel(x,y):
fler_vagg(x,y)
first_tak(y)


full_rektangel(x,y)
>>
>>57370082
15! is a pretty big max
>>
>>57370082
wow that's really cool so did i do it right?

and I actually ahd planned on messing with it to where it's afor loop that keeps spawning boxes ahha.

Yours is absolutely impressie I never though on doing that ;-;
>>
>>57370109
4 u
>>
File: big bang.png (11KB, 445x376px) Image search: [Google]
big bang.png
11KB, 445x376px
>>57370109

It's not that big.
>>
File: 1440710441011.png (479KB, 500x701px) Image search: [Google]
1440710441011.png
479KB, 500x701px
>>57370128
>wow that's really cool so did i do it right?

i guess so, i dont remember the actual assignement. Was it really just to make a function that printed that box? In that case you can just put print "*box*" in the function and call it a day.

Here's some similar shit i did. I havent been in this folder in a long ass time.

space = " "
fstring = raw_input("Enter Text: ")
string = fstring*8
length = len(string)

top = string[:int(length/4)] + space*int(length/4) + string[int(length/4):]
topmid = string[:int(length/4)] + space*int(length/4) + string[:int(length/4)] + space*int(length/2)
mid = string + string[:int(length/4)]
botmid = space*int(length/2) + string[:int(length/4)] + space*int(length/4) + string[:int(length/4)]
bot = string[int(length/4):] + space*int(length/4) + string[:int(length/4)]

print "\n" + (top+"\n")*int(length/8) \
+ (topmid+"\n")*int(length/8) \
+ (mid+"\n")*int(length/8) \
+ (botmid+"\n")*int(length/8) \
+ (bot+"\n")*int(length/8) \


I dont know why but i've always liked text inputs in my scripts
>>
>>57370198
for you
>>
File: 1451360631727.png (4KB, 631x63px) Image search: [Google]
1451360631727.png
4KB, 631x63px
Why the fuck doesn't std::vector's operator[] throw an exception?

I just spend 3 days worth of freetime troubleshooting an issue because of that shit
>>
where do you get your pdfs/epubs /dpt/?
All the major search engines have failed me and it's not in g.sicp.me
>>
>>57370279
Just started learning programming using thinklikecscientistptyhon or something. I don'treally read the chapters just go to the examples for trying improve my ability to abstract logic there.
>>
>>57370330
its a pretty neat book imo
>>
>>57370294
Performance, if you want exceptions use get().
>>
can anyone recommend me a page or guide to get started with concurrency and thread in java
I have an exam in 5 hours
>>
>>57369926
cd /path/to/script && ./script.sh?
>>
File: FnRZtww.png (10KB, 440x122px) Image search: [Google]
FnRZtww.png
10KB, 440x122px
>>57370575
Nah, dont think i'm allowed to change directory like that. Getting pic related.
>>
>>57370646
Then use a non shitty distro because that works for me.

Or put it in your .*rc file?
>>
I'm working on an interpreter in Fortran for a procedural meme of a language. The rest of /g/ isn't working on anything because nobody here can code.
>>57369870
>INT(LENGTH(LIST) / 2)
Not even valid code, and 'len' returns an int, meaning in python 2, you can just use '/', and in python3, you can just use '//'.
>>
>>57370692
It's not supposed to be valid. It's pseudocode???
>>
>>57370692
>Not even valid code
It's pseudocode, dumbfuck.
>>
https://medium.freecodecamp.com/what-programming-language-should-i-learn-first-ʇdıɹɔsɐʌɐɾ-ɹǝʍsuɐ-19a33b0a467d

it's official
>>
File: opTPAUI.png (25KB, 543x412px) Image search: [Google]
opTPAUI.png
25KB, 543x412px
>>57370667
Shittiest fucking fix ever

Made a script that runs ./ so that i can sh that script and get it to ./ the other. it actually works.
>>
>>57370646
>Failed to execute child
>>
>>57370737
Are you mentally retarded?

Why am I even asking, this is 4chan...
>>
>>57370737
what is $PATH

just add /home/anon/bin to your path and put all your garbage scripts in there
>>
>>57370013
That's really bad code. If you're going to write bad code, at least make it short.

for _ in range(2):
print '+ ---- '*2+'+'
for _ in range(4):print ('|'+' '*6)*2+'|'
print '+ ---- '*2+'+'
>>
File: wewlad.webm (306KB, 1024x768px) Image search: [Google]
wewlad.webm
306KB, 1024x768px
>What are you working on, /g/?
I finished this fucking triangulation algorithm, way harder than I thought
>>
>>57370708
>>57370732
It's attempting to look like Python. You don't use fucking different intrinsic function names in pseudocode; you just abstract. If it was pseudocode, why the hell would he be wrapping his division up in an 'INT' statement as safety for his slice?
>>
>>57369926

make a folder called bin in your home folder
move your scripts there
add
export PATH="$PATH:~/bin"
to your .bashrc
>>
>>57370867
Looks good. What algorithm did you use?

>>57370900
It's attempting to look like python but somehow not python at the same time... hmmmm... I wonder if maybe that's because it's pseudo code

btw, there's no standard for pseudo code. Pseudo code is just any piece of code that's not designed to be compiled, instead it's supposed to be human readable. Since Python is already human readable, the two often look a lot alike.
>>
>>57370900
>>57371035
Also you can tell it's not Python because Python's random function returns a float between 0 and 1.

If it was designed to look like Python, it would be randint
>>
File: 1467629729343.jpg (157KB, 557x539px) Image search: [Google]
1467629729343.jpg
157KB, 557x539px
>>57369870
>What are you working on, /g/?

Research with a professor, or how I like to call it "a fucking waste of time to get my remaining credits so I can finally graduate".

>anon take my code and do this shit
>ok I'll try
>professor I can't do this shit because I don't understand you code; it's a garbage written in c++ that you dedicated 3, maybe 4 years of your life yet you didn't put a single comment on it
>how so? this shit is trivial anon go home try again and see me next week
>>
>>57371035
I used triangulation by ear clipping
>>
>>57370013
>structer
kill yourself, you dirty illierate
>>
File: 1451012607680.png (17KB, 661x208px) Image search: [Google]
1451012607680.png
17KB, 661x208px
>>57371078
>http://jeiks.net/wp-content/uploads/2014/08/TriangulationByEarClipping.pdf
That actually is a pretty cool algorithm.

I'd probably have never thought about it.
>>
>>57371233
no lmao
>>
File: igetanerrorwhyplshelp.png (74KB, 1063x278px) Image search: [Google]
igetanerrorwhyplshelp.png
74KB, 1063x278px
Need help using Android NDK to run my .mk files.

The library was created by someone else, and I have edited a few of the .cpp files.
I need it to build so that I can use the library in my project.

>https://github.com/finnstr/gdx-liquidfun-extension
The .mk files and .cpp files I need to build are inside /jni/

Please help, I am stuck

The link below is all the info I have
>https://developer.android.com/ndk/guides/ndk-build.html
>>
>>57369926
do you have a
#!/bin/bash
in the beginning of your script?
>>
>>57371295
I used exactly this pdf, it's bretty gud
>>
How can high traffic sites like Reddit be powered by Python? It's slow as fuck, but it somehow manages all that traffic. Do they simply spend a fortune on processing power to overcome the slowness?
>>
>>57371312
It's a Linux-based build system you're gonna need cygwin if you're gonna build on Windows.
>>
File: output1.webm (424KB, 1024x768px) Image search: [Google]
output1.webm
424KB, 1024x768px
>>57371295
Here, I made it make a 1 second pause when it find a triangle so you can see it work
>>
>>57371443
>he fell for the "if it's not C, it's slow" meme

Slow is relative, and highly dependent on what you're actually doing.

There's a massive practical difference between doing insanely manually-optimized mathematical algorithms and handling simple data requests.

Calling Java, C#, and Python "slow" in some contexts is meaningless. In the context of development iteration turnaround, those languages are sometimes orders of magnitude faster than something like Assembly or C.
>>
>>57371443
It probably doesn't do that much. I mean what can you do on reddit? Upboat? Oh okay boat++. Post text? Oh okay add item to database that does the real work. Large websites are mostly a getting data to the right place problem not a doing lots of processing on data problem. Google is an exception. They spend a lot of time digging through their data trying to pull signal out of the noise. Forums are about moving noise around.
>>
>>57371476
What do I do once I have downloaded cygwin?

I have tried putting the same commands into the MinGW cmd, but I get the same errors.
>>
>>57371500
That's fucking nice bruh.

Are you using OpenGL to draw everything?
>>
>>57371565
Kys

>>57371443
Cucks donate them golds so they can waste powerful servers with their shitty webshit.
>>
>What are you working on, /g/?
I decided that implementing an audio compression decoder from scratch was too much work for me, so i'm now looking at how to use Microsoft Media Foundation.
>>
>>57371647
Well I'm using a lib called SFML which itself uses OpenGL, I'm just to lazy
>>
>>57371649
Offer a dissenting argument if you want to be taken seriously, faggot.
>>
can i get the picture to roll and work on a new project. need practice for when im out of school
>>
>>57371632
Not trying to be condescending but you seem to lack even basic understanding of the command line so trying to help you set this up would be a major back and forth of questions.
Try and google how to setup and use the ndk on Windows with cygwin, maybe someone has written a step-by-step tutorial or something.
>>
>>57371729
http://better-dpt-roll.github.io/

Don't shit up the thread with rolls
>>
>>57371746
dont have to be rude i just want to learn
>>
>>57371769
I wasn't being rude at all, you dumb faggot.

Occasionally when someone posts a roll image, we get 30-50 posts that just say something like "roll" which buries some discussion.

To avoid this, I've provided you a handy link that even does the rolling for you. I'd call that pretty civil, from a utilitarian perspective.
>>
>>57371686
everything will be ok
>>
File: 1474229641700.jpg (12KB, 258x245px) Image search: [Google]
1474229641700.jpg
12KB, 258x245px
>>57371794
>I wasn't being rude at all, you dumb faggot

fucking kek
>>
dumb thin-skinned frogposter
>>
you guys are fucking retarded
>>
File: code.png (39KB, 534x579px) Image search: [Google]
code.png
39KB, 534x579px
Rate my code pls

/**
* @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;
}
>>
rate my >>57369464
with ada.text_io, ada.integer_text_io;
use ada.text_io, ada.integer_text_io;

procedure cal is
subtype Weekday is integer range 0 .. 6;
subtype Month is integer range 1 .. 12;

month_names : array (Month) of String (1 .. 9) :=
("January ", "February ", "March ",
"April ", "May ", "June ",
"July ", "August ", "September",
"October ", "November ", "December ");

function is_leap_year(y: Integer) return boolean is
begin
return (y mod 4 = 0 and y mod 100 /= 0) or y mod 400 = 0;
end is_leap_year;

function length(m: Month; y: Integer) return Integer is
begin
if m = 2 then
if is_leap_year(y) then
return 29;
else
return 28;
end if;
elsif m in 9 | 4 | 6 | 11 then
return 30;
else
return 31;
end if;
end length;

-- returns the weekday of the last day of the month
procedure print_month(m : Month; y : Integer; day : in out Weekday) is
mon_len : Integer range 28 .. 31 := length(m, y);
begin
Put_Line(month_names (m));
for i in Weekday range 0 .. day - 1 loop
Put(" ");
end loop;

for date in Positive range 1 .. mon_len loop
Put(date, 3);
if day = 6 then
Put_Line("");
day := 0;
else
day := day + 1;
end if;
end loop;
Put_Line("");
Put_Line("");
end print_month;

y : Integer;
startday : Weekday;
begin
Put("Enter year: "); Get(y);
Put("Enter first day of week (0..6): "); Get(startday);

for m in Month loop
print_month(m, y, startday);
end loop;
end cal;


Realized that I haven't touched Ada for years and wanted to give it a shot. There's probably a better way to do that month name array initialization but I'm too lazy to remember/relearn how unbounded strings work.
>>
>>57371794
dont have to be rude i was just telling you not to be rude
>>
>>57371565
>>57371611 (checked)
I understand that the server is mostly waiting for the database to retrieve the requested data, but still. On such a grand scale, things like URL routing in Python will add up quickly in terms of CPU time.
>>
>>57371846
clear/10
>>
>>57371857
this code is CUTE
>>
>>57371874
>things like URL routing in Python will add up quickly in terms of CPU time
What makes you think this?
>>
>>57371836
>/g/
>not retarded

pick one
>>
>>57371730
>you seem to lack even basic understanding of the command line
Indeed I do.

I just want to make some fun physics on Android, but wanting to edit native code has lead me out of my depth. I don't want to give up though.

I feel like a down syndrome trying to solve a Sudoku.

Thanks for the help though, I will follow your advice
>>
File: 1472451101578.png (6KB, 146x365px) Image search: [Google]
1472451101578.png
6KB, 146x365px
>>57371846
Can f be both a function and a variable at the same time?
I didn't realize that. Neat

Also is that faster than the standard
def fib(n):
a,b=1,0
yield b
yield a
for i in range(n):
a,b = a+b,a
yield a

It looks like it because the loop looks like O(log n)
>>
>>57371846
No brief explanation of what the function is doing.
single letter variable names which looks like is picked in alphabetic order rather than according to the usual terms in any context.
Weird comment for an if statement and the return statement, but nowhere where it might be useful. (eg. like why n > 92 is a failure or what the function does)

When all this is combined, you have bad code.
>>
>>57371935
Even though a web server spends most of its time in a database and writing data, there is still *some* overhead. If you could reduce the overhead 10x by using C++ over Python instead, you'll reduce CPU time. If you have large amount of traffic, you could serve even more clients per server, thus saving money. I know that development time is more costly than buying extra machines, but does that also apply on a large scale like Reddit?
Also, URL routing is just an example. It doesn't require I/O (hard drive, or network).
>>
>>57372140
>Can f be both a function and a variable at the same time?
Yes, the f inside the function masks the function f.

>Also is that faster than the standard
I suspect so, but to be sure you'd have to benchmark both of them. You're correct that it's O(lg n).

>>57372143
Hmm, I see what you mean. Maybe the comment should be

/* if n is greater than 92, we will run out of bits, so fail */


There aren't really any good names that I could use for those variables.
>>
>>57372159
>If you could reduce the overhead 10x by using C++ over Python instead
Why do you think there is this much overhead?

Why do you think that C++ specifically would be a good choice to do this?

Do you understand how much development time would be required for a re-write of backend systems? Keep in mind, we're not talking about just a first-iteration re-write that "works"; risk must be taken into account in potentially much more massive bugs due to using an unsafe language.

And keep in mind that all of this still goes back to the fact that it's extremely unlikely that you could squeeze an order of magnitude more performance out of a back-end rewrite in a different language, rather than simply optimizing the implementation in the current technology stack.

Then there's the 100's of libraries they're using that they'll have to find or develop C++ equivalents of...

All in all, it's easy to sit here and recommend a lower-level language for anything that could *potentially* benefit, but ultimately it just doesn't hold up to a business-case conversation.

By the way, I don't think Reddit is at the scale you're thinking it may be. At least, not in a way that a low-level language would significantly effect without an undue amount of staffing and development.
>>
It seems that everyone has forgotten that you must be mentally retarded to create a social network similar to the Reddit scheme.

>inb4 4chan is in PHP
Fuck off
>>
File: hueg.png (89KB, 655x418px) Image search: [Google]
hueg.png
89KB, 655x418px
Holy shit, llvm is huge.
>>
File: tomboy.jpg (103KB, 1280x720px) Image search: [Google]
tomboy.jpg
103KB, 1280x720px
Ok i'm ready to be laughed at.
 usernumber = raw_input("enter a number and I'll tell you if it is a prime number or not. Use only integers.")
number = int(usernumber)
def isPrime(num):
for i in range(2,num - 1):
if num % i == 0:
print "It's composite"
break

isPrime(number)
raw_input()

the idea is that I want the function to print a statement also if the number is prime, but for the life of me i cant think of a way to do that. It's probably something really simple im missing too.
>>
>>57372286
bloatware
>>
>>57372307
Are you looking for the "else" command?

If this, else this.
>>
>>57372307
You only need to test up to sqrt(num).
>>
>>57372307
> enter 78213808329
> wait for 50 years

nice anon, you'll go far
>>
>>57372247
http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=python3&lang2=gpp
Python is much slower than C++, but that's just when number crunching.
But you're right. Python makes much more sense to use than C++ for the reason you mentioned (library support, safety, time).
>>
1082 def getrandmon():
1083 rn = random.randint(1, 100)
1084 if floor <= 5:
1085 if rn <= 25:
1086 return 0
1087 if rn > 25 and rn <= 50:
1088 return 10
1089 if floor == 3:
1090 if rn > 50 and rn <= 75:
1091 return 30
1092 if rn > 75 and rn <= 88:
1093 return 0
1094 if rn > 88:
1095 return 10
1096 if floor > 3 and floor <= 5:
1097 if rn > 50 and rn <= 75:
1098 return 20
1099 if rn > 75:
1100 return 30
1101 if rn > 50 and rn <= 75:
1102 return 0
1103 if rn > 75:
1104 return 10
1105 if floor > 5 and floor <= 10:
1106 if rn <= 25:
1107 return 40
1108 if rn > 25 and rn <= 50:
1109 return 50
1110 if floor == 8:
1111 if rn > 50 and rn <= 75:
1112 return 60
1113 if rn > 75 and rn <= 88:
1114 return 40
1115 if rn > 88:
1116 return 50
1117 if floor > 8 and floor <= 10:
1118 if rn > 50 and rn <= 75:
1119 return 60
1120 if rn > 75:
1121 return 70
1122 if rn > 50 and rn <= 75:
1123 return 40
1124 if rn > 75:
1125 return 50
1126 if floor > 10:
1127 if rn <= 25:
1128 return 80
1129 if rn > 25 and rn <= 50:
1130 return 90
1131 if floor == 13:
1132 if rn > 50 and rn <= 75:
1133 return 100
1134 if rn > 75 and rn <= 88:
1135 return 80
1136 if rn > 88:
1137 return 90

I made a cool function guys
>>
>>57372368
If by "cool", you mean horribly written, then sure.

You wrote a "cool" function.
>>
>>57371857
Your month_names should be an enumeration instead of an array of strings.

Y should be a natural

Other things, basically you're not using the type system to its full advantage. For example, inputting the day of the week as a number instead of the work is a contrivance for C.
>>
File: nyoro~n.jpg (21KB, 260x260px) Image search: [Google]
nyoro~n.jpg
21KB, 260x260px
>>57372331
I had an else statement, but i couldnt get it to work properly, it would sometimes list composite numbers as prime and such.
>>57372338
thank you for the advice.
I'm terrible at math
>>57372339
pls no bully, I just want to be a good programmer one day
>>
>>57372388
pls no rudeposting
>>
trying to find host names and IPs on a subnet
it segfaults at the for loop. I think I should be using a structure instead.

int main(int argc, char* argv[]) {

char *subnet = "255.255.255.255", *hostIP = "127.0.0.1";//default
u_long host, mask, broadcast;
struct hostent *host_ptr;
char broadcast_addr[INET_ADDRSTRLEN], addr_ptr[INET_ADDRSTRLEN];
u_long ip_addr_long = 0;
int i = 1;

if(argc > 1) subnet = argv[1];
if(argc > 2) hostIP = argv[2];
else {
printf("Specify a sub-network mask and an IP for target host\n");
return 1;
}
if (inet_pton(AF_INET, hostIP, &host) == 1 && inet_pton(AF_INET, subnet, &mask) == 1) {
if((broadcast = host | ~mask) != 0) {//xor mask with host
inet_ntop(AF_INET, &broadcast, broadcast_addr, INET_ADDRSTRLEN);//get broadcast string address
printf("IP: %s\tSubnet: %s\tBroadcast: %s\n", hostIP, subnet, broadcast_addr);
}
else {
printf("Failed to convert Broadcast");
return -1;
}
}
else {
printf("Mask and IP do not match\n");
return -1;
}

for (i = 1; i < (~mask); i++) {//not for range of IP addresses
ip_addr_long = host & ~(mask - i);
printf("%d...\n",ip_addr_long);
//addr_ptr = ntohs(ip_addr_long);
if((host_ptr = gethostbyaddr(&ip_addr_long, sizeof(ip_addr_long), AF_INET)) != NULL) {
printf("%s\t", host_ptr->h_name);
}
}
return 0;
}
>>
File: indians.png (5KB, 235x117px) Image search: [Google]
indians.png
5KB, 235x117px
>>57372423
I'll stop rudeposting if you stop pajeetposting.
>>
>>57372419
You're gonna make it, but math is important for programming.
>>
>>57372441
when did i?
>>
>>57372213
by good names, I mean you could start with uint64_t fibonacci(uint8_t input)
and then use the mathematical descriptions you would use for the algorithm.
Not coming up with variable names is not just lazy, it can make life a lot harder for you if you were to ever reuse a function again.

For example: say you a year from now were to find this project again.
Now you know that you store all your projects in the ~/code dir or something, but there is so many projects there, so it is easier just to grep recursively after the function name.
what would you search for?
If you were to show this to another person, do you really want to explain it in person or would you prefer to hand it over and expect them to read it without wasting time figuring out what you meant by something or why it doesn't work in a weird scenario or something.
There is nothing to gain by obfuscating your code. there are a lot better ways to do that if you really want to.
>>
>>57372441
Hi Pajoot.

Please do kys.

Thanks
Weeboo
>>
>>57372449
By posting code that fundamentally violated basic DRY.

It could be rewritten to something much clearer and easier to maintain/modify.
>>
>>57369870
porting one of my university projects from python to c++(11/14) so that my portfolio looks better when i apply for jobs next week.

project is a secure chat client/server.

architecture is roughly:
- srp for client authentication with the server
- aes256 + hmac for message encryption and signing
>>
>>57372475
i haven't posted code in this thread
>>
>>57372455
I figured it out in less than 10 minutes by compiling the code myself and seeing what it does.

Don't be lazy 2bh
>>
>>57372429
well, use gdb or ddd to find out why it segfault then
>>
>>57372419
How about some boolean true when a number is composite and then check after the loop whether the variable was true or not?

Or if you enjoy brian damage, use "for else". Your favorite search engine will know the rest. Seriously, don't do this.
>>
>>57372475
If you're not using a pure functional lazy statically typed language then you don't get to say anything about DRY.
>>
>>57372159
If there is a function that would benefit that much from C++, you'd probably just end up using swig. Hell if it's web stuff it's probably already a library and if it would benefit from a compiled language it's already compiled with a python wrapper around it.

Still if your software system as a whole is bottlenecked by I/O you don't gain anything by shaving cycles off the CPU. When optimizing the best place to start looking is what takes the most time. 90% reduction of time in code that uses 1% of your time is only a .9% reduction. If you're using 100% of your hardware's I/O and 50% of your hardwares CPU, you still need to buy more hardware after the CPU is only using 20%.
>>
>>57372507
What does laziness have to do with it?
>>
File: 59653298_p0.jpg (538KB, 1000x729px) Image search: [Google]
59653298_p0.jpg
538KB, 1000x729px
>>57372368
>1137 lines of this
Fucking wut.. I'm too scared of outside because of monsters akin to this. TT__TT
>>
>>57372484
He asked for people to rate his code.
It was bad code.
Compiling it to see what it does is what millennials do since they never learn to read code.
>>
>there are "people" in this thread who dont understand pointers

kek
>>
>>57372484
>10 minutes to compile a dozen line of code

what?
>>
>>57372368
What does it do? Return some kind of pokemon?
>>
>>57372537
it's actually 2007 lines right now
>>
>>57372551
this, pointers and memory are just a comonad
>>
File: Kissu.png (1MB, 3058x4019px) Image search: [Google]
Kissu.png
1MB, 3058x4019px
>>57372498
i actually did try that at first, my idea was to have a universal value start off as true, and if it detected a composite number in the range, it would turn false. I couldn't get anything to print properly with that for some reason though
>>57372443
thank you
I'll have to learn, but one day i will spread my wings and become a mighty pajeet
>>
>>57372409
>month_names should be an enumeration
oh that makes sense
>y should be a natural
should it? there are years before year 0

that last one was because I was trying to stick to the anon's java assignment but yeah, overall I didn't put enough thought into types here.
>>
>>57372582
I once unironically wrote a >thousand line function with just nested if statements copypasted to handle every possible case for x86 instruction decoding.

I claim sleep deprivation.
>>
File: kitty cat stare.jpg (82KB, 480x336px) Image search: [Google]
kitty cat stare.jpg
82KB, 480x336px
>>57369870
Hey /dpt/, where should I go to learn OpenGL? I've got some good exposure to C programming, and I've made some simple games in SDL. I'd like to know the authoritative source for modern OpenGL programming.
>>
>>57372455
I think I see what you mean.

I could avoid the searching problem just by copy-pasting the code into each project I need it in though, couldn't I? Then I'd only have to grep in one project dir.
>>
>>57372608
Why not simply using macro or meta-programming?

>sleeep
whatever
>>
>>57372613
the one that was posted on /r/learnprogramming yesterday
>>
>>57372568
>less than 10 minutes
that
>>
>>57372604
The problem statement says years will only be positive.
>>
>>57372551
uintptr_t *p;
p = (uintptr_t *)&p;
*p = (uintptr_t)p;
printf("%p %p\n", p, (void *)*p);
*p = 0;
printf("%p %p\n", p, (void *)*p);
>>
>>57372656
>me in charge of reading
>>
>>57372613
Modern OpenGL programming is an oxymoron.
>>
File: llvmrust.png (154KB, 879x526px) Image search: [Google]
llvmrust.png
154KB, 879x526px
>tfw waiting for compiler to compile
>>
File: snap066.png (160KB, 1332x586px) Image search: [Google]
snap066.png
160KB, 1332x586px
>>57372633
Don't even ask. It's the most retarded code I've ever written.
>>
Coeffects are neat.
>>
>>57372639
Sorry, I don't use www.reddit.com, could you please send me a link?
>>
>>57372711
Sure: >>>/trash/
>>
>>57372671
Is there something else I should be using for portable computer graphics?
>>
>>57372729
Simple Directmedia Layer.
>>
>>57372729
Learn GPU ASM
>>
>>57372159
If 90% of the CPU load is in the database queries, then a 10x speed-up in the other 10% only gives you a 10% speed-up overall.

Also, typical back-end web code is mostly delegating to relatively high-level methods which are implemented in C or C++.

Python sucks badly for "Fortran-style" code (primitive operations in nested loops), but that doesn't say much about the kind of code for which it's normally used.

For C/C++, the development time is increased dramatically by the fact that C/C++ code has to be almost perfect. A segfault means restarting the host process, memory corruption will affect subsequent requests until the host process eventually crashes. Whereas an uncaught exception only affects the request being processed.
>>
>>57372677
What compiled the first compiler?
>>
>>57372729
Probably not. I'm just saying it's outdated although still necessary because the new stuff doesn't have a lot of support yet.

open.gl
>>
>>57372597
Well, if you still have problems with the approach or anything, post the code you are working on and we'll sort it out.
>>
>>57372754
It was made by hand.

Just like chickens
>>
>>57372754
God
>>
>>57372754
By hand.
>>
>>57372613
khronos.org -> specification. Reading it once through wont hurt even if you don't understand all. You can also read just ES spec if you feel lazy. Avoid man pages.
>>
>>57372801
Thank you, sounds like if I just grind through this once I can come back and get specific knowledge when I need it, should be kinda fun :)
>>
>>57371443
it's called distributed computing.

reddit is very likely loadbalanced like crazy and their db's are probably clustered.
>>
File: php.jpg (18KB, 357x264px) Image search: [Google]
php.jpg
18KB, 357x264px
I have a total beginner question.
I started learning a little bit PHP on codecademy, and on Codecademy it compiled just fine, but how come "Hello world!" doesn't show up when I open the HTML file my self?
>>
>>57372887

you don't have apache server running
install xampp or something
>>
>>57372887
You will go far, kid.
>>
>>57372913
thanks, dad

>>57372896
Oh.. what's that..?
>>
File: 1476168208554.png (125KB, 287x281px) Image search: [Google]
1476168208554.png
125KB, 287x281px
>>57372887
>>
>>57372887
PHP is a server side language, it must be interpreted, the browser will only render HTML and execute JS, so it doesn't do anything with your PHP code. You need a web server that will proxy the requests to a PHP interpreter.
>>
>>57372613
The authoritative source is the latest edition of the red book (The OpenGL Programming Guide). it's up to the 9th edition now, although the 7th or 8th will suffice if you just want to avoid "legacy" (pre-GPU) OpenGL and don't need the latest features.

>>57372742
SDL is fine for interfacing with the OS (i.e. window management and input handling), but its rendering API shouldn't be used for anything.
>>
File: 1471128996267.jpg (256KB, 1280x960px) Image search: [Google]
1471128996267.jpg
256KB, 1280x960px
I actually kind of like modern C++. Is this bad?
>>
File: Exceededexpectations.png (210KB, 1802x1801px) Image search: [Google]
Exceededexpectations.png
210KB, 1802x1801px
>>57372951
Thanks, you explained it quite well, have a ribbon!
>>
>>57372690
What are they? Link pls?
>>
So can anyone point me to documentation for minimax trees?
>>
File: chill.gif (1MB, 960x540px) Image search: [Google]
chill.gif
1MB, 960x540px
Any windows sysadmins here?

>>57372105

Just to add, SchTask is executed from .bat (with admin priv) file who executes .vbs file (then it also gains admin priv) which runs a SchTask command.

If there is no normal way to achieve this maybe its possible to do a work around? If that VBS script wouldn't also executes as admin, it wouldn't create a schedule on admin.

Fuck, i have no idea what to do.
>>
>>57372766
usernumber = raw_input("enter a number and I'll tell you if it is a prime number or not. Use only integers.")
number = int(usernumber)
value = True
def isPrime(num):
for i in range(2,num - 1):
if num % i == 0:
value = False
break

if value == True:
print "It's prime"
else:
print "It's composite"

isPrime(number)
raw_input()

now I know there is a syntax error somewhere because it terminates when I try to enter a prime number. I'm trying to figure it out myself but it's frustrating knowing that its probably something so incredibly simple to fix.
>>
>>57372961
Modern C++ is nearly as far from C++ as possible, so it's a good thing
>>
>>57372801
The specifications aren't useful as an initial learning resource. None of it makes any sense until you have a reasonable "big picture" understanding of OpenGL.

But once you're familiar with the generalities, they're essential for understanding the fine details, as they contain information which won't be found anywhere else.

Unfortunately, understanding the interface between client (CPU) code and shaders (GPU code) isn't made any easier by the fact that each part is covered by a separate specification.
>>
>>57373003
What if num=2?
>>
>>57369926
sh != bash
if you run it as sh, you are not using bash.
>>
File: 1458626540237.png (24KB, 240x240px) Image search: [Google]
1458626540237.png
24KB, 240x240px
>>57373071
the script terminates because I'm a shitty programmer and didnt account for that
>>
>>57373102
baka desu senpai
>>
171th for C++
>>
>>57372677
did you use
make -j
anon?
>>
>>57373003
It's not a syntax error (if it was, you'd get a SyntaxError exception as soon as you run the program).

The error is that the "value" variable inside isPrime() is a local variable, distinct from the "value" variable created outside it.

If the number isn't prime, value (the one inside isPrime) never gets set, so the test will raise an UnboundLocalError exception.

Whether a variable is local or global is determined when the function is compiled. If a variable is assigned to within the function and there isn't a "global" declaration for the variable, then it's local, otherwise it's global. Referencing a local variable which was never assigned raises an exception; it doesn't fall back to using a global variable with the same name.

tl;dr: put value=True inside the function.
>>
>>57373118
make -j3 so i can use 1 core for shitposting
>>
>>57373003
You should try to run the python file from command line. This is pain but will help you in the future as you can see error messages early.

What happens when isPrime is called the second time? What value does the "value" have if previous number was a composite? Perhaps you should clear the value at the beginning of the function.

Your issue is basically "what is 'value' variable"? Its both global and local vaiable which makes things go wrong. In python by writing a variable in a function anywhere declares such local variable implicitly even if the code is not executed. That's why reading "if value==True" will be an error if value was not assigned to. Move "value = true" inside the function. This removes the global "value" variable so you'll always be using the local variable.

Don't feel bad, in many other languages this would have been legal.
>>
>>57373129
> If the number isn't prime
Should have been "if the number IS prime".
>>
>>57373130
Ok, that a huge program then
>>
head fibs = 0
head (tail fibs) = 1
tail (tail fibs) = zipWith (+) fibs (tail fibs)
>>
>>57373156
It's the rust compiler, which requires llvm
>>
It's amazing how complex modern C++ is getting to emulate Java and other superior languages.
>>
>>57373179
>Java
>Superior to anything
>>
You have a couple of errors:
>>57373129
Is correct.

>>57373003
Also raw_input takes the whole line. So you'll be taking the text you print out when it gets assigned to the variable.

Try printing the text then calling for input
print "enter a number"
usernumber = raw_input("")
>>
>>57372961
what do you think might be bad about it?

"modern c++" is just creating useful, minimal abstractions that make code more compact and readable while, at the same time, adding some safety for free. The use of templates in the instantiation of new features gives compile-time assurances without any associated runtime overhead. It's beautiful what the ISOCPP board is doing to the language. Furthermore, changes are almost entirely within the STL and not the underlying language.

I would love to hear from someone who has complaints about "modern c++" without griping specifically on the added functionality of the new STL (ie: why are you mad about changes that you don't even have to use? Do you think the ISOCPP committee could have spent time doing something else to improve the language? If so, what?).
>>
>>57372307
>raw_input
You fucked up when you used python 2
>>
>>57373198
>Java
>Inferior to everything

pick two
>>
>>57372429
Use argp.
broadcast_addr is being passed uninitialized, so are host and mask but I forget if you can pass pointers to uninitialized data or not.
>>
>>57373055
I believe that skimming through the spec will at least enable people use the correct terminology which will help the find more resources by themselves. I agree spec is a suboptimal way to learn and I would recommend a tutorial if I knew a good one, unfortunately most tutorials I know target ancient GL with EXT tags on even basic buffer APIs.
>>
>>57373086
>sh != bash
true
>if you run it as sh, you are not using bash.
true sometimes. sh is almost always just a symlink to your default shell. A lot of the time, that is bash.
>>
>>57373201
scratch that second part i'm retarded
>>
>>57373003
>raw_input
You fucked up when you chose python 2
>>
>>57373235
I recommend you check out this fancy hipster distro called Ubuntu. Protip: it runs dash, not bash.
>>
File: 2016-11-03_21:51:54.png (288KB, 1920x1080px) Image search: [Google]
2016-11-03_21:51:54.png
288KB, 1920x1080px
>>57373302
wut?
>>
>>57373302
>>A lot of the time, that is bash.

that's all i said, and i wasn't implying anything else.
>>
>>57373323
sh is a link to dash in ubuntu (and most Debian derivatives)
>>
>>57373235
Meh, using shit like sh when you should have just set your interpreter from the Unix scripts convention and set your permissions OR just use the correct shell. God knows what anons on that specific *buntu variant with a ton of unknown PPAs are running.
>>
>>57373339
Well, I'm running ubuntu and did change it, still bash
>>
>>57369870
>that image
That font gives me eye cancer and I refuse to read it
>>
>>57373339
can confirm
>>
File: 1471216526275.jpg (50KB, 433x469px) Image search: [Google]
1471216526275.jpg
50KB, 433x469px
>>57373129
I Knew it had to be something to do with the local/global variable differences. I tried putting my initial boolean value inside of my function beforehand, but the script kept terminating and I got frustrated because I didn't know why. Turns out I had just temporarily lapsed into the mind of a retard and failed to notice the fact that the only issue was that i didn't indent "value" when I put it inside my function. felt pretty stupid as soon as i figured that out.

As a related question, could I have also solved the problem by using the global keyword?
>>
>>57373339
>>57373349

never mind, read too fast
>>
>>57373363
that's bad form. just declare the value variable inside the function if that's the only scope you are using it in
>>
>>57373179
C++ is miles ahead of java in terms of superiority.
>>
>>57373363
Yes, you could have. However, like said above using globals is bad and should be avoided if possible. But for small scripts, it doesn't really matter.

Basically, why they should be avoided is that they make debugging harder as you cannot just run function and be sure that the returned value is always that. You must think both the code and the state of the whole surrounding program. In larger projects with large number of global variables, this would be extremely complicated and time consuming.
>>
PSA: If bash is called from sh it behaves differently.

>If bash is invoked with the name sh, it tries to mimic the startup behavior of historical versions of sh as closely as possible, while conforming to the POSIX standard as well.

Debian made dash for smaller footprint and faster execution time but dash and bash in posix mode are very similar.
>>
>>57373381
I don't even really know the proper syntax for using global. I was just curious if it could be done.
>>
>>57373226
> I agree spec is a suboptimal way to learn
As a first learning resource, it's worse than suboptimal, it's impossible.

And I have 59 different OpenGL specs (GL, GLX, GLSL, GL ES) on this PC, and learned most of the version differences from the specs.

But I started with the red book, and used tutorials for the major upgrades (e.g. multi-texture, shaders).

But trying to learn OpenGL itself from specs would be like one of those logic problems where you have to figure out who lives where and drives what from a bunch of "Joe lives next door to the woman with the red Porsche" clues.
>>
File: paste.webm (2MB, 697x428px) Image search: [Google]
paste.webm
2MB, 697x428px
Can anyone tell me how I can improve my Program. It searches pastebin.com/archive/python for paste that contain certain keywords. The only problem it has is that it gets the links on the side. Other then that what other ways can I improve it? heres the source:
http://pastebin.com/RCB01g03
>>
>>57373448
you would have to declare the global variable inside the function if you want to use it in other scopes. This does not work:
global foo
foo = 0
def bar():
foo += 1
print(foo)
bar()


but
def bar():
global foo
foo = 0
print(foo)
bar()
foo += 1
print(foo)

works
>>
File: Selection_001.png (15KB, 386x483px) Image search: [Google]
Selection_001.png
15KB, 386x483px
What am I doing wrong?

Scanner in = new Scanner(System.in);
int size = in.nextInt();

for (int i = 1; i <= size; i++) {

int n = size - 1;

for (int j = 1; j <= n; j++) {
System.out.print(" ");
}

for (int j = 1; j <= i; j++) {
System.out.print("#");
}

if (i < size) {
System.out.println();
}
}
>>
>>57373448
>>57373478
this is also python 3, i'm not sure if there are differences with python 2. I would just start using python 3 unless you need to maintain legacy code for some reason or need a library only available in python 2.
>>
>>57373484
Swap the the for loops
>>
reflection is java is really fucking useful. how do other languages like sepples or c handle such "meta programming" (?) ?
>>
>>57373484
The first loop should only go up to n-i, not to n.
>>
>>57373488
I'm self taught, when I first started trying to learn, I remember reading that python 2 was better in some way. I can't remember where but i do remember reading that. and the tutorials i learned from all featured python 2.
>>
>>57373518
https://www.youtube.com/watch?v=abdeAew3gmQ
>>
>>57373457
I must backpedal a little. I did not mean the specification as the only resource, just the initial one just to get the terminology and "a hunch" of everything what you'll encounter in the following tutorials/learning resources. I just really like the idea of one (+sl) self-contained pdf containing the base of everything you'll need on the way to the goal. But I must admit that the spec might be to speccy for some (most?) people. Maybe I am just a speccy person that likes reading the basics?
>>
>>57373474
anyone?
>>
Is there like a bible for network programming? I'm interested in the low level details of internet protocol and the magic that's usually hidden from you by networking libraries and frameworks.
>>
>>57373323
What window mannager is that?
>>
>>57373544
so instead of implementing reflection a trick has to be found first? it's like the wild west
>>
>>57373586
It's called university education :^)
>>
>>57373589
i3, as written in screenfetch in my screencap
>>
>>57373538
Probably learn python the hard way?

You can read this: https://hynek.me/articles/python3-2016/

Either way you can learn either one and will be fine, the changes aren't overwhelming.

The divide is more annoying than anything.

>>57373474
>>57373580
I'll take a look in a sec
>>
>>57373625
Well, unfortunately I majored in biotech and I just do programming as a hobby so I have to learn from reading books ;^)
>>
>>57373586
If you want the bare TCP/IP stuff, then "TCP/IP Illustrated (Volume 1)" by W Richard Stevens is probably the best. Its main limitation is that it doesn't cover IPv6. The other volumes are less relevant.

For higher-level protocols, coverage is mixed. For simple protocols, you can just read the appropriate RFC. But most of those are obsolete now (good luck getting anything other than HTTP through a corporate firewall). And HTTP has grown into a monster which is more than anyone can learn in one lifetime.
>>
>>57373586
https://beej.us/guide/bgnet/ is always a good place to start. if you're looking for kernel networking internals, you'll most likely have to browse through some niche sources and ask questions on IRC (or read/ask questions on SO). for IRC, i'd recommend ##security, ##networking, ##c, ##c++ on freenode
>>
>>57373688
I hate the writing style of his
>>
>>57373580
>>57373474
what is it doing that you don't want it to? It looks fine for now, I'm not sure what you want exactly. Runs perfect for me.
>>
>>57373649
thanks
>>
>>57373719
The only problem is it gets the public pastes on the side as well, I don't want it to do that.
>>
>>57373474
Kill yourself pedo.
>>
>>57373586
>>57373688
also, you can find university course websites online that make all of the class information available to you (lecture slides, assignments, projects, tests/quizzes/exams, etc.). i'm not talking about coursera type courses. just regular university classes that publicly post everything.

shameless plug for my favorite previous professor: http://david.choffnes.com/teaching.php#current
>>
>>57373735
use beautifulsoup and extract the elements from the main div only then
>>
What does /dpt/ think of clojure/clojurescript? I really want to learn a non-R non-Python language and getting into functional programming seems like a good choice. Thoughts?

>>57373729
sure! Let me know if you have any questions.
>>
>>57373735
>>57373775

wait you're already using bs, i didn't read the ciode
in which case first use .find('table', _class='maintable') then do .findAll('a') on the result object
>>
>>57373777
learn javascript instead.
>>
Haskell
>>
>>57373687
>>57373688
Those look pretty manageable, guess I'll start there.

>>57373770
Yeah, I've used those kind of resources before since course materials tend to show more examples than books a lot of the time. I'll give it a look.
>>
Ruby
>>
>>57373826
You're supposed to name something good
>>
>>57372409
>>57371857
gave it a little modification, is this better?
with ada.text_io, ada.integer_text_io;
use ada.text_io, ada.integer_text_io;

procedure cal is
type Month is (January, February, March, April, May, June, July, August, September, October, November, December);
type Weekday is (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday);
package day_io is new Ada.Text_io.enumeration_io(weekday);

function is_leap_year(y : Natural) return Boolean is
begin
return (y mod 4 = 0 and y mod 100 /= 0) or y mod 400 = 0;
end is_leap_year;

function length(m: Month; y: Integer) return Integer is
begin
if m = February then
if is_leap_year(y) then
return 29;
else
return 28;
end if;
elsif m in September | April | June | November then
return 30;
else
return 31;
end if;
end length;

-- returns the weekday of the last day of the month
procedure print_month(m : Month; y : Natural; day : in out Weekday) is
mon_len : Integer range 28 .. 31 := length(m, y);
begin
Put_Line(Month'image(m));
for b in Weekday range sunday .. day loop
if b < day then
Put(" ");
end if;
end loop;

for date in Positive range 1 .. mon_len loop
Put(date, 3);
if day = Saturday then
Put_Line("");
end if;
day := (if day = Weekday'last then Weekday'first else Weekday'succ(day));
end loop;
Put_Line("");
Put_Line("");
end print_month;

y : Natural;
startday : Weekday;
begin
Put("Enter year: "); Get(y);
Put("Enter first day of week: "); day_io.Get(startday);

for m in Month loop
print_month(m, y, startday);
end loop;
end cal;


is there a way I can include
Sun, Mon, Tues, Wed, Thurs, Fri, Sat, Su, M, Tu, W, Th, F, Sa
in the Weekday type but have it so that
Sunday = Sun = Su
? Does that even make sense?
>>
>>57373777
Erlang.

Seriously, it's a pretty cool niche language that's been slowly growing since things have been moving from dedicated servers onto the cloud. Being able to dynamically scale up and down as needed is pretty desirable these days.
>>
>>57373855
Why, does ada not have constants or macros or something?
>>
>>57373813
I've played around with haskell a bit but don't see much practical use for it.

>>57373826
Yeah, not learning Ruby. Isn't rails even slower than django?

>>57373797
I've been considering that, I probably will do that. I know react is a good choice for the front-end but what fw to learn for the backend? Just express?

>>57373860
Interesting suggestion, I'll look into erlang. I think I have a book for it somewhere...

>>57373855
ew, what language is this?
>>
>>57373794
Im pretty new to this, can you show me some psuedo code on how this should work.
>>
>>57373688

wow, Beej still updates this guide? Beej was a great starting point 20 years ago!
>>
File: vomit.jpg (90KB, 650x650px) Image search: [Google]
vomit.jpg
90KB, 650x650px
>>57373855
>Ada
>>
>>57373877
>I've played around with haskell a bit but don't see much practical use for it.
It's a general purpose programming language
>>
>>57373688
Seems like a great book

I've been loking for c# socket programming book but there aren't any, i guess i'll have to learn c
>>
>>57373855
>
if day = Saturday then

should probably be
if day = Weekday'last then


>>57373893
>>57373877
fuck right off
>>
>>57373893
shit taste
>>
>>57373878
Instead of:
for link in soup.findAll('a'):


Try:
tbl = soup.find('table', _class='maintable')
for link in tbl.findAll('a'):
>>
>>57373653
Putting the cheeky bantz aside, we used this book
>>
>>57373865
constants yes, macros no
>>
>>57373897
fair enough. To be honest, I only spent a few hours messing with it. I'll delve a bit deeper.
>>
>>57373918
Ahh, thanks, ill try that.
>>
>>57373932
then why can you not just do
Sun = Sunday
>>
>>57373911
>>57373914
Ada is the most retarded mastubatory shit I've ever seen.
>>
Recoverable errors should not halt or interrupt execution, but should also not be entirely transparent to the user. At the same time, deeper parts of the code should not have direct access to stdio, so how do i communicate a recoverable error to the user?
What are some good strategies?
>>
>>57373947
You can
Sun: constant Weekday := Sunday;

I assume they just didn't think/know of that.
>>
>>57373957
log file
>>
>>57373950
C was a mistake
>>
>>57373919
http://www.nylxs.com/docs/cmpnet.pdf
>>
>>57373957
WriterT log (ExceptT exception IO) value
>>
Is lua a good language for game scripts?

Is it better to live in PA or NJ if you wanna write code?
>>
>>57373971
Whatever helps you sleep at night, mate.
>>
>>57373966
This assumes the user habitually reads the log file.
>>
>>57373963
>>57373947
that's not a part of the type though and the main reason I want this is for that
day_io.Get(startday);
bit.
>>
>>57373855
Your indentation makes me upset. Also, the length function should return a subtype range 1..31, not an integer.
>>
>>57373992
>is it better to live in PA or NJ
what kind of question is that? Just live where the work you want to do is.
>>
>>57373972
will that tell me how to make mmorpgs?
>>
Why libraries need to be this leaky?

Direct leak of 152 byte(s) in 2 object(s) allocated from:
#0 0x4086a9 (/home/anon/Workspace/5/main+0x4086a9)
#1 0x7f80e4515b6c (/usr/lib/libX11.so.6+0x54b6c)

Direct leak of 72 byte(s) in 1 object(s) allocated from:
#0 0x40850e (/home/anon/Workspace/5/main+0x40850e)
#1 0x7f80e4552f40 (/usr/lib/libX11.so.6+0x91f40)

Direct leak of 1 byte(s) in 1 object(s) allocated from:
#0 0x40802f (/home/anon/Workspace/5/main+0x40802f)
#1 0x7f80e451f554 (/usr/lib/libX11.so.6+0x5e554)

Indirect leak of 1520 byte(s) in 19 object(s) allocated from:
#0 0x40850e (/home/anon/Workspace/5/main+0x40850e)
#1 0x7f80e4515b3e (/usr/lib/libX11.so.6+0x54b3e)

Indirect leak of 128 byte(s) in 16 object(s) allocated from:
#0 0x40802f (/home/anon/Workspace/5/main+0x40802f)
#1 0x7f80e45165bd (/usr/lib/libX11.so.6+0x555bd)

Indirect leak of 80 byte(s) in 3 object(s) allocated from:
#0 0x4086a9 (/home/anon/Workspace/5/main+0x4086a9)
#1 0x7f80e4516500 (/usr/lib/libX11.so.6+0x55500)
>>
>>57374022
No, I mean which state is it easier to write code in. Like it's better to use something like sublime instead of notepad.
>>
>>57374014
I was using tabs and 4chan mangled them :(
not like this, right?
function length(m: Month; y: Natural) return Natural range (28 .. 31) is


>cal.adb:15:58: constraint not allowed here
>>
>>57374054
>Expecting X to be anything but a slowly derailing trainwreck
Can't wait for WAYLAND
>>
>>57374075
not happening for another decade or two
>>
>>57374075
>Can't wait for WAYLAND
That still hasn't been released? Wayland confirmed for vaporware.
>>
>>57374061
??? is there something I'm missing
>>
>>57373891
he does still update the guide. i personally find the guide to be a fantastic starting point even in 2016. it leaves you with a solid understanding of the systems api (specifically for posix/linux). some of his updates have included addendums for windows.

basically, i see beej's guide as a great point to work down from. in my own progression, i used beej's guide to wet my feet and then learned a lot from university (courses, projects, free time to explore).

in 3 of my courses, i had projects that required dealing with the OSI stack directly. this included going as far as implementing a TCP/IP stack and a limited HTTP implementation on top of that.

this progression worked well for me, so that's what i recommend
>>
>>57374064
You have to declare a new type. Then your mon_len will also be that type. This will actually make you program more efficient, since the program won't have to implicitly check the assignment when the length function returns.
>>
>>57374022
Man child with no responsibilities detected
>>
>>57374038

Yes, that's chapter 2.
>>
>>57374111
Wayland has been out for fucking ages.
It's the compositors that still need to catch up.
>>
>>57370815
sorry i'm just learning how to code. I'm very bad but I try and I'm learning by doing exercises atm.

Just found some more to day this one was rather easy -

Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5,
between 2000 and 3200 (both included).

   1 def find():
2 list_numbers = []
3 for i in range(2000, 3201):
4 if i % 7 == 0:
5 if i % 5 == 0:
6 continue
7 else:
8 list_numbers.append(i)
9
10
11 for i in list_numbers:
12 if i % 5 == 0:
13 print('error')

>>
>>57373992
lua is popular as a game (UI) scripting language primarilly because it can be embedded nicely. small interpreter with high flexibility
>>
>>57374122
True, but that poster is clearly considering moving somewhere else so is probably in a similar situation.
>>
>>57373918
Another question, why the underscore before class?
>>
>>57374136
>(UI)

what did you mean by this
>>
>>57374154
User Interface

You're pretty dumb anon
>>
>>57374153
because class is a reserved keyword in Python so it couldn't be used as a named parameter so the devs decided to use _class instead (this is basically searching for an element with class="maintable" in HTML)
>>
>>57374161
really nigga now
i didn't mean what UI means
I meant why'd you mention UI like that even though Lua is used much beyond that
>>
>>57374179
he said what its most common usage was.
>>
>>57374179
>i was just pretending
sure you were
>>
>>57374165
oh ok
>>
>>57374165
actually, that wasn't working, so rather then:
tbl = soup.find('table', _class='maintable')


I did:
tbl = soup.find('table', {'class': 'maintable'})


and it worked. Still thanks though.
>>
>>57374238
probably a change in some recent-ish version, it's been a while since I used BS
>>
>>57374154
i assumed that you were alluding to how lua is used for addon type work (ie: wow, wildstar, etc.).

the reason i said "UI" is because i didn't want to discuss internal scripting within the game company. for example, blizzard does use lua for a lot of scripting, internally, on top of their core game for things like boss fights, quests, etc.

a lua interpreter comes packaged in games like wow to allow users to create UI addons. the reason lua is a good choice for that is because of the small interpreter and language flexibility.

my main point, i guess, is that your original question was too ambiguous to not make the "UI" distinction.

>game scripts
that doesn't differentiate between the scripting of game functions and UI scripting as a post-release feature.

if you can clarify what you mean by "game scripts" i can be more clear about what i'm saying
>>
>>57374117

That's great. He got me on the fast track to building net protocols right out of college. He really taught me 90% of what I needed to know to be very functional working with TCP and UDP.
>>
>>57374136
>>57374154
>>57374255
i'm the person you replied to originally. i wasn't the one calling you dumb :P
>>
>>57374283
:P
>>
>>57374283
:P
>>
question about OOP

If I have a parent class (Attribute) and make other classes that derive from it (NumberAttribute) and have an unrelated class store a list of Attribute, is there a way to write a method in the unrelated class that returns the specific type of Attribute from the list of generic attributes? I'm using c# if that makes a difference

so for example

abstract class Attribute {
//defines stuff
}

class NumberAttribute : Attribute {
//implements stuff
}

class UnrelatedClass {
List<Attribute> attributes;
?? GetAttribute() {
//how do I return the specific type of attribute?
}
}
>>
>>57374289
>>57374316
XD
>>
>>57374320
OOP is retarded and should be avoided
>>
>>57374330
>>57374335
:^)
>>
>>57374335
that doesn't answer my question thoough
>>
File: paste2.webm (585KB, 694x427px) Image search: [Google]
paste2.webm
585KB, 694x427px
>>57374253
The program works perfect now, thanks. Any ideas on how I can make it more aesthetically pleasing?
>>
>>57374383
the answer is don't even try
>>
>>57370734
>So you should consider the following factors:

> the job market for the language
> the long term prospects for the language
> how easy the language is to learn
> what projects you can build while you’re learning (and share with friends so you can stay motivated)

Yeah, who cares about the language actually being good, fun, safe, fast etc.
>>
>>57374391
>the answer is don't even try
This is like, basement dweller 101.
>>57374320
Don't come on /g asking about oop unless you are prepared to just get shit on.
>>
>>57374320
You mean downcasting? Just cast to it?

Note, use of downcasts usually suggests code design/architecture issues.
>>
>>57374346
>>57370032
^___^
>>
>>57374423
>code design/architecture issues
such as oop
>>
File: test.png (47KB, 767x357px) Image search: [Google]
test.png
47KB, 767x357px
>>57374388
maybe install pygments and pipe the paste contents through pygmentize -O style=monokai -f console256 -g, so it will give you syntax-highlighted entries like pic related
>>
File: retardation.jpg (3KB, 100x100px) Image search: [Google]
retardation.jpg
3KB, 100x100px
>>57370734
Kill this faggot asap.

>Teaching Javascript to kids is worse than rape
>>
>>57374536

new
>>
>>57374320
RTTI.

That said, you should think about whether you really need to know the concrete type of each element. There's already a way of doing different things depending on the concrete class and it's called method overriding. That, or don't cram everything into one list under one superclass if you can help it.
>>
>>57374320
You can do it with refection.
But that's usually poor form. If you need to know the type you shouldn't be using subtype polymorphism (the point of it is to be able to not care about the specific subtype), Attribute should be a concrete class with say an enum or something.
>>
>>57369926
>>57370646
Late to the party but the only thing you need to do is make sure your script is executable (chmod +x script.sh) and make sure it has a shebang (#!/bin/sh at the very beginning of the file). Then you can just create your shortcut by using its absolute path (e.g. /home/user/scripts/script.sh).
>>
>>57374320
This should work:
T[] GetAttribute<T>() {
return attributes.OfType(x is typeof(T)).ToArray();
}

Where you'd call
NumberAttribute[] na = GetAttribute<NumberAttribute>()


God bless C# method templates.
>>
>>57374815
Actually that's the syntax for where. You'd want
attributes.OfType<T>().ToArray();
>>
Is JavaScript my only option for web app frontends that run in a browser?
>>
>>57374984
WASM will save us all.
>>
>>57374994
Waiting 5 years isn't an option
>>
>>57375005
Just write a WASM interpreter in Javascript.
>>
>>57374536
new
>>
>>57370867
Does this work on a non simple shape?
>>
>>57374984
> Is JavaScript my only option for web app frontends that run in a browser?
Yes. You can compile other languages to JS, or you can write an interpreter for some other language in JS, but JS is the only language you can expect to be supported by every browser.
>>
>>57374136
Also, Lua supports full coroutines, which is really useful for scripting entity behaviour.
Thread posts: 330
Thread images: 41


[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.