[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: 314
Thread images: 34

File: dpt.png (200KB, 448x648px) Image search: [Google]
dpt.png
200KB, 448x648px
Old thread: >>61239343

What are you working on, /g/?
>>
>>61246538
First for Scheme
>>
first for i'll never pass a technical interview and i should go fuck myself
>>
>>61246538
That picture is not okay OP.
You need leave and delete this thread.
>>
first for it doesn't count i was second cause my countdown was running but i still wrote the message first fuck you >>61246558
>>
>>61246538
Delid this pic
>>
>>61246571
>deleting a thread
newfag
>>
>How to hack a plane for dummies
>>
Should I start with Learn You A Haskell or the Wikibook?
>>
DELIT!
>>
>>61246590
Wikibook

or both
>>
>>61246571
>>61246577
>>61246592
>hating on anime
>>>/plebbit/
>>
>>61246576
>second
fourth

>>61246590
Wikibook's have always been shit in my experience
>>
>>61246609
That's not anime. That's western muslim propaganda.
>>
File: 9c0.jpg (43KB, 600x480px) Image search: [Google]
9c0.jpg
43KB, 600x480px
https://marketplace.visualstudio.com/items?itemName=kbuchi.ClaudiaIDE
>>
>>61246622
What's so bad about Islam?
>>
>>61246622
What's so bad about Muslims?
>>
Fun fact: a Hijab was worn to prevent head lice. This way you didn't have to shave your head like the Egyptians did.
Now it's a symbol of oppression.
>>
>>61246622
So?
>>
>>61246622
Fuck off, you Islamophobe!
>>
>>61246677
>>61246660
>>61246657
>>61246656
>>>/pol/
>>
>>61246687
/pol/ hates moslems, newfag
>>
>>61246696
Discussion of muslims is completely off topic. I really wish /g/ was text only.
>>
>>61246620
>Wikibook's have always been shit in my experience
I feel like the wording is inconsistent. I guess that's because it's a collaborative effort.
What resource would you recommend to a beginner?
>>
>>61246696
This. /g/ is tolerant.

>>61246704
Then stop whining about a goddamn pic!
>>
i found an image ripping program (in python...) but bumped into a problem. to be exact, this part:
 # Extract needed info from JSON
image_url = json_dict["image"]
image_file_ext = json_dict["original_format"]
image_height = json_dict["height"]
image_width = json_dict["width"]
# Build image output filenames
if settings.output_long_filenames:
# Grab the filename from the url by throwing away everything before the last forwardslash
image_filename_crop_regex = """.+\/(.+)"""
image_filename_search = re.search(image_filename_crop_regex, image_url, re.IGNORECASE|re.DOTALL)
image_filename = image_filename_search.group(1)
image_output_filename = image_filename+"."+image_file_ext
else:
image_output_filename = submission_id+"."+image_file_ext
image_output_path = os.path.join(output_folder,image_output_filename)
# Load image data
authenticated_image_url = image_url+"?key="+settings.api_key
logging.debug("Loading submission image. Height:"+repr(image_height)+", Width:"+repr(image_width)+", URL: "+repr(authenticated_image_url))
image_data = get(authenticated_image_url)
if not image_data:
return
# Image should always be bigger than this, if it isn't we got a bad file
if len(image_data) < 100:
logging.error("Image data was too small! "+repr(image_data))
continue
# Save image
save_file(image_output_path, image_data, True)

as you can see it creates files with double extensions. but that's fine, nothing that total commander can't take care of. but why the hell does it create a link like "asdf.png.svg" to download but still grabs png instead of svg when the very same url ending in "png.svg" makes my browser grab svg?
>>
>>61246709
>This. /g/ is tolerant.
No it isn't. Back to pol faggot.
>>
File: 1474095504564.jpg (24KB, 600x451px) Image search: [Google]
1474095504564.jpg
24KB, 600x451px
C# is the best programming language. Prove me wrong.
>>
>>61246726
I literally can't
>>
>>61246726
Microsoft did their best to cripple the ecosystem on Linux.
>>
>>61246726
OOP
based on java
>>
>>61246620
>fourth
fourth AND second
>>
>>61246743
>OOP
t. functional memester
>based on java
It's miles better than Java
>>
>>61246726
Syntax sugar was not the thing Java was missing.
>>
>>61246726
>C# was made by the jews
/pol/ is always right
>>
>>61246708
Depends on the subject. If you want to learn Haskell, I'd recommend looking at some Haskell source code.
>>
>>61246767
>i learn languages by just reading source code
>i also dream in code
>XDDD
>>
File: 1492739086282.jpg (49KB, 310x236px) Image search: [Google]
1492739086282.jpg
49KB, 310x236px
>>61246538
>Want to do a mobile app project which involves someone else's databases
>Their database schema sucks so much I am having a hard time even starting
>>
>>61246708
The Haskell wikibook is good
>>
>>61246726
>restrictive language
>>
>>61246562
>technical interview
>important
They just want to fill positions, that's all. Tell yourself, they would even hire a goldfish if they could.
>>
Looking for help with this, please
>>61245643
>>61245677
>>
>>61246786
What is that even supposed to mean?
>>
>>61246804
you have to do very specific things otherwise you'll get bitchslapped by compiler
>>
>>61246802
Flexbox
>>
>>61246776
Once you know the bare basics of a language's syntax, the best way to learn is to study (and I do mean study) some working examples of software written with that language.
>>
File: 1495588230171.gif (1MB, 720x720px) Image search: [Google]
1495588230171.gif
1MB, 720x720px
If I want to create GUI scripts for my team at a non-programming office job and I need to distribute them with minimal dependencies should I make them in Java or C#?
>>
>>61246826
I'll take a look at that, thanks. Does the problem come from the CSS then? I was worried I fucked up with JS.
>>
>>61246767
i don't like that approach. I did something similar with C++ and learned myself some inane anti patterns.
I
>>
>>61246820
Can you give me an example? That's usually done to enforce good practices and write safer code.
>>
>>61246838
Neither, Visual Basic
>>
Rewriting C in HTML.
>>
>>61246784
I think I'll go on with that.
>>
>>61246867
ask if you have questions
>>
>>61246643
>Anon what do you have open?
>Just VS, I'm adding [feature]
>...why is that lady there?
>N-no reason
>>
>>61246848
Well C++ is no ordinary language. C++ is probably the worst language to learn by example, because so many people mix legacy C++ code with modern C++ code, and don't understand modern C++ idioms.
>>
>>61246838
Just use AutoIt
>>
>>61246538
>pedophile mohammed's bride
take that shit back to /pol/, you sick asshole.
>>
>>61246879
I'll certainly do that. I've seen lots of kind anons here helping out newbies like myself. haasn for instance is one of them.
>>
>>61246538
I demand a non-terrorist, non-troll thread. this one is not ok!
>>
>>61246884
>>61246643
>5*
>>
>>61246895
b-b-but C is the language of humility and simplicity!
>>
>>61246852
well for example you must objectify everything even though there's often absolutely no need to
>>
>>61246945
*everything* in C# is an object, it doesnt mix primitives and object-everything like Java does.
So idk what you're talking about
>>
>>61246924
fuck off terrorist piece of shit.
>>
>>61246908
>seiba avatar
based
>>
>>61246972
Making a class the fundamental unit of code is the good example. Everything is seen through the lens of OOP.
>>
>>61246972
besides C# is very windows only
>>
>>61246994
you misspelled rin
>>
>>61246687
>>>/r/islam/
4chan is a white nationalist board and if you don't like it you can fuck off back to 9gag
>>
>>61247020
.NET is cross-platform and open sourced, it's just not widely adopted beyond windows currently.
>>
>>61247030
.NET Core is cross-platform and open sourced, .NET is not
>>
>>61246726
http://www.curly-brace.com/favorite.html
>>
File: oop in brief.png (152KB, 1948x858px) Image search: [Google]
oop in brief.png
152KB, 1948x858px
>>61247027
>defending white trash
I guess you also think Indians are mustard race because Aryans come from there.
>>
>>61247053
That's because .NET core is .NET without the windows-specific shit, which would make no sense to be available cross-platform.
It's otherwise the exact same thing, provided you're writing your programs in a modern fashion.
>>
>>61246860

Looks very interesting. Thanks.

>>61246893

I've already committed to using AutoHotKey on other projects, even if the language looks like shit so I'll rather learn something with more use cases.
>>
>>61247070
>pic
it's funny because it's true. i remember my fist lessons on OOP and teacher showing something on the left and convincing us how wonderful it is
2 hours later nobody really knew what the fuck is happening
>>
File: double compile!.jpg (20KB, 400x300px) Image search: [Google]
double compile!.jpg
20KB, 400x300px
>>61247027
Sorry buddy, but 4chan is a weeb nationalist board, and this is the programming thread of the technology arm

Please come back with an argument
>>
>>61246717
anyone?
>>
>>61247147
Log every step and see what happens.
I don't feel like plowing through the mess.
>>
>>61247208
how do you do that in python?
>>
File: 435.jpg (105KB, 717x880px) Image search: [Google]
435.jpg
105KB, 717x880px
>>61247027
>this is what Reddit actually believes
>>
>>61247243
print(image_url)
>>
>>61247243
https://docs.python.org/2/library/pdb.html
or litter your code with print statements
>>
File: trololol.png (23KB, 892x223px) Image search: [Google]
trololol.png
23KB, 892x223px
Hello guys,
this is a guide on how 2 solve a project euler problem with bloat.
First of you gotta calculate all needed primes with the worst algorithm ever.
Then you just have to do all that other shit with just pure bloat.
Looks like this then:
#include <stdio.h>
#include <math.h>

#define LIMIT 1000000

int primes[LIMIT] = {0};
int count = 0;

int is_prime(int n);
void get_primes();
int is_circular_prime(int n);
int pow_10(int);

int main()
{
get_primes();
int circular_count = 0;
for(int i=0; i < count; i++) {
if(is_circular_prime(primes[i])) {
circular_count++;
printf("circular: %d\n", primes[i]);
}
}

printf("count: %d\n", circular_count);
}

int is_prime(int n)
{
if(n <= 1)
return 0;
else if(n <= 3)
return 1;
else if((n%2 == 0 ) || (n%3 == 0))
return 0;
long long i = 5;
while(i*i <= n)
{
if((n%i == 0) || (n%(i+2) == 0))
return 0;
i += 6;
}
return 1;
}

void get_primes()
{
for(int i = 1; i < LIMIT; i++) {
if(is_prime(i)) {
primes[count++] = i;
}
}
}

int is_circular_prime(int n)
{
int places = (int)(log10(n)+1);
int fact = pow_10(places);

for(int i=0; i < places; i++) {
int tmp = (n%fact)*10;
n = (n/fact) + tmp;
int is_prime = 0;
for(int j=0; j < count; j++) {
if(n == primes[j]) {
is_prime = 1;
break;
}
}
if(!is_prime) return 0;
}
return 1;
}

int pow_10(int exp)
{
int erg = 1;
for(int i = 0; i < exp-1; i++)
{
erg *= 10;
}
return erg;
}
>>
>>61247276
>>61247287
well, okay
>>
>>61247296
holy shit, I just executed that on the first raspberry pi
pi@raspberrypi:~/projecteuler $ time ./a.out 
count: 55

real 6m33.260s
user 6m25.740s
sys 0m0.180s
>>
Stop posting muslims in a blue board
>>
>>61247412
On my computer.
count: 55

real 0m2.307s
user 0m2.305s
sys 0m0.001s
>>
>>61247421
First of all, how can you be sure someone is muslim??? Western women had headscarves until the middle of the 20th century. For all I know, OP image is an anime grill with a somehow traditional oriental outfit.
>>
>>61247495
yeah. Takes about 14 on mine. Still way too fucking long.
Gotta write myself some utils library for project euler. For like generating primes below X (properly) and all that shit what is needed every once in a while
>>
>>61247276
>>61247287
you could warn me about "IndentationError: unexpected indent" you know...either it doesn't build or builds but program crashes
>>
>>61247561
>this entitlement
do you even know python?
>>
>>61247598
if i did, i wouldn't be asking
>>
>>61247608
Well go learn the bare bones of python before you try to debug a python program
>>
>>61247545
Research on prime numbers really is in shambles and since the AKS primality test, there hasn't been much improvement in the domain. There's no general form of the prime numbers found yet (and there's no proof there isn't one) and their distribution relies on Riemann's hypothesis, which is still on hold as of today...
>>
>>61247561
It's your shit, not mine.
>>
>>61247545
Implement a sieve two ways
One as a bit array
The other as a byte array

I'd like to see timing trade-offs of the cache thrashing caused by the byte array, and the additional steps required to mark bits in a bit array.

Remember your 2, 3, 5 wheel factoring!
>>
File: 1498435585165.png (180KB, 1304x641px) Image search: [Google]
1498435585165.png
180KB, 1304x641px
>>61246643
Been using it for months now, it's pretty neat
>>
File: p36.png (25KB, 724x200px) Image search: [Google]
p36.png
25KB, 724x200px
>>61247754
Won't do that one today, m8. That's a task for sometime later when problems get more heavy
Just solved one more problem and going to sleep now.
This one was quite easy.
runs in 0.02s on muh desktop and 0.6s on muh raspberry
#include <stdio.h>

#define LIMIT 1000000

int is_palindrome_dec(int z);
int reverse_number(int n);
void to_bin(int n);
int is_palindrome_bin();

char bin_num[1000];
char bin_len = 0;

int main()
{
int sum = 0;
to_bin(1);
printf("%d\n", is_palindrome_dec(1));
printf("%d\n", is_palindrome_bin());
for(int i = 1; i < LIMIT; i++) {
if(is_palindrome_dec(i)) {
to_bin(i);
if(is_palindrome_bin()) {
printf("new palindrome: %d; ", i);
for(int j = 0; j < bin_len; j++) {
printf("%d", bin_num[j]);
}
printf("\n");
sum += i;
}
}
}

printf("sum: %d\n", sum);
return 0;
}

int is_palindrome_dec(int z)
{
if(z == reverse_number(z)) {
return 1;
}
return 0;
}

int reverse_number(int n)
{
int num = n;
int rev = 0;
int dig;

while(num > 0) {
dig = num % 10;
rev = rev * 10 + dig;
num = num / 10;
}

return rev;
}

void to_bin(int n)
{
bin_len = 0;
int rem = 0;

while(n > 0) {
rem = n%2;
n /= 2;
bin_num[bin_len++] = rem;
}
}

int is_palindrome_bin()
{
int a = 0;
int b = bin_len-1;

//if(bin_num[0] == 0) return 0;

while((b - a) > 0) {
if(bin_num[a++] != bin_num[b--])
return 0;
}
return 1;
}
>>
If bash is released under GPLv3, do I have to license my bash scripts under GPLv3 too?
>>
>first test 9,7
>second test 4,3

I barely passed... I thought I'd do better than that. What should I do to relax?
>>
>>61246838
use python and then pyinstaller, will package everything in a no-dependency package with .exe or whatever you need
>>
>>61248136
afaik you dont HAVE to license anything, but I guess it depends on how far you will distribute it
>>
Can you learn programming w/o a degree and get a job? I've been interested in it but I can't stand the school setting. I'd rather just learn and move at my own pace. If the answer to my main question is yes, anyone have any resources to start me in the right place?
>>
>>61248383
No because HR sucks
>>
Java tutorials that are a quick skim?

I just need to relearn it after not using it in so long. but I have an interview coming up
>>
File: old_hag_langs.png (173KB, 600x355px) Image search: [Google]
old_hag_langs.png
173KB, 600x355px
>>61246726
It's not C.
>>61247296
Is converting to string more efficient than taking logs?
>>
A good c++ library for splitting pdf files?
>>
>>61248383
Best programmers i've ever met where self taught, granted they spent most of their youth on it, if you're already old you can learn just fine but getting hired with no experience or qualifications is a whole different thing
>>
>>61248435
Is almost 20 considered old?
>>
>>61248505
after 20 you're old, optimally you want to start at 12-14 years old.
>>
>>61248505
lmao
>>
>>61246916

Muslims can't enjoy programming>
>>
>>61248526
Fucking rip me then. I already have some programming experience but it's super basic C++.
>>
>>61248505
If you manage to learn AND have a few open source projects with decent usage you could probably get yourself hired

My suggestion would be go to trade school instead
>>
>>61248601
I mean, you can still program.

But if you're attempting to find a job without a formal education you do need work experience. I'm a highschool dropout who spent his entire teenage years learning his professional trade and entered the workforce at 16 doing computer repairs. My resume simply does not include an education section at all. I've only had one job interview that I couldn't get on the grounds that I didn't have a degree, which funny enough, I had already worked for that company as a contractor and I was applying for a similar position in a different department years later.

No one but HR cares.
>>
>>61247754
My bitsive in Python is ~2.5 slower than a char array, but for 8 times less memory usage. I would assume this performance penalty is true for all languages, because as far as I know, you can't set multiple bits at once efficiently, as your bit array being either 64 or 32 bit means you still have to access multiple indices through each loop, e.g. 101 -> bitarray_64bit[index>>6] = set_bit, then bitarray_64bit[(index+101)>>6)] = set_bit, and so on. So in a regular byte sieve, you set the bit once, then move on, while with a bit array you have to index, offset, and then mask, and since primes quickly increment in steps larger then your bit size, you have to access and set individually.
>>
I'm having a look at Nim
>>
File: 32412524152341.gif (613KB, 498x498px) Image search: [Google]
32412524152341.gif
613KB, 498x498px
How do we kill the python?
>>
>>61248762
>>61246272
>>
File: xsquared.png (9KB, 500x313px) Image search: [Google]
xsquared.png
9KB, 500x313px
is there anyone that actually uses mathematica here or you just spread your forced language memes?

Range[1, 20]
#^2 & /@ %
Table[{%%[[i]], %[[i]]}, {i, 1, 20}]
ListPlot[%, PlotMarkers -> {"\[Wolf]", 20}]

Export["C:\\Users\\SteveJobs\\Desktop\\xsquared.png", %,
ImageResolution -> 100]
>>
>>61248799
You do realize that was a shitty argument, right?
>>
>>61248766
rewrite tensorflow in haskell
>>
File: smug_ran6.jpg (114KB, 802x1240px) Image search: [Google]
smug_ran6.jpg
114KB, 802x1240px
>>61248800
<< KnotTheory`
>>
>>61248836
But what does that have to do with python specifically? It's written in C++ anyway.
>>
File: -----.jpg (61KB, 675x1200px) Image search: [Google]
-----.jpg
61KB, 675x1200px
Anyone know how to check the type of a value of a Listbox object in c# forms?

Right now I have a Listbox, with a list of items of <string, server>. I want to get some input validation whenever the Lbox index is changed to make sure that the item Ive selected has a value of "server"(custom class).

This is annoying me.
>>
>>61248838
>KnotTheory

based anon
>>
>>61248800

I remember one case where I was in a Math class and the professor was showing us how to use either Mathematica or Matlab (can't remember which, it was a while ago) to solve a particular problem. I took one look at the syntax and asked him if it would be acceptable to use a different language for my assignments if I could find an equivalent library. He approved and I used Python.

I think Python and sometimes R have been my go-to languages for very math-heavy tasks.
>>
Okay so problem is people don't want to install but they still need to do stuff. So the easiest way for them to do the stuff is with browser on some shitty website.
There needs to be better platform for this, something that doesn't require http + html renderer + js engine for eveyrthing but would let you provide minimal applications easily.
How would you go about designing this kind of platform that basically is combination of sandboxed program runner in clients machine, protocol and server hosting the executable.
>>
>>61248854
python is only used because academic libs are written in it
>>
>>61248762
Id like to see more nim benchmarks in various things.
Seems like a ruse.
>>
>>61248896
That's my gripe. Are there not alternatives in c++?
>>
>>61248930
c++ is not used because its not garbage collected
>>
File: 1490568756286.jpg (36KB, 1000x607px) Image search: [Google]
1490568756286.jpg
36KB, 1000x607px
>finally got an interview
>they write in java
>>
>>61248954
I can't tell if you're memeing or not
>>
File: SussmanAbelsonBTFO.png (7KB, 1024x768px) Image search: [Google]
SussmanAbelsonBTFO.png
7KB, 1024x768px
>>61248762
Should have used memoize from std.functional
>>
>>61248984
that and its awful syntax
lack of functional support
c++ will never replace python and vice versa
>>
>>61248859

Must be Matlab since it's very close to python in terms of syntax but a bit outdated, mathematica diverges from python imo and is considered the goto language for mathematicians and physicists, unfortunately many computer scientists neglect it because they lack mathematical background.
>>
>>61248954

Academics write plenty of C++. They're just all really bad at it.
>>
>>61249018
>gc
Memory management being ANY kind of burden is just such a stupidly retarded meme.
>syntax
It's got the prettiest syntax of them all.
>lack of functional support
Objectively False. And it doesn't matter anyway, it's another stupid meme.
>>
>>61249026

Right. What benefit would I get from using the proprietary Mathematica over Python or R anyways? Both seem to have some pretty well-supported libraries for math and data science and such.
>>
>>61249063
>Memory management being ANY kind of burden is just such a stupidly retarded meme.
It is, unless you have RAII.
>>
File: 9128391823112.jpg (27KB, 479x313px) Image search: [Google]
9128391823112.jpg
27KB, 479x313px
>>61249072
>talking about c++ in the first place
>unless you have RAII
>>
I started working on a little space shooter thing this morning. I'll probably get it a little bit more finished up and post it on itch.io tonight.
>>
File: Hostel1-jumbo.jpg (166KB, 1024x683px) Image search: [Google]
Hostel1-jumbo.jpg
166KB, 1024x683px
>>61248383
no because there will always be a pajeet who's better than you and who works for less.

Take a degree or they won't even read your CV
>>
File: pic_kawaii_linux.jpg (33KB, 506x600px) Image search: [Google]
pic_kawaii_linux.jpg
33KB, 506x600px
>>61246538
Someone create a new /dpt/ thread.
And do it properly this time!
>>
>>61246590
Haskell from first principles. There's a pdf floating around.
>>
>>61249156
>developing shitty videogames
>itch.io
>>>/v/
>>
>>61249204
Looks like more than 99% of posters here can do.
>hurr i did an interview algo question! im smert!
>>
I made this function for printing the contents of an two-dimensional int array:
void
PrintArray_SingleForLoop(int a[NUM_ROWS][NUM_COLS]) {
int * p;
int counter = 0;

puts("Array contains the numbers:");
for (p = &a[0][0]; p <= &a[NUM_ROWS - 1][NUM_COLS - 1]; p++) {
printf("%d", *p);
++counter;

if (counter == NUM_COLS) {
counter = 0;
printf("\n");
} else {
printf("\t");
}
}

puts("");
}
>>
>>61249270
This doesn't do what you think it does.
>>
>>61249246
everyone can do shitty games in Unity you shill
they don't post them cause they know it's ridiculous, you did it and face the consequences
>>
I made this Haskell function to calculate a graph width:
(&)=elem
l=length
t n g s=last$minimum[max(t n g b)$t(n++b)g$s\\b|b<-filterM(\_->[0>1,1>0])s,l b==div(l s)2]:[l[d|d<-fst g,not$d&n,d/=s!!0,(d&)$foldr(\x y->last$y:[x++y|any(&y)x])[s!!0]$join(>>)[e|e<-snd g,all(&(s!!0:d:n))e]]|1==l s]
w=t[]<*>fst

jk, copied it from sc
>>
>fall for the Nim meme thinking it was a rigged benchmark
>
operation successful (10846 lines compiled; 0.328 sec total; 14.348MiB peakmem; Release Build) [SuccessX]


Literally how did they manage this
>>
>>61249284
It produces this output:
Array contains the numbers:
11 12 13 14
21 22 23 24
31 32 33 34
>>
>>61249325
what's the source
>>
>>61248257
Is there a way to get a single file exe from donig so?
>>
>>61249356
the fib
proc fibonacci(n: int): float =
if n < 2:
result = float(n)
else:
result = fibonacci(n-1) + fibonacci(n-2)

echo fibonacci(50)


fib 100 is still compiling though.
debug builds are as slow as i expected though.
>>
File: 1492204251243.jpg (104KB, 999x1037px) Image search: [Google]
1492204251243.jpg
104KB, 999x1037px
>>61248968
Welcome to the real world
>>
I just created the first demo for my online 3d lolicon game
use the arrow keys to move the character
http://freelancesharp.com/gaem/
>>
>>61249325
$ ldc2 -O4 -release app.d && cat app.d && time -p $(./app > /dev/null)
import std.bigint, std.functional, std.stdio;

void main()
{
BigInt x = 5000;
fib(x).writeln;
}

BigInt fib(BigInt n)
{
return n < 2 ? n : memoize!fib(n -2) + memoize!fib(n-1);
}
real 0.01
user 0.01
sys 0.00
>>
>>61249375
does it have a REPL?
try compiling just the proc and then calling fig yourself
>>
>>61246538
>hijab loli
I want Ahmed to leave
>>
>>61248136
no
>>
>>61249423
D fags confirmed for retarded.
>>
>>61249423
Yeah i already managed a better one in D earlier, still impressive for a young language, shame its syntax is horrid.
>>61249425
there is one but its early.
Im already turned off of Nim, but this was interesting..
>>
not sure if this belongs in /sqt/ or not, but in C, is a #define statement just a way to declare constants? I don't understand why you don't specify datatypes when doing this.
>>
>>61249465
It probably evaluates fib(100) at compile time and just compiles

echo(result)
>>
>>61249477
any line with a # in front of it is a preprocessor directive. The preprocessor makes basic text substitutions to the content of a source file before passing it to the real compiler.

A #define macro like
#define PI 3.14
literally just specifies that all instances of the symbol PI will be replaced by the number 3.14 before the file is fed to the compiler.
>>
>>61249477
#define declares a macro, which can expand to arbitrary text, but is often used to implement constants.
#define thing 7

int main()
{
int a = thing;
}

After it all goes through the C preprocessor, it'll come out as
int main()
{
int a = 7;
}

and this is what the compiler will actually see.
>>
>>61249423
>time -p $(...)
command substitution? time takes the command as an argument, not the output.
>>
>>61249477
#define is literally a shitty search and replace/text substitution
>>
>Inheritance is fundamental to object-oriented programming. A programming language may have objects and messages, but without inheritance it is not object-oriented (merely “object-based”, but still polymorphic).

How do you have polymorphism without inheritance? Do they refer to function overloading?
>>
>>61249531
>>61249537
thanks I think I get it
>>
>>61249477
This is a constant in C
const int x = 5;
>>
Suppose I'm writing a booking system.
create table flight (
id integer primary key,
num_seats integer not null
);

create table booking (
flight_id integer,
foreign key (flight_id) references flight(id)
);

I don't want to pull a United so I need to avoid overbooking.
bool make_booking(int flight_id) {
let tx = db.startTransaction();

try {
let max_seats = tx.queryOne("select num_seats from flight where id=?", flight_id).num_seats;
let current_bookings = tx.queryOne("select count(flight_id) as num_bookings from booking where flight_id=?", flight_id).num_bookings;

if (current_bookings >= max_seats) {
return false;
}

tx.exec("insert into booking (flight_id) values (?)", flight_id);
tx.commit();
return true;
} catch {
// log or whatever
tx.rollback();
return false;
}
}

Is that everything I need to consider? Is there any obscure way that an overbooking could happen with this code?
>>
>>61249572
You can have plain function pointers and lambdas I guess. I get the feeling that's not what they mean.
>>
>>61249491
Its kind of weird though, just edging it up to 55 dramatically increases the time. And actual execution time for the .exe is much longer than a second.

So Nim is a lie.
>>
>>61249588
That's not an ICE, so it can't appear in certain places.
const int x = 5;
switch (some_shit) {
case x:
do_thing();
}

Is not valid C.
There is a proposal for the next version of C which would implement "true" named language constants that will work in these sorts of situations.
>>
>>61249607
Isn't that object composition? Is that polymorphism?
>>
>>61249611
edging to 55 might be to do with arbitrary precision integers
or maybe its a compile time evaluation heuristic

here's a pretty fast haskell version

fibs = 1 : 1 : zipWith (+) fibs (tail fibs)


fibs !! 100
evaluates pretty quickly in the repl
>>
File: crash.png (22KB, 1366x741px) Image search: [Google]
crash.png
22KB, 1366x741px
u413, got the gui working with boards and stuff, was able to update some parts of the code without breaking it, will try to port it to mysql
>>
>https://sites.google.com/site/steveyegge2/five-essential-phone-screen-questions

>tfw i wouldn't pass the phone interview for amazon
>>
>>61249625
You don't need objects to have higher order functions.
>>
File: aaaa.jpg (35KB, 317x344px) Image search: [Google]
aaaa.jpg
35KB, 317x344px
How do I do, in Javascript, something like static methods in Java? I want to call a method in a class but not make an object from it. I have an Algorithms class for a project I'm doing and I just want it to crunch numbers. Unless there's a better design pattern in JS for this purpose.
>>
>>61249727
>design pattern
triggered
>>
>>61249572
Interfaces.
>>
>>61249727
Stop thinking procedurally.
http://www.yegor256.com/2014/05/05/oop-alternative-to-utility-classes.html
>>
>>61249750
Interfaces are nothing but purely abstract base classes. Just because the keyword is implements instead of extends doesn't mean it's not inheritance.
>>
>>61249743
y
>>
Rate my first Python program (a 'yes' clone).

#!/usr/bin/env python3

import sys

if len(sys.argv) > 1:
var = ' '.join(sys.argv[1:])
else:
var = 'y'

while True:
print(var)


A thing I don't get: Why does len(sys.argv) have to be greater than 1 when checking if one argument is present?
>>
>>61249776
>interfaces are a type of class
Wow, you are dumb.

Interfaces are contracts, you fucking moron. Don't talk about thinks you know nothing about.
>>
>>61249800
The first argument is always the path of the .py being executed
>>
> When would you use a linked list vs. a vector?

> Can you implement a Map with a tree? What about with a list?
>>
>>61249818
But isn't that argv[0], so ... oh. I think I get it, len counts from 1?
>>
>>61249829
>homework
>>
>>61249766
this is SUPER gay dude
>>
>>61249829
>> When would you use a linked list
Almost never.
>>
>>61249843
nah interview prep
>>
>>61249840
Yep
>>
>>61249846
Stop using the word "gay" as if it was an insult or a bad thing, you homophobe.
>>
>>61249860
ty
>>
>>61249862
gaaaay
>>
>>61249862
Shut up faggot.
>>
>>61249862
this, it's not year 1500 anymore
>>
>>61249800
Perfect. Now make a clone of gcc.
>>
>>61249829
>When would you use a linked list vs. a vector?
There are some rare situations where you need the ease of concatenating linked lists, or doing other things like making circular lists, but most of the time a dynamic array is more appropriate.
>Can you implement a Map with a tree?
A trie is a tree structure which can map strings (not just character strings) to arbitrary values. However, it has more properties than just that.
>What about with a list?
Yes, but it would probably be pretty stupid.
>>
>>61249907
linked list is gud for removing arbitrary elements easily or adding new elements at the beginning
>>
>>61249920
Even then, their locality of reference is terrible, so a dynamic array still ends up being faster.
>>
>>61249862
what a flaming homo
>>
>>61249660
> Candidates should know what bits and bytes are. They should be able to count in binary; e.g. they should be able to tell you what 2^5 or 2^10 is, in decimal. They shouldn't stare blankly at you when you ask with 2^16 is. It's a special number. They should know it.

Go fuck yourself, Steve
>>
>>61249938
Does that just hold if your array fits in only one/a few cache lines?
>>
>>61250018
No. The difference for larger arrays/lists is even more pronounced.
>>
>>61250074
That seems counterintuitive.
>>
Me: So! What data structures do we have available to us, as programmers?
Them: Arrays, queues, vectors, stacks, lists, um, linked lists...
Me: OK, any others?
Them: Um, doubly-linked lists, and, uh, array lists.
Me: Have you ever used a tree?
Them: Oh! (laughs) Yeah, um, I forgot about those.

Translation: "My family tree doesn't branch."

Probable failure modes for this candidate: Very likely to fail data structures questions. Will fail any recursive problem, even a simple one like printing the elements of a linked list recursively. Will fail the HTML-phone-number question, since they obviously haven't ever used Perl if "hash" didn't leap to mind.

-----
he got me at this one. I don't use trees and I'm shit at recursion. i kill it at scripting tho
>>
>>61250092
Memory is pretty good at being read sequentially, so iterating over an array is basically one of the best use-cases you can have.
Linked lists jump all over the place, and basically every access of a new list element leads to a cache miss.
>>
>>61248855
Without going into detail about your implementation "Listbox.SelectedItem as Server" or whatever your type pair is should give you an item of that type or null if the cast fails
>>
>>61249862
That was the gayest comment I've read so far the last couple of days, and I come from /b/ facing everyday gaylords like you.
>>
Working on writing a desktop 4chan client in rust and GTK. Is it absolute cancer? Yes, but I'm too dumb to set up the Qt bindings
>>
File: skeleton-1.jpg (14KB, 450x324px) Image search: [Google]
skeleton-1.jpg
14KB, 450x324px
>from __future__ import braces
>>
>>61250098

HTML phone number question?
>>
>>61250316

see >>61249660
>>
>>61250098
fucking brutal
>>
>>61250098
>trees not coming to mind when asked about data structures means the guy doesn't know what a directory tree or recursion are
what a bunch of smug retards
>>
>>61247027
fuck off. 4chan is an anime website, not a political one you fucking queer. /pol/ ruined this site
>>
I'm fucking sick of all these college fags who have baby duck syndrome who think Python is the shit because it is their first and only language. Guess what? Ruby is WAY better than Python.
>>
What is the best IDE?
>>
>>61250846
>Ruby vs Python
Girls vs Traps
>>
File: Untitled.png (14KB, 862x286px) Image search: [Google]
Untitled.png
14KB, 862x286px
I keep getting this error whenever I try to make my post, why?
https://ghostbin.com/paste/tp5kk

I'm obviously not banned and this is the same IP, I just can't post something in that text.
>>
>>61250900
Cloudflare has some weird phrases that it blocks and makes the post show up as a connection error.
"ls -l" is one (I double spaced it, but 4chan should replace it with one).
Maybe there is one such phrase in your post.

>in C (but under a C++ compiler)
Why the fuck would you do that?
>>
>>61250858
emacs

>>61250859
More live 2D vs 3D
>>
>>61250960
Please don't insult 2d by comparing it to awful languages like ruby or python
>>
>>61250936
Weird, I noticed the same problem the other day in a shell thread. That's annoying.

>Why the fuck would you do that?
I'm stuck with it for right now, I plan on trying to transition the whole project in to straight C when I can but for now I'm just trying to get things working, an API I'm working with relies on implementing some C++ classes but a lot of what I'm doing relies on straight C (which is why I'm not using a vector for this).
>>
>>61251001
Write what you can in C, and just link them all together.
>>
Quick question, best free ide for python? VS?

Inb4 please no notepad++

Also is there anyone that actually uses tcl? I struggle to find a good online source and the section in stackoverflow is pretty poor.
Also, any good book would be helpful.
>>
File: meme.png (50KB, 500x800px) Image search: [Google]
meme.png
50KB, 500x800px
>>
>>61251001
>>61250936
>>61250900
The phrase is
char (*)
without the space.
>>
>>61251022
I think the only difference will be the cast of malloc in this case anyway, no? I intend to do all the C stuff like that but the question is more general anyway of how it should be allocated and if it should be cast from a double pointer to an array (either 1 or 2 dimensions) or if people don't do that, I know I can do it but I don't know if that's normal to do here if I want to access indices.

>>61251039
>>61251048
>>61251053
>>61251060
>>61251062
Are you trying to figure out what triggers the filter?
>>
>>61251036
Don't use an IDE for Python, use a goddamn text editor.
Unless you do, in which case PyCharm is the only sensible option.

Also, nobody uses TCL anymore, Python has pretty much replaced it, except in maintaining old projects. If you want to learn TCL get the relevant O'Reilly book.
>>
>>61251081
C++ has a lot of differences with C, and it's best not to try to write C code for a C++ compiler. It is wise to write them separately, and link together, this will produce the least fuckery. extern "C" is your friend.
>>
>>61251079
Interesting, I wonder why. It was driving me crazy I thought someone had jacked my connection for a minute or some idiot in my city got us all range banned.
>>
>>61251081
>Are you trying to figure out what triggers the filter?
Yes, that is what I was doing. I deleted them, since I found it.
>>
>>61251036
If you really *must* use an IDE, try Pycharm. Jetbrains make solid IDEs
>>
>>61251093
I intend to migrate all the C++ code to straight C later, the question isn't about that though, it's about casting in C.
>>
>>61251116
But you said you're using a C++ compiler. Even if you're writing "C-like" C, it will still be parsed and compiled as C++.
>>
>>61249660
>all programmers should know unix
This guy can go fuck himself.
I bet he wrote this article at starbucks.
>>
>>61251216
Go home, winbabby. The adults are talking here.
>>
>>61251216
Anyone who does not understand Unix, is cursed to re-implement it
poorly
>>
>>61251134
Is that relevant to this specific question? The only difference I identified was the cast to malloc, I included the environment just to make the reader aware of it, that detail shouldn't be very important to my knowledge but that's why I'm asking.

Let me rephrase the question specifically addressing you here (although I'd still like a general answer), in C, is it typical for people to cast a **pointer to an array, or do people usually just use the regular arithmetic syntax. Same question for C++. In the event I write this for a C++ compiler, what issues would I face when porting to C?
>>
>>61251237
>adults
>special children that have never done anything outside of compsci and think everyone must mimic their One True Operating System
>>
>>61251252
Your OS should not be your library.
>>
I'm not really sure how to ask the question, but I have a bunch of loops that are almost identical, but I need to call a different function each time. Is it possible for a function to have another function as an input? or is there some other way to do it?
>>
>>61251331
It depends on what language you're talking about, but almost certainly: yes.
>>
>>61251331
Yes, this is called a higher order function and is a gateway to functional programming.
>>
>>61251341
C
>>61251353
I'll read about that, thanks for the quick replies.
>>
>>61251373
in C the syntax isn't great but it looks like this

void hofun(int len, char* arr, void (*fun) (char))

void (*fun) (char)

out_type (*identifier) (param1type, param2type)
>>
>>61251373
#include <stdio.h>

void my_fn(size_t len, int array[len], void fn(int arg)) {
for (size_t i = 0; i < len; ++i) {
fn(array[i]);
}
}

void print_int(int arg) {
printf("%d\n", arg);
}

int main() {
int array[3] = {2, 3, 5};
my_fn(3, array, print_int);
}
>>
>>61251216
Are you going to tell me that programmers don't need to know SQL next?
>>
>>61251405
It, like unix, is not as that article suggested "one of the ABCs of programming"
>>
File: 1374577328217.png (224KB, 554x439px) Image search: [Google]
1374577328217.png
224KB, 554x439px
>>61251405
I don't really know SQL. I've never been bothered to do shit with a relational database.
>>
>>61251448
Well anon over there thinks you're not a real programmer
>>
>>61251421
All the article states is that a candidate should know when use a utility such as grep rather than writing a C++ program.
>>
>>61251494
#include <regex>
>>
>>61251511
Slow garbage.
>>
File: JetBrains_Drive_to_develop[1].png (27KB, 800x320px) Image search: [Google]
JetBrains_Drive_to_develop[1].png
27KB, 800x320px
I could jerk off to their compilers all day
>>
>>61251526
>Calling an IDE a "compiler"
How was your first week programming?
>>
>>61251523
Portable.
>>
>>61251533
I swear to you I was gonna correct that but it's done, whatever you know I meant IDE, that's fine just let go
>>
>>61251526
their IDEs are breddy gud yea
>>
>>61251533
mine hasn't finished yet

how was yours dude?
>>
>>61251599
I've been programming for about 5 years and have a computer science degree.
>>
dudes, how much do nip tech companies value being fluent in japanese along with your coding skills?

do they even put that into account? I wasted 6 years of my life when I was a teenager learning this shit I want to know if it helps or they just don't care, or they may
>>
cannabis is now legal...
surprise SURPRISE biggots!
>>
>>61251625
>he cannot remember how his first week coding was
Sad!
>>
>>61251664
>coding
I'm a programmer, not a """coder""".
>>
any online c# compiler with support for c# 6.0? I tried looking but not even a single one of them does

I just need to run some code in an agnostic environment to see if the output is changed
>>
>>61251676
Both moan like fuccbois in bed all the same to me
>>
>>61246884

not saying b-besuni
>>
>>61246538
>burkha anime shit
>>
I just got a laptop with a fucking GTX 1060 bros. What should I program with it?
>>
>>61251727
Find the position of all primes up to 1 million on pi's digits.
>>
File: 1493053269083.jpg (17KB, 542x540px) Image search: [Google]
1493053269083.jpg
17KB, 542x540px
>teammates code on vim
>keep doing lines with 80+ characters to see if they get salty
>mfw they actually do
>>
>>61246838
>https://marketplace.visualstudio.com/items?itemName=kbuchi.ClaudiaIDE


>Using Java in 2017.

lmao nigga use C#
>>
>>61251758
you're doing God's work
>>
>>61251758
Incidentally, can someone explain the 'Vim when you are in a GUI environment" meme to me?
>>
>>61251859
It works the same in both modes, it just looks different.
>>
>>61251859
Why would being in a "GUI environment" change my choice of text editor?
>>
>>61252144
You are suppose to magically enjoy bloated text editors or IDEs
>>
does a function count as "functional" if it mutates an internal variable like a counter but still always returns the same value?
>>
>>61252204
Can the counter be observed outside the function?
>>
>>61252204
Talk about "purity" not "being functional".
And yes, a function is allowed to have mutable internal state yet still be pure.
>>
>>61251448
I wouldn't consider myself a programmer by any stretch (just learning python) and SQL was pretty easy to pick up. Not as master of it by any means though.
>>
Remember that referentially transparent functions are the only practical approach to programming
>>
Thinking about getting into .NET Core. Is it useful for anything besides webdev? If I wanted to make something like command line tools, what kind of dependencies would the average user need to install to run it?
>>
>>61252330
>command line tools
If you're not writing your command line tools in POSIX C, you're seriously doing something wrong.
>>
>>61252337
I only write my tools in embeddable common lisp, which translates the lisp to C
>>
more like dead programming thread
>>
Anyone have any tkinter experience? I'm doing some gui work in python with tkinter, but I've come across an annoyance. I have a treeview with an attached vertical scrollbar. When I open a node with a mouse click the scrollbar properly resizes because of the additional nodes displayed. But if I use the right arrow key on my keyboard to open the node, the scrollbar doesn't update until I manually scroll it. I think this might be some sort of tcl oversight, but is there any way to get the scrollbar to update its size?
>>
>>61252407
it's 4am
>>
>>61252434
brits pls go
>>
>>61252431
Just use qtcreator and wash your hands of it
>>
>>61252337
Okay, but I don't see how spending months getting my C knowledge on par with my .NET knowledge and rewriting or trying to interop with large amounts of existing code would be beneficial. At lest .NET Core is mostly just a subset of .NET so it doesn't seem like it'd be a huge transition.
>>
>>61252450
stop using my language
>>
>>61252431
Use pyqt if you are doing something complex or if you are making a proof of concept/prototype use appjar. http://appjar.info/

Ditch tkinter. The only reason to learn tkinter is cause it is in the standard python library. No reason to actually use it.
>>
>>61251261
Idk if you're still here, but in C it is unusual to cast a pointer to an array. It is considered very unwise to do so. Array's are reserved for stack allocated arrays, while heap-allocated arrays are kept as pointers.

>>61251287
A good OS is a good development environment.
>>
>>61252675
Your OS should not be your library
>>
>>61252709
Why? If an OS is good, there's no reason not to utilize it.
>>
>>61252722
Avoid context switching, you technological illiterate first-timer.
>>
File: 1497925988861.png (182KB, 191x200px) Image search: [Google]
1497925988861.png
182KB, 191x200px
>>61252731
Okay, so you've got nothing to say, good to know.
>>
>>61252722
Not portable
>>
New thread:

>>61252761
>>61252761
>>61252761
>>
>>61252759
Portability is only an issue if your application targets inferior operating systems.
>>
>>61252722
>>61252759
Not to mention that you're going across boundaries - language boundaries, program boundaries, etc.

Imagine if instead it was standard library code that could be inlined and specialised.

>>61252771
Like unix.
Thread posts: 314
Thread images: 34


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