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

File: OOSC.jpg (29KB, 356x486px) Image search: [Google]
OOSC.jpg
29KB, 356x486px
Old thread: >>58882828

What are you working on, /g/?
>>
>>58888613
"The most powerful programming language is Lisp. If you don't know Lisp (or its variant, Scheme), you don't know what it means for a programming language to be powerful and elegant. Once you learn Lisp, you will see what is lacking in most other languages." -Richard Stallman
>>
>>58888673
*haskell
>>
File: 15822597.jpg (5KB, 370x334px) Image search: [Google]
15822597.jpg
5KB, 370x334px
I have decided to write a *nix desktop framework entirely written in Rust and Golang.

The DE will be free for buffer overflows and memory leaks.

However, writing a window manager for X is not a simple task.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <X11/Xlib.h>

int main()
{
Display *d;
Window w;
XEvent e;
int s;

if (!(d = XOpenDisplay(NULL))) {
fprintf(stderr, "Couldn't open display and I hate C.\n");
exit(1);
}

s = DefaultScreen(d);
w = XCreateSimpleWindow(d, RootWindow(d,s), 0, 0, 110, 20, 0,
0, WhitePixel(d,s));
XSelectInput(d, w, ExposureMask | KeyPressMask);
XMapWindow(d,w);

while (1) {
XNextEvent(d, &e);
if (e.type == Expose) {
XDrawString(d, w, DefaultGC(d, s), 5, 15, "Can you read me?", 16);
}
}

XCloseDisplay(d);
return 0;
}


^I hope it gives you an impression how unproductive C is.
>>
File: 1459278447844.png (250KB, 649x616px) Image search: [Google]
1459278447844.png
250KB, 649x616px
in the current year of the lord
second for Rust
>>
thanks anon from prev thread
now if I had an array of 100 elements where would I input a print line to fill this all out
>>
File: 4567yghj3.png (67KB, 593x478px) Image search: [Google]
4567yghj3.png
67KB, 593x478px
>>58888720
works for me
>>
>>58888720
>Xlib
Please anon, it's 2017.
Use xcb instead.

But really, don't blame your own ineptitude on C.
>>
File: watari.png (406KB, 500x660px) Image search: [Google]
watari.png
406KB, 500x660px
This is the the face of a Perl program :3
>>
File: tumblr_nzqieofCCb1shlg3vo1_500.gif (1MB, 500x281px) Image search: [Google]
tumblr_nzqieofCCb1shlg3vo1_500.gif
1MB, 500x281px
>>58888807
You are not trolling me, anon
>>
>>58888807
is xcb available in lisp
>>
File: vomit.jpg (90KB, 650x650px) Image search: [Google]
vomit.jpg
90KB, 650x650px
>>58888834
>That gif
Jesus Christ, anon. What the fuck?
>>
>>58888746
Change line 20 to use print, then print whatever you want to fill the row with after that, using println.
>>
>>58888807
What makes Xcb so special?
>>
>>58888888
>>
haskell is shit
>>
>>58888871
no
>>
File: andrei.jpg (18KB, 200x256px) Image search: [Google]
andrei.jpg
18KB, 200x256px
D
>>
>>58888864
The API is much cleaner, in my opinion.
Although I haven't done any "serious" X programming.
>>
Rust
>>
File: 1463061905756.jpg (98KB, 620x520px) Image search: [Google]
1463061905756.jpg
98KB, 620x520px
>>58888884
Well, if one wants to make an independent from GTK/Qt libraries X program, does Xcb provide him such possibilities?
>>
>>58888962
yes
>>
>>58888962
It's just an alternative to Xlib. It's not tied to any of the toolkits at all.
>>
>>58888882
Does D have monads?
>>
>>58888962
XCB is just a different API for X, it's functionally equivalent to Xlib.
>>
File: 123wed.jpg (17KB, 404x375px) Image search: [Google]
123wed.jpg
17KB, 404x375px
post all the programming language paradigms you know
>>
>>58889078
Hinduism
>>
>>58888613
Not technology
>>
What's good glib alternative for C?
>>
>>58889125
You don't need to use a library that ridiculously bloated.
>>
File: 1485002137932.png (704KB, 2015x2204px) Image search: [Google]
1485002137932.png
704KB, 2015x2204px
>>58889078
Well, it must be defined before what categories we are talking about at first.
I can name imperative and declarative programming, and say "That's all, I've named them all!".
>>
I'm in second semester of computer engineering atm...
It's so stupid. Reports seem like such a waste. Half of the information in there is just filler text.

I'm at uni around an hour a week, and I am still ahead of the schedule.
I can finish a group assignment due in 3 weeks by myself on the same day it's given.
The only subject I struggle with is physics, which 99% of the students will never need in their job life. But hey, gotta generalise amirite.

I'm legitimately thinking about just trying to find a job, and quit uni if I find a decent one related to computers.
>>
>>58889125
http://www.etalabs.net/compare_libcs.html
>>
>>58889160
>second semester of degree
>I know everything

Don't drop out anon, you don't know shit.
>>
>>58889169
>but as I am the author of (((musl))), that may have influenced my choice of which aspects to compare.
>>>>>>>>>>>>>>>>>>>>>>>>>/trash/
>>
>>58889169
glib not glibc you stupid fucking nigger.
>>
>>58889125
Never mind I think I found a good one
https://github.com/rampantpixels/foundation_lib
>>
>>58889175
I'm not a know-it-all mate.

I am aware I don't know everything, but I have looked at and read a lot about what we are going to learn.

I know that I know everything this uni is going to try teach me. However, I'm not saying I know more than a veteran programmer.

I've been doing this for almost a decade now. I am not retarded.
>>
File: 1481916546254.jpg (47KB, 645x968px) Image search: [Google]
1481916546254.jpg
47KB, 645x968px
>>58889160
>The only subject I struggle with is physics,
>>
>>58889230
Why do you space your posts like that, redditor?
>>
function query(slug, id)
{
fetch('/api/'+slug).then(function(response) {
return response.json();
}).then(function (jsonr) {
console.log(id);
output_response(jsonr);
});
}

for (i = 0; i < slugs.length; ++i) {
query(slugs[i], i);
}


How do you make this work like a sane person would expect it to (ie. the console.log in the fetch callback logs 0, 1, 2 ... slugs.length, rather than just repeatedly logging slugs.length)?
>>
>>58889293
I don't know, I feel it's easier to structure easier that way. Maybe I'm autistic. Who knows.

I don't use Reddit, so I'm not sure what you mean. It seems you know all about it though.
>>
>>58889314
use arrow functions and for each of, then consider fucking off and not using jablescript
>>
File: why go.jpg (25KB, 655x349px) Image search: [Google]
why go.jpg
25KB, 655x349px
Or rather, why not Go?
>>
Lisp WASN'T built for functional programming.
>>
emacs or vim?
>>
>>58889438
Go should have been named Stop
>>
>>58889438
Golang is Java and C# done right.

Waiting for that autistic microsoft shill to screech on me
>>
>>58889480
Go has all of the disadvantages of a garbage-collected language and none of the advantages, and all of the disadvantages of a low-level systems language and none of the advantages.
>>
>>58889435
> then consider fucking off and not using jablescript
I wish I could just do this. I fucking have Javascript and webshit in general.

How would arrow functions be used in this case? I tried looking them up on MDN but I honestly don't see how to make them work here.
>>
File: 12506712.jpg (20KB, 331x315px) Image search: [Google]
12506712.jpg
20KB, 331x315px
>>58889496
Oh here we go, Im sorry pajeet but your shitty C# and Java are going to die once golang mobile goes mainstream
>>
>>58889497
function(response) {
return response.json();
}

becomes
resp => resp.json()

and
function (jsonr) {
console.log(id);
output_response(jsonr);
}

becomes
jsonr => {
console.log(id);
output_response(jsonr);
}

also
for (let slug of slugs) {
>>
>>58889520
I can't wait for C# and Java to die.
>>
Jesus the Vulkan API registry is so bad.
>uses XML
>uses the same tag for different things, uses differentiated by an attribute, instead of just different tags
>uses <type> for things that aren't types
>contains literal C code like "type *name" that isn't marked up accordingly and has to be parsed on top of the XML if you're not generating a header for C or C++
It's basically poorly marked up C.
>>
>>58889496
this
>>
>>58889540
what are you parsing it for?
>>
>>58889573
Rust
>>
>>58889529
Doing that results in the exact same problem. console.log output still only just prints slugs.length multiple times.
>>
File: languages3.png (17KB, 522x384px) Image search: [Google]
languages3.png
17KB, 522x384px
Reminder that pic related is correct
>>
>>58889715
>Haskell
>Fast development
>>
>>58889715
Python is good for rapid prototyping and so is Ruby.

Golang is more productive and faster than .NET and JVM languages. How about posting your epic fizzbuzz instead of your forced meme. Both are equally laughable.

>Hasklel
>Good for anything
I genuinely chuckled
>>
>>58889715
Neither is missing Rust
>>
>>58889840
>t. neo-/g/ "programmer"
>>
>>58889864
t. ""rust artisan"""
>>
>>58888771
>Works for me
I know, and yet I hate C. Do you see how ugly my code is?
>>
>>58889874
t. (((expert))) C kernel hacker
>>
File: C3WNK48VMAE7KzN.jpg (93KB, 800x806px) Image search: [Google]
C3WNK48VMAE7KzN.jpg
93KB, 800x806px
>>58889874
>>58889896
Calm down
>>
File: dpt.png (550KB, 1905x1001px) Image search: [Google]
dpt.png
550KB, 1905x1001px
Toy programming project in C++ / OpenGL, next up I will generate vegetation with L-systems :)
>>
#include <stdio.h>

int main (void) {
const volatile static unsigned long long int hi = 0;
if (!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!hi) {
puts("Hi2u2!");
}
return 0;
}


>Current state of C
>>
File: Cov.jpg (144KB, 480x480px) Image search: [Google]
Cov.jpg
144KB, 480x480px
I need some advice /g/uys.

So I'm graduating this quarter with a bachelors in CS from a pretty good Cal state. I live in the LA area, so I've been able to apply to what seems like a fuck ton of jobs. I've already visited 2 companies for interviews and have been rejected from both. I'm worried that because I have no internship experience or on the job experience I'm not gonna get anything.

One of the companies said that I needed "more experience". Mind you, this was after a very lengthy interview process which included a take home coding project. The job was also described as being entry level, which is all I really apply for. I'd like to think I'm pretty good at not being autistic and presenting myself well at these interviews.

Am I just worried for no reason? Should I just keep using the shotgun approach and applying anywhere hiring "entry level" until something sticks?
>>
>>58890017
>job was also described as being entry level,
>said that I needed "more experience"
Welcome to the job market, friend.
>>
>>58889991
why not c and vulkan you casual
>>
>>58889991
How many lines of code?
>>
Is it normal to feel overwhelmed and miserable every day in a SD job? I have a feeling I am in for a heck of a career
>>
>>58890030
And here I thought it was a meme

:(
>>
>>58890001
There are some other qualifiers you could have thrown in there without just adding duplicates.
>>
File: Capture.png (39KB, 589x342px) Image search: [Google]
Capture.png
39KB, 589x342px
>tfw babby's first graphic programming
I already hate myself and everything
>>
>>58890001
I just posted this code in the C thread. It's my intellectual property. Don't post it again or legal action will be taken.
>>
>>58890017
>apply to programming job
>you need to know how to program
you don't say
>>
>>58890121
you should have added a copyright warning
>>
>>58890105
The only people who say that either got their job via nepotism or don't have a job
>>
File: alan2.jpg (43KB, 512x288px) Image search: [Google]
alan2.jpg
43KB, 512x288px
>>58890001
>>
>>58890130
© me.
>>
>>58890120
git gud
>>
>>58890121
Too bad it wasn't GPL'd
>>
>>58890129
I have a few decent projects on my resume that I always talk about, one of them being a first place prize (for some API) at a hackathon.
>>
>>58890048
I enjoy some std every now and then. Id like to try out Vulkan but I'm still fairly novice with 3D graphics so I figured it's wiser to start with the easier API.

>>58890065
2251
>>
>>58890201
you probably sucked at the take home coding project and at demonstrating technical knowledge. just because you can wrote code doesn't mean they don't have applicants who are orders of magnitude better than you
>>
>>58890232
yeah! you're shit! this chronic negativity and piss taking has to end in the industry, and i'm not even a fag woman or anything
>>
>>58890252
What did he mean by this?
>>
>>58890252
you just need to git gud, fucking faggot. "idiot acceptance" might help protect your fragile ego but it probably won't get you a six figure salary
>>
>>58890232
The take home project was like the third step of the interview process. They could have rejected me right after I submitted it but they passed me to the next step, which was the interview at their office.
>>
File: oldmanwhat.jpg (21KB, 384x313px) Image search: [Google]
oldmanwhat.jpg
21KB, 384x313px
So apparently there's this cool API called OpenCV that handles computer vision (e.g. webcam footage). This essentially boils down to tracking, gestures, depth analysis, et cetera.

Do you guys think it'd be cool to make a gimmick program that helps with gesturing actions? I know my case is very limited, but I hate having to get up and go to my computer when I'm trying to sleep with netflix on to either turn the volume down, fast forward, rewind, skip videos or movies, and so on.

I guess the real solution is to get a programmable TV stick that can do all these things much better than motion tracking but it has made me really think about the possibilities of using the web cam for helping automate tasks.

Any of you guys have any gimmicky ideas to use with OpenCV? I'm curious.
>>
>>58890350
use your phone
>>
>>58890120
hi notch
>>
>>58890340
You probably weren't missing anything. Like legit life is more fulfilling as a neet than as a developer.
>>
>>58890359
Oh yeah I forgot about that. I broke my phone though so I guess I've been kind of narrow minded lol.

I'm such a fucking idiot.
>>
What the fuck is Neovim? Did I just waste time learning vim?
>>
>>58890392
you fucked up anon
>>
>>58890392
lol neovim has the same keybindings as vim, compatible with vim as well.
>>
>>58890093
>overwhelmed
No.
>miserable
Yes.

Get yourself diagnosed with a well-paying disability and embrace the NEET life.
>>
>leave assignment for last day
>panic and think i do really good for the time i had left
>program doesnt work as it should but most of the logic is fine anyway
>get an A
CS is comfy as fuck
>>
>>58890437
>>58890439
But which one do people use now?
>>
>>58890597
Both. I suggest you stick to vim and pathogen
>>
>>58890597
Neovim is just vim with less insanity.
>>
>>58890483
you mean CS TAs don't give a fuck
>>
>>58890628
>CS TA
this isnt murica im talking about
why even need a teacher assistant
no good professor should need that
>>
>>58890667
they need herders for their $$$ farms

https://www.theatlantic.com/business/archive/2013/09/is-harvard-so-rich-that-it-should-literally-be-illegal/280002/
>>
i have char* a and char* b

i need to append b to a in char * c

how
>>
>>58890740
Does c already point to a valid block of memory?
>>
>>58890740
this is binary data, not strings
>>
tfw you don't know what to work on
>>
>>58890750
Just memcpy that shit then.
It's not like there is much else you can do.
>>
>>58890747
yeah

A is a file, B is a block of data i created, C points to an array of a size which fits A and B
>>
Guys I need some help from you. I'm trying to program a little something for my job (not a programmer) and I'm using visual studio. If anyone's got any knowledge on that and wanna give me a hand I'd really appreciate it. It's mostly about filling text boxes and plugging the data into an excel sheet. Should be pretty simple for someone more knowledgeable, but I'm stuck.

If anyone wanna help here's my email:

[email protected]
>>
>>58889336
Reddit does this newscast justification thing with their text so you get huge spaces between lines or something. I don't go there or I could say more on the topic. But as far as I know they like to be able to use their peripherals to scan for keywords so that they can speedread through persusive topics or look for things they can more naturally attune themselves to without having to make a post just to say tl;dr.

For the most part, that's the problem with the reddit. Weird formatting makes it like the University of Click Bait where you learn the theory, practice, pedagogy, what have you, of the click bait and in term live it. You pick up lots of bad habits, there are marketing firms literally scouring it all the time matching your reading times to the text on screen, matching your mouse cursor movements, there's all kinds of shit.

The problem with this website now is that posts aren't contained well enough anymore and we get far and wide spreads of text all bunched together. It used to be the containment worked towards the literary practices, like keeping text to within a breath a sentence, or risk the run-on, and maybe timing suspense and things of the sort. It becomes a real lexicon. It matters less who posted it and so you can delve into the topic more discretely. Because markets are huge and they are fighting to keep education out of our minds and in our pockets. They will seek you out!

Take my word on it. Oh and don't forget. It isn't fun.
>>
>>58890773
sent ;)
>>
>>58890773
>[email protected]
Signed up for all of the spam.
>>
>>58890797
Don't really give a shit. As long as you help me I'll even take on all your dick pics if you want faggot.
>>
>>58890767
how tho
memcpy is (destination, source, size)
i need
(destination, source, startindex, size)

i guess i could memcpy A and then add B by hand?
>>
>>58890824
memcpy(destination + startindex, source, size)
or source + startindex, because I don't know what that is supposed to index in to.
>>
>>58890814
>Don't really give a shit
>faggot.
You certainly sound unrustled.
>>
>>58890844
Please anon, your new is showing.
Just because someone insults you and posts aggressively, that does not mean that they are mad.
That is just the default tone here.
>>
>>58890841
i see thank you
>>
>>58888720
You hate C because you are a terrible programmer.
>>
>>58890859
Oh I do apologise, I've only been here since before /dpt/s began.
Do enjoy your spam.
>>
>>58888613
Can anyone help me with this? This is an assignment where you are given the source code of a program that simulates a bomb with 7 stages, and a password for each stage. I've figured out all the other stages except stage 5. Here's the function for that:
void part5(char buffer[], const int bufferSize){
const char allowed[] = "az3hoPeACce6";
int i, j, x;

for(i=0; i<bufferSize; ++i){
char c;

x = getchar();
if(x == EOF)
explode(10);
else if(x == '\n')
explode(11);

c = (char)x;
for(j=2; j<10; ++j){
if(c == allowed[j]){
buffer[i] = c + 1;
break;
}
}
if(j == 10){
explode(12);
}

}

j = 0;
for(i=1; i<bufferSize; ++i){
if(buffer[i] != buffer[i-1]){
j = 1;
break;
}
}
if(j == 0)
explode(13);

/* this checks that you are at the end of the line */
/* Windows encodes an end-of-line as two characters: \r\n */
/* Linux just uses \n */
/* This will accept either version */
x = getchar();
if(x == '\r')
x = getchar();
if(x != '\n')
explode(14);
}


The char array being passed into the function is buffer[10] and the int buffersize is also 10. Any hints at least? I'm stuck and can't for the life of me figure it out.
>>
>>58890784
You tease, I've gotten nothing from you!

Really though, or just point me into an active forum or irc channel. I wanna finish this thing.
>>
>>58890883
tick tick tick BOOM!

looks like you were too much of a brainlet to save the president's daughter
>>
>>58890876
Pretty sure I am better than you.
>>
>>58890882
That anon wasn't me, but do send all the spam you want. It'll give something to do, filtering all that crap.

But I wish to spam this thread no longer, let's just keep it to the topic in hand alright.
>>
>>58890925
Fair enough. Good luck with your project, dude.
>>
>>58890924
I wouldn't bet on that, Mr terrible programmer.
>>
>>58890959
lol
>>
>>58890924
>>58890959
Time for a code-off, chaps.

First one to rewrite the Linux kernel in Haskell wins.
>>
>>58890980
>Haskell
It should be in Liskell, surely?
>>
>>58890984
Not according to /dpt/ tradition.
>>
>>58890980
Easy
module Main where

main :: IO ()
main = printAll $ map fizzBuzz [1..100]
where
printAll [] = return ()
printAll (x:xs) = putStrLn x >> printAll xs

fizzBuzz :: Integer -> String
fizzBuzz n | n `mod` 15 == 0 = "FizzBuzz"
| n `mod` 5 == 0 = "Fizz"
| n `mod` 3 == 0 = "Buzz"
| otherwise = show n


Where is my cookie
>>
>>58890990
Times change, mom.
>>
There is literally nothing wrong with Java
>>
>>58891004
>separate case for 15
Into the trash it goes.
>>
>>58891005
Not in my thread they don't.

>>58891004
This man wins the prize.
Bonus points for extra-retarded explicit recursion instead of mapM*.
>>
why is OOP so good?
>>
>>58891004
Now make it print "Fuzz" for multiples of 7 and "Bizz" for multiples of 11 too.
>>
File: pizzamber_img0000.png (1MB, 720x480px) Image search: [Google]
pizzamber_img0000.png
1MB, 720x480px
Haven't coded anything in a few days but I did draw this
>>
>>58891060
Because despite having no redeeming features it has dominated programming.
>>
do you just have to make it not explode?
what is the goal
>>
>>58891080
for
>>58890883
>>
>>58891080
That might be the best way to go about it. At the end of the day, it's a job.
>>
File: 1472694730638.jpg (69KB, 678x516px) Image search: [Google]
1472694730638.jpg
69KB, 678x516px
> get student research position at uni
> Feel the NEET fear wash away from me
>>
>>58891080
The goal is to defuse the bomb, so you have to get through all 7 stages without it exploding.

I've figured out the first 4, and I'm pretty sure I know the last 2, but it's stage 5 that I can't figure out.
>>
>>58891136
well 'hhhhhhhhhc' would work
>>
>>58890883
How far have you gotten on this one?
>>
>>58890883
they just want you to use those 10, 11 and 12 second intervals as the deadline for throwing every character at every point in the allowed[] and checking for a match, putting it in buffer and moving on to the next element.

It's kind of brute force but looking at the code and coming up with the an answer is even lazier.
>>
>>58891158
Just cleared stage 5

>>58891143
that was it, thanks for getting me unstuck. I see what it was doing now.
>>
(define (fizzbuzz n)
(let ((xs (iota n 1))
(conds '((5 Fizz)
(3 Buzz))))
(for-each
(lambda (k)
(let ((fizzed?
(foldl (lambda (acc x)
(if (= 0 (modulo k (car x)))
(begin (display (cadr x)) #t)
acc))
#f
conds)))
(if fizzed?
(newline)
(begin (display k) (newline)))))
xs)))


r8 mine
>>
>>58890883
one non-allowed, one allowed, newline
>>
>>58891199
nvm
>>
File: 1437970171918.jpg (122KB, 1278x1181px) Image search: [Google]
1437970171918.jpg
122KB, 1278x1181px
I am probably missing something here. Why, in python, do I get differently ordered tuples with itertools.permutations? Like
perm = itertools.permutations(cartesian_product)
>>> next(tupler.perm)
(('row1', 'line1'), ('row1', 'line2'), ('row1', 'line3'), ('row2', 'line1'), ('row2', 'line2'), ('row2', 'line3'), ('row3', 'line3'), ('row3', 'line2'), ('row3', 'line1'))
>>> next(tupler.perm)
(('row1', 'line1'), ('row1', 'line2'), ('row1', 'line3'), ('row2', 'line1'), ('row2', 'line2'), ('row3', 'line1'), ('row2', 'line3'), ('row3', 'line2'), ('row3', 'line3'))


They are the same till you get to the last 4 items.
>>
Which english speaking europe city to go to after I get cs degree
>>
>>58891252
>implying they don't all speak arabic now
>>
>>58891252
Before last year it would have been London
>>
god like programmer here

ask me for any help on your programming questions
>>
>>58891020
This.

He would absolutely fail the interview. What would happen if somebody wanted a new case for multiples of 10, and so on?
Reminds me of those CS graduate memes where they explicitly write out every single case in if statements.

Such is the life of the Haskell nigger.
>>
>>58890883
I'm fairly sure I need to know the value of bufferSize for this. What is it?
>>
>>58891020
>>58891293
if( n % 3 == 0 && n % 5 == 0)
{
"FizzBuzz"
}


makes more sense logically
>>
>>58891309
Derp, RTFQ, my bad.
>>
why don't you guys program something useful like the best SEO optimization for websites and make a lot of money?
>>
>>58891311
It's not extensible.

#include <stdio.h>
#include <stdbool.h>

int main(int argc, char **argv) {
for (int i = 1; i <= 100; ++i) {
bool printed = false;

if (i % 3 == 0) {
printf("Fizz");
printed = true;
}

if (i % 5 == 0) {
printf("Buzz");
printed = true;
}

if (! printed) {
printf("%d", i);
}

printf("\n");
}

return 0;
}
>>
>>58891311
That's still unnecessary.

"fizzbuzz" should never be explicitly printed anywhere by the code. If it fizzes, then print "fizz", if it buzzes, then print "buzz." If something fizzes and buzzes, then both will occur on their own. Writing "fizzbuzz" is a red flag to the interviewer that you missed the point of the exercise.
>>
>>58891363
At least it works, I guess.

https://css-tricks.com/tales-of-a-non-unicorn-a-story-about-the-trouble-with-job-titles-and-descriptions/
>>
>>58891340
Advertising conflicts with my morals.
I don't want to program anything that greases the wheels of capitalism with the blood of labor.
>>
>>58891345
>>58891363

don't you agree though logically it makes more sense to have first case check for both if it is divisible by 3 and 5 so there is no error in logic from a math point of view
>>
>>58891402
I hope you're using FOSS software on a machine you built yourself
>>
>>58891402
explain how is that bad?
>>
>>58891405
No, it doesn't.
>>
>>58890883
3hoPeACcee
>>
>>58891424
>>58891345
>>58891363
public class FizzBuzz {
public static void main(String[] args) {
for (int i = 1; i <= 100; i++) {
if (i % 15 == 0) {
System.out.println("FizzBuzz")
} else if (i % 3 == 0) {
System.out.println("Fizz");
} else if (i % 5 == 0) {
System.out.println("Buzz");
} else {
System.out.println(String.valueOf(i));
}
}
}
}


The % 15 version is simpler and easier to read. This version neatly delineates the problem into the 4 different cases, and handles each case. In contrast, your version introduces a boolean logic flag (which I consider to be a significant anti-pattern) and a not entirely intuitive dependence on the order of the if statements.
>>
>go doesnt have classes on purpose only methods on types

OOP is kill?
>>
>>58891020
>>58891293
>>58891363
>>58891424
Since when? I could understand if the interviewer specifies "it should be easy to add new cases" or something, but the standard description of the problem does not ask for that.
>>
>>58891409
I am using FOSS. OpenBSD.
The "if you're a real Communist, exit society entirely" argument is spurious and I will not entertain it.

>>58891419
Read Marx
>>
>>58891462
>muh patterns

that post was ENTERPRISE quality
>>
File: 1485806140408.jpg (1MB, 4030x4096px) Image search: [Google]
1485806140408.jpg
1MB, 4030x4096px
bet you pajeets can't do a recursive fizzbuzz up to an arbitrary number
>>
>>58891468
It's not necessarily a matter of scalability.
It's introducing redundant logic where it is uncalled for and signifies that the interviewer has a brainlet on his hand.
>>
>>58891468
>>58891462
The next step of the interview is asking you to make it print something else too if the number is a multiple of 7. Handling each case individually would mean handling 2^3 = 8 cases.

Here's a functional version:

import scalaz._, Scalaz._

def fizzbuzz: effect.IO[Unit] = {
val cases = IList.apply(
3 -> "Fizz",
5 -> "Buzz"
)

(1 to 100).toList.traverse_ { i =>
effect.IO.putStrLn(cases.foldMap { case (factor, string) => (i % factor == 0) option string } getOrElse i.shows)
}
}
>>
>>58890883
Did this work for you: >>58891461
>>
>>58891462
>a boolean logic flag (which I consider to be a significant anti-pattern)
Okay, what's the OOP enterprise design pattern way of doing what you'd do with a boolean flag in C? I don't mean for this particular exercise, but in general. I strongly doubt it's any simpler or clearer than a boolean flag.
>>
>>58891501
I wouldn't care if someone did it that way at first, but I'd get annoyed if they didn't refactor after I asked them to print Wizz for multiples of 7 or something.
>>
>>58891501
I suppose it makes sense, but this is the first I've heard of interviewers being that interested in how you do your fizzbuzz. If it were 3 cases it would be quite obvious that using the flag is the right way to do it, but with only 2 cases the code is about the same size either way.

In fact, the interviewer might look at using the flag for the 2 case problem as indicative of a propensity to prematurely abstract and/or optimize instead of just doing what you're told, so really it can go both ways. I guess it depends on what kind of position you are looking for.
>>
>>58891603
Yes, it's the difference between an engineer and a code monkey.
>>
File: 1439162127609.jpg (57KB, 268x240px) Image search: [Google]
1439162127609.jpg
57KB, 268x240px
>It's another fizzbuzz thread
>>
>>58891639
Every thread is FizzBuzz thread.
>>
>>58891622
no it isn't you would still get the position eitherway also FizzBuzz is a meme program
>>
>>58889991
wow dude that's impressive
>>
>>58891683
>meme
Does this word mean "something too advanced for me" on /g/?
>>
>>58891603
Flags are for commies and queers,
>>
>>58891622
Engineers thoroughly familiarize themselves with a problem before solving it. Premature optimization and abstraction does not fall under this.
>>
>>58889991
That is damn sexy.
>>
>>58891709
You mean like familiarizing yourself with tech interviews, and thus knowing that fizzbuzz is likely to come up, and that the best way to solve it is not to handle each case individually because the interviewer will ask you to extend it with additional behavior after you initially solve it?
>>
>>58891738
>because the interviewer will ask you to extend it with additional behavior after you initially solve it?
I've never done an interview nor researched what usually comes up myself but if this is the case then I totally agree with you. My bad.
>>
>>58889991
Looking good my dude
>>
>>58891755
That's the way I've always asked it, but I suppose it's possible some interviewers stop after the interviewee solves the initial problem.
>>
File: 1471446054502.jpg (216KB, 660x720px) Image search: [Google]
1471446054502.jpg
216KB, 660x720px
>wake up in the morning
>It's another episode of the daily fizzbizz circlejerk thread
>>
i can write a 200 line fizzbuzz in haskell
>>
>>58891812
i can write an ai which trains itself to write an n-line fizzbuz in any language
>>
>>58891843
in haskell? if not, you've just made a worthless post
>>
>>58891639
>>58891798
Blame the Haskell nigger.
And the funny thing is that his ``elegant" fizzbuzz is shite LMAO
>>
>>58891798
It's 9PM or 11AM
>>
>>58891798
But anon, I need to tell you why you shouldn't write an explicit case for fizzbuzz in your code and why you'll fail your interview if you do so
>>
What stupid meme languages have you discovered, /g/?
Today I learned Hylang (Lisp on top of Python) and Myrddin (C replacement by the folks at suckless.org) were a thing.
>>
>>58891871
my own anime language i'm currently creating
>>
>>58891784
real good companies will not try to trick the person by saying after you write this code now extend it without changing it lol what sorcery is this?
>>
>>58891891
What the fuck would that consist of, coding in moon runes and "NANI?"
>>
>>58891901
It's what happens all the time. Requirements change. Clients decide they want something else. Projects grow and evolve.
>>
>>58891911
what's this meme "N-NANI"?

give me a quick rundown
>>
>>58891911
weeb terms are variable types
>>
File: 1410826043235.jpg (11KB, 251x242px) Image search: [Google]
1410826043235.jpg
11KB, 251x242px
>>58891462
>(which I consider to be a significant anti-pattern)
>>
>>58891911
yes, and i'm making a parser for my own format of storing anime which i'm planning to use with that language to randomly pick some anime for me to watch.
>>58891929
i wonder which website this """"person"""" is from
>>
>>58891927
yeah but all interviewers I been too they would tell you that if they want the program extended or you to change it etc beforehand and not try to low blow you like you said I guess it depends where
>>
File: loving every laugh.png (775KB, 999x945px) Image search: [Google]
loving every laugh.png
775KB, 999x945px
>he actually thinks FizzBuzz is a common interview problem
Do you fall for every meme you see on 4chan? Actual interview problems are much more difficult and require knowledge of data structures/algorithms.
>>
>>58892002
like what?
>>
>>58891960
I won't hold an inflexible initial implementation against an applicant if they do well in the rest of the interview.

However, that sort of shit is what I deal with when I'm writing code instead of giving interviews, being told "oh, that will definitely never change", and later suddenly being told it will and we need to start handling it before the end of the day.
>>
>>58892002
hahaha

https://css-tricks.com/tales-of-a-non-unicorn-a-story-about-the-trouble-with-job-titles-and-descriptions/
>>
>>58892016
https://www.youtube.com/watch?v=XKu_SEDAykw
>>
>>58892016
Go read CTCI my nig.
>>
File: pachi scip.jpg (243KB, 700x849px) Image search: [Google]
pachi scip.jpg
243KB, 700x849px
>>58892002
>>58891938
Anyone else cringe a bit when people still try to frogpost? It's like ragefaces and guy fawkes masks
>>
>>58892086
Says the guy posting 2hu and SICP
go back to 2008
>>
>>58892086
frogposting is still cool
>>
>>58892063
>ukulele music
closed
>>
>>58892125
I wish I could go back to pre-chanology 4chan but time travel doesn't exist

>>58892133
it was never cool here, it was just newfags who brought it here
>>
>>58892086
yeah
good image by the way
>>
>>58891857
>There are two timezones in the world
>>
Working on working up the will to wrap up one of my python projects and then start K&R
>>
File: 1458078464513.jpg (214KB, 600x620px) Image search: [Google]
1458078464513.jpg
214KB, 600x620px
>>58892144
>time travel doesn't exist
>>
>>58892153
UTC+09:00 and UTC−05:00 are the only ones that matter

>>58892177
The kind I want doesn't, being able to theoretically send information back to a machine from the point it was flipped on or using gravity to compress it doesn't count
>>
>>58892002
This is true. It's all about data structures and algorithms
>>
>>58892214
>The kind I want doesn't
Well, there are different kinds. Which one do you want exactly?
>being able to theoretically send information back to a machine from the point it was flipped on or using gravity to compress it doesn't count
What makes you think that's what I'm talking about?
>>
>task: make this code shorter
function setProjectField() {
projectField.textContent = randomProject();
}

setProjectField();

myButton.onclick = function() {
setProjectField();
}
>>
>>58892254
myButton.onclick = function() {
projectField.textContent = randomProject();
}
>>
>>58892278
no that doesn't work, because i have to show a project before the user click on a button
>>
>>58892307
are you literally from fucking india? deport yourself back to your subreddit
>>
>>58892317
can't understand english, faggot?

if you haven't something to contribute to the thread, shut the fuck up.
>>
>>58892222

that's why python and python jobs are the best. you don't need to learn data structures or algorithms since python handles it all
>>
>>58892332
you deserve to be punished.
>>
>>58892344
t. Ahmed al-shalimai
>>
>>58892254
>myButton.onclick = function() {
> setProjectField();
>}

myButton.onclick = setProjectField;
>>
>>58892332
>haven't something to contribute
>english
Do you understand English?
>>
File: WontCallPrivateFunction.png (52KB, 779x606px) Image search: [Google]
WontCallPrivateFunction.png
52KB, 779x606px
>>58888613
>What are you working on, /g/?
Im working on calling a private class function from within main() in c++.
>>
>>58892063
(define (pair-sum? nums sum)
(if (list?
(call/cc (lambda (return)
(foldr (lambda (x acc)
(if (member x acc)
(return #t)
(cons (- sum x) acc)))
'()
nums))))
#f
#t))

(pair-sum? '(1 9 2 3) 8) => #f
(pair-sum? '(4 2 4 1) 8) => #t

Works if list is sorted or unsorted.
>>
>>58892254
Replacement for entire code:

(myButton.onclick=()=>projectField.textContent=randomProject())();
>>
>>58892470
Formatting …

(myButton.onclick=()=>projectField.textContent=randomProject())();
>>
>>58892426
Why?
>>
Should I use emacs for lisp/scheme/clojure?
>>
>>58892339
stay retarded
>>
>>58892490
>>58892505
thanks babe
>>
>>58892509
Yes. Show some respect Stallman and his dear friend Sussman.
>>
>>58892519
?
>>
>>58892509
I have never used anything but vim for it and it's fine.
>>
>>58892159
Currently reading through TCPL2—it's well-written and the UNIX interface part is interesting.
>>
>>58888673
FORTH > LISP
>>
File: inlineassembly2.png (43KB, 659x741px) Image search: [Google]
inlineassembly2.png
43KB, 659x741px
>>58892505
I just called a Private function from within main().
C++ compiler BTFO
>>
Am I doomed to never learn Lisp/Scheme if I know Haskell?
>>
File: ThisIsWhatHackingLooksLike.gif (4MB, 356x200px) Image search: [Google]
ThisIsWhatHackingLooksLike.gif
4MB, 356x200px
>>58892695
>>
>>58892710
It it strikes you as inferior for functional programming, consider it for its meta-programming features. Read about macros for fun. Maybe you'll find that more interesting.
>>
File: Pocket PerfMon.png (35KB, 480x640px) Image search: [Google]
Pocket PerfMon.png
35KB, 480x640px
A while ago I started making a (PC) resource monitor on my old PDA, to put it to some use after all the years it sat in a drawer. I'm pretty much done with the first actually usable version, may add some extra polish though.
>>
>>58888991
it has even better, template metaprogramming
>>
>>58889715
horry shit Scheme is dogshit
>>
>>58889158
Declarative programming is not a programming paradigm but a buzzword people use to shill their junk. I say this as a strong proponent of pure functional programming languages.

I would say some real programming paradigms are:

Functional programming - Lambda Calculus
Imperative programming - Random Access Stored Program Machine
Message passing - Process Calculi
Actor Model - Actor Model
>>
What are the next 5 big programming languages going to be?
>>
>>58892992
>05:26
Anon get some sleep
>>
>>58893131
Soon
>>
>>58893115
The next big programming language will provide an easy an intuitive way to create performant lock-free datastructures.
>>
>>58893115
Lisp, Lisp, Lisp, Lisp, and Lisp.
>>
File: 1486690644495.png (113KB, 255x256px) Image search: [Google]
1486690644495.png
113KB, 255x256px
>The design goals for XML are:
>4. It shall be easy to write programs which process XML documents.
>6. XML documents should be human-legible and reasonably clear.
>8. The design of XML shall be formal and concise.
>>
>>58893115
The ones growing the most according to the TIOBE Index are Go, JavaScript, Object Pascal, Swift and Scratch.
>>
>XML should be easy to write XML with
>>
>>58893323
Something tells me they didn't succeed at their goals.
>>
>>58893323
what the hell is going on with this girl(?)?!
>>
I've just started using vim. I'm having some fun with astyle and color schemes. What color scheme do you use, guys?

youcompleteme is nice, but unfortunately it isn't as good as visualstudio's intellisense
>>
>>58888673
it's seriously a meme

it's only useful in academia, and even MIT uses python now
>>
>>58888842
there's always CLX, stumpwm uses it
>>
>>58893425
Use omnicomplete
>>
is overloading constructors bad?
>>
>>58888613
>What are you working on, /g/?
trying to maintain my enthusiasm for technology why working in a soul crushing enterprise.
>>
>>58893589
anything to do with constructors is by definition bad.
>>
>>58893621
why is that
>>
File: no fun allowed.jpg (88KB, 987x740px) Image search: [Google]
no fun allowed.jpg
88KB, 987x740px
>>
>>58893760
that's autistic
>>
>>58893760
do you learn how to conceive original thought
>>
>>58893760
>java 1 class

nice java 1 class you are taking buddy
>>
>>58893786
>>58893796
I was docked several points from my first assignment because one of my comment lines went over 80 spaces. I now have to keep a mark at the 80-character column line overlaid on my Eclipse window so the same thing doesn't happen to me again.

>>58893846
It's technically data structures 1 so you can't go into the class as a complete java beginner, but it might as well be the same thing tb.h
>>
>>58893760

1-3: This should be expected of any program.
4-10: Reasonable coding conventions, although having { and } aligned actually goes against standard Java coding conventions, so the professor's clearly a weirdo.
11-14: Will result in over-commenting
15: Oh come on, this is Java we are talking about.
>>
>>58893864
>so you can't go into the class as a complete java beginner
lmao, like you could be a complete beginner. What are you even learning in your data structures 1 course?
>>
>>58893760
>all variables have a comment
>>
>>58893886
real software engineers can write Enterprise Java applications in 80 lines or less
>>
>>58893890
it's really early in the course still so we're just starting to learn about basic container manipulation stuff
>>
When programming in python am I mostly going to be importing libraries to do whatever I want to do and not do "coding"?
>>
why does endl: work but not endl(); even though c++ is suppose to always have brackets
>>
>>58893941
That is coding.

That's what you're doing when you type shit like Print or Input. You're using the standard library. Or when you use pow() after importing math.

You're more than welcome to write your own functions.
But, why bother when someone has done it for you?
>>
>>58893621
>>58893650
answer me faggot I know you are still here
>>
>>58893919
I've done it before, but it is genuinely a pain in the ass. It is not a language that lends to short lines of code.

>>58893941
Just because you're importing libraries for a lot of the heavy work doesn't mean you're not going to be doing a lot of coding yourself. For what it's worth, the standard library is still a library. You wouldn't think it reasonable to roll your own print function in a normal program. You shouldn't think it reasonable to have to roll your own GUI toolkits, database connectors, network stack, etc...
>>
>>58893994
endl isn't a function
>>
>>58893552
>omnicomplete
doesn't seem better at all
>>
>>58894015
OOP is a codeword for bloat
>>
int n, number, numberLength;

scanf("%i", &number");

for (n = 1, count = 1; n < number; n = 10 * n, ++count)
if ( number % n < 10 )
numberLength = n / (n/count);
break;
else
continue;

printf("Number length: %i digits", numberLength);


Am I retarded? Is there an easier way to do this with out using any length or math functions?
>>
What are you guys going to do when Pajeet takes all your software and IT positions?
>>
>>58894057
Here's how I would do it:

int digits(int n)
{
int len = 1;
while(digits /= 10) ++i;
return len;
}
>>
File: tumblr_o4zkezDlcW1r2yhxwo1_1280.jpg (201KB, 1018x1280px) Image search: [Google]
tumblr_o4zkezDlcW1r2yhxwo1_1280.jpg
201KB, 1018x1280px
refresher problem
>>58894045
>>
>>58894051
it's also a codeword for having a job
>>
>>58894057
I just realized this doesn't even work because it will round.
Fuck this exercise.

Programming in C, exercise #6 in chapter 6 if anyone gives a hoot.

>take an int, 932 for example, print out in english "nine three two".
Can't use arrays or length or anything like that, only loops and operators.
Easy to write it backwards, but I can't figure out how to write it forwards because I have ape brain.
>>
>>58894062

Laugh all the way to the bank, because I'm getting my PhD and planning on becoming a professor.
>>
>>58894092
Yes, that's clearly better.
We haven't learned to write functions yet though and I'm trying to do it in order.

I don't even think I need digits, it was just something I got side tracked on. I just don't know how to get the leading digit of an integer of any length.
>>
>>58889314
promises
>>
>>58894111
import java

public class ILoveBeingACuck
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int digits = scan.nextInt();
int temp = 0;

while(digits != 0)
{
temp = digits % 10;

switch(digits)
{
// if else statements going 1 through 9 based on number print out english word for it
}
digits /= 10;
}
}

}

>>
>>58894148
(same poster)

My thought process was get the length of the integer, so that I can divide it by the power of 10 and just ditch the remainder. So I'm only left with the leading digit. And then redo that for the remainder and so on.

This must be the stupidest most inefficient way.

ie, 932 / 10^1 = 9, 32 / 10 = 3, 2 / 1 = 2
>>
this thread should be called amateur programming thread
>>
>>58894240
should be calle faggot thrhead now that ur here
>>
>>58894187
That will write them backwards.
>>
>>58894284
Instead of appending the numbers at the end like
a + b
append it in the front
b + a
>>
>>58894284
lol yeah I did few mistakes because I wrote it as fast as possible but pretty much did most of it correct but that is the fun in Java meme programming typing as fast as possible in Java
>>
>>58894187
Does static in java mean the same thing as in C?
>>
>>58javascript:quote('58888613');888613
>Old thread: >>58882828
>What are you working on, /g/?
>>58javascript:quote('58888613');888613
>Old thread: >>58882828
>What are you wor>>58javascript:quote('58888613');888613
>Old thread: >>58882828
>What are you wor>>58javascript:quote('58888613');888613
>Old thread: >>58882828
>What are you wor\\\

>>58javascript:quote('58888613');888613
>>58javascript:quote('58888613');888613
>>58javascript:quote('58888613');888613
>>58javascript:quote('58888613');888613`
>>
>>58894659

In C, static is file scope.
In Java, static is class scope.

A static function in C can only be accessed by functions within the same file. Same with a static global variable

A static function in Java, if public, can be referenced by other classes.
>>
other thread is a pyhton thread

>>>58894674
>>
File: 2017-02-11_07-59-20.jpg (72KB, 1006x458px) Image search: [Google]
2017-02-11_07-59-20.jpg
72KB, 1006x458px
Now it works, even when the "watch bar" is missing.

http://pastebin.com/uaFDB5y2
Thread posts: 325
Thread images: 41


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

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


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