[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: 329
Thread images: 48

File: monk.jpg (53KB, 368x500px) Image search: [Google]
monk.jpg
53KB, 368x500px
old thread: >>60704655

What are you working on, /g/?
>>
haskell!
>>
proc multiplyAtv(v: [?Dv], Atv: [?DAtv]) {
forall i in DAtv do
Atv[i] = + reduce (for j in Dv do A[j,i] * v[j]);
}

Jesus fucking Christ
>>
nth for python is shit
>>
File: 1494135896430.png (147KB, 231x361px) Image search: [Google]
1494135896430.png
147KB, 231x361px
As an Australian, what is the best language for me?
>>
>>60710811
Whats this?
>>
>>60710838
sql.

>OY, MATE; SELECT * FROM BEER; -- WOULD YA, YA CUNT?
>>
>>60710842
generic function in chapel.
>>
File: 1496109290190.jpg (364KB, 752x800px) Image search: [Google]
1496109290190.jpg
364KB, 752x800px
>>60710740
So called "programming" is for the simple-minded.
>>
>>60710842
Prototype function to summon Satan
>>
>>60710668
>>60710701
Any second opinions? Is D really the language for me?
>>
>>60710911
Please tell us how a superior mind operates, smug anime girl.
(I think it's a Touhou character, but I don't know her name)
>>
File: mitsuha_sip.jpg (57KB, 818x750px) Image search: [Google]
mitsuha_sip.jpg
57KB, 818x750px
I'm starting to learn the MEAN stack ^-^ also just got tasks in my new work today ;_;
>>
>>60710937
Are you a gypsy?
>>
>>60710939
>The MEAN stack is MongoDB, Express.js, AngularJS (or Angular), and Node.js
kill yourself my man
>>
Just wasted fucking hours and hours trying to figure out how strings and encoding are working in C++.

After spending literally hours wondering why the fuck I could iterate over a string and print a meaningful result ONLY IF the string's length was below a certain value I finally realized that the first element of a string must be a pointer and that, for whatever reason, it points to the next element in the string if the length is below a certain number and to somewhere else in memory if it's above a certain number.

To explain better,

std::string sampstr1 = "DDDDDDDDDDDDDDDD";
std::cout << &sampstr1 << " " << (void*)&sampstr1[0] << "\n";
std::string sampstr2 = "DDDDDDDDDDDDDDD";
std::cout << &sampstr2 << " " << (void*)&sampstr2[0] << "\n";
std::string sampstr3 = "DDDDDDDDDDDDDDDD";
std::cout << &sampstr3 << " " << (void*)&sampstr3[0] << "\n";


1. The addresses of sampstr[0] and sampstr3[0] are always very close in memory, if not consecutive.
2. sampstr and sampstr3's [0] element addresses are never/rarely consecutive with their variable's pointer value in memory.
3. sampstr2's pointer and [0] element are always(?) consecutive in memory.
4. all sampstr's addresses in memory are very close.

Why does this happen? I'm just an idiot for not realizing the actual first element of a string is a pointer, but this other stuff I can still only guess at. Why does the consecutive nature change based on length like that? Does this have something to do with string pooling or a related concept?
>>
File: 1496174654982.png (393KB, 582x533px) Image search: [Google]
1496174654982.png
393KB, 582x533px
>>60710938
>Please tell us how a superior mind operates
That would be too hard to comprehend for someone such as yourself.

>smug anime girl
>I think it's a Touhou character
Exhibit A.
>>
how qt is my lang and how can I make it qtier
proc repeat
over println
1 -
dup 0 > @repeat if
end

"Hello world!" 100 repeat
>>
>>60711019
>end
>@
the syntax sucks.
>>
>>60711019
incomprehensible to mere mortals such as myself
>>
>>60711026
what'd you use instead?
>>
>>60711005
Also I guess I should note I'm using VS2010 to experiment here. I can imagine this behavior is compiler/settings dependent and not necessarily a language feature of C++.
>>
I want to setup a cmake cross compile build environment for android and ios on arch.
This is far beyond my capabilities. Pls gib 1 command script.
>>
File: 1486678895770.png (122KB, 262x207px) Image search: [Google]
1486678895770.png
122KB, 262x207px
>>60711019
Make it so that non-terminating programs are treated as a compile-time error.
>>60711043
He would probably use some plebeian garbage so I wouldn't listen to him.
>>
>>60711019
A little confusing, do you have any documentation on it or anything? why is there an if at the and and what does the `1 -` mean?

I like the syntax though.
>>
>>60710740
i'm following a guy's (pythonprogramming.net)'s tutorial for tensorflow and i actually feel like i'm learning because he leaves bugs in the code (unintentionally, i suspect) and i have to fix them
>>
>>60711056
https://en.wikipedia.org/wiki/Halting_problem
>>
File: 1425534564742.png (990KB, 702x525px) Image search: [Google]
1425534564742.png
990KB, 702x525px
>>60710970
i-it's good money in my country
>>
>>60711066
It's based on reverse polish notation, so basically everything is on a stack. 1 - would subtract 1 from whatever was on top of the stack. In this case it's a counter.
If takes quote from the stack (@repeat) and only executes it if whatever on top of the stack is not zero. In this case that would be the result of the > operation
>>
>>60711019
Is this like, stack-based?
>>
>>60710838

The only Australian among my university's faculty is a fan of Haskell and Prolog.
>>
>>60710960
No.
>>
>>60711056
> Make it so that non-terminating programs are treated as a compile-time error.
So indefinitely running services like Web servers would be impossible?
>>
>>60711106
what country?
>>
>>60711049

That's right, the way std::string works under the hood is dependent on your standard library.
Typically your string implementation owns a char* to the heap, a size variable and a capacity variable.
An effective optimization would then be to use a union to treat the char* and capacity as a char[] if the size of the string is small enough to fit in that space.
>>
>>60711092
How is that in any way related to my post?
>>60711124
Indefinitely running isn't the same as non-terminating.
>>
>>60711092

The solution to this is to make your language not turing complete. This is, of course, undesirable behavior, especially given that non-terminating programs are very often considered desirable.
>>
>The solution to this is to make your language not turing complete
Blatantly retarded and wrong.
>>
How to shuffle the bits of an int based on the input of another int in a fast way?
More generally how to shuffle bits based on an input in a way that's fast.
>>
File: 1493668195995.jpg (62KB, 907x830px) Image search: [Google]
1493668195995.jpg
62KB, 907x830px
>>60711143
Philippines, lots of companies outsource their sites and startup ideas to us
>>
>>60711173

The halting problem applies to all turing machines. Therefore, either the language is not turing complete, or the compiler cannot tell if a given program halts.
>>
>>60711019
Have you released the source for this language?
>>
>or the compiler cannot tell if a given program halts
The compiler can't decide halting for all programs. Nobody mentioned all programs.
>>
>>60711156

>>60711160
>>60711217
>>
>>60711230
Yeah, I wrote an interpreter in C
https://github.com/Guad/batt
>>
>>60711206
gotcha. Hope your doing well after the ISIS scare a few days ago. MEAN is considered a meme here, most things are done in relational databases and statically typed languages. Angular is on its way out I think.
>>
>>60711251

>>60711173
>>60711242
>>
>>60710838
You guys are always being fucked by other, more important countries, so I would go with a language that accurately sums up "I like taking it up the ass for no reason." Probably C.
>>
>>60711242

The claim was that non-terminating programs should be treated as a compiler error. This is the same as saying that the compiler should test each and every program for non-termination, and fail those that can't terminate. Plenty of good programs are unable to terminate unless forced to by a user (i.e. via sigint, sigkill, etc...), such as a daemon.
>>
>>60711272
not making the language Turing complete to fix the problem is stupid.
There can be no general procedure to decide if a self-contained program will eventually halt, so detecting on compile time is stupid.
>>
>such as a daemon.
Can be written in total languages.

>>60711345
>not making the language Turing complete to fix the problem is stupid.
Do you have problems with reading comprehension?
>There can be no general procedure to decide if a self-contained program will eventually halt
Nobody claimed this is untrue.
>>
>>60711383
I was agreeing with the first statement.

If it is true, how do suggest a complier to detect if a program is non-terminating?
>>
any people with experience with tensorflow here? this guy's tutorial tests accuracy by loading the entire test set into memory and running that, and i don't know how to do it one by one. code segment in question

        correct = tf.equal(tf.argmax(prediction, 1), tf.argmax(y, 1))

accuracy = tf.reduce_mean(tf.cast(correct, 'float'))
print('Accuracy:',accuracy.eval({x:mnist.test.images, y:mnist.test.labels}))


i can't even look at the structure of mnist.test.images
>>> import tensorflow as tf
>>> from tensorflow.examples.tutorials.mnist import input_data
>>> mnist.test.images
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'mnist' is not defined
>>>
>>
>>60711414
>how do suggest a complier to detect if a program is non-terminating?
By doing termination analysis. Obviously you won't be able to decide halting for every program, but that's not really needed.
>>
>>60710881
>generic
What's a "Generic"?
>>
>>60711478
>code
I think you mean "program".
>>
>>60711494
It's not really worth it when you're going to end up getting a 'maybe' most of the time when dealing with more complex programs, having a compiler not compile a program if it's very obvious that the program will not terminate is sort of useless and not something that would be of help to the user as most of the time it would be intentional anyway, as the compiler wouldn't be able to determine it if the user couldn't.
>>
>>60711571
machine learning isn't programming, though
>>
>>60711598
>It's not really worth it
It's pretty interesting to implement for your own language, which is what this was initially about.
>when you're going to end up getting a 'maybe' most of the time when dealing with more complex programs
That's not really the case though.
>as the compiler wouldn't be able to determine it if the user couldn't
Indeed. If only there was a way to signal your intent to the compiler in some easy way.
>>
>>60711663
Sure do it for fun but it's not something that would be terribly useful and a valued aspect of this compiler above others.
>>
>>60711713
I wouldn't touch a compiler which doesn't do some form of termination checking.
>>
File: 1496316525091.jpg (111KB, 741x741px) Image search: [Google]
1496316525091.jpg
111KB, 741x741px
>>60711262
Aww thankoo for your kindness~~ I'm away from the south where the muzzies are racking up some terror ;_; and tbf MEAN is a meme, but I think it won't hurt to play around with it hehe. Relational databases and those statically typed languages are still my forte, though
>>
File: 1493891882825.png (645KB, 670x997px) Image search: [Google]
1493891882825.png
645KB, 670x997px
Working on the eternal roguelike game project made with C.

Will try to keep this as my project for some years while learning C.

Trying to make clever comments on the code so i don't need the SDL2 documentation soon.

Pic related.
>>
Even if you could detect an infinite loop, I don't think a compiler should bother wasting time on doing so. Sometimes this is desirable behavior:

#include <unistd.h>

int main(void)
{
while(1) { fork(); }
return 0;
}


Particularly if the desire of the programmer is to harm the machine the program is being run on.
>>
File: 1485051311622.jpg (11KB, 384x384px) Image search: [Google]
1485051311622.jpg
11KB, 384x384px
Fact: any language, which doesn't have a turing-complete type system, is garbage.
>>
>>60711854
Which compiles just fine.
>>
>>60711906
Type systems are useless.
>>
>>60711929
t. php/javascript dev
>>
>>60711854
Can you stop with the retarded spacing?
>>
>>60711944
Never understood the hate for those languages. They're easy to adapt to if you're not retarded.
>>
>>60711965
>human
>not retarded
>>
File: dlang_chan.jpg (138KB, 470x545px) Image search: [Google]
dlang_chan.jpg
138KB, 470x545px
Threadly reminder that dlang-chan is not dead; she's going to have her GC tumor removed (eventually); she's super duper cute; and she's a blast to write in! Say something nice about her, /dpt/!

>Features
https://dlang.org/comparison.html
>Standard library
https://dlang.org/phobos/index.html
>Package manager
https://code.dlang.org
>GC
https://dlang.org/spec/garbage.html
https://dlang.org/blog/2017/03/20/dont-fear-the-reaper/
https://dlang.org/blog/2017/04/28/automem-hands-free-raii-for-d/
>Books
https://wiki.dlang.org/Books
>>
>>60711764
just moved to the philippines. Nice convergence.
>>
>>60711906
Literally the exact opposite
>>
>>60712037
I have no idea what you're trying to say.
>>
>>60711844
>Starting a new project before finishing the
kek, first time I notice the joke here
>>
>>60710938
Superior minds run on category theory.
>>
>>60712042
when are you going to write a bot to post this?
>>
>>60712042
Hello Andrei. Please stop spamming this shit in every thread.
>>
File: Generic Retardation.png (24KB, 779x133px) Image search: [Google]
Generic Retardation.png
24KB, 779x133px
>>60711535
>not knowing what a generic is
Holy fuck. There needs to be some way to filter out the fucking summerfags better. Generics exist in several languages.
>>
>>60711960

Would you prefer the two lines be flush against the block of code? Because that would look like garbage.
>>
>>60712312

It's a recurring shitposter.
>>
>>60712312
>straight to Java for the example.

t. Pajeet
>>
>>60711120
Do you live in Scotland ?
>>
>>60712376

Java Generics are the worst example of generics, basically just a macro for producing casts.
C# and C++ are much better examples.
>>
>>60712042
how does this compare to rust ? currently learning rust and having a blast
>>
File: 1489697002176.jpg (827KB, 2000x1425px) Image search: [Google]
1489697002176.jpg
827KB, 2000x1425px
>>60711906
Fact: any language for which the halting problem isn't trivially decidable is garbage.
>>
>>60712376
It was the example because I did not want to put forth any more effort than a wikipedia definition. They exist in several languages, like I said if you were literate enough to read.

t. Summerfag
>>
>>60712397

Nope. I live in the Pacific Northwest.
>>
>>60712312
>>60712412
What is a "Generics" though?
>>
>>60712453
>summerfag calling anyone summerfags over the What is "thing`` shitposter
>>
File: 1495692268004.jpg (115KB, 1080x1247px) Image search: [Google]
1495692268004.jpg
115KB, 1080x1247px
>>60712468
What can I say? Hook shit is tasty.
>>
does anyone have that comic mocking java where they're showing how would you use java to fly a kite and it looks overly complicated
>>
File: minimalism.jpg (60KB, 500x600px) Image search: [Google]
minimalism.jpg
60KB, 500x600px
>>60712541
>>
File: 1494922328031.png (194KB, 562x389px) Image search: [Google]
1494922328031.png
194KB, 562x389px
>>60710740
What are some interesting open problems to work on?
>>
File: .jpg (24KB, 570x574px) Image search: [Google]
.jpg
24KB, 570x574px
>>60712569
cheers
>>
>>60712569
What a retarded comic
>>
>>60712580
Proof of P = NP
>>
>>60712580
Is the number 1 equal to 0.999... ?
Is the sum of all positive integers equal to -1/12 ?
>>
>>60712580
How about the halting problem.
>>
>>60712609
These are not open problems you faggot.
>>
>>60711175
That's too generic of a question to answer, what kind of shuffling are you actually trying to do
>>
>>60712598
Found the java "programmer"!
>>
>>60712609
Yes.
>>
>>60712609
The limits are
>>
>>60712603
I said interesting.
>>60712614
Anon, what?
>>
>>60712609
>number 1
What number "one"?
>>
>>60712609
>Is the number 1 equal to 0.999... ?
Yes.
>Is the sum of all positive integers equal to -1/12 ?
No. The Ramanujan sum of all positive integers does converge to -1/12 though. (Physicists are brainlets when it comes to math.)
>>
>>60712653
Work on the halting problem and determining if a program terminates, like many people are currently still researching
>>
>>60712684
What kind of programs are those, anon?
>>
>indexes start from 1
Why would programming language do that?
>>
>>60712627
found the brainlet who doesn't understand object oriented programming
>>
>>60712704
https://en.wikipedia.org/wiki/Termination_analysis
>>
>>60712740
Why would this be "working on the halting problem"?
>>
>>60712713
int* arr = malloc(sizeof(int)*32)-1;
arr[1]; //acceses first element
>>
>>60712729
>object oriented """"programming""""
Use >>>/g/wdg/
>>
>>60712580
>implementation of non-Abelian qubits
>QMC sign problem
>high-dimensional DMRG
>large system exact diagonalization
>>
>>60712789
free(arr);
undefined dumb nigger.
>>
>>60712816
That wasn't supposed to be a complete program
>>
>>60712795
It's amazing how easily influenced /dpt/ is by a single youtube video.
>>
>programming language has more programmers than programs
>>
>>60712835
also you are subtracting 1 from void* which is not same as int* - 1.
dumb nigger
>>
>>60712859
>(((youtube)))
Use >>>/v/
>>
>>60710740

A memory-considerate SPIR-V reflector.

>inb4 baka! you are supposed to know your pipeline layout ahead of time!

FUCKING NOPE! Link by name, then plan for obfuscation. Littering rendering code with concept of descriptor sets makes everything unmaintanable and a PITA to extend.
>>
>>60712789

>-1
You want - sizeof(int), or you want to cast to int* before the subtraction. Since malloc() returns void*, subtracting 1 will not go to a previous int-aligned address.
>>
>>60712871
Lmao I'm glad to give you the opportunity to correct a tiny piece of code I wrote while at lunch
>>
>>60710740
>What are you working on, /g/?
a PDM assembler written in C for fun & education
>>
What features should I add to my lisp compiler written in C
>>
>>60712713
don't know sir
>>
>>60712957
Declare I/O to be undefined behavior.
>>
>>60712957
indexes starting at 1
>>
>>60712976
Should I compile to an empty program if the user calls print
>>
>>60712957
Make it so that non-terminating programs are treated as a compile-time error.
>>
>>60712994
Any kind of recursion or backwards jumps should fail to compile?
>>
File: old_hag_langs.png (173KB, 600x355px) Image search: [Google]
old_hag_langs.png
173KB, 600x355px
>>60712957
Write it as if you're writing for a quantum computer.
>>
>>60713012
>recursion
>backwards jump
>non-terminating
>>
>>60712992
Yes.
>>60713012
Only if it fails to terminate.
>>
>>60710939
>Mongo
>Express
Time to an hero buddy ol pal
>>
>>60713031
How can you make a non terminating program without those features (or blocking i/o which is basically a loop implemented somewhere)
>>
>>60713063
He didn't imply anything like that.
>>
>>60713012
>all recursive programs don't terminate
Rate my fizzbuzz pls
int[2] euclidean(int x,int y)
{
int q = 1;
loop:
int r = y - x*q;
if(r > x)
{
q = q + euclidean(x,r)[0];
goto loop;
}
else
{
return {q,r};
}
}


int truncate(int x)
{
int n = 1;
while(euclidean(x,n*10)[0] > n*10)
{
n++;
}
return x - euclidean(x,n*10)[1]
}

int coprime(int x, int y)
{
if(x < y)
{
int r = euclidean(y,x)[1];
coprime(x,r)
}
if(x == 1 || y == 1)
{
return 1;
}
}

void fizzbuzz(int x)
{
double pi = 4.0 * atan(1.0);
int n = truncate((int) (pi * 10)) / 10;
double sum = 0.0;
for(int s=1;s<10000;s++)
{
sum += 1/s^2;
}
int m = truncate(((int) sum ) * 4) - 1;
if(euclidean(x,n*m)[1] == 0)
{
print "phyzze-boughczy";
}
if(euclidean(x,m)[1] == 0 && not(euclidean(x,m*n)[1] == 0))
{
print "boughczy";
}
if(coprime(n,m) == 1)
{
if(euclidean(x,n)[1] == 0 && not(euclidean(x,m*n)[1] == 0))
{
print "phyzze";
}
}
else
{
if(euclidean(x,n)[1] == 0 && (not(euclidean(x,m*n)[1] == 0) && not(euclidean(x,m)[1] == 0)))
{
print "phyzze";
}
}
}
>>
>>60710740
writing a C compiler in C which compiles to C
>>
>>60713078
I know I'm just saying that I have to make all possibly non terminating programs fail
>>
>>60713063
while(1) ;
>>
File: rust.jpg (43KB, 628x472px) Image search: [Google]
rust.jpg
43KB, 628x472px
Trying to learn Rust, so i started writing a little text-based game.
I'm probably gonna give up soon, the syntax perturbs me a bit. Especially the lifetimes crap, just feels like it could have been implemented much better.
I really wanted to give it a chance anon. Maybe it will improve over time.
>>
>>60713127
>not for(;;);
s m h f a m
>>
>>60713127
That's a loop, which should compile to a backwards jump
>>
>>60712326
Yes I would, and no it wouldn't. You do that every single post and it's triggering me for some reason.
>>
>>60713151
yo,
I like rust, learning it too
I agree syntaxically lifetiems are weird but overall I love the abstractions
>>
>>60713174
It is my intention to trigger as many people as possible.

>>60713151
It's like an acquired taste. You have to program in Rust for a bit before you get used to the borrow checker. It helps if you've used C++ before, I think. Most of Rust is just a more logically consistent C++, minus a few features, mainly dealing with templates.
>>
Fortran code to simulate starquakes.
>>
>>60713151
>>60713367
>>60713412
lifetime syntax is necessary awkward, since no other language i know of can explicitly talk about the lifetime of a variable
>>
>>60713105
It's already done.
https://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob_plain;f=src/cat.c;hb=HEAD
>>
>>60710740
Anyone have the git repository that has a bunch of resources for type theory? I think it had them ordered from beginner to expert.
>>
>>60713445
Graphically? Or are you calculating something?
I'm interested.
>>
>>60713102
>the fucking Baroque animememeposter who ruined /classical/ for months now shitposts in /dpt/
Go back to >>>/jp/ you codelet violinist.
>>
File: fuck_off2.png (52KB, 214x211px) Image search: [Google]
fuck_off2.png
52KB, 214x211px
>>60713554
Didn't I tell you to not reply to me already you fucking loser? Are you this desperate for my attention?
>>
>>60713571
>Didn't I tell you to not reply to me already
Not to my recollection. (Why are you still here?)
>>
Wait, I visit /classical/ too.
What's going on here?
>>
>>60713582
That just makes you even more pathetic doesn't it rando? I'll tell you to fuck off now, make sure to remember that.
>>
>>60713105
So it's a C optimizer? Obfuscator?
>>
>>60713627
You visit what?
>>
>>60713636
I really wish you'd use a trip.
>>
File: programmer_employability.png (27KB, 520x544px) Image search: [Google]
programmer_employability.png
27KB, 520x544px
>>60712580
Start here
>>
File: 1493148426764.jpg (221KB, 1600x900px) Image search: [Google]
1493148426764.jpg
221KB, 1600x900px
thumbs up if you are browsing /dpt/ while waiting for your shitty project to build
>>
>>60713708
>his projects don't build in less than a minute
go to bed grandpa
>>
>>60713701
I wrote a Memory game clone in Java. How employable does that make me?
>>
>>60712580
P = NP

also, a lot of the exercises listed as open problems in The Art of Computer Programming are still open problems.
>>
Should I rewrite my python fap roulette (webm randomizer) in C#? Does C# have easy to use keyhooks for quick program control?
>>
>>60713720
my project is the CLANG compiler you dingus
>>
>>60713759
Why even bother? You can do the same with a simple bash script. Actually, I think mpv has shuffled playlists as a feature, so you can open wembs in mpv as a playlist mpv * with some shuffle flag. Talk about wasting your time.
>>
>>60713759
>Does C# have easy to use keyhooks for quick program control?
NO. The whole Windows API was not ported to .net.
>>
File: gif Properties.png (13KB, 363x481px) Image search: [Google]
gif Properties.png
13KB, 363x481px
>>60713821

how else can I learn programming while leveraging my 26 GB of porn webms?
>>
>>60713759
>Does C# have easy to use keyhooks for quick program control?
Yes
>>
>>60713721
Pls repspond I'm serious.
>>
>>60713701
I never really got the prime issue. Wouldn't it be as simple as making a list of all the numbers up to 2 million, and then taking away each one and all the products of it in a row? Like first remove 2 and then every single product of 2, next move to 3 and so on and so on?
>>
>>60713873
You can write a program to delete them all and prevent you from being such a degenerate again.
>>
>>60713905
Just make 3-5 more projects and you're good.
>>
>>60713913

That's the sieve of Eratosthenes, yes. People fuck it up even if they think of it though.
>>
>>60713952
Should I use different languages for the other projects? And are these sort of simple, old game clones and other dumb apps like a GUI calculator good enough or should I aim for something else?
>>
hello guys, i need to connect a database with a programming language for an uni project
i don't even know how to start, whats a good programming language to do that with the less amount of work? i know C, java and a bit of c++, but i have time to learn other
the db in question is oracle or mysql
>>
>>60714005
You are free to do whatever you want, but focus on a language that isn't dead. Use this for projects: https://wiki.installgentoo.com/images/5/5c/Programming-Projects-for-N00bz.jpg
>>
>>60714026

Unironically PHP.
>>
>>60712254
This is a work of love.

>>60712422
I don't know much about Rust. But think of dlang-chan like she's a vastly improved C++ with a GC you can (with limitations) turn off and on.
>>
>>60714052

>a vastly improved C++ with a GC
xD
>>
>>60712609
>>>/sci/
>>
>>60714050
uhh, i really dislike this language and everything that goes with html in general
btw, should i install a virtual machine to use the database? my teacher uses one but he didn't explained why
>>
>>60714074

I can't blame you, PHP is pretty bad.
>>
>>60714052

You cannot improve upon C++ by adding a garbage collector.
>>
>>60712994
I see wot you did there
>>
>>60713913
It's called a sieve, and it's not as trivial to optimize as you think. For example, you suggest sieving from 2, but all even numbers are not prime, so no point to sieve through the even range; you say "take away", but this is usually an O(n) array operation. So it's in fact better to mark off multiples of primes via truth testing, which is O(1). But then you have the memory requirements required for the array, which are O(n). So you need to implement segmentation, which increases the time complexity. Then you have inherent problems with the sieve, such as the overdraw (e.g. 3*20 = 60 and 5*12 = 60, meaning you sieve redundantly). But none of this matters for trivial limits such as 2 million, as you can just use trial division for numbers that small.
>>
>>60714037
Thanks for the advice I appreaciate it.
>>
>>60713873
I suggest upgrading to Linux.
>>
>>60714126

You can, but only if it truly is optional and doesn't exclude you from using all the libraries.
>>
>>60714026
Java is fine and has plenty of tools for dealing with databases, the most common if which is Hibernate.

>>60714074
not necessary, but may be preferable if you want to work in linux
>>
>>60710740
int x = 5;
int *y = &x
const int *z = &x

Can I change the value of x through y still?
>>
>>60714156

If it's on by default, it's not an improvement.
>>
>>60714163

Yes.
>>
>>60714126
That's why I said "like," you retard. The GC needs to be completely optional, but as it right now, dlang-chan is perfectly fine. You'll lose some features when you turn it off for performance critical code, but otherwise, the GC does a fine job.
Also, C++ is a mess, and few programmers know how to right good sepples. dlang-chan has clear and defined standards to write by.
>>
>>60714169

We're in agreement then.
>>
>>60714181

>C++ is a mess, and few programmers know how to right good sepples
The benefit of this is keeping morons out of the fray.

>dlang-chan has clear and defined standards to write by.
So does Rust.
>>
>>60714203
>The benefit of this is keeping morons out of the fray.
No, you're thinking of C. The problem with C++ is it lets people write terrible code, without it being immediately obvious.
>>
>>60714203

>The benefit of this is keeping morons out of the fray.
Plenty of morons used to write C++, and they made huge piles of garbage because of it.
>>
>>60714203
>The benefit of this is keeping morons out of the fray.
Terrible argument to justify it being a bloated mess.

>So does Rust.
And this has to do with dlang-chan how? I'm talking about two languages right now, not three.
>>
How good of an idea is it to do a bunch of little projects that don't actually do much but are impressive from a technical standpoint and then throw them all on a resume?
>>
>>60714300
Depends on who you interview with. If you're interviewed by other programmers, this might make sense. Otherwise, it won't be very impressive.
>>
>>60714341
On top of this, rarely anyone gives a shit about projects anyway.
>>
>>60714373
what do they give a sh*t about?
>>
>>60714401
Social skills go a long way.
>>
>>60714401
>sh*t
fag
>>
Yo guys I've just started with HTML and CSS and would like to experiment with Javascript and PHP. I would like to get a domain on the internet so I can show off my super 1337 prowess. Noob question I'm sure, but what web hosting service is the best for someone who would like to show off their mad coding skills in internet languages as a sort of portfolio?
>>
>>60714439

Host your own.
>>
File: Thinking_Intensifies.png (58KB, 1080x471px) Image search: [Google]
Thinking_Intensifies.png
58KB, 1080x471px
>responding to a retard
>>
>>60714459
lol
>>
>>60714216
>>60714217
The flipside is that template errors will blow up in the face of a noobie and can discourage them.

>And this has to do with dlang-chan how? I'm talking about two languages right now, not three.
And I'm being a contrarian.

>>60714459
Largest integer value that can be stored in a 32-bit float is somewhere along the lines of 2^23. Denormalized numbers can get fucked, as they've always been fucked.
>>
>>60714564
-2147483648 == 2147483648.000000 :^)
>>
floating point is for people who don't know the range of values they need
>>
>>60714439
You can host your site directly on github if I'm not mistaken.
>>
>>60714163
You can even change it through z if you cast away the const.
>>
>>60714786
Or for people who want high performance.
>>
>>60714763

Denormalized. The second you get past the point in floating point numbers where n - 1 or n + 1 is a valid floating point number, is the second you can stop giving a shit.
>>
>>60715086
You're taking about fixed point
>>
>>60715218

Actually, I was talking about 32-bit floats. Every denormalized value in a 32-bit float is not worth taking into consideration when talking about conversion to other types. If you are storing integers within floats, your effective range for using it as an integral type is somewhere along the lines of ± 2^23, all of which can be stored within an int.
>>
>>60710775
There are people that use C because the speed of C will make up for their O(n^2) code.

And there are hasklel faggots who think they can write anything faster than O(n^n)
>>
pessoa *jovem(pessoa *pessoas) {
int menor = pessoas->idade;
char *novo = pessoas->nome;

while(pessoas->idade != '\0') {
pessoas++;
if (pessoas->idade < menor) {
menor = pessoas->idade;
novo = pessoas->nome;
}
}
return menor;
}

warning: return makes pointer from integer without a cast [-Wint-conversion]


Why can't I return "menor" correctly? "Nome" is also of type char. I'm messing a little bit with pointers.
>>
>>60715454
The function is set to return a pointer to pessoa
>>
File: 1495147543587.png (6KB, 472x508px) Image search: [Google]
1495147543587.png
6KB, 472x508px
>>60715334
>It's safe to convert floats to ints, as long as you check they are valid ints
There's a word for this...
>>
>>60715454
Just read the damn error message. You even when out of your way to post it.
>>
>>60715454
Post full information next time. Menor is int, your return type is pessoa*. This is not the same type according to your compiler. You have to cast it (which seems like a bad idea here unless you really know what you're doing) or use the correct return type in your function.
>>
>>60715483
>>60715490
>>60715498
Oh, sorry, it was supposed to return "novo" and not "menor".
It still displays a similar warning, but I know what i did wrong now.

Thanks.
>>
>>60715529
novo is still not a pointer to pessoa you portuguese speaking fuck
>>
>>60715454
>>60715529
            novo = pessoas->nome;

What exactly is that supposed to do? This looks like dead code to me. I think you're really confused regarding your algorithm.
>>
>>60715541
It's a pointer, it's just not the correct type.
>>
>>60715559
nvm. I got confused by the language
>>
>>60710740
becoming proficient in vims language, used to use mouse and arrow keys like a noob
>>
>>60715561
no shit
try to dereference anything that function returns and you're getting garbage
>>
>>60715584
Chill. I just read what you wrote wrongly. I ignored the "pointer to pessoa".
>>
File: maxresdefault[1].jpg (34KB, 1280x544px) Image search: [Google]
maxresdefault[1].jpg
34KB, 1280x544px
>>60715601
GET OUT
>>
>>60715611
Alright. I just solved my problem.
>>
File: 1489360070154.jpg (47KB, 550x449px) Image search: [Google]
1489360070154.jpg
47KB, 550x449px
>>60715621
Cool m8
>>
>>60714948
>floating point
>performance

>>60715454
Your function is defined as returning a pointer-to-pessoa, however you're returning the variable "menor", which is declared as an int. I'm not sure exactly what your function is supposed to be doing, but you should settle on one or the other - either change the function declaration to indicate that the return value is an int, or return a pointer-to-pessoa value (the argument "pessoas" seems to be the best candidate if this is the case).

Also, I noticed your while loop is comparing "pessoas->idade" (meaning "age of person"?) to the null character literal, which doesn't really make sense. Either change the null character literal to an integer zero, or maybe you meant to be comparing the value pointed to by "novo" there instead?
>>
Name me one language that won't get shitposter at.
>>
>>60715660
OCaml
>>
>>60715660
asm
>>
>>60715402
haskell!
>>
I want to write a program that I can use to explore financial data with so I need to be able to draw things like candle stick charts with lines like trend lines and moving averages and so forth. I've been looking at graphing libraries and all of them seem to not be designed to do this, for example mathgl and root seem to be for generating static images not interactive charts like this, and the other popular graphing libraries like mathplotlib and gnuplot, python and calling an external program, dont seem to fit the bill either. It seems like I'm just going to have to use a 2d graphics library like they use to make 2d games like maybe SDL or Cairo. Am I missing anything or mistaken?
>>
>>60716151
What would prevent your from calling an external program? What constraint do you have to force having everything self-contained?
>>
>>60716181
I might consider using it. But first off does gnuplot even support something like this interactive candlestick charts you can easily scroll around in and change timeframes and add indicators and so forth?
Have you used any charting applications like this?
>>
>>60713756
If you want my advice, you'd rather find a technique to expose undecidable problems more visibly before touching this class of problems.
>>
>>60715660
Dead ones.
>>
>>60716314
Interactively I think only matplotlib does it and I'm not sure. Maybe Mesa's off screen rendering is enough for your use.
>>
>>60715660
webasm
>>
>>60716413
>Mesa
You mean use OpenGL directly? Do you think something like SDL or Cairo would work, I mean they make interactive 2d game with it so why not interactive candlestic charts?
>>
fibonacci sequence in your favorite language go

fib(n) // should return a list of the first n fibonacci numbers
>>
>>60716694
fib n = take n fibs
where fibs = 1:1:(zipWith (+) fibs (tail fibs))


*Main> fib 15 
[1,1,2,3,5,8,13,21,34,55,89,144,233,377,610]
>>
>>60716694
int fib(int n)
{
if(n<=0)
{
return 0;
}
if(n <= 2)
{
return 1;
}
else
{
return fib(n-1) + fib(n-2);
}
}
>>
>>60716001
TRASHKELL!!
>>
>>60714948
which seems counterintuitive even if it is true
>>
>>60716821
haskell!
>>
>>60716833
TRAHKELL!!
>>
>>60716833
>>60716001
6 Gb/s
>>
>>60716843
Actually that's 12 Gb/s. Hasklel produces garbage at the rate of 6 Gb/s and the GC collectes garbage (which misses hasklel itself) removes garbage at 6 Gb/s

So 12 Gb/s in total
>>
>>60716814
I can count Fibonacci series by hand faster than haskell programs
>>
>>60716857
kek
>>
Lisp newfag here.
Is there a way to make the loop macro skip the rest of the body and continue with the next iteration?
>>
File: 1494127528269.gif (721KB, 227x165px) Image search: [Google]
1494127528269.gif
721KB, 227x165px
i need to refresh myself on C++ and Python over the weekend for a technical interview monday

any recommendations on video series and programming challenges to get back into both?
>>
>>60716863
Did you write >>60716820 ?
Let's race! First to compute the 100,000 fibonacci number wins!
>>
>>60716907
you could put a tagbody in the loop and jump to the end

(loop do
(tagbody
(if something (go end-of-loop))
end-of-loop))
>>
>>60716947
>Did you write >>60716820
No
>>
>>60716962
Then you have a lot of work to do!
>>
>>60716947
Sure, should I make a time comparison between shitkell and C? I don't think it's going to end up well for shitkell but if you like pegging I will oblige
>>
>>60716985
Yes, please! I do not enjoy pegging but I am curious as to the results!
>>
does everything pointers do in C applies on C++?
also, whats a good way to get into oop? is c++ good for learning these concepts with no previous knowledge?
>>
>>60716694
OCaml
let fib n =
let rec fib_aux arg =
if arg < 2 then
1
else
(fib_aux (arg-1) + fib_aux (arg-2))
in let rec create_list amount =
if amount < 0 then
[]
else
amount::(create_list (amount-1))
in List.map (fib_aux) (List.rev (create_list n))
>>
>>60717097
utop # fib 15;;
- : int list = [1; 1; 2; 3; 5; 8; 13; 21; 34; 55; 89; 144; 233; 377; 610; 987]
>>
File: 1463163008848.png (638KB, 4760x4986px) Image search: [Google]
1463163008848.png
638KB, 4760x4986px
>>60716820
>>60716814
>>60717097
>fib recursively
>instead of iteratively
>>
>>60717120

https://artofproblemsolving.com/wiki/index.php?title=Binet%27s_Formula
>>
>>60716694
let fib n = 
let gld_cst = (1. +. sqrt 5.) /. 2. in
int_of_float (floor (((gld_cst ** float_of_int n) /. sqrt 5.) +. 0.5));;

Recursive and iterative babies BTFO. Also, to show OCaml ugly syntax.
>>
>>60717120
my haskell solution is not recursive! I'm proud of that fact!
>>
>>60716820
>>60717133
You both failed since you didn't solve the problem.
>>
>>60716985
I take it your program is still running? I'm sorry anon, maybe you'll do better next time!
>>
File: patchouli_athsma.png (160KB, 395x587px) Image search: [Google]
patchouli_athsma.png
160KB, 395x587px
>>60717146
std::vector <int> fibarray[n];
for(int x=1;x<=n;x++)
{
fibarray[x-1] = fib(x);
}
>>
File: 1488754372308.jpg (24KB, 500x282px) Image search: [Google]
1488754372308.jpg
24KB, 500x282px
>>60717133
>ugly
You mean flawless right?
>>
>>60716448
Sure as long as it remains 2D it will be simpler to use than raw opengl.
>>
Did the rust shills get tired of getting btfo? Where are they?
>>
>>60716950
This is too confusing.
>>
File: 1439174060686.gif (3MB, 528x308px) Image search: [Google]
1439174060686.gif
3MB, 528x308px
>>60716931
anyone?
>>
>>60717216
Sum all primes number under 2 millions.
>>
Any computer vision / image processing anons here?
>>
>>60717212
Mozilla is running low on budget so they can't fund their PR department as well as before.
>>
D master race
import std.stdio;

void main()
{
int count = 10;
fib(count).writeln();
}

auto fib(const ref int limit)
{
auto current = 0;
auto next = 1;
for (int count = 0; count < limit; count++)
{
auto temp = current;
current = next;
next = current + temp;
}
return current;
}
>>
>>60716985
Here are the results from my run! I'm sorry but I got bored running your C program. Let me know if you have the patience to finish!

C:
$ gcc fib.c -O3 
$ time ./a.out
^C

real 9m14.163s
user 9m10.897s
sys 0m1.702s


Haskell:
$ ghc -O2 fib.hs
$ time ./fib
354224848179261915075

real 0m0.021s
user 0m0.002s
sys 0m0.005s


I'm sorry, but it looks like you got btfo!
>>
>>60717327
oh and I only did it for 100th fibonacci number! Let me know if you want to go for 100,000th! I think the results might be interesting!
>>
>>60717327
Are you sure you actually know C? Not him but D does it pretty fucking quick
d$ ldc2 -O3 -nogc -release main.d && cat main.d && time -p ./main 
import std.stdio;

void main()
{
int count = 1_000_000;
fib(count).writeln();
}

auto fib(const ref int limit)
{
auto current = 0;
auto next = 1;
for (int count = 0; count < limit; count++)
{
auto temp = current;
current = next;
next = current + temp;
}
return current;
}
1884755131
real 0.00
user 0.00
sys 0.00
>>
Fib[x_] := Module[{n,fibarray},
fibarray = {};
n = Solve[m^2 + m - 1 == 0,m,Resolve[m>=0]];
For[s=1,s<=n,s++
fibarray = Append[fibarray,n^s];
];
];
>>
>>60717372
Oops it should be
s<=x
.
>>
>>60717365
his implementation was extremely poor! read the code too see why! (>>60716820)

Also you are required to generate a list of the first n fibonacci numbers which you did not do! Following directions is a skill!
>>
>>60717387
>First to compute the 100,000 fibonacci number wins!
Yeah, I know how to follow your "directions". Are you suffering from autism?
>>
>>60715647
>floating point
>performance
Correct.
>>
>all /g/ are retarded
Holy shit it's like I'm surrounded by idiots.

The 1000th number is (pic related)

Too bad our 1337 code haxors don't have any common sense

>>60717212
Maybe we are actually programming instead of circle jerking ITT
>>
>>60717502
D fag here, I was actually thinking about the overflows while I was coding the fib(n). Too bad /g/ isn't up to the speed.
>>
File: 1478747037400.gif (105KB, 777x533px) Image search: [Google]
1478747037400.gif
105KB, 777x533px
Anyone know of a good tutorial to templates for C++? I get the idea of using them to compute average of interest and floats with one function, but beyond that the syntax and explanations get more and more obtuse.
>>
>>60717518
It's sad isn't it, and what's more annoying is that whenever you bring up safety /pol/ cross-boarders get offended. Maybe it hits their spot of not being able to understand programming in general.
>>
>>60717327
Well, aren't you feeling ashamed yet?
I swear FP autists and C toddlers have ruined the chance of /dpt/ being a constructive thread that could be taken somewhat seriously
>>
>>60716694
Rate my crystal
def fib(n : UInt64)
a : UInt64 = 0_u64
b : UInt64 = 1_u64
while n - 1_u64 > 1
t : UInt64 = a
a = b
b += t
end
return b
end
>>
>>60717502
>Maybe we are actually programming
Nice contradiction, faggot.
>>
This is why you need GC, faggots
>>
>>60717348
I did some modifications because the number is too big for my resolution.

I don't know haskell but can you please provide the full code and compilation command so I can compare?
>>
File: 1467122446920.png (20KB, 586x550px) Image search: [Google]
1467122446920.png
20KB, 586x550px
>>60717327
>Trashkell computes the 100th fibonacci in more time than D computes the 100,000th
Can't make this shit up
>>
>>60717787
Well to be fair, I just computed the 1000th number. Pretty sure I'd beat hasklel in that game too
>>
>>60717805
Oh wait no, kek I actually did count the 100000th one
ahahahahaha
>>
File: 1478128368324.png (143KB, 332x394px) Image search: [Google]
1478128368324.png
143KB, 332x394px
>>60717787
>>60717805
>>60717814
Jesus christ top kek
hasklel haskill
>>
>Current state of /g/

Although it's funny >>60717787 (this one)
>>
(((shitkell)))
>>
How would you extract strings inside strings.
i.e retrieve characters after encountering a " and stop after encountering another "
>>
>>60717841
O(n) solution just iterate through the string and build your new string
>>
>>60717841
you should be able to do this
>>
>>60717387
You're a faggot!
>>
From this point on, it's considered to be shameful that you have hasklel compiler in your PC
>>
>>60717348
libgmp is pretty fast.

#include <stdlib.h>
#include <gmp.h>

int main(int argc, char **argv)
{
mpz_t buf[2];

mpz_init(buf[0]);
mpz_init(buf[1]);
mpz_set_ui(buf[0], 1);

if(argc != 2) return 1;

for(int i = 0; i < atoi(argv[1]); i++)
{
mpz_add(buf[0], buf[0], buf[1]);
mpz_swap(buf[0], buf[1]);
}

gmp_printf("%Zd\n", buf[1]);

return 0;
}


$ gcc fib.c -lgmp -O2 -o fib
$ time ./fib 100
354224848179261915075

real 0m0.002s
user 0m0.000s
sys 0m0.000s


$ gcc fib.c -lgmp -O2 -o fib
$ time ./fib 100000
259740693472217241661550340212759154148804853865176965847247707039...

real 0m0.044s
user 0m0.043s
sys 0m0.000s
>>
File: 1496276268739.jpg (68KB, 700x700px) Image search: [Google]
1496276268739.jpg
68KB, 700x700px
Stop bullying haskell
>>
Re-did fibo list using OCaml Num module for mixed sizes of integers:
open Num;;

let fib n =
let fib_0 = ref (Num.Int(0)) in
let fib_1 = ref (Num.Int(1)) in
let fib_2 = ref (!fib_0 +/ !fib_1) in
let rec fib_aux i n l =
if i > n
then l
else
begin
fib_0 := !fib_1;
fib_1 := !fib_2;
fib_2 := !fib_0 +/ !fib_1;
fib_aux (i+1) n (!fib_2::l)
end
in List.rev (fib_aux 3 n [!fib_2;!fib_1;!fib_0]);;

string_of_num (List.nth (fib 100000) 100);;
(* shows the 100th number in the list of 100000 *)

Looks pretty fast on the interpreter, I may compile it later for performance comparisons.
>>
>>60712042
Until D gets a better standard library and there is a way to properly debug code, I can't adopt D. I wanted to but these two things held me back. That and the IDEs for the language suck but shit, I'd be happy with the first two items I talked about get fulfilled.
>>
>>60718238
fug, forgot the output
# string_of_num (List.nth (fib 100000) 100);;
- : string = "354224848179261915075"
>>
New thread.
>>60718265
>>60718265
>>60718265
>>
>>60718251
https://marketplace.visualstudio.com/items?itemName=webfreak.debug
>>
File: BIG.jpg (12KB, 367x202px) Image search: [Google]
BIG.jpg
12KB, 367x202px
I can't seem to figure out what i'm doing wrong with this code.
  public static int greatest(ArrayList<Integer> list) {
int itemCount = 0;
int greatest = -1;
for(int number:list)
itemCount++;
for(int i = 0;i>itemCount-1;i++){
if(list.get(i)>list.get(i+1))
greatest = list.get(i);
}
return greatest;


It's meant to go through an integer array and return the greatest number. After wrestling with the Java debugger unsuccessfully, I decided to just debug it the old fashioned way of using print statements. It appears the
for(int i = 0;i>itemCount-1;i++)
for loop isn't running at all. Why? I put a print for the value of item count directly before, verified that it equals 4. Integer i is set to 0, i is greater.....

Holy fuck i'm an idiot.
>>
>>60718238
>Looks pretty fast on the interpreter, I may compile it later for performance comparisons.
$ time ./fib 1000

real 0m0,002s
user 0m0,000s
sys 0m0,000s
$ time ./fib 10000

real 0m0,012s
user 0m0,010s
sys 0m0,000s
$ time ./fib 100000

real 0m0,217s
user 0m0,180s
sys 0m0,033s

breddy gud actually
>>
>>60718124
This shit doesn't work
Thread posts: 329
Thread images: 48


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