[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: 318
Thread images: 29

File: daily programming thread2.webm (2MB, 600x338px) Image search: [Google]
daily programming thread2.webm
2MB, 600x338px
old thread: >>58448304

What are you working on, /g/?
>>
>>58453794
First for D
>>
>>58453794
Thank you for posting Hime. Have some feminine code as a reward :
use std::mem::transmute as crossdress;

struct Boy;
struct Girl;

fn main() {
let hime: Girl = unsafe { crossdress(Boy) };
}
>>
>>58453794
Should I learn Python or C?
Which one is more useful?
>>
>>58453987
python
>>
>>58453987
>Which one is more useful?
Python, but learn C If you want to learn programming.
>>
please rate my fizzbuzz
#include<stdio.h>
#include<pthread.h>
#include <unistd.h>
pthread_mutex_t lock;

void* fizzbuzz(const void* n)
{
pthread_mutex_lock(&lock);
int i = n;
if(i%15 == 0){
printf("fizzbuzz\n");
}
else if(i%5 == 0){
printf("buzz\n");
}
else if(i%3 == 0){
printf("fizz\n");
}
else
printf("%d\n",n);
pthread_mutex_unlock(&lock);
}
int main(void)
{
int threads = 0xFF;
pthread_t thread_id[threads];
int i;
int j[threads];
for(i=1;i<threads;i++)
{
j[i] = i;
pthread_create (&thread_id[i], NULL , &fizzbuzz, j[i]);
usleep(1);
}

for(i=1;i<threads;i++)
pthread_join(thread_id[i],NULL);
}
>>
>>58454012
>Python, but learn C If you want to learn programming.
Would I not learn programming from Python?
Okay, I'll get the meme C book
>>
>>58453987
Learn Python first, then C to better understand how things work under the hood, and in case you need performance.
>>
>>58453817
pls respond
>>
>>58454089
Assembly programmers
>>
>>58454035
You would, but you'll miss out on all of the low level concepts such as pointers and addresses.

Also C is the lingua franca of computer science. If you're a programmer who doesn't know any C you won't even be taken seriously. Again, if you want to program for the sake of making simple scripts and small projects then look no further than Python, it's the best language for "getting shit done". But if you want to become an actual programmer then you must learn C.
>>
>>58454017
>doesnt initialize mutex lock
i'd say it's about deadlock/5
>>
>>58454141
I would say that C is the lingua franca of software engineering, but not computer science.
>>
File: anim.webm (246KB, 1123x846px) Image search: [Google]
anim.webm
246KB, 1123x846px
ok, playing music works now

now i just have to implement proper pausing (instead of stopping), a seek bar, skipping to next/previous, and so on

and of course improve looks
>>
File: 123456.png (11KB, 1638x893px) Image search: [Google]
123456.png
11KB, 1638x893px
>If it's stupid but it works, it's not stupid.

is this valid in programming? do you care?
>>
Fizzbuzz is too easy.
Everyone should be able to implement a naive substring search.

If not, you shouldn't be allowed near a computer.
>>
>>58454119
Yeah no. GCC and other compilers are so advanced today that there's no point in programming in Assembly except for very niche situations. In general properly written C/C++ code will run just as fast.
If the top of the food chain is simply the most low level language then it stops at C, everything else is a meme.
>>
>>58454228
it is completely valid unless it's so stupid it slows everything to a crawl (like doing intense i/o in every iteration of a loop or something equally retarded)

i noticed that many newbies are afraid of sharing their code because they're not confident and think that people will laugh at their mistakes, but if a program does what it's supposed to do and consumes a reasonable amount of resources, and is moderately fast, it's great in my book
>>
>>58454234
A search for... all the substrings in a string?
>>
is using multiple contexts with opengl useless except for data transfer and having multiple windows?

like if you want to render to a shared texture (let's say it's an expensive shader and you don't need the result immediately) and the opengl implementation is single-threaded then it will just be the same as (or a bit slower than) doing single-threaded rendering?
>>
>>58454266
Probably means if string X is in string Y
>>
>>58454390
Shits easier than fizzbuzz
>>
>>58454157
You mean UB/5
>>
>>58454141
I agree, but Python is still very useful and more friendly for beginners.
It can also introduce them to OOP and functional programming once they have a good grasp of procedural programming.
The best thing is to learn both. If you aren't familiar with at least 3 languages using different paradigms and features, I would say that you aren't a real programmer.

>>58454251
Audio devs often use SSE/AVX instructions and the like to tighten their processing loops, and I'm sure game dev do the same, but yeah, it's generally just inline assembly in the context of a C/C++ program.
>>
File: 1480711057957.gif (2MB, 179x320px) Image search: [Google]
1480711057957.gif
2MB, 179x320px
>>58454390
Oh, that's easy. It's just
if sub in str:
.
>>
>>58454234

rate me /dpt/

bool charSearch(char* toSearch, char* term)
{
int len = strlen(toSearch);
int termLen = strlen(term);

for (int i=0; i<len; i++)
{
if (term[0] == toSearch[i])
{
bool found = true;
for(int x=1; x<termLen; x++)
{
if(toSearch[i+x]!=term[x])
{
found=false;
break;
}
}
return found;
}
}
return false;
}
>>
>>58454466
if you found it already, just return true immediately, you don't need any breaks in that loop.
>>
>>58454225
Nice.
>>
>>58454234
fn contains_substr(to_search: &str, to_find: &str) -> bool {
to_search.contains(to_find)
}
>>
>>58454466
>creating variables inside a loop

no
>>
>>58454466
what the fuck, fix those braces
>>
>>58454234
char *strstr(const char *haystack, const char *needle)
{
size_t h_len = strlen(haystack);
size_t n_len = strlen(needle);
size_t i, j;
for (i = 0; i < h_len; i++)
{
size_t found = 0;
for (j = 0; j < n_len; j++)
{
if (i + n_len < h_len)
if (haystack[i + j] == needle[j])
found++;
}
if (found == n_len)
return &needle[i];
}
return NULL;
}
>>
>>58454225
looks cool.
>>
>>58454466
> Not using regex
>>
>>58454549
>what is an optimizing compiler
>>
>>58454466
good but you need to pick up a more conventional code style and also it can be cleaned up a bit like >>58454471 said
>>
>>58454492
>>58454597
Thank you bros, next week I will probably post some binaries and code too
>>
>>58454640
actually nvm you need to check the whole thing and not return immediately so keep it as it is
>>
>>58454234
const char* strstr(const char* haystack, const char* needle) __attribute__((leaf, nonnull)) {
size_t i;

for( i = 0 ; *haystack && haystack[i] ; haystack++ )
for( i = 0 ; haystack[i] == needle[i] ; i++ )
if( !needle[i] )
return haystack;

return NULL;
}
>>
>>58454466
the outer loop should go to len - termLen so you don't go out of bounds
>>
>>58454656
Fug.

         for( i = 0 ; haystack[i] == needle[i] ; i++ )
if( !needle[i + 1] )
return haystack;
>>
>>58454234
bool is_substring(char* sub, char* str)
{
char *tmpsub, *tmpstr;
for(;*str != 0;str++) {
if (*str == *sub) {
tmpsub = sub;
tmpstr = str;
while (*tmpsub != 0) {
if (*tmpsub != *tmpstr) goto resume_main_loop;
tmpsub++;
tmpstr++;
}
return true;
}
resume_main_loop:;
}
return false;
}

This is very ugly, but it works
>>
How would you reconcile the overlap between regex and file globbing?
>>
>>58454728
>goto resume_main_loop
How about just continue?
>>
>>58454769
Didn't see inner loop because your indent is shit.
>>
>>58454769
Because it would return true otherwise, I don't know to structure this in another way.
Sorry btw for the fucked up indentation, my Emacs config use tabs instead of 8 spaces for some reason.
>>
>>58454466
it should only return if found, otherwise it should keep searching
>>
How would one loop through an int value in c#?

Please show the implementation or just describe how you would do it.

imagirlbtw
>>
>>58452653
And once again, this doesn't do what the example does and is still worse
>>
>>58454917
If you mean look at each digit in a multi-digit int, like 12345, just take % 10 and store the answer, divide the number by 10, rinse and repeat until the number is 0.
>>
>>58454985
can someone say this in english pls im a girl
>>
File: photo.jpg (132KB, 900x900px) Image search: [Google]
photo.jpg
132KB, 900x900px
>want to make toy prog language
Should I call it EvilC?
>>
>>58454993
If you take modulo 10 of a number 12345, you get 5. If 12345 is an int as you said, dividing it by 10 will give you 1234. If you take modulo 10 of 1234, you get 4, and so on and so forth until your number is 0 and you break the loop.
>>
>>58455009

wouldn't that just be regular c?
>>
>>58455040
what's a modulo?
>>
I am hoping to use the MPQA Subjectivity Clues tff file to use as a dictionary of negative and positive words in a basic sentiment analysis tool I am making in Java. How would I parse the file into prefix trees in my code?

type=strongsubj len=1 word1=scrupulously pos1=anypos stemmed1=n priorpolarity=positive
type=strongsubj len=1 word1=scrutinize pos1=verb stemmed1=y priorpolarity=neutral
type=strongsubj len=1 word1=scrutiny pos1=adj stemmed1=n priorpolarity=neutral
>>
>>58455058
what's a google?
>>
>>58455058
Google it you stupid twat.
>>
>>58454141
>If you're a programmer who doesn't know any C you won't even be taken seriously.
lol
>>
File: sadpepe.jpg (97KB, 700x437px) Image search: [Google]
sadpepe.jpg
97KB, 700x437px
>>58455058
>>58455074
these are not me!!!
>>
>>58455116
post feet to prove you're a girl if you want more help
>>
>>58455152
solve my problem for me and i will consider it anon
>>
>>58455058
It gives you the remainder of a integer division.
>>> print([n % 3 for n in range(1, 7)]) # n = [1..6]
[1, 2, 0, 1, 2, 0]
>>
#include <stdio.h>

main()
{
int c = EOF;

printf ("%3d\n", c);
}

Is this faulty in any way? Will the concept of EOF become more clear as I progress through the meme book?
>>
Is modulo useful for anything other than clamping a number to a certain number range?
>>
>>58455170
see >>58455040
>>
>that guy who doesn't compile with -fno-exceptions -fno-rtti

What's his story?
>>
>>58455193
First thought for another use is prime factorization.
>>
File: pretty-pwease.jpg (158KB, 1024x1445px) Image search: [Google]
pretty-pwease.jpg
158KB, 1024x1445px
>>58455194
c'mon anon implement it for me please!
>>
>>58455193
fizzbuzz
>>
>>58455009
Learn Haskell first
>>
>>58455224
tits first
>>
>>58455224
>implying you're actually a girl
>implying it's hard to find the solution on google
>>
>>58455173
> It gives you the remainder of a integer division.
Not always.
>>
>>58455224
What do you wanna do with the digits though ?
You didn't tell.
>>
>>58455264
Liars get no code.
>>
>>58455074
What is love?
>>
>>58455289
check em
>>
Anyone with experience using the BASC_py4chan python wrappers to use the 4chan API?

I'm trying to get all the links and the files of a thread in two separate lists within a loop, but this throws an error:

def get_img_links(self, thread, _res):

# File = high, width and file
board = basc_py4chan.Board('g')
board.get_thread(get_id(thread))
links = []
zsfile = []
post = 0
try:
for file in threadid.files():
links.append(file)
zsfile[post] = File(threadid.posts[post], file)
post += 1
except Exception as e:
print("Error: " + str(e))
Run.restart(self)


Error: list assignment index out of range

watdo?
>>
>>58455298
check = lambda n: "checked" if n%10 == n/10%10 else "kys"
>>
whoops, forgot code tags.

    def get_img_links(self, thread, _res):

# File = high, width and file
board = basc_py4chan.Board('g')
board.get_thread(get_id(thread))
links = []
zsfile = []
post = 0
try:
for file in threadid.files():
links.append(file)
zsfile[post] = File(threadid.posts[post], file)
post += 1
except Exception as e:
print("Error: " + str(e))
Run.restart(self)
>>
Would it be better to use a prefix tree or hash table, if the structure will be formed at the start of the program, and read from hundreds of times a minute?
>>
>>58454728
pleb
#include <set>
#include <string>

bool is_substring (const std::string &sub, const std::string &str) {
const size_t sub_size (sub.size ());
if (sub_size == 0) {
return true;
}
const size_t str_size (str.size ());
std::set<size_t> state { 0, };
for (size_t i (0); i < str_size; i++) {
const char c (str[i]);
std::set<size_t> next_state;
for (size_t j : state) {
if (sub[j++] == c) {
if (j == sub_size) {
return true;
}
next_state.insert (j);
}
}
state = next_state;
state.insert (0);
}
return false;
}
>>
>>58455331
>zsfile[post]

you cant do that
>>
>>58455412
More verbose than C
>>
>>58455441
Show me the same in C.
>>
>>58455362
I think a string comparison + a lookup in a hash table would be less expensive.
>>
>>58455445
see >>58454568
>>
>>58455492
How dare you compare your algorithm and mine?
>>
Why don't you just call the standard library's "Contains()" method?

Fucking nerds, wasting your time doing simple bullshit that's already built-in.
>>
>>58455412
Okay, but my code is C89 compliant and doesn't need the stdlib if you add
#define bool int
#define true 1
#define false 0
>>
>>58455573
It's just not the same algorithm. I could write my code in C89 but I would have to re-implement sets, I am too lazy for that.
>>
>>58455412
pleb
#include <string>
/**
* @brief is_substring
* @var sub
* substring
* @var str
* string
* @return
* true if substring is part of string.
*/
bool is_substring( const std::string &sub, const std::string &str) {
size_t found = str.find(sub);
return found != std::string::npos;
}
>>
>>58455640
>size_t
>not std::string::size_type

F-
>>
>>58455541
it's a problem solving exercise which is simple enough to do in a minute or so. the point is not to achieve the result YOU FUCKING RETARD. when you get past the code monkey shit you work with you'll actually have to do some real programming
>>
>>58455670
>not auto
>>
Where is microsounds, AkariBBS has been down for a while
>>
>>58455677
>real programming
>using the standard library to implement something that's in the standard library

Also fucking lol at
>the point is not to achieve the result

That's immediately apparent when some faggot makes a function that averages two integers, or any other useless trivial bullshit that gets done here constantly.
>>
>>58455715
kill yourself
>>
>>58455707
I'm trying to restart my VPS but it doesn't respond.

Avoid alpharacks, they're pure shit.
>>
>>58455640
>>58455670
>>58455685

>storing it in a variable at all

bool is_subtring(const std::string &sub, const std::string &str) {
return str.find(sub) != std::string::npos;
}
>>
>>58455727
Man, I'm trying to help you!

In fact, I believe your time would be better spent playing video games than implementing things that have already been done by teams of professionals with decades of experience.

At the very least, with video games your mood might improve a bit. Maybe go for a walk, or even come up with a decent project to work on that isn't trivial bullshit.
>>
>>58455794
fuck off you're absolutely retarded
>>
>>58455785
well fuck me.
I always reuse the position, I am getting sloppy.
>>
>>58455794
>>>/stackoverflow/
>>>/reddit/
>>>/hackernews/
>>
https://www.youtube.com/watch?v=2C0F7eFxhXM
What music are you programming to my dudes
>>
>>58455960
https://www.youtube.com/watch?v=5TF3kxIrFWo&t=1924
>>
>>58455677
The task of FizzBuzz is not to implement modulus.
If I was interviewing someone and they told me there is simpler way I haven't considered, then I wouldn't mind calling that a win.
Would you rather hire the developer who invent everything over the one that knows the simple practical solution?
>>
>>58455960
Good taste.

https://www.youtube.com/watch?v=9ByTkIMo4YI
>>
>>58455960
https://www.youtube.com/watch?v=CoN22-_nuUQ
>>
>>58456036
You're reading too much into it.
It's just a retard test.

If you can't solve it, you're clearly lying on your resume.
>>
File: lena_effect.png (1MB, 1024x1024px) Image search: [Google]
lena_effect.png
1MB, 1024x1024px
Hmm, since there's no requirement for the input to be a well-formed normal map, you can actually do all sorts of things.
>>
>>58456036
fucking idiot, non-trivial programming tasks require actual problem solving and writing the implementation yourself, not just calling a library function, but such tasks are typically much too big and hard to fit in a simple exercise, so you start with things like fizzbuzz or substring search as a beginner's learning exercise or for a job candidate to show that they have a basic understanding of the job they're applying for
>>
>>58456036
see >>58454234
It was just a basic algorithmic exercise. Not need to get all worked up.
/dpt/ is mostly populated by newbies anyway, if you want to see more serious and in-depth discussions about programming, see >>58455833.
>>
How long will it take for me to learn C#, if I'm already proficient with Java?
>>
>>58456396
Probably pretty quick considering they're basically the same language
>>
>>58456036
int mod(size_t a, size_t b){
int division = 0;
int rest = a;
int shifted_b = b;
for(int i = sizeof(size_t)*8-1; i >= 0; --i){
shifted_b = b << i;
if(rest >= shifted_b && shifted_b > 0){
rest -= shifted_b;
division += 1 << i;
}
}
return rest;
}

void fizzbuzz(int max, size_t f=3, size_t b=5){
std::string fizz = "fizz", buzz = "buzz", p;
for(int i = 1; i <= max; ++i){
p = "";
if(!mod(i,f)){
p += fizz;
}
if(!mod(i,b)){
p += buzz;
}
if(p.empty()){
p = std::to_string(i);
}
std::cout << p << std::endl;
}
}
>>
>>58454234
step aside losers
    function Find (Haystack, Needle : in String) return Natural is
begin
for I in Haystack'First .. Haystack'Last - Needle'Last + 1 loop
if Needle = Haystack(I .. I + Needle'Length - 1) then
return I;
end if;
end loop;
return 0;
end Find;
>>
>>58456396
should be very quick to get a shallow understanding of it and be able to use the language, will take longer to get through all the nooks and crannies before you can call yourself a C# expert
>>
How do I learn the .NET framework
I just wanna build neat shit for windows machines
>>
>>58456664

MSDN.
>>
>>58456664
Be more specific for what you're thinking of doing, because I have no idea what to recommend based on this comment alone.
>>
Is C# a solid choice for ransomware?

Obviously I'm only targeting Windows
>>
>>58456742

Does MSDN also offer tutorials?
>>
rate my 3rd c program

#include <stdio.h>
main () {
redo:
puts ( "do u like anime ? (y/n)" );
fflush ( stdout );
int i = getc ( stdin );
switch ( i ) {
case 'y':
case 'Y':
goto fag;
case 'n':
case 'N':
goto alpha;
default:
puts ( "retard" );
goto redo;
}
fag:
puts("ur a fag");
fclose ( stdout );
alpha:
puts ( "ur a cool guy" );
}
>>
>>58456968
>goto
>puts
>that indentation
Holy moly
>>
>>58456996
whats wrong with puts?
>>
>>58456968
>switch case goto
wtf
>>
>>58456968

10/10, rate mine:

http://pastebin.com/590tPDD9
>>
>>58456968
You might as well just use assembly if you're going to write C like that.
>>
File: DZYCVzp.png (394KB, 1126x849px) Image search: [Google]
DZYCVzp.png
394KB, 1126x849px
Is this gui layout decent? I'm adding a seek bar now
>>
>>58457246

Don't use extravagant colors unless the user chooses to have them
>>
>>58457246
I'm incredibly upset by that previous-track button being more off center than the next-track button
>>
>>58457030
nothing
>>
>>58457293
yeah, it's because they're characters from fontawesome, I will have to manually adjust their positions so that they're evenly spaced
>>
File: 1395812548986.png (862KB, 816x782px) Image search: [Google]
1395812548986.png
862KB, 816x782px
>>58457246
>burger menu
>>
File: 1421519955428.jpg (46KB, 413x427px) Image search: [Google]
1421519955428.jpg
46KB, 413x427px
alright so I've been breaking my head over this for too long now:

I am building some binary tree, but I need to do it concurrently. The way it should be done is that I start with the root node, then continue building the left subtree on the current thread and split off a task for the right subtree. There's a thread pool that I need to distribute the tasks to. So I used a concurrent queue in order to pop and push tasks from multiple threads.

The problem is managing the threads. I need to somehow have the threads keep consuming tasks from the queue, but a consumed task can itself add new tasks to the queue, so I can't simply quit when the queue is empty, as new tasks may still be produced, which the worker threads then need to eat up again.

I've been thinking about a solution with some waiting/signaling and semaphores to keep track of the amount of busy threads (empty queue and no busy threads would be a termination condition), but I can't quite figure it out.

Is there a common pattern for problems such as this? I'd love a neat solution.
>>
>>58456942
There are fucktons of write-up tutorials.

They have free video tutorials, too:
https://mva.microsoft.com/en-US/training-courses/c-fundamentals-for-absolute-beginners-16169?l=Lvld4EQIC_2706218949
>>
You make a bug report about memory leak and the maintainers gives you this
But it gets freed after return EXIT_SUCCESS;? :)

What do you do?
>>
>>58457653
for a short life-span program its faster to not free
but it's a horrible practice
>>
>>58457653
Lots of time there isn't a good reason to free things
>>
>>58456968
>writing to stdout after closing it
>wrong declaration of main()
>>
>>58454251
>GCC and other compilers are so advanced today that there's no point in programming in Assembly except for very niche situations.
No, not even close.
Any half decent asm programmer can trivially beat any C or C++ compiler, especially when it comes to code size.
>>
Is Perl better than Python?
>>
>>58457754
Source please
>>
Why does dressing like an Anime girl improve one's programming skills?
>>
>>58457791
Why haven't you killed yourself yet.
>>
>>58457773
>are hammers better than screwdrivers?
>>
File: 1421139501879.jpg (61KB, 420x599px) Image search: [Google]
1421139501879.jpg
61KB, 420x599px
>>58457803
>>
>>58457653
it's fine
>>
>>58457773
>is garbage better than gold?
>>
File: star.png (3KB, 336x306px) Image search: [Google]
star.png
3KB, 336x306px
i have two books

java for dummies 6th editon and thinking in java 4th edition

wich one should i start. I actually know basics in java but i feel insufficient.
>>
>>58457842
>python
>gold
kys yourself an on
>>
>>58457754
>doubt.jpg
maybe in very specific cases like inline assembly in tight loops where the programmer has more information about the problem than the compiler does
>>
>>58457773
Perl if you work alone and no one will ever read your code.
Python if collaboration is part of your process.
>>
File: 1427396083993.jpg (294KB, 1024x768px) Image search: [Google]
1427396083993.jpg
294KB, 1024x768px
>>58453794
>that everything
Is newer anime really this shit or is it just the fanservice/weaboo shit that overshadows the good anime?
>>
>>58457898
all anime is shit
>>
Can anyone post the pic with all the project ideas, so we can roll on what to do?
>>
>>58457898
Himegoto was fucking garbage.
I don't know why the literal fags on here keep posting that stupid shit.
>>
>>58457960
>the literal fags
it's one guy who keeps forcing it

sometimes someone else will post it ironically
>>
>>58457987
I have a feeling that /g/ consists from fucking one forcing guys
>>
>>58457960
Himegoto was shit, and the sub group knew that. The Funsubs make watching it entertaining though.
>>
>>58458039
The particular webm is just some autist who edited the subs.
Nobody would actually release a fansub like that, considering that the """""jokes""""" are far too niche.
>>
>>58458068
>jokes
There wasn't anything funny about that webbum.
>>
>>58458076
Didn't you notice the """"""""""?
Of course they're not funny.
>>
File: WHY.jpg (15KB, 318x318px) Image search: [Google]
WHY.jpg
15KB, 318x318px
>Tell one of my most trusted professors I want to specialize in C# and I'd appreciate some guidance
>He straight up laughs and tells me to go Java instead if I don't want to end up being, and I quote "Microsoft's little bitch"
>mfw

Should I pull the trigger and specialize in C#? should I even specialize at all? Why do most of my professors hate C#?

Help me /dpt/ I can't freelance forever.
>>
>>58457906
but Anime makes you a better programmer
>>
>>58458087
Listen to your professor
>>
>>58458084
:)
>>
>>58458109
I know java opens up a lot of doors but I have faith in C# becoming widespread in the following 5-10 years, I know I'm pretty much taking a gamble but imagine the possibilities.
>>
File: assembly.png (312KB, 506x662px) Image search: [Google]
assembly.png
312KB, 506x662px
>>58458087
Specialise in Web Assembly.
>>
I'm trying to figure out why the output of Racket's inflate/deflate isn't the same as the output from zlib-flate. Data compressed by one cannot be uncompressed by the other and it seems as though the difference is two bytes: zlib-flate will create compressed data with
#x78 #x9c
at the beginning while Racket does not have those two bytes. Removing them before sending to Racket for processing will make Racket happy and adding those two byes to Racket's compressed data will make zlib-flate happy.

I'm just really confused as to why there's two bytes missing from Racket's compression functions. There might be something that's different between the two at a more fundamental level, but I don't know DEFLATE well enough to go into either and look at the source.
>>
I plan to make an app where I can track all the food I buy by scanning it and entering an expiration date. The app will notify me when the expiration date is arriving and might also provide some tips when connected to the internet.

Is this beginner friendly?
>>
>>58458087
based professor

don't listen to the microcuck shills on here

>>58458147
>I have faith in C# becoming widespread in the following 5-10 years
C# is genuinely an inferior language to java and people in the industry avoid microsoft's platforms as much as they can, you can't trust microsoft
>>
>>58454225
Cool, helpful idea
>>
>>58458169
>you can't trust microsoft
Not that I don't agree with you, but you can't really trust Oracle either.
>>
>>58457246
Give it a grey gradient or even steal a popular music player's colour scheme so normies can relate
>>
>>58458200
:)
>>
>>58458200
I have no problems with stealing a layout, a dark one would be good I guess. It's all just a matter of swapping some css around. Suggestions? What do normies use these days?
>>
>>58458168
In general, the more IO there is, the less beginner friendly something is. This has to:
- Convert a physical code to a representation in the program's memory
- Connect to a database (or at least a file of some sort) with all the information required to recognise scanned products
- Display this data back to the user in a nice format
>>
>>58458287
>What do normies use these days?
Spotify on their iPhone or Android
>>
>>58458087
>Should I pull the trigger and specialize in C#? should I even specialize at all? Why do most of my professors hate C#?

Where I live you're better of specializing in C#.
Most development here is being done for businesses, which are using windows ~80-99% of the time, so .Net is pretty much a perfect match for everything you want to do.

Hating any programming language (The whole C# vs Java thingy) is childish and should not be promoted by professors. They should be ashamed when calling themselves software developers / engineers / whatever and start teaching unbiased lessons.
>>
>>58458169
>people in the industry avoid microsoft's platforms as much as they can
Talking out of your ass.

Active Directory, Exchange, and SQL Server are ridiculously widespread among businesses, particularly the SMB world.

Why do you think Oracle is any better than Microsoft?

At least Microsoft is beginning the process of making all the dev tools free and open-source. Hell, .NET is first-class tech on Red Hat Enterprise Linux now, and Canonical (Ubuntu) has joined the .NET Foundation.

It's odd though. If you would have told me in 2008 that Microsoft was going to be actively contributing to and advocating FOSS, I'd have called you crazy. It makes sense, though, considering Azure is growing insanely fast, so if they open up their ecosystem, more will want to use it.
>>
>>58458093
Yes, it is very educational.

https://www.youtube.com/watch?v=Iojvf72xJfs
>>
>>58458310
I need to create projects for my internship applications due by Nov this year. I need good ideas so I can get a Google internship!
>>
>>58458087
>Should I pull the trigger and specialize in C#? should I even specialize at all? Why do most of my professors hate C#?

You should learn everything you can, and expose yourself to many languages.

That being said, C# is huge in my market space, so I'm glad I know it. Comfy language, too.

If you want exposure to the most possible jobs, then learn Java. C# has a fuckton of jobs, and is generally more enjoyable to work with, in my experience. C, C++, and Python all have many jobs, and are very common as well.

You do you, man. Do some research and stick with what you like.
>>
>>58458385
>I need good ideas so I can get a Google internship!
Just stop.
Google (probably?) only takes top notch people.
Top notch people have the ideas they need without asking other people for them.
>>
>>58458387
go where?
/dpt/?
>>
>>58458346
>businesses, which are using windows ~80-99% of the time
but /g/ told me that all businesses use linux
>>
>>58458402
>google takes top notch people only
>they created an entire shitty braindead programming language with shitty interns in mind

hmm
>>
>>58458405
yes.
>>
>>58458402
>>58458385
I think they take like 1-2 software devs per year, and that's out of tens of thousands of applications.
>>
>>58458387
Yes, but first you need to write a function that reverses a string in Haskell.
>>
>>58458432
okay.. I've never done coding before but I trust you.
Where do I start?
>>
>>58458402
>Google (probably?) only takes top notch people. Top notch people have the ideas they need without asking other people for them.
I don't restrict myself with preconceived notions such as what you've done.
>>
>>58458431
Google hires 1500 interns per year.
>>
>>58458432
In Haskell, you can leverage a zygohistomorphic prepromorphism and it's just:
import Control.Morphism.Zygo
import Control.Morphism.Prepro
import Control.Morphism.Histo
import Control.Functor.Algebra
import Control.Functor.Extras

zygoHistoPrepro
:: (Unfoldable t, Foldable t)
=> (Base t b -> b)
-> (forall c. Base t c -> Base t c)
-> (Base t (EnvT b (Stream (Base t)) a) -> a)
-> t
-> a
zygoHistoPrepro f g t = gprepro (distZygoT f distHisto) g t
-- unless you want a generalized zygomorphism.
>>
>>58458492
>all this to do a simple operation

Why is Haskell so absolutely heretical
>>
File: 1473222274372.jpg (81KB, 720x720px) Image search: [Google]
1473222274372.jpg
81KB, 720x720px
>Learn the fundamentals of python.
>forgotten all of it.

It's hard for me to learn something if I don't have a class for it.
>>
>>58458534
>i need to pay money to remember things

hahahaha
>>
>>58458466
I've heard this book is pretty nice to get started with Haskell : http://gen.lib.rus.ec/book/index.php?md5=5F7CF3E82EFFFECBF70CC7EF6BE6AA63
Otherwise the classic introduction is http://learnyouahaskell.com/
>>
Has anyone used the Google places API for android? I want to get the place ID at a specified latitude and longitude, but the reverse geocoding API only gives an address. Is there a direct way to get the place at a specified latitude and longitude?
>>
>>58458534
>forgotten all of Python
Nothing of value was lost.
>>
>>58458632
Python is a fantastic language with endless applications.
>>
>>58458534
so you don't know how you learn, or at least how to do it without outside pressure. this a project more important than any programming language
python is shit though
>>
>>58453794
What anime is this?
>>
>>58458652
>indentation as code blocks
>fantastic
Maybe when I was 12 or something like that
>>
>>58458669
It's shit one
>>
>>58458677
Yeah, better to pollute the code with tons of unnecessary {{{braces}}}

(also i am absolutely not surprised that the untermenschen would overlook an entire language because of a largely cosmetic issue)
>>
Hello /g/entoomen. I seek your wisdom concerning books for a beginner programmer.

My end game: AI and/or robotics (from industrial to whatever) from a design standpoint (management or prototyper etc)

My experience: Currently studying Electrical Engineering Technology in College (hands on engineer I guess? Between an industrial electrician and full blown engineering). I've taken a few new robotics courses working with Ardunios. Gonna get PLC exp soon.

I'm decent at math, but something I'm working on to improve, slowly working through Spivak's Calculus. I have some previous experience coding, I find I have a good head for programming, comes relatively easy to me and I'm anal about organization and neatness in code. I like to get creative with solutions.

I have a few books in mind I also want to pick up:
Code Complete 2nd ED
Head First Design Patterns Into Design Patters: Elements of OOP
Algorithms Unlocked Into Introduction to Algorithms (Thomas H. Cormen)
Code: The Hidden Language of Computer Hardware and Software
Structure and Interpretation of Computer Programs
Refactoring: Improving the Design of Existing Code

Took these books from the highest rated/most recommended lists, are they memes? Worth my time?

I'm looking to start learning C, Python, Java and get into R, Lisp, C++ later on. I guess I'm asking you guys what are some solid books, in your opinion, that I can get to start learning the first 3 languages. THANK YOU IN ADVANCE.
>>
>>58458677
>muh indentation
Nice meme.
Meanwhile, scientists are using SciPy and Caffe to do actual research while you shitpost on this Guinean watercolor enthusiast forum.
>>
>>58458689
Then what should I watch?
>>
>>58458782
it has been good for exposing to morons (and up) an interface to the code that does the real work. i agree with this completely
>>
>>58457702
>t. pajeet
>>
>>58458837
watch himegoto instead of that shit in the op
>>
funext : ((x : A) => (f x == g x)) => (f == g)
funext p @ i = \x -> p x @ i
>>
>>58458889
Not an argument
>>
>>58458891
>4 min. per ep.
What
>>
Instead of having global variables am I supposed to pass every single variable that a function needs as an argument instead?

What if it results in like 50 different arguments and there are other functions that also depend on those variables? Wouldn't it be better to just have global variables.
>>
>>58458929
>What if it results in like 50 different arguments

That's what struct pointers are for.
>>
>>58458908
Just promise me you'll never writing a long-running application of any kind
>>
File: Mind the gap.png (159KB, 754x561px) Image search: [Google]
Mind the gap.png
159KB, 754x561px
So I'm trying to fix Unity's totally fucked occlusion
The matrix I'm dealing with is the one in green. For some reason, as the near clipping plane gets farther from the camera, this fucking matrix seems to scale, translate, or something else the same distance away from not the camera, but the camera's near clipping plane.

Two questions.
1. Does anybody know the exact semantics/breakdown of how an "occlusion matrix" would work? It's not a projection matrix, as when I assign the occlusion matrix to the projection matrix everything gets fucked
2. Does anybodyk now what kind of matrix math I'd need to fix this? It's even worse with oblique frustums, causing the side that's moving to scale its distance at the distance it should ^ 2, which causes an invalid matrix incredibly quickly
>>
>>58458934
What are struct pointers in JavaScript? Just objects? I only program in JavaScript desu.
>>
>>58458935
I would use unique_ptr, shared_ptr and RAII anon, unless I'm stuck with C.
>>
>>58458968
struct pointers would be object references in JS.
>>
File: segg.jpg (761KB, 2000x848px) Image search: [Google]
segg.jpg
761KB, 2000x848px
Image segmenter.

>takes .pgm of handwritten/digitally written words, numbers, etc
>converts to 2D vector of 0s and 1s
>splits each character into separate 2D vectors
>normalizes them to be 1:1 aspect ratio and empty rows/cols culled to trim as close to the character as possible
>output are several .pgm images of each character
>>
>>58458929
If you need 50 different arguments, there is something wrong with your code. Use arrays.
>>
>>58458167
Are you using mzlib/deflate or file/gzip? Specifically which procedure? At least in other (retarded) languages that I've used, there were options for writing out a raw zlib bytestream vs a proper gzip bytestream, with all necessary header information. So could it be that?
>>
File: microsoft pajeets working hard.jpg (36KB, 1234x406px) Image search: [Google]
microsoft pajeets working hard.jpg
36KB, 1234x406px
What's wrong with microshit?
>>
>>58458515
You know he's memeing you, right?

reverse str
>>
>>58458935
> Lots of times
> Interprets it as all the time
Brush up on your English, Rajesh
>>
You realize no matter how good you get at coding, chad will always pull more anime girls than you, right|?
>>
>>58459097
one is plenty
>>
>>58459053

Nice.
>>
>>58459056
You realize that I'm memeing you, right?
>>
>>58458985
Which are techniques for freeing things while allowing for e.g. ownership transfer, etc. I was just pointing out that not freeing things in a long-running application is not a particularly good idea.

Not freeing things with an explicit free()/delete is another topic and using reference counted pointers or destructor semantics instead still counts.
>>
>>58453794

How do you write collision detection for a raytracer that only has spheres
>>
>>58454234
bool hasSubstring(String string, String subString){
int found = 0;
for(int i = 0; i < string.Length; i++{
if(string.Length < subString.Length)
return false;
if(string[i] == subString[i]){
found++;
continue;
}
else
string = string.Substring(1, string.Length - 1);
if(found == subString.Length)
return true;
}

return false;
}

r8
>>
>>58459168
syntax error/10
>>
>>58458891
himegoto is the shit in the op
>>
>>58459057
>Actually trying to defend being a shit programmer by autistically pointing out the precise meaning of a sentence and why that justifies your incompetence
I'm sorry Pratheepan
>>
>>58459097

void becomeChad(int heightStartsWith, long long moneyInBank, bool hasFacialAesthetics, bool hasSixPack) {
if (heightStartsWith == 5){
heightStartsWith = 6;
}
if (moneyInBank < 100000){
moneyInBank *= 9999999;
}
if (!hasFacialAesthetics){
cout << "consider plastic surgery" << endl;
}
if (!hasSixPack){
workOut();
eatHealthy();
}
}
>>
>>58458087

Being a Microsoft bitch is better than being an Oracle bitch. Fuck Java; it's an unpleasant language to work in.
>>
>>58459127
I know, I know, and when I use malloc()/new, I always try to free the memory even when I only allocate a couple of things on the heap, because it's good practice, and if the application grows it will be easier to build something over the existing code.
It's just that this pajeet meme adds nothing to the discussion.
>>
>>58459190
It's OK, Hiran, everyone makes mistakes, but not every program needs to free all the variables before close because you have OCD.
>>
>>58459051
I'm using deflate from file/gzip - different from the gzip functions in the same library. I wonder if that's something I should test...
>>
>>58454234
beginsWith = zipWith const >=> (==)
-- no explanation needed


contains [] _ = False
contains (x:xs) s = (x:xs) `beginsWith` s || xs `contains` s
-- if it is empty, it doesn't contain anything
-- if it begins with s, it has the substring s
-- otherwise, check if the tail contains the substring s
>>
>>58459196
code doesn't actually alter reality like that
>>
>>58457037

> pleb
> cant handle goto
> mind is blown to pieces
>>
>>58459239
> I always try to free the memory even when I only allocate a couple of things on the heap
Sounds good to me.

>this pajeet meme adds nothing to the discussion
True, but I enjoy biased racial stereotyping. I'm sorry anon, I can't help it :(
>>
>>58459287

unfortunately.

thats why i made it for my WoW character.
>>
>>58459176
fugg
>>
>>58459253
No problem Ranganathan, as long as you're just writing toy web applications there's no need to worry and you can leave the server apps to the pros.
>>
>>58459053
Reminder that Go was designed to be a langugae or Googlers too dumb to learn C. Looks like MS is using it as was intended.
>>
>>58459305
>True, but I enjoy biased racial stereotyping. I'm sorry anon, I can't help it :(
It's alright, it's my fault anyway. I should spend more time programming instead of browsing imageboards so I could hang out with all the cool progressive Bay Area kids on HN.
>>
>>58459196
>
moneyInBank *= 9999999

Nothing multiplied by 9999999 is still nothing, nerd.
>>
>>58459028

Also rate my code:

http://pastebin.com/b5Ndw6B2
>>
>>58459051
>>58459270
The output of mzlib/deflate and file/gzip (with regards to the deflate function) are identical.
>>
>>58459352
just hope he doesn't have an overdraft...
>>
>>58457037
Inside a switch case is the only valid reason to use goto in some languages, as it facilitates case-fallthrough.
>>
>>58459329
Samar, why are you autistically acting like knowing when freeing memory is unnecessary implies I don't know how and when to use it?
>>
>>58459196
>heightStartsWith
This is what you get for not using the metric system, America.
>>
File: 1478810413613.jpg (57KB, 480x608px) Image search: [Google]
1478810413613.jpg
57KB, 480x608px
>>58459361

>typedef unsigned int usint;

stopped reading here
>>
>>58459382
not an argument.
>>
File: 1483423464145.jpg (96KB, 576x720px) Image search: [Google]
1483423464145.jpg
96KB, 576x720px
>>58459053
https://github.com/Microsoft/go-winio/blob/master/wim/lzx/lzx.go
Jesus fucking Christ, it's real.
>>
>>58459352

if (moneyInBank > 1 && < 100000){
moneyInBank *= 9999999;
}


happy faggot?
>>
>>58459053
I wonder what brought your attention to this?

https://github.com/Microsoft/go-winio/issues/38
https://www.reddit.com/r/ProgrammerHumor/comments/5nksq5/should_we_tell_them/
>>
>>58458740

Okay... is there somewhere better I can ask this question?
>>
>>58459469
>>58459442
https://github.com/Microsoft/go-winio/issues/38
>>
>>58459478
reddit
>>
>>58459478
>>58458740
Haskell From First Principles
>>
File: MTQxMTY3ODM0MTQ2Mjg1MjUy.jpg (36KB, 641x480px) Image search: [Google]
MTQxMTY3ODM0MTQ2Mjg1MjUy.jpg
36KB, 641x480px
>>58454812
(setq-default indent-tabs-mode nil)

If thats not good enough for you:

(add-hook 'before-save-hook (lambda () (untabify (point-min) (point-max))))

t. Emacs Shill
>>
>>58458383
omg lol
>>
>>58459467
That doesn't change anything you retard
>>
bnis n vggna
>>
File: 1483930295515.jpg (5KB, 228x221px) Image search: [Google]
1483930295515.jpg
5KB, 228x221px
>>58459486
>replies to >>58459469
>posts the link in >>58459469
>>
Sup faggots first one to name best java environment for beginners isn't a faggot 3 2 1 GO
>>
>>58459695
vim
>>
>>58459695
emacs
>>
>>58459695
Trick question.
>>
Does anyone have any examples of a useful application in Scala that I can look at the code for?
>>
>>58459695
nano
>>
>>58459630

it does i just forgot to include the variable in the 2nd condition
>>
File: file.png (12KB, 821x187px) Image search: [Google]
file.png
12KB, 821x187px
So which one of you is this?
>>
>>58459695
I like IntelliJ
>>
>>58453794

working on not sucking.

Slow going...
>>
>>58459739
I actually wrote an email to Stallman asking him to recommend me a decent free program for editing small text files quickly and he said GNU nano. What did he mean by this?
>>
>>58459695
>>58459712
>>58459721
s p a c e m a c s

However I dont write java, depending on what kind of code you're cranking out maybe an IDE would be less stressful to learn. If you need some corporate-bullshit-level build system or 2million LOC codebase managament, maybe one of those would be better. Intellij IDEA would be my first suggestion in that case. It has a built in plugin that emulates vim binds and I've heard it has one for emacs keys too.
>>
>>58459750
that's me, why are you asking?
>>
>>58459786
why do you have a zizek avatar ?
>>
>>58459750
What the fuck? That's my post the i posted here: >>58459333
>>
>>58459768
Exactly what he said. Nano is great for editing config files and such.
>>
>>58459798
because he's a cool guy and this photo looks like a generic github user avatar
>>
File: 1403837987365.png (48KB, 400x389px) Image search: [Google]
1403837987365.png
48KB, 400x389px
>If you are interested, we are looking forward to your current profile in Word format (please no PDF)!
>>
>Haskellfags can't solve this!
Given a list of numbers,
find the arithmetic mean of the numbers,
reading the list only once and using O(1) memory
>>
>>58459742
>it does
The only thing that could change is if moneyInBank is 0, and it's going to stay 0 with or without your change.
>>
>>58459955
import statistics
statistics.mean(alist)
>>
File: 1439659548554.gif (698KB, 350x148px) Image search: [Google]
1439659548554.gif
698KB, 350x148px
>>58459935
>[Company] is looking to revamp its website to look and function more like Youtube and is looking for students with a deep understanding of web development and design who would like to take this on as a class project. [Company] is an online forum where authors can publish original short stories, blogs, art, memes, gifs, podcasts, photos, poems, etc. This is an unpaid opportunity, but is a great way for students to get some real world experience.
>>
>>58459994
You are not getting hired with such code.
>>
>>58459955
numbers = [1, 3, 7, 4]

mean = 15/4
>>
>>58459955
Given a list of numbers,
find the arithmetic mean of the numbers,
reading the list only once and using O(1) memory


for each_index in list_of_numbers:
list_of_numbers[0] += list_of_numbers[each_index+1]
if (length(list_of_numbers)-1 == each_index):
return (list_of_numbers[0] / length(list_of_numbers))
>>
>>58460164
>>58459955
to clarify my solution, only the memory need to store the list of numbers to be calculated is used. no other memory is used in this solution
>inb4 cpu stack memory. Im not giving an assembly language solution.
>>
>>58460120
>you are not getting hired for getting shit done
>>
How do I calculate the mean of a derivative function without triggering the arithmetic boolean loop in the core? I need to shut down the proxyguard in a vpn
>>
rip next thread
2017-2017
you were only 12 posts old
>>
>>58458432
foldl (flip (:)) []
>>
>>58459126
Jinx
You've been countermemed

Now you're only allowed to program in Haskell
>>
>>58459955
>Haskellfags can't solve this!
mean lst = (foldr (+) 0) lst / (fromIntegral . length) lst
>>
>>58460630
The first step is to read the question.
The second step is to understand it.
The third step is to attempt it.

Where did you go wrong?
>>
File: hacker.jpg (64KB, 740x400px) Image search: [Google]
hacker.jpg
64KB, 740x400px
Can you get a job with assembly?
>>
new thread now
e
w

t
h
r
e
a
d

n
o
w
>>
>>58459955
https://hackage.haskell.org/package/inline-c-0.5.5.9/docs/Language-C-Inline.html
>>
>>58460686
>>
>>58460691
(new)
>>
File: apu.jpg (34KB, 655x527px) Image search: [Google]
apu.jpg
34KB, 655x527px
>>58459955

val (sum, n) = ((.0, .0) /: xs)((λ, µ) => (λ._1 + µ, λ._2 + 1.0))
sum/n
>>
>can NEVER think of things to code
Guess I'm waiting until my next easy as fuck school assignment
>>
>>58454466

This will return (either true or false) if first character matches regardless of whether the rest of the characters match.
Thread posts: 318
Thread images: 29


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