[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 28
File: sx24a9.jpg (46 KB, 1600x900) Image search: [Google]
sx24a9.jpg
46 KB, 1600x900
old thread >>54216976

What are you working on /dpt/?
>>
Thank you for waiting for the bump limit
>>
>months later find a heap corruption issue in my code

got
damn
it
>>
>>54225689
>code is 100% bug free
>implement a fairly complex change
>randomly get a segfault
>can't reproduce or find anything wrong
>>
>>54225660
I can now that the trapfag is banned
>>
>>54225723
or actually nvm it was when i wasn't done with the change and it was probably in the shader code
>>
Made a site to promote vegetarianism, opinions? eolas.xyz/vegetarian/animals.html
>>
>>54225807
Fuck off to /wdg/
>>
>>54225832
srry my bad
>>
>>54225619
nobody holds a cigarette like that
>>
>>54225880
Some people bite their cigarettes, but more softly.
>>
>>54225880
Revy don't give a fuck
>>
>>54225880
yeah but anime artists can't draw for shit
>>
How do I understand Monads?

Need them for a Coursework.
>>
>>54225949
Try to understand some basic examples.
>>
File: Untitled.png (2 MB, 1680x1050) Image search: [Google]
Untitled.png
2 MB, 1680x1050
debating whether or not to use InitializeCriticalSectionAndSpinCount instead of the regular InitializeCriticalSection for browser #113.
>>
>>54225807
It's shit
>>
>>54225986
Got any decent ones? Preferably state Monads desu
>>
>>54225989
what's the point, what are you trying to achieve with this? why not develop an app instead?
>>
>>54225807
fuck off hippie
>>
>>54225989
Horrible ui
>>
>>54226020
The Error monad is my favorite
data a = Success a | Error String

return x = Success x

Success x >>= f = f x
Error s >>= _ = Error s

map f (Success x) = Success (f x)
map _ (Error s) = Error s

It's the exception monad, and you have it in almost every language (except C and ASM).

Do you dig it?
>>
>>54226058
>why not develop an app instead?
what? it IS an app
lication
.

what I'm trying to achieve is more performant execution.
>>
>>54226112
if i was going to make something like that i would make somesort of machine learning thing, where it watched me as i browsed 4chan and after awhile tried to recommend me things based on threads i've been in and what i posted
>>
>>54226143
what i mean by "things" is recommend me threads across the site, not actual things
>>
>>54226166
>actual things

that's not a bad idea. it could automatically order things from amazon, based on your 4chan browsing habits. think of what wonderous things will be on your doorstep tomorrow!
>>
>>54226206
i'd get dragondildos, guns, waifus, and some chinese chink that is going to drive me over in his chink car
>>
>>54225807
What are you a retard KEK
>>
Nice thread guys...
>>
>>54226307
>Directory listing on a site with only static files makes me a hacker
Hahaha
>>
Will we ever be able to program meat?
>>
File: scr_mbr.png (45 KB, 701x138) Image search: [Google]
scr_mbr.png
45 KB, 701x138
Does pic related apply outside of classes?
Is it bad practice if I do the following:
for (int foo = 0; foo < bar; foo++) {
for (int foo = 0; foo < foobar.size(); ++foo)
// ....
}

Knowing that I won't ever use the foo of the first loop inside the second loop.
>>
>>54225619
>dumb makiposter
>>
>>54226549
>maki
Try again

>>54226514
You're redefining foo in the second for loop. Any compiler will throw an error there.
>>
File: maxresdefault.jpg (171 KB, 1200x900) Image search: [Google]
maxresdefault.jpg
171 KB, 1200x900
anyone else can't stand underscores in code? It looks absolutely horrible to me.
>>
>>54226586
they're way nicer to look at than semicolons and braces.
>>
>>54226586
Underscores look pretty cool if used for macros
>>
>>54226604
THIS_TBQH_FAMALAM
>>
>>54225880
Nobody cares, either.
>>
>>54226584
>Any compiler will throw an error there
Compiles without errors on my machine.
>>
>>54226586
Would you prefer variable names like:
whatTheFuckDidYouJustFuckingSay



I mean shit, there's probably a plugin out there for whatever editor to make underscores appear in light grey or whatever so they almost blend in with the background and look like spaces instead.
>>
>>54226664
I guess it does, huh.... Well in any case it's bad form and not the easiest to read. Just use another letter.
>>
>>54226716
poopFooBar
poopBazQux


is by far better than

poop_foo_bar
poop_baz_qux
>>
Hi friends, good luck with all of your endeavors. I'm doing gamedev in Unity (C#) and trying to wrap my head around enumerators (IEnumerators?). I sort of get what C# is doing in that they're pretty much always abstracted away, but it seems like Unity uses them in a weird way. Lots of fun.
>>
>>54226735
Also it disallows using the first variable in the second scope
>>
>>54226740
i personally prefer underscores
doesnt fuck with my dyslexia as much
>>
>>54226740
true. I still like to use a g_ prefix for globals though.
>>
>>54225619
im decypering the giberish in the enter the gungeon c#dll still. got all the tools to work and have been changing things and doing test runs

so far i would say that chest quality chance to spawn is not chest chance to spawn. room drop quality seems to be average room dificulty. 4 lead maidens in a row(room after room) with it set to S more common than D

rainbow chance on room clear doesnt seem to make rainbow chest spawn on room clear. if i had to guess it seems more boss quality

the devs used a obfuscator . half the shit is called stuff like /u00002333323. i wouldnt doubt they mislabeled things
>>
File: post.gif (665 KB, 500x280) Image search: [Google]
post.gif
665 KB, 500x280
>>54226807
>Just accept responsibility for something you don't personally believe is even happening :^)
>>
>>54226776
Guys guys, asides from all of this, you have to admit the design's pretty sexy
>>
>>54226740
nope

depends on the application
snake case for anything low level
camelcase for anything else
>>
>>54226857
no it's gay as shit kill yourself fag
>>
>>54226870
>snake case for anything low level
so you can feel like le epin haxor programming in ansi C in your loonix consolel
>>
I'm a total beginner in programming so the question is real: can I make a desktop application with Python or is this language just used for web dev?
>>
>>54226903
exactly
>>
>>54226904
you "can" make something that resembles a desktop """"""""app""""""""
>>
hey /dpt/ how do i take the next step and start refactoring my code?
i have a project that's several thousand lines across a dozen or so source files written in python (ik, sorry).
there's room to deduplicate some of it by rewriting more general code or object-orientify things, but i'm not sure what the point is

any tutorials or books you could recommend would be much appreciated, thnx.
>>
>>54226549
Revy
>>
>>54226586
As in,
int this_function_here();
?

Or do you mean something like
(define-syntax hash-ref*
(syntax-rules ()
[(_ hsh k0 ...)
(values (hash-ref hsh k0) ...)]))
>>
>>54227134
What about shit like __int128_t
>>
>>54227139

The exhaustive list is much longer.
>>
>>54227134
I'd say one thing C got wrong was allowing underscores as the start of an identifier.
It should treat underscores like digits: allowed, but just not as the first character.
>>
>>54227150
>Leading double underscore
C defines any identifier that starts with either two underscores or an underscore and a capital letter to be reserved by the standard and the implementation. So an implementation pretty much as to do that.
>>
>>54225742
>I'm not a real programmer
anon...
>>
>>54225619
How and where do I get started with programming? I just want the feeling of creating the something I would actually have use for.
>>
File: 1458953104621.png (105 KB, 766x434) Image search: [Google]
1458953104621.png
105 KB, 766x434
anybody got more of these?
>>
>>54227524
I started on codecademy learning Ruby.
Python is also an okay place to start, but has a lot of weird fucking quirks that are idiosyncratic to it.

Learn the basics of whatever you feel comfortable using, and then IMMEDIATELY stop using that and go to something like C#, Java, C, C++
>>
>>54227524
What would you have a use for?
>>
need some books on developing android apps, are there any worth reading?
>>
Apparently we actually have to talk about programming here. Who'd have known?
>>
>>54226964
Look at your code and think of ways to make it more efficient.

Is there frequently used snippets of code to do the same thing? Factor that out into it's own method.
Are there really long script files full of spaghetti code? Rename some variables and consolidate them into separate files more organized.
>>
File: 1377917529650.jpg (37 KB, 535x577) Image search: [Google]
1377917529650.jpg
37 KB, 535x577
> no career goals

Where do I go after being in a programming position for a long period of time?
>>
File: Curly Braces.png (17 KB, 2414x648) Image search: [Google]
Curly Braces.png
17 KB, 2414x648
>>54227531
>>
>>54227608
a better paid role doing the same thing.

or management.

probably.
>>
>>54227620
>Ex-ruby programmer.png
>>
File: 1461550698142.jpg (303 KB, 1180x1080) Image search: [Google]
1461550698142.jpg
303 KB, 1180x1080
>search for ways to implement something in C++
>stackoverflow with someone asking the same question
>specifically says he doesn't want anything to do with boost
>every answer is about boost
>every answer in every thread pertaining to the question is about boost
Every fucking time.
>>
>>54227651
Have you tried using boost?
>>
>>54227634
no anon ruby devs only use two spaces for indent to make them believe that their shitty nested code is actually good
node js syndrome
>>
>>54227651
What do you want to implement?

inb4: use boost
>>
>>54227480

Well, I'd like to give you a reply, but apparently I've been given a warning for off topic discussion.

>>54227608

You stay a programmer, and maybe work on more interesting projects. Why would you become a programmer if programming for the rest of your career wasn't what you wanted to do?
>>
I saw so much greyed out content, I thought the whole thread has been deleted.
>>
>>54227684
>Why would you become a programmer if programming for the rest of your career wasn't what you wanted to do?

$$$
>>
>>54227566
there's some harvard seminars on youtube:
Sleek Android Design, by Jordan Jozwiak
Android 101 by Fred Widjaja
>>
>>54227724
I stepped out for a moment--why was everything deleted?
>>
>>54227608
make your own company? back end? i heard a lot of ux companies are hiring right now.
>>
>>54227751
the vegetarian communist fag kept talking shit
>>
>>54227684
>>54227736
https://www.youtube.com/watch?v=PBwAxmrE194

>>54227751
Because sandy-vag janny didn't realise we were talking about the Vegemite's website, and educating him about how to properly cite ```sources```.
>>
>>54227559
>>54227558

Idk what the ups and downs of each programming language is, but I learned the basics of c++ in school, up to classes etc. Endgame-dream is to make games though.
>>
I'm working on:

public class Test {

public static void main(String[] args) {

System.out.println("Hello /dpt/!");

}
}
>>
>>54227796
You could keep using C++ for games. Or learn something easier to use like C#, and then use monogame or unity to make games with it.
>>
>>54227807
>System.out.println
Why can't a simple println suffice
>>
>>54227724

Nah, janitor just doesn't like off topic content. I can kind of agree with that, but that doesn't mean I'm not going to be easily baited by certain types of off topic posts.

>>54227736

But there are so many other jobs that also pay shit tons. Programming really should be something you do because you enjoy it. Personally, I'm considering getting a job at Microsoft after I have my master's, and if they ask what I'd like to be doing in 10-20 years, I'm just going to give them something like "lead developer of the Windows Kernel." Because I'd legitimately find something like that pretty damn fun. Fuck management.
>>
File: CE65CFXUkAE4t9X.jpg (19 KB, 575x323) Image search: [Google]
CE65CFXUkAE4t9X.jpg
19 KB, 575x323
>>54227531
>Public String setDefinition() {
> return definition;
>}
>>
>>54227823
Because you might want to print to an input stream, silly :^)
>>
>>54227829
>Programming really should be something you do because you enjoy it.

Programming is awful. I would never do it in my free time for fun. That's gay.
>>
i want a C function to return a character, but also advance the string passed to it to the next word in the string.

i can't into the pointers for this. how do i increment the char* passed to the function?
>>
File: bookbot.png (67 KB, 588x449) Image search: [Google]
bookbot.png
67 KB, 588x449
Would anyone with a Twitter mind helping me beta test my little book downloader bot?

Pic related, those are zeroes and not o's
>>
>>54227790
>Because sandy-vag janny didn't realise we were talking about the Vegemite's website, and educating him about how to properly cite ```sources```.
tfw my on-topic post got caught in the shitstorm
>>
>>54227823
>why doesn't everything pollute every namespace
because java is not a shitter lang
>>
>>54227849
It must be a char **, not just a char *.
>>
>>54227829
Good luck getting that. Working on the windows kernel sounds pretty demoralising. There's been some internal chatter that no one gives a fuck about the NT kernel so long as it works. Not a lot of interest in fixing bugs or improving performance when there's a chance something might break.

That's what I've heard at least.
>>
>>54227796
And I'm currently taking a course in C# on udemy, but it's super centered on making games, so. I'm looking for somewhere to learn C# or C++ which isn't focused on making games and such.
>>
>>54227849
What do you mean by "advance the string passed .. to the next word in the string"?

Do you want the function to remove a word from the string?
>>
File: jejj.gif (2 MB, 265x308) Image search: [Google]
jejj.gif
2 MB, 265x308
>>54227870
>java
>not a shitter lang
>>
>>54227823
Because it doesn't work like that, mate.
>>
>>54227850
Do I just tweet a book name at it?
>>
>>54227870
I dunno, seems like every other language got along just fine
>>
>>54227911
yeah, in quotes

thanks bro
>>
>>54227907
He's right though. Java programmers prefer designated shitting streets.
>>
>>54227922
actually nevermind seems like twitter banned my old account lol
>>
>>54227928
RIP thanks anyway
>>
>>54227917
C++ has std::cout
C# has Console.WriteLine
C is shit but you still have to explicitly include stdio.h and then shit like printf and puts are understood to be "reserved"
>>
>>54227823

Java doesn't believe in top level functions. In any case, it's not too difficult to understand the components behind it.

>System
A class acting as a namespace for the standard i/o objects.

>out
An object representing the standard output file.

>println
A method that prints to whatever file is being held by the object it's called on.

So you can also do..

System.err.println(stuff);


>>54227881

I've heard some horror stories as well. But hey, I like low level shit, so why not give it a shot?
>>
>>54227901
i want this function:

1. take a string
2. find first alphabetical char
3. offset the start of the string to point to the first whitespace after the first alphabetical char
4. return the first alphabetical char

essentially, return the first letter in the string, but also "cut off" the word that the first letter was a part of. I wanted to do it this way so i could keep calling the function to get the first letter of each word in a string.
>>
>>54227949
you can even do things like

PrintStream myOut = System.out;
myOut = System.err;
>>
>>54227949
>so why not give it a shot?
I say go for it. But I would have imagined there would be better jobs out there.. Why not Apple for example? They seem to care more about their kernel. Or red hat or some shit. I'm sure Google have some linux kernel guys too.
>>
>>54227944
All of those are shorter than what Java has. And other langugaes are even less verbose. Those are all C style langugaes.
>>
>>54225807
>Strawman arguments: the website

Wow this is going to change a lot of minds. You forgot to counter the argument "we're not required to be perfectly moral creatures, therefore, I don't have to maximize the morality of all my life choices, including diet."
>>
File: pepe rain.gif (1 MB, 500x500) Image search: [Google]
pepe rain.gif
1 MB, 500x500
>make something
>work hard
>pour more hours into it than you should have
>show people
>nobody cares
>they don't even call it shit
>they just ignore it
>>
>>54228014
as if it even matters, and if you're so concerned you can use out.println or o.println

who the hell even makes console applications, and if it's too "verbose" for your stupid little scripts then don't use java, fucking fag
>>
>>54228038
>as if it even matters
yes
>>
>>54228028
I'm proud of you anon. Keep it up.
>>
>>54228053
no it fucking doesn't, maintainability is what matters, not the time taken to write out the code, and you can write System.out.println in no time, especially with auto complete

and most serious applications don't print to stdout for fuck's sake

stupid codemonkey
>>
>>54228017
Jesus fucking christ, sandyjan didn't even delete the fucking post that started it all.

Hiroshimoot what have you done?
>>
>>54228028
It's okay anon, I think it's absolute shit :3
>>
>>54227944

printf and puts aren't reserved, they're just a part of the standard library. But you're not required to use the standard library, and can indeed implement those functions yourself in C, especially if you want to implement the standard library yourself.

>>54227973

Why not simply return a pointer to the first alphabetic character in the string?

>>54227993

>Apple
Apple is the kind of company that takes months to fix a critical security vulnerability, and manages to fuck it up anyways. Also, they'd probably have a problem with me bringing in an Android phone to work every day.

Red Hat is a company I'd consider working for, as is Google. I've also considered Cyanogen Inc.
>>
>>54228074
this, it's fucking babby's first webshit, it doesn't belong in a programming thread
>>
>>54228069
You're right, most serious applications don't print to stdout.
They don't use Java either.
>>
>>54228028
You showed people on here? Or in real life?
>>
>>54228069
>maintainability is what matters
brevity improves readability. Readability improves maintainability.
>>
Playing with automatic type differentiation
type 'a seq =
| Empty
| Cons of 'a * 'a seq
;;

(* automatic type differentiation *)
type 'a dseq =
| Cons_head of unit * 'a seq
| Cons_tail of 'a * 'a dseq
;;

let rec move_up = function
| Cons_head _ -> failwith "can't move up"
| Cons_tail (x, Cons_head ((), seq)) -> Cons_head ((), Cons (x, seq))
| Cons_tail (x, dseq) ->
let dxs = move_up dseq in
Cons_tail (x, dxs)
;;

let rec move_down = function
| Cons_head ((), Empty) -> failwith "can't move down"
| Cons_head ((), Cons (x, xs)) -> Cons_tail (x, Cons_head ((), xs))
| Cons_tail (x, dseq) ->
let dseq = move_down dseq in
Cons_tail (x, dseq)
;;

let rec print_seq pp_a ppf = function
| Empty -> Printf.fprintf ppf "\r\n"
| Cons (x, xs) ->
Printf.fprintf ppf "%a %a" pp_a x (print_seq pp_a) xs
;;

let rec print_dseq pp_a ppf = function
| Cons_head ((), seq) -> Printf.fprintf ppf "|%a" (print_seq pp_a) seq
| Cons_tail (x, dseq) ->
Printf.fprintf ppf "%a %a" pp_a x (print_dseq pp_a) dseq
;;

let print_int ppf n = Printf.fprintf ppf "%d" n;;

let print dseq = print_dseq print_int stdout dseq;;

type command =
| Move_up
| Move_down
;;

let rec read_command dseq =
print dseq;
let line = read_line () in
match line with
| "<" -> Move_up
| ">" -> Move_down
| _ -> read_command dseq
;;

let op_of_command dseq = function
| Move_up -> move_up dseq
| Move_down -> move_down dseq
;;

let main () =
let l = [3; 4; 6; 13; 6; 2; 5; 54] in
let seq = List.fold_left (fun accu x -> Cons (x, accu)) Empty l in
let dseq = Cons_head ((), seq) in
let rec loop dseq =
let command = read_command dseq in
let dseq =
try
op_of_command dseq command
with
| Failure s ->
Printf.eprintf "failure: %s" s;
prerr_newline ();
dseq in
loop dseq in
loop dseq
;;

let () = main ();;
>>
>>54228101
kill yourself

>>54228108
kill yourself RETARD KIL: L YOURSELF SERIOUSLY FUCKING RETARDED SHITTER
>>
>>54228069
>most serious applications don't print to stdout for fuck's sake

Plenty of them do.
>>
>>54228094
>Apple is the kind of company that takes months to fix a critical security vulnerability, and manages to fuck it up anyways.
We're comparing them to MS here you know.
>>
File: Untitled.png (730 KB, 840x921) Image search: [Google]
Untitled.png
730 KB, 840x921
>100 pruned replies

nice.
>>
>>54228121
even if they do, it's usually with some logging framework, not with System.out.println
>>
File: ok m8.gif (309 KB, 117x142) Image search: [Google]
ok m8.gif
309 KB, 117x142
>>54228119
>>
>>54227973
What you are trying to do is very difficult, if not impossible, without the possibility of serious memory issues.

A better solution would be for the function to take in two parameters: a string and a pointer to the char you want to start your search at. Then have your function return a pointer to the next alphabetical char, which you then feed back into the function.
>>
>>54228028
well maybe it was just shit but they wanted to spare you
>>
>>54228119
>kill yourself RETARD KIL: L
Why do some programmers not want to be good /dpt/?
>>
>>54228165
have fun maintaining your codegolfed babby python shit lmfao kill yourself delusional tard
>>
>>54227829
Why didn't he delete the post that started all the hub-bub?
>>
>>54228094
i'm an idiot, and i haven't written C in 4 years.

jesus fucking christ why didn't i think of that.
>>
File: when the D hits you.jpg (23 KB, 512x512) Image search: [Google]
when the D hits you.jpg
23 KB, 512x512
>>54228177
No anon, not Python
>>
>>54228177
I don't like python.
>>
>>54228188
D isn't particularly terse compared to java
>>
>>54227776
Don't call me communist faggot.
>>
>>54228221
kill yourself fag
>>
>>54228129

MS isn't THAT terrible about responding to security vulnerabilities. At least not these days.

>>54228184

We all have our derp moments when we're rusty.
>>
Stupid question here,

Does anyone know if C's strcmp destroys arrays?
>>
>>54228254
They purposefully hold back critical updates until patch Tuesday, because publishing them any earlier would be "inconvenient".
Sounds like a pretty shitty place to work to me.
>>
>>54228297
No. Just read the man page anon.
>>
>>54228297
destroys the string*
>>
>>54228297
strcmp does not modify the inputs in any way.
>>
>>54228297
how the fuck would it, it only reads from the addresses you give it, doesn't write shit apart from the return value.
>>
>>54228328
>>54228316
fuck if I know, but I'm trying something and when I call strcmp my inputs are destroyed, so figured I was missing something.
>>
>>54228340
are you sure you're not calling strjew
>>
>>54228340
Yeah, it's probably something else.
>>
>>54228340
In sepples at least, the passed strings are defined as const so they cant be modified at all.

Gonna need to see some context if you actually want help with this.
>>
>>54228312

I think the main reason for that is that they customers don't want to deal with updates all the time, and less so much that it's inconvenient for them. In any case, 2 weeks to a month is a much better response time than 6 months, and I can imagine with a bad enough bug, they might release earlier.
>>
syso ctrl+space -> System.out.println();

and you're truly awful at programming if you think this is even a valid concern in the first place
>>
>>54228404
mind checking? the only difference between it working and not working is the strcmp.
int i;
char * arr[10];
...
i=1;
arr[0] = strtok(buf," ");
while(arr[i]!=NULL){
arr[i] = strtok(NULL," ");
if(strcmp(arr[i],"thing")==0)
//do thing
i++;
}
//printing arr as a general check


if I comment out the strcmp is works fine, if I leave it in the print is actually getting ignored, as well as the following code.

which in retrospect wouldn't indicate a deletion but something else and I'm just being an idiot.
>>
>>54228475
It's not the time it takes to type it anon.
>>
>>54228574
as for readability, it's syntax highlighted, so it's as "readable" as if it had been just println, but you have the additional visual cues of System.out so that you immediately know what it's doing

so mcfucking kill yourself retard
>>
>>54228500
I guess I should point out that the "do thing" is just some simple assignments and prints unrelated to the array. may as well be z = 1+1;
>>
>>54228589
Nothing you said makes any sense though.
>>
also i'm going to bed so don't think you're right just because you have the last say

fuck you
>>
>>54228500
>i=1;
>while(arr[i]!=NULL){
Every time you're making that comparison, arr[i] is uninitialised.
Also, use a for loop instead of a while loop.
>>
>>54228610
because you're a retarded Cshart that thinks Console.WriteLine is infinitely better than System.out.println lmfao kill yourself delusional fag
>>
>>54228624
Console.WriteLine is even longer. You're not the sharpest knife in the drawer are you?
>>
>>54228638
No it isn't, it's 1 character shorter.
>>
>>54228638
it's not, you fucking retard, and even if it had been, my point would still be valid because you're a Cshart and you wrote >>54228014
>>
kill yourself newfag tripfag Orb i'm not wasting more time on your inane wankery about the best syntax for printing to console like a tip top code monkey pleb

i'm off to bed now fuck you
>>
File: You kids wanna try D.jpg (44 KB, 512x512) Image search: [Google]
You kids wanna try D.jpg
44 KB, 512x512
>mfw writeln
D wins again
>>
>>54228656
Console.WriteLine vs out.println? out.println does appear to be shorter.
>>
>>54228692
java wins again
>>
>>54228683
sleep well anon. Thanks for the bants
>>
>>54228624
>Cshart

here we go again.
>>
>>54228712
love you too hun
>>
>>54228692

using static System.Console;

...

WriteLine("Hello World!");
>>
Daily reminder that testing is for code monkeys. True coders prove their code.

Axiom mif : forall (T : Type) (P : Prop), (P -> T) -> (~ P -> T) -> T.
Arguments mif {_} _ _ _.

Axiom mif_true :
forall (T : Type) (P : Prop) (t : P -> T) (f : ~ P -> T) (H : P),
mif P t f = t H.
Arguments mif_true {_} _ _ _ _.

Axiom mif_false :
forall (T : Type) (P : Prop) (t : P -> T) (f : ~ P -> T) (H : ~ P),
mif P t f = f H.
Arguments mif_false {_} _ _ _ _.

Theorem absurd : forall A : Prop, A \/ ~ A.
intro A.
apply mif with (P := A).
auto.
auto.
Qed.

Definition total_order : forall T : Type, (T -> T -> Prop) -> Prop :=
fun T leq =>
(forall x : T, leq x x)
/\ (forall x y : T, leq x y -> leq y x -> x = y)
/\ (forall x y z : T, leq x y -> leq y z -> leq x z)
/\ (forall x y : T, leq x y \/ leq y x).
Arguments total_order {_} _.

Definition max : forall T : Type, (T -> T -> Prop) -> T -> T -> T :=
fun _ leq x y => mif (leq x y) (fun _ => y) (fun _ => x).
Arguments max {_} _ _ _.

Theorem max_is_max :
forall (T : Type) (leq : T -> T -> Prop) (x y : T)
(H : total_order leq),
let m := max leq x y in
(m = x \/ m = y) /\ leq x m /\ leq y m.
intros T leq x y Horder m.
assert (leq x y \/ ~ leq x y).
apply absurd.
case H.
intro H0.
assert (m = y).
unfold m.
unfold max.
apply mif_true with (P := leq x y) (t := fun _ : leq x y => y).
auto.
split.
auto.
rewrite H1.
split.
auto.
apply Horder.
intro H0.
assert (m = x).
unfold m.
unfold max.
apply mif_false with (P := leq x y) (f := fun _ : ~ leq x y => x).
auto.
split.
auto.
rewrite H1.
split.
apply Horder.
assert (leq x y \/ leq y x).
apply Horder.
case H2.
intro H3.
exfalso.
apply H0.
auto.
intro H3.
auto.
Qed.


I never test my max function. Please can you find bugs in it?
>>
>>54228759
Ah yes, just give me a second to read through your perfectly readable language
>>
>>54228738
Yeah. C# is awesome. But trying to compare like with like here. Wasn't even comparing Java with C# in the first place. I think it's the only other language Prajeets know though.
>>
>>54228784
Usually I ignore the fact that some use trip, but I start to understand why they can be annoying. Have you an attention complex anon?
>>
>>54228821
What do you find annoying about a trip?
>>
>>54228830
You want attention.
>>
>>54228849
How so?
>>
File: clsstrct.png (25 KB, 661x104) Image search: [Google]
clsstrct.png
25 KB, 661x104
Half of the thread got deleted.
How did this happen?
>>
File: Triggered.jpg (44 KB, 720x599) Image search: [Google]
Triggered.jpg
44 KB, 720x599
>>54228830
>>54228861
>>
>>54228874
that doesn't really answer my question though. What makes you think i want attention? I get attention when i post anonymously too.
>>
>>54228871
A vegetarian and a communist walk into /dpt/...
>>
>>54228613
actually wasn't the problem.

using strcmp(NULL, x) is a segmentation fault. and since the while loop was going to NULL and doing the cmp regardless it resulted in weird shit.

just incase anyone was wondering.
>>
File: 1461167610613.jpg (40 KB, 500x375) Image search: [Google]
1461167610613.jpg
40 KB, 500x375
I need to specialize my programming. I'm pretty much a shitty jack-of-all-trades, master-of-none and i'd like to focus my attention on what gets you hired.

so do you guys know what industry needs the most programmers?
>>
>>54228929
>just incase anyone was wondering.
Be reassured, nobody was wondering.
>>
>>54228940
well considering nobody pointing out the glaring null usage in strcmp causing an error, its probably good for you to know.
>>
https://ideone.com/Sr25NY

Why does it display 2 characters rather than 16?
>>
>>54227807
By extension,

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class TestFX extends Application {

public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {

StackPane pane = new StackPane();
Text text = new Text("Hello /dpt!/");

pane.getChildren().add(text);

Scene scene = new Scene(pane, 250, 250);
primaryStage.setScene(scene);
primaryStage.show();

}
}
>>
>>54225989
>debating whether or not to use InitializeCriticalSectionAndSpinCount instead of the regular InitializeCriticalSection

Why would you want to use the AndSpinCount variant?

In 20 years of Windows programming, I've never once called that function. Correct is more important than performance optimized, when it comes to multithreaded programming.

I'd suggest that you only look at dicking with the spin count once you have the software working completely and correctly.
>>
>>54228931
learn to be a web programmer
it's easy as shit and you will be hired by clueless idiots to make lots of money
>>
>>54228940
*be assured
>>
>>54228956
Nobody cared. Don't insist anon.
>>
>>54228975
Thank you.
>>
>>54226358
You said that. Not him
>>
>>54228989
np
>>
Just started SICP and I can't understand why I'm getting an error for calling my iterate function with only one argument when I clearly call it with two in mit-scheme:

(define (iterate x y)
(/ (+ (/ x (* y y)) (* y 2)) 3))

(define (stopitr y)
(< (abs (- (iterate y) y)) 0.001))

(define (cubeassist x y)
(if (stopitr y)
y
(cubeassist trgt (iterate x y))))


Manually calling increment works, but the function doesn't when given a target and a guess.
>>
>>54229046
Also, replace "trgt" in there with "x", forgot to include that correction in the copypasta.
>>
>>54226777
>dyslexic
>a programmer
How's that working out

do{
tin myVra=1;
}wheli();
>>
File: 1457909144172.jpg (41 KB, 500x500) Image search: [Google]
1457909144172.jpg
41 KB, 500x500
If you had to develop an nime image blocker for 4chan, how would you implement one?
>>
>>54228971
>working completely and correctly.
It already is, as far as I can tell. there's no major bugs and the code's execution seems solid enough.

but it'd be great if I could make it more performant with a few simple tweaks. switching over to InitializeCriticalSectionAndSpinCount takes like 5 seconds of effort. I can't tell yet, but I don't think it actually improves anything. I need to test out more spin values.
>>
>>54229070
hash based is easiest to do, but also the easiest to get around. (such as when /r9k/ enforced unique images)
>>
>>54229046
>>54229057
HURR DURR just found it nevermind
>>
>>54229075
adding to that, browser #113 might not be a large enough program to benefit from the spin count. it only has like 10-20 threads, and there isn't usually a whole lot going on at any given time.
>>
Is K&R bad for an absolute beginner to programming?
>>
>>54229075
>switching over to InitializeCriticalSectionAndSpinCount takes like 5 seconds of effort. I can't tell yet, but I don't think it actually improves anything. I need to test out more spin values.

It doesn't take five seconds of effort. It takes a few months of effort to actually construct software that can demonstrate a benefit from such changes, and from particular selections for the spin count.

Sounds like you just want to make random changes and see what happens. Fine, but don't kid yourself: you don't know anything about why you should use that API nor what spin count would be a good idea for your particular software.
>>
>>54227973
By now, I'm sure your requirements have completely changed and this will be useless to you. However, I wrote the function you described for fun.

bool isAlphaChar(char ch) {
return (ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z');
}

char firstWhitespaceAfterAlphachar(char **string) {
char *str=*string;
char firstAlphaChar=0;
while(*(str)) {
if(!firstAlphaChar) {
if(isAlphaChar(*str)) firstAlphaChar=*str;
} else {
if(*str==' ') {
*string=str;
return firstAlphaChar;
}
}
str++;
}
*string=NULL;
return firstAlphaChar;
}


Test:
char string[] = "Hello, /g/. Testing, testing.";

char *str=string;

while(str) {
cout<<"FirstWhitespaceAfterAlphachar is '"<<firstWhitespaceAfterAlphachar(&str)<<"'\n";
if(str) cout<<"new string is \""<<str<<"\"\n";
}


Output:

Return value is 'H'
new string is " /g/. Testing, testing."
Return value is 'g'
new string is " Testing, testing."
Return value is 'T'
new string is " testing."
Return value is 't'


So you can print the first letter of each word with
while(str) cout<<firstWhitespaceAfterAlphachar(&str);
>>
>>54229147
Yes, it's not good for beginners
C Programming: A Modern Approach is top notch
>>
>>54229147

Yes. It's very dense. It is a guide to the C language for people who are already programmers.

If you're a newb, learn Python. Then C for fundamentals. Then C# or Java for employment. Then whatever else you want (functional, JavaScript etc.).

K&R is a beautifully example of efficient writing. It's also a gold standard by which book printing should be judged (i.e. extremely high quality paper and printing). But it's not a good intro to general programming.
>>
>>54229194
I'd just like to interject for a moment and recommend C++ for a first language instead.
>>
>>54229177
>you don't know anything
well I do have SOME idea of what I'm doing. I know enough to be aware of user vs kernel cpu time, and that using a spin count is probably only useful for massively multi-threaded apps that are quickly manipulating the same target.

but you're right -- I'm trying out random things, just for fun.
>>
>>54229251
Without any reason?
I can think of quite a few reason that one shouldn't learn C++ first.
>>
File: 1406803019377.jpg (103 KB, 1280x720) Image search: [Google]
1406803019377.jpg
103 KB, 1280x720
>>54229251
>recommend C++
Disgusting
>>
>>54229267
I can think of quite a few reasons that one shouldn't learn Python first.
>>
>>54229251
I'd just like to interject for a moment. What you're referring to C++ is really C with classes, or as I've recently taken to calling it, C plus classes.
Many programmers write in a modified version of the C language everyday, without realizing it.
Through a peculiar turn of events, the version of C which is widely used today is often called “C++”, and many of its users are not aware that it is basically the C language, developed Dennis Ritchie.
>>
>>54229251

LOL, good one.

I actually went to college when C++ was hot. It was ridiculous watching CS101 types being told to just ignore all the magic behind, "cout << "Hello, world" << endl;"

That same college refused to acknowledge my AP exam scores (4/5 and 5/5) because we used Pascal... Until I met with the head of the CS department and he went, "uh, yeah, who cares what language it was in?".
>>
>>54229326
I am recommending it because it touches on all facets of programming, and it determines whether or not you're a good programmer and can think programmatically. What other language does that?
>>
>>54229350
>What other language does that?
Pretty much any of them.
C++ is just a clusterfuck of random features, which somehow are supposed to make the language "better".
>>
>>54229369

To be fair, C++'s random clusterfuck often makes it easier to get work done than simpler languages (C, Pascal).

I still wouldn't learn it as a first language, though.
>>
>>54229283
Me too. I find that there are things that make Python not ideal for learning, but I find that they aren't nearly as bad as C++, a language completely unsuited for beginning programmers.
I personally think learning a Lisp (e.g. Racket) is a great idea, however a lot of people disagree because "the industry!!" So I think that if you have an open mind you can move past some of the inefficiencies of Python. However, C++ is a complete monster of a language, with numerous features all suited for experienced programmers who are trying to write efficient code (e.g., NOT A BEGINNER). I say this from the perspective of someone who writes a lot of C++ code and actually enjoys it.
I think that implicit behavior is the worst thing a programming language can offer to beginning students. C++ is ripe with implicit behavior in nearly every feature it has built upon C.
>>
>>54229350
>I am recommending it because it touches on all facets of programming

You have to be kidding. C++ offers nothing.

* Shitty OOP
* Shitty fundamentals in modern C++
* Shitty everything

Like I said before, Python, then C, then C#/Java, then others.

C++ just demonstrates that you can wrangle a ridiculous language with ungodly foot-shooting potential. I lived through the template-heavy curiously-recurring-template-pattern Win32 programming years. Never again.
>>
>>54229369
And python isn't? In fact that's literally what Python is, a clusterfuck of random features.
>>
>>54229409
I'm not advocating memesnake though.
>>
>>54229394
>C++'s random clusterfuck often makes it easier to get work done than simpler languages (C, Pascal).

Huh? You spend more time writing boilerplate bullshit than you do actually solving problems.

Not to mention the ridiculous verbosity that you hit as soon as you start using STL and actual modern C++. People criticized Java for being so verbose, meanwhile I'm over here writing std::map<ID_NUMBER, std::list<TRANSACTION_RECORD> transactions;" looking bullshit all the time.
>>
>>54229422
ah so that's why it's the chosen language of most competitive programmers?
>>
Has anybody here actually read SCIP?
Do you recommend it?
How should I follow it?

I know Python and Javascript, but Scheme looks quite weird desu.
>>
is it okay if i use nested for loops?

max im gonna need is 3
>>
Jesus, this Trump markov chain is genius.

i order thousands of you im very good.
i cant be allowed to tell me oh well.
>>
>>54229434
>ah so that's why it's the chosen language of most competitive programmers?
>competitive programmers
>competitive
>>
>>54229455
https://www.quora.com/What-is-the-best-language-for-Competitive-Programming
>>
>>54229422

That's the price you pay for templates and nice data structures being part of the standard. You don't get map OR list in C.
>>
>>54229451
Why wouldn't it be ok? Nest away!
>>
>>54229434
>it's the chosen language of most competitive programmers?

LOLWUT.

>https://www.quora.com/What-is-the-best-language-for-Competitive-Programming

So... You're basing your recommendation on what is the best for contrived *competitions*? Am I understanding you correctly?

You're not looking at suitability to learning. You're not looking at suitability to industry. You're not looking at efficiency at various program sizes. You're literally basing your recommendation entirely on what you think is a good language for academic programming competitions? And ultimately on a single Quora answer?
>>
>>54228931
>what industry needs the most programmers
The one I'm currently working in.
>>
>>54229422
I'm not going to say that C++ ISN'T verbose, but what can help is if you:
>use 'auto' as often as possible
>redeclare types with the 'using' syntax to make things shorter and more clear
>specifically, I declare nearly all of my std::shared_ptr<>/std::unique_ptr<>'s with 'using' (DESU i wish those fucking smart pointers weren't so goddamn verbose)
>put things in a struct to be even more precise on what is going on

>>54229451
Don't listen to the conformists who tell you to over-refactor.
If it's clear what your code is doing in all of those loops, then do it. Make sure it's not like
for (int i = 0; i < s.length; ++i) {
int k = 0;
for (int c = 0; c < i + k; c++) {
for (int j = i; j < s.length; j++) {
if (s[i] == s[j] + c)
k = 1;
else
j--, c++;
}
}
}
>>
>>54229507
No, I was answering your rebuttal retard. You said you spend most of the time on boilerplate. If that was true then why would competitive programmers use it?
>>
>>54229480
>That's the price you pay for templates and nice data structures being part of the standard.

No, that's the price you pay for a shitty parsing system and a standards committee that moves at a glacial pace.

C++ would have been much more tolerable if the auto type keyword had existed 15 years ago, but it didn't. And ranged for loops. Instead, we had mind-numbingly repetitive code in which substantial bugs could easily hide.

>You don't get map OR list in C.

Which is why you use Java and C# for real work.

C++ is C that tried to be better for larger projects. It became a nightmare. C# and Java are far superior for large projects, and C is superior for small, tight projects.
>>
>>54229535
>Which is why you use Java and C# for real work.

You should prefer memes like D, Go, and Nim for real work.
>>
>>54229544
>nim
>real work
excuse me?
>>
>>54229520

> >>use 'auto' as often as possible

Uh, fucking NO. auto is for very specific circumstances. It should only be used when the return type can be easily inferred from the following code.

>>redeclare types with the 'using' syntax to make things shorter and more clear

Ah, yes, more overloading of existing keywords because the retarded committee favors unreadable code over ever possibly breaking anyone's compile, ever, by introducing a new keyword.
>>
>>54229552
You objected to Nim from that list?
>>
>>54229544

No, as I've said repeatedly, C# and Java.

D will never be a thing. Go might be in 25 years, when people are trying to maintain shit written by current startup hipsters.

C and Java will be here for eternity.
>>
>>54229570
Not saying I agree with the C++ committee, just tryna help you.

>>54229574
I was going to say D but I know that mentioning that language gets dpt riled up. However I'm willing to admit that some "real work" actually gets done in Go, even if I personally don't like the language.
>>
>>54229580
>C and Java will be here for eternity.

Don't remind me. :(
>>
I've been using this for a while to encode strings to URL for a while in bash, but I recently had an issue with a special character "" causing it to error, any ideas?

rawurlencode() {
local string="${1}"
local strlen=${#string}
local encoded=""
local pos c o

for (( pos=0 ; pos<strlen ; pos++ )); do
c=${string:$pos:1}
case "$c" in
[-_.~a-zA-Z0-9] ) o="${c}" ;;
* ) printf -v o '%%%02x' "'$c"
esac
encoded+="${o}"
done
echo "${encoded}" # You can either set a return variable (FASTER)
REPLY="${encoded}" #+or echo the result (EASIER)... or both... :p
}
>>
Made a bot doe the SEC

How long before my door gets kicked in?
>>
>>54229645
Okay, so 4chan refused to send it but its the unicode character for a star

>>
File: nx6bpv5ZLK1r5kws5o1_540.jpg (89 KB, 291x810) Image search: [Google]
nx6bpv5ZLK1r5kws5o1_540.jpg
89 KB, 291x810
>>54225619
In your opinion, in any programming language of your choice, what's the "most correct" way of writing:

>if logged in and the correct user, [do a thing]
Thread replies: 255
Thread images: 28

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.