[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: 334
Thread images: 31

File: logocaml-oreilly.gif (5KB, 375x352px) Image search: [Google]
logocaml-oreilly.gif
5KB, 375x352px
Previous: >>57441814

What are you working on, /g/?
>>
>>57445354
OP here. I totally agree.
>>
File: it's a trap.png (873KB, 1275x677px) Image search: [Google]
it's a trap.png
873KB, 1275x677px
>>57445354
explain
>>
let debug = false;;

let fdebug f =
if debug then
begin
Printf.eprintf "# %t" f;
prerr_newline ()
end
;;

let get_dir file = Filename.dirname file;;

let get_extension file =
let i = String.rindex file '.' in
String.sub file i (String.length file - i)
;;

let get_sha1 file =
let sha1_command = Printf.sprintf "sha1sum %S" file in
fdebug (fun epf -> Printf.fprintf epf "sha1 command %S" sha1_command);
let ic = Unix.open_process_in sha1_command in
try
let sha1 =
let line = input_line ic in
Scanf.sscanf line "%s" (fun s -> s) in
match Unix.close_process_in ic with
Unix.WEXITED 0 -> sha1
| Unix.WEXITED _
| Unix.WSIGNALED _
| Unix.WSTOPPED _ -> failwith "sha1sum failed"
with
| x ->
ignore (Unix.close_process_in ic);
raise x
;;

let main () =
let file =
match Array.length Sys.argv with
| 2 -> Sys.argv.(1)
| _ -> failwith "usage: tosha1 FILE" in
let dir = get_dir file in
fdebug (fun epf -> Printf.fprintf epf "dir %S" dir);
let extension = get_extension file in
fdebug (fun epf -> Printf.fprintf epf "extension %S" extension);
let sha1 = get_sha1 file in
fdebug (fun epf -> Printf.fprintf epf "sha1 %S" sha1);
let target = Filename.concat dir (sha1 ^ extension) in
fdebug (fun epf -> Printf.fprintf epf "target %S" target);
let command = Printf.sprintf "cp %S %S" file target in
fdebug (fun epf -> Printf.fprintf epf "command %S" command);
Printf.eprintf "%S => %S" file target;
prerr_newline ();
match Sys.command command with
| 0 -> ()
| _ -> failwith "cp fail"
;;

let () = main ();;
>>
File: working.gif (2MB, 459x358px) Image search: [Google]
working.gif
2MB, 459x358px
Good programmers learn everyday, even when the end is near.
What have you learned today, /dpt/?
>>
>>57445335
I need help with fucking tsql

I have a column that is a DATE field

I want to create a procedure that inserts 300 dates on this, based on the day of the week and month (no december, january ou july) but i'm really not sure on how I could do that, specially the part of going through the days until it finds a suitable one

please ask questions if you think its necessary
>>
>>57445354
Polling > both
>>
>>57445399
>fprintf ... (string) sprintf
for what purpose
>>
File: hereyougo.gif (88KB, 10000x10000px) Image search: [Google]
hereyougo.gif
88KB, 10000x10000px
9th for python
>>
>>57445402
>What have you learned today, /dpt/?
That windows replace fprintf(f, "\n") by \r\n if the file is open in text mode
>>
>>57445416
Where?
>>
>>57445445
oh nvm you re-use it

desu you should group the lets and fdebugs
>>
>>57445465
>the lets and fdebugs
What for?
>>
>>57445472
>you get to choose
optional callbacks

>flatten the program
good for execution but normally it's bad programmatically

>slow
depends
>>
File: "Curvy".jpg (56KB, 408x383px) Image search: [Google]
"Curvy".jpg
56KB, 408x383px
There is literally nothing wrong with a programming language being bloated. Prove me wrong.
Protip: You can't.
>>
>>57445555
Python is god.
>>
>>57445399
Why???
>>
>>57445576
Why what?
>>
>>57445594
>dems don't pander to idiots
Yes, straw man, but just point out that it's a shitty argument.
>>
>>57445594
>He's literally pandering to uneducated people though.
Thats what shillary is doing, anyway.
go shill on pol or something you retard
>>>/pol/
>>
>>57445593
Why have you written a shell script in Ocaml?
Why does it add an extension to the end of a hash sum?
>>
>>57445519
Events can always trivially be converted to callbacks whereas the reverse is not so easy.
>>
>>57445632
It was more simple to write it in ocaml than in bash with those ugly substitutions.
>>
File: Beg your pardon.jpg (18KB, 274x305px) Image search: [Google]
Beg your pardon.jpg
18KB, 274x305px
>>57445636
>Being smart is useless for a leader.
I know America has a different mentality, but this is genuinely funny from a Yurofag PoV.
>>
>>57445639
that's because callbacks are flexible and powerful while events are fixed and concrete
>>
>>57445639
You're trolling anon. Callbacks are hidden events. So it's the opposite anon.
>>
>>57445650
It's the other way around.
>>
>>57445654
>Callbacks are hidden events
>>57445655
You're both retarded.
>>
>>57445657
>Educated people make their own minds up and are a minority. The former a direct result of being educated in the first place
That's not true, actually!
It's a common fallacy among educated people that they are somehow immune to biais and manipulation, but it's been proven wrong repeatedly.

Educated people are on average slightly harder to pander to since some obvious bullshit might not fly, but everyone's emotions can be manipulated.
>>
>>57445654
>Callbacks are hidden events.
Exactly.
>So it's the opposite anon.
No you retard.
Callbacks is events + hidden event loop dispatching to function pointers.
Events is you coding the event loop yourself, ergo you can easily just call functions if that is what you want.
But trying to get back the event loop (and control how it runs) from a callback-only model is much more difficult (if not impossible).
>>
>>57445667
Thinking that politicians are "dumb fucks" or "retards" is extremely naive.

They know exactly what they're doing.
The reason politicians always talk with simple words and simple ideas is to reach simple people, not because they're idiots.
>>
>>57445640
It would be five times smaller there.
>>
>>57445689
>Callbacks is events + hidden event loop dispatching to function pointers
No, callbacks could be done however the framework chooses.
Consuming iterators - callbacks
Async - callbacks

Anything remotely monadic is basically callbacks
>>
>>57445689
>But trying to get back the event loop (and control how it runs) from a callback-only model is much more difficult (if not impossible).
That's exactly what I was saying.
>>
File: 1434046275125.jpg (59KB, 500x684px) Image search: [Google]
1434046275125.jpg
59KB, 500x684px
>>57445402
Reading about pipes and conduites in Haskell.
I think I'll go with pipes, since the programmer seems like a nice dude and the tutorial is good.
A year ago or so I had a problem where a program would unexpectedly take up gigabytes of memory, now I know why (forM) and how to fix it (pipes)
Apart from that I need to brush up my knowledge of Monad Transformers.
Been using them already, but I want deeper knowledge.
>>
>>57445702
Show me. With sh, not bash. And it must be portable.
>>
>>57445707
>Educated people stay away from corrupted or manipulative sources in the first place. They don't subject themselves to pure manipulation. They weight up the consequences of their vote on either candidate and make a decision.
You wish, but it's been shown to not be true at all, sadly.
You'll have tons of very well educated people who only read opinions that agree with them. Engineers in particular are surprisingly vulnerable to this.

>If you are being emotionally manipulated by the media into voting you are not educated and you are not actively seeking out truths. This is a flaw on your part.
That's incorrect. You're wrongly equating being educated with being rational.
>>
>>57445516

I voted to Make America Great Again today.
>>
>>57445732
bote jeb bush
>>
>>57445705
At the core of any callback dispatcher is some kind of infinite loop doing the dispatching.
If you have to do the continuation manually yourself (akin to call/cc) then it's not really a callback model.
The main distinction is wherever you are in control of the dispatching loop or not.
>>
>>57445728
>Engineers in particular are surprisingly vulnerable to this.
What the fuck? Where did you get this bullshit?
>>
>>57445756
>The main distinction is wherever you are in control of the dispatching loop or not.
And that's why callbacks suck. Becuase the developer lost the main control.
>>
Fuck trump and shillery, I just want to talk about how great python is.
>>
How come i get banned for posting pol here and you faggots dont?
>>
>>57445761
I'll invite you to look at the worrying number of engineers who joined Isis because some goat-fucker with a beard manipulated them into believing some bullshit.
I'm taking the example of Isis because it's blatantly stupid, but that's part of a larger pattern of people not realizing their biais.

Knowledge is not a substitute for intelligence and critical thinking.
>>
>>57445740
>>57445759
>>57445767
you have an entire fucking board
you absolute fucking cunts

>waaah why can't i break the rules
fuck you
fuck you
fuck you
fuck you
>>
What are the filtered words again? I know c.u.c.k and f.a.g turn into cuck and fag, i forgot the other two
>>
wait, what? kek>>57445805
>>
>>57445756
reread my post

in an event system that is normally true, but not always

>>57445765
this is nonsense
>>
>>57445805
Shake my head, to be honest, family.
Baka, desu, senpai.
>>
>>57445811
Yea I know but what are the words that get filtered?
>>
>>57445805
roodypoo
candyass
>>
>>57445815
There's fucktons of them, the spamfilter is a mess.
I think the most recently added is height chan.
>>
>>57445813
>heh, i'm so much better than those pol kiddos
YOU ARE CANCER

>>57445817
>We aren't breaking the rules
Yes, you fucking are you stupid cunt.
Don't even fucking try this bullshit.
Shame on you, you piece of shit.
You know full well there's a place for you, and it's not here.
>>
If I have a 4chan pass does it still affect me? senpai baka
>>
>>57445815
hands free fapping
>>
>>57445834
Can we all talk about how great python is. I mean look how easy it is to write to a file:
with open('hi.txt') as f:
f.write('Hey bud')
>>
>>57445810
>in an event system that is normally true, but not always
And that is why events are more flexible, because you can control the dispatching - which was my original argument.
Callbacks is you setting up functions to be called, then letting other code dispatch back to you, this is always less flexible than if you could do the dispatching yourself.
>>
>>57445842
Tbqh as a C++ programmer I'm jelly of python just for this reason.
It's ridiculous that in 2016 it still takes 10 lines to read a file into a string in C++. And let's not even talk about the disaster that is Java streams.
>>
>>57445842
in haskell this is just

writeFile "hi.txt" "Hey bud"


>>57445847
>And that is why events are more flexible
What the fuck? How the fuck do you draw this conclusion?
>>
>>57445721
Well, your program isn't as portable as you think it is. Here, on FreeBSD, I don't sha512sum program, so I replaced it with sha512 and I don't use bash - only the native bourne shell.
#!/bin/sh
set -e
if [ -z "$1" ]; then
echo "Usage: $0 FILE" >&2
exit 1
fi
old_dir=`pwd`
cd "$(dirname "$1")"
f=$(basename "$1")
cp "$f" "$(sha512 -q "$f").${f##*.}"
cd "$old_dir"

You can enable debugging by tweaking shell's flags.
>>
>>57445853
I could fucking bother to address any of the horseshit you fucking spew while you selfishly ruin the thread with your own little topic, or i could remind you this is a programming thread and not a technology thread
>>
Server/Client
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Sockets; use GNAT.Sockets;

procedure Client is
Client : Socket_Type;
Address : Sock_Addr_Type;
Channel : Stream_Access;

begin

Initialize; -- initialize a specific package
Create_Socket (Client);
Address.Addr := Inet_Addr("127.0.0.1");
Address.Port := 12321;

Connect_Socket (Client, Address);
Channel := Stream (Client);
loop
declare
Data : String := Get_Line;
begin
exit when Data(1) = 'q';
String'Output(Channel, Data);
end;
end loop;

end Client;

with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Sockets; use GNAT.Sockets;

procedure Client is
Client : Socket_Type;
Address : Sock_Addr_Type;
Channel : Stream_Access;

begin

Initialize; -- initialize a specific package
Create_Socket (Client);
Address.Addr := Inet_Addr("127.0.0.1");
Address.Port := 12321;

Connect_Socket (Client, Address);
Channel := Stream (Client);
loop
declare
Data : String := Get_Line;
begin
exit when Data(1) = 'q';
String'Output(Channel, Data);
end;
end loop;

end Client;
>>
>>57445852
Yeah man I wish we could just do...
std::ofstream s{"hi.txt"};
s << "Hey bud";


Oh wait...
>>
>>57445855
>What the fuck? How the fuck do you draw this conclusion?
As I've repeatedly said - with events you can fully control the dispatching.
>>
>>57445871
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Sockets; use GNAT.Sockets;
with Ada.IO_Exceptions;
procedure Server is
Receiver : Socket_Type;
Connection : Socket_Type;
Client : Sock_Addr_Type;
Channel : Stream_Access;
begin
Create_Socket (Socket => Receiver);
Set_Socket_Option
(Socket => Receiver,
Option => (Name=>Reuse_Address, Enabled => True));
Bind_Socket
(Socket => Receiver,
Address => (Family=>Family_Inet,
Addr=>Inet_Addr ("127.0.0.1"),
Port=>12321));
Listen_Socket (Socket => Receiver);
loop
Accept_Socket
(Server => Receiver,
Socket => Connection,
Address => Client);
Put_Line("Client connected from " & Image (Client));
Channel := Stream (Connection);
begin
loop
Put_Line(String'Input (Channel));
end loop;
exception
when Ada.IO_Exceptions.End_Error =>
Put_Line("Client Leaving");
end;
Close_Socket (Connection);
end loop;
end Server;
>>
>>57445852
C++ is the best language though so no need to be jelly.
>>57445855
ok, try getting the html from a webpage with haskell:
import requests

with requests.Session() as c:
rget = c.get('http://boards.4chan.org/g/thread/57445335')
html = rget.text
>>
>>57445882
You can do that with callbacks, all you're arguing about is doing it yourself rather than having a framework.
>>
trump will implement generics in go within the first 100 days
>>
>>57445879
That's writing, and it's pretty cool (although probably super slow because C++ streams..).
Reading is still stupidly contrived, unless you do a clever two-liner with horrible performance.
>>
>>57445889
>.text
what does this do?
>>
>>57445893
>You can do that with callbacks
Not as easily - and if the callback dispatcher is running in a dedicated thread you get tons of overhead trying to make it thread safe.
>all you're arguing about is doing it yourself rather than having a framework.
Yes, essentially.
>>
>>57445863
${f##*.} is portable on all shells?
>>
>>57445916
>it's stringently related!
Make a fucking thread about it then you autist
You have no excuse
>>
>>57445906
the rget would just be the response, so if you do:
print(rget)

you would get
Response 200

Which is what you want, but if you actually want the html you have to do rget.text
>>
Pull > push
>>
>>57445936
Enjoy your high latency and wasted CPU time
>>
>>57445889
one second
>>
>>57445944
>>57445889
You are comparing libraries, not languages.
import requests
main = do
html <-getHtml "http://boards.4chan.org/g/thread/57445335"
>>
>>57445914
Yes, on all POSIX-compliant shells.
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
>>
>>57445923
>Make a fucking thread about it then you autist
Don't need to; already in one.

>You have no excuse.
Don't need one. Already have a thread pertaining to technology and programming.
>>
>>57445904
Well yes since the original post with Python was also writing to a file but reading with streams isn't that bad either.

std::ifstream s{"file.txt"};
std::string v{};
s >> v;
>>
>>57445971
That will only read one word though, and it will be extremely slow.
>>
>>57445967
OK. But you sheat by using sha256 and not sha1. There is no -q on sah1. (And I don't care about an OS without sha1).
>>
>>57445944
requests is part of the library's that come with python so I counted it as part of the language.
But if you want to go that way, let's see you reverse a string in haskell.
cuck = 'Some String'
rev_cuck = cuck[::-1]
>>
FRP
>>
>>57445842
> how great python is
but anon that's wrong
>>
>>57445980 is for >>57445962
>>
>>57445889
import Control.Monad (>=>) 
-- most of this module should be in prelude desu
import Network.HTTP (simpleHTTP, getRequest, getResponseBody)

http = simpleHTTP . getRequest >=> getResponseBody
-- the same as
-- http x = simpleHTTP (getRequest x) >>= getResponseBody

main = (http >=> print) "http://boards.4chan.org/g/thread/57445335"
-- main = http "..." >>= print


shorter:
import Network.HTTP
url = "http://boards.4chan.org/g/thread/57445335"
main = simpleHTTP (getRequest url) >>= getResponseBody >>= print
>>
>>57445991
Why do you say that?
>>
>>57445842
File.AppendAllText(dir + "test.txt", "hey bud");
>>
>>57445977
Won't differ much from Python or other convenient language when you want to start reading specific amount of bytes and such.
>>
>>57445980
foldl (flip (:)) [] "Some String"
>>
>>57445998
Because Python took a page from Perls book in terms of making a "naturally readable" language, and then told perl to fuck itself and proceeded to take a fat shit on all things performant.

Python is easy to use, don't get me wrong, but it's a trash language that should only seriously be used by researchers or scientists who don't have time to learn good programming habits and don't have time sensitive data execution.
Which is why so many of them do use python. It takes three hours to crunch this data instead of 15 minutes? Not like I care, that's fast compared to my experiments!
>>
>>57445976
>Amateur. It's how you do it in C:

My point is that if everything is hidden in a library then it's not elegant or a selling point of the language.

>>57445980
reverse = foldl (flip (:)) []>>57445980


Also, Extended Slices are just sugar and not a real language feature imo.
If you want to talk real elegance, we will have to compare real programs.
This is where haskell shines, and python can't keep up with.
>>
>>57446022
That's why python is meant for prototyping and not cpu intensive programs, you can whip up a program in an instant, test it, if it works, convert it to the language of you're choosing. Or you can use it for sockets or something which isn't cpu intensive and runs like a charm. That's why python is god.
>>
>>57445979
Oh, I'm sorry, that was my particular habit of using sha256, I can replace it literally here with sha1 and it will work.
>There is no -q on sah1.
There is. All seven utilities for checksums on bsd have the same flags.
sha1sum from coreutils, on the other hand, doesn't have such a flag. https://linux.die.net/man/1/sha1sum Correction with respect to its clumsy output takes one like of code.
>(And I don't care about an OS without sha1).
What kind of portability are you concerned about, then?
>>
>>57446003
Fair enough, but it's still disappointing when C++ could be both fast and easy.
>>
>>57446043
>So python is perfect then
...for people who do not program, yes. That doesn't make it a good language in any way.

>>57446050
Literally any scripting language in the history of forever can do exactly that without being a slow pile of garbage.
>>
>>57446048
What do you consider a real program?
>>
>>57446058
I mean my reverse shell works perfect in python and isn't slow at all. I am not saying python is the best at everything. But it is the best at what it is meant for.
>>
>>57446060
good question.
I would say a real program is something we cannot discuss inside the scope of this thread.
And to understand the elegance of this real haskell program you would have first learn haskell for a year or two.
An example of what I think is good, would be miku
https://github.com/nfjinjing/miku
a webdsl, which is cute, tiny and seriously powerful.
You would have to understand Monad Transformers first to get it though.
>>
>>57446078
You can write shit in it all you want, that's fine, it's easy to do if whitespace syntax doesnt bother you.
But it's not the best at anything other than being easy for non-programmers to use.

>>57446086
See above. Mathematicians aren't inherently handy with a programming language, and they're not exactly sitting around doing theoretical equations with a timer on the clock. There's no impetus for them to learn a faster language or one more suited to building applications.

If bash had the same package spread as Python they'd probably use that instead. It's a matter of convenience, not any form of superiority.
>>
i want man pages on windows
>>
>>57446099
That's pretty cool. But there are also many real world python programs that many people use and aren't slow at all. One of my favorites is kazam
https://github.com/aaae/kazam
A simple screen capture program that is perfect for all my needs. Also, in unison with ffmpeg, it is beautiful.
>>
>>57445788
What??? Are you talking about sandniggers or real people?

>Knowledge is not a substitute for intelligence and critical thinking.
True, however intelligent people usually have greater knowledge.
>>
>>57446132
You should want as little development inside of windows as possible.

I say this as a prior .NET factory dev (C# is pretty based tho) and a current devops.
Fucking hell I hate powershell and active directory. So god damn much. I want to cry every time I go into work.
>>
File: 1387994959678.jpg (104KB, 640x426px) Image search: [Google]
1387994959678.jpg
104KB, 640x426px
>>57445335
I feel like the resident retard but I just want to take a minute of your time to chuckle at those who called me a retard at FizzBuzz the other day.
Go run it yourself.
public class FizzBuzzTest{
public static void main(String[] args){
long startTime = 0;
long stopTime = 0;
long runningTime = 0;

for(int i=0; i<1000; i++){
startTime = System.nanoTime();
FizzBuzz1();
stopTime = System.nanoTime();
runningTime += stopTime - startTime;
}
System.out.println("Method 1: "+ ((float)runningTime/1000)+" nanoseconds.");

runningTime = 0;
for(int i=0; i<1000; i++){
startTime = System.nanoTime();
FizzBuzz2();
stopTime = System.nanoTime();
runningTime += stopTime - startTime;
}
System.out.println("Method 2: "+ ((float)runningTime/1000)+" nanoseconds.");
}

public static void FizzBuzz1(){
StringBuffer str = new StringBuffer("");

for(int i=1; i<=100; i++){ //Standard FizzBuzz
if(i%3==0) str.append("fizz ");
if(i%5==0) str.append("buzz ");
if(i%3!=0&&i%5!=0) str.append(i+" ");
}
}

public static void FizzBuzz2(){ //Retard FizzBuzz
StringBuffer str = new StringBuffer("");

for(int i=1; i<=100; i++){
if(i%3==0){
str.append("fizz ");
if(i%5==0) str.append("buzz ");
continue;
}
if(i%5==0) str.append("buzz ");
else str.append(i+" ");
}
}
}

Granted, even though I feel right and justified, I still feel like the retard as this slight betterment (in performance, at least) is likely well-known but just dismissed for reasons I can't be arsed to look for.
Still, Retard FizzBuzz is some 25% faster than Standard FizzBuzz.
>>
>>57446155
>What??? Are you talking about sandniggers or real people?
Real people, anon. It's surprisingly easy to manipulate people, even educated people.

Even scientists aren't immune from biais, it's well known that science advances when the older generation dies off. And their whole job is trying to be objective.
>>
>>57446099
>is cute, tiny and seriously powerful.
>webdsl
>>
>>57446201
i asked your mom for her /d/s/l
>>
>>57446178
First run:
Method 1: 17073.447 nanoseconds.
Method 2: 12338.236 nanoseconds.

Second run:
Method 1: 16809.736 nanoseconds.
Method 2: 12555.534 nanoseconds.

Third run:
Method 1: 18363.879 nanoseconds.
Method 2: 13225.745 nanoseconds.

Each run runs each method one thousand times and gives the average runtime.
>>
>>57446119
Well, I can't tell you whats so elegant about it if you don't understand it at all.
If you want an answer that just scratches the surface I can tell you what everybody else is also saying.
The powerful functional composition capabilities of Haskell allow for abstractions which allow us to write concise, elegant programs, which are easy to understand and reason about when you have the required knowledge.

>>57446135
That python has nice programs or whatever is not a real selling point of the language itself.

>>57446201
Your point?
>>
>>57446165
Still pretty garbage senpai

public static void FizzBuzz3(){
StringBuffer str = new StringBuffer("");

for(int i=1; i<=100; i++){
if(i%15==0){
str.append("fizz buzz");
} else {
if(i%3==0){
str.append("fizz ");
} else if(i%5==0){
str.append("buzz ");
} else {
str.append(i+" ");
}
}
}
}


Method 1: 9995.685 nanoseconds.
Method 2: 6994.427 nanoseconds.
Method 3: 6150.527 nanoseconds.


Full program
http://ideone.com/lpPdwX
>>
File: stack language pt2.png (49KB, 474x706px) Image search: [Google]
stack language pt2.png
49KB, 474x706px
>>57446119
>>
>>57446213
Method 3: 9950.646 nanoseconds.
Method 2: 7488.234 nanoseconds.
Method 1: 6745.611 nanoseconds.

Interdasting

Any insights into why this would affect it?
>>
>>57446225
whoops, that comment should add "pop"
i.e. you can implement "empty" as

empty = if isEmpty then done
else pop then empty
>>
>>57446211
It doesn't explore depths of computer science.
>>
>>57446213
First run:
Method 1: 12565.354 nanoseconds.
Method 2: 19246.072 nanoseconds.

Second run:
Method 1: 12835.301 nanoseconds.
Method 2: 20276.354 nanoseconds.

Third run:
Method 1: 20827.426 nanoseconds.
Method 2: 30320.604 nanoseconds.

...
God damn it.

>>57446219
I retract my statement. It's garbage.
>>
File: 1478132750137.png (858KB, 734x804px) Image search: [Google]
1478132750137.png
858KB, 734x804px
>>57446246
It's okay anon
You have the spirit that wants to be faster and more elegant, and that's what counts
>>
>>57446242
what doesn't?
If you mean Miku, read through the code and you will know why it actually does.
>>
What's with all the post deletion faggotrie
>>
>>57446306
>faggotry
ftfy
>>
>>57446306
Mods have been acting like real fuckin weirdos lately, lots of shit keeps getting deleted on /g/ and /ck/
>>
>>57446306
I got forever banned because I'm such a huge faggot. Finally the time to be united with my waifu.

You'll miss me guys. ;-;
>>
>>57446306
4chan servers can't handle election night
>>
>>57446242
what?

>>57446306
There were a load of politics posts
>>
>>57446259
But the question then becomes why and how to remove this nuisance of speed being dependent on the order you run the loops.
The whole reason I was proud of the ugly code was that it only did two conditional tests per iteration rather than three or more, hopefully reducing number of operations hence increasing speed.
But alas...

Anyway, reading a stackoverflow question on this, what it looks like is that the virtual machine is automatically optimising the method as it runs. Which sounds bizarre to me.
I'll have to find out how to do call a precision clock in C++ to test it there.
>>
>>57446369
Your ugly code might not be slower since your benchmark is biased anyway.

Have you tried using System.gc() after each loops?
>>
>>57446369
oh, my guess was that some strings were getting cached
>>
>>57446230
caching/warm up
>>
>>57446225
what's the point of calling empty after popping all of the values?
>>
>>57446379
>calling garbage collection unironically
>>
>>57446398
to make sure the result is the only part of the stack
>>
>>57446421
If it's just for the sake of benchmarking I don't see any problem with it.

Also, I hate Java anyway.
>>
File: IMG_0849.jpg (93KB, 777x728px) Image search: [Google]
IMG_0849.jpg
93KB, 777x728px
Is kotlin a meme?
>>
>>57446494
I've never heard of it, so it's not even a meme
>>
>>57446494
It makes developing for android bearable.
>>
>>57445335
Why the fuck is this thread 140 posts in when the other thread isn't even at bump limit?

Kill yourself, OP.
>>
>>57446379
To be honest, I've never heard of garbage collection, so no.
Currently grappling with C++'s high res clock. Every time I try to compile, I'm greeted with a wall of error messages.
>>
I can't figure out how to fix my program. I have a while loop that takes a user input and adds it to a list, then in there, that loop is functions outside the loop that check the list for a condition. When condition is met it prints 'player won' but can't break out of the while loop.

    if counter % 2 == 0:
new_state.insert(col, 'X')
new_state.pop(col + 1)
elif counter % 2 == 1:
new_state.insert(col, 'O')
new_state.pop(col + 1)

for i in range(len(game)):
print(game[i])

vertical_win(game)
diagonal_win(game)
horizontal_win(game)
counter += 1
>>
>>57446585
do you mean that vertical_win, diagonal_win and horizontal_win have the break statements in them?

that won't work, what you have to do is return a boolean (true/false) from these functions and do

if vertical_win(game) or diagonal_win(game)_ or hoerizontal_win(game):
break
>>
>>57446585
So what's the problem?
Would the problem be solved with a tactical break?
>>
>>57446553
>>57446427
That's not how garbage collection in java work just so you know. It does't work the moment you call it. Its not even designed to be called by you despite being visible. Even pajeets know this
>>
File: image.png (150KB, 1366x768px) Image search: [Google]
image.png
150KB, 1366x768px
>>57446602
I'm very new to programming so I dont' know what that is?

I did this weird code like this

which breaks the while loop but gives me an error.
>>
>>57446626
>I'm very new to programming so I dont' know what that is

Right, with languages based in C, you get continue and break which you can stick in a loop to either skip a loop ("continue" the loop) or jump out of it ("break" the loop).
E.g:
for i in range(0,24):
if(i==12):
print("skip")
continue
elif(i==18):
print("I'm out, bitches!")
break
else:
print(i,", ",sep="")

Should demonstrate how they work.
>>
>>57445402
Learnin' Common LISP, lovin' it
>>
>>57446613
Well sorry for spreading misleading information. Thank you for correcting the record. Java is too complicated for my simple brain.
>>
>>57446626
What are you doing on omegle?
>>
>>57446717
I chat with people from another board on there funnily enough.

I solved my problem by creating a global variable.
>>
How do I solve the diamond problem in c++?
>>
File: FUCK.gif (869KB, 400x265px) Image search: [Google]
FUCK.gif
869KB, 400x265px
>>57446369
I declare victory over <chrono>.
#include <iostream>
#include <string>
#include <chrono>
using namespace std::chrono;

void FizzBuzz1();
void FizzBuzz2();
void FizzBuzz3();

int main(){
typedef high_resolution_clock Clock;
time_point<high_resolution_clock, nanoseconds> startTime;
time_point<high_resolution_clock, nanoseconds> stopTime;
duration<int, std::ratio<1, 1000000000>> runningTime;

runningTime.zero();
for(int i=0; i<1000; i++){
startTime = Clock::now();
FizzBuzz2();
stopTime = Clock::now();
runningTime+=(stopTime - startTime);
}
std::cout << "Method 2: " << runningTime.count() << " nanoseconds." << std::endl;

runningTime.zero();
for(int i=0; i<1000; i++){
startTime = Clock::now();
FizzBuzz1();
stopTime = Clock::now();
runningTime+=(stopTime - startTime);
}
std::cout << "Method 1: " << runningTime.count() << " nanoseconds." << std::endl;

runningTime.zero();
for(int i=0; i<1000; i++){
startTime = Clock::now();
FizzBuzz3();
stopTime = Clock::now();
runningTime+=(stopTime - startTime);
}
std::cout << "Method 3: " << runningTime.count() << " nanoseconds." << std::endl;
}


/*typedef high_resolution_clock Clock;
auto t1 = Clock::now();
auto t2 = Clock::now();
std::cout << t2-t1 << '\n';*/

void FizzBuzz1(){
std::string str = "";

for(int i=1; i<=100; i++){
if(i%3==0) str+="fizz ";
if(i%5==0) str+="buzz ";
if(i%3!=0&&i%5!=0) str+=(i+" ");
}
}

void FizzBuzz2(){
std::string str = "";

for(int i=1; i<=100; i++){
if(i%3==0){
str+="fizz ";
if(i%5==0) str+="buzz ";
continue;
}
if(i%5==0) str+="buzz ";
else str+=(i+" ");
}
}

void FizzBuzz3(){
std::string str = "";

for(int i=1; i<=100; i++){
if(i%15==0) str+="fizz buzz";
else{
if(i%3==0) str+="fizz ";
else if(i%5==0) str+="buzz ";
else str+=(i+" ");
}
}
}

Results suggest speeds are entirely order-dependent.
That or I fucked up somewhere again.
>>
>>57446892

Only do single inheritance. Done.
>>
>>57446892
Use a better language
>>
>>57446773
>solved problem
>global variable
No, you just made a new one.
>>
>>57446895
With optimizations on all those functions can be eliminated as dead code.
>>
>>57446892
> How do I solve the diamond problem in c++?
Use a virtual base class.
>>
>>57446895
Run the tests multiple times (1 - 2 - 3 - 1 - 2 - 3 - 1 ...) and compute the average at the end.
>>
>>57446892
Composition.
>>
Trying to move a character roguelike style in ncurses is pretty hard.
>>
>>57445402
Not every learning experience is a good experience.
Yesterday I learnt swing
>>
>>57445335
could someone rewrite this to have correct indentations please?
https://pentesterscript.wordpress.com/2013/07/27/python-script-to-crack-md5-hash-using-dictionary-attack-2/
>>
>>57447045
copy & paste into a text editor an format
>>
>>57447065
I just ran it through a "beautify" site and that seems to have worked, thanks anyway though
>>
>>57447065
not sure the editor can decide what should be indented and not. he should fuck off though
>>
>>57447073
> not sure the editor can decide what should be indented and not
It can't. It can determine when to increase indentation, but in most cases it can't determine where to decrease it (the main exceptions being "else", "except" or "finally" keywords which have to be at the same level as an "if" or "try", and "pass").
>>
When checking if a number is inbetween a range is there a faster way than
num < a
do this
num > b
do this
num =< a && num => b
do this

I can just change the last check into an else right?
>>
>>57447148
if (num < a) {}
else if (num > b) {}
else {}
>>
File: 1478359721484.jpg (53KB, 606x630px) Image search: [Google]
1478359721484.jpg
53KB, 606x630px
>>57445335
Anyone have a suggestion for a http server library for python for simple API servers?

I want something that is asynchronous and I am not too worried about bloat as long as the library is easy to use. I also want the library to handle parameters form POST and GET.

Is Tornado my best bet?
>>
File: 6a8d3f3c.png (333KB, 628x526px) Image search: [Google]
6a8d3f3c.png
333KB, 628x526px
>>57446970
At first, I was getting results strongly suggesting order-dependence with averages of:
Method 1: 57706.0
Method 2: 58206.3
Method 3: 57039.6

But then I dove down a rabbit-hole of stuff I never knew existed and the averages became:
Method 1: 31038.00
Method 2: 30371.00
Method 3: 31037.83

Even the order-dependence disappeared.

Code now:
#include <iostream>
#include <string>
#include <chrono>
using namespace std::chrono;

typedef high_resolution_clock Clock;
typedef time_point<high_resolution_clock, nanoseconds> Timepoint;
typedef duration<int, std::ratio<1, 1000000000>> Duration;

void FizzBuzz1();
void FizzBuzz2();
void FizzBuzz3();
void run(short int x, void (*fizz)(), Timepoint startTime, Timepoint stopTime, Duration runningTime);

int main(){
Timepoint startTime, stopTime;
Duration runningTime;

run(3, FizzBuzz3, startTime, stopTime, runningTime);
run(2, FizzBuzz2, startTime, stopTime, runningTime);
run(1, FizzBuzz1, startTime, stopTime, runningTime);
}

void FizzBuzz1(){
std::string str = "";

for(int i=1; i<=100; i++){
if(i%3==0) str+="fizz ";
if(i%5==0) str+="buzz ";
if(i%3!=0&&i%5!=0) str+=(i+" ");
}
}

void FizzBuzz2(){
std::string str = "";

for(int i=1; i<=100; i++){
if(i%3==0){
str+="fizz ";
if(i%5==0) str+="buzz ";
continue;
}
if(i%5==0) str+="buzz ";
else str+=(i+" ");
}
}

void FizzBuzz3(){
std::string str = "";

for(int i=1; i<=100; i++){
if(i%15==0) str+="fizz buzz";
else{
if(i%3==0) str+="fizz ";
else if(i%5==0) str+="buzz ";
else str+=(i+" ");
}
}
}

void run (short int x, void (*fizz)(), Timepoint startTime, Timepoint stopTime, Duration runningTime){
runningTime.zero();
for(int i=0; i<1000; i++){
startTime = Clock::now();
(*fizz)();
stopTime = Clock::now();
runningTime+=(stopTime - startTime);
}
std::cout << "Method " << x << ": " << runningTime.count()/1000 << " nanoseconds." << std::endl;
}
>>
Should I turn all if statements to case statements when I can? Case runs faster right?
>>
File: 1462082471526.gif (2MB, 380x238px) Image search: [Google]
1462082471526.gif
2MB, 380x238px
>>57447265
readability > micro-optimization

If a case makes more sense then use it. Otherwise use whatever is easiest to read and write.
>>
>>57447265
Do neither.
Always calculate both branches and select correct answer with bit masking.
>>
>>57447265
Why not javafx instead?
>>
>>57447000
whoops meant to be for
>>57447290
>>
>>57447265
Faster because it skips false conditions faster, kinda hard for me to explain.

You cant be trigger happy though, sonarqube quality says if your conditions go past around 7 consider changing it
>>
>>57447265
It depends. It's more complicated than "switch is faster than if".
But really, unless you're in an extremely performance-intensive part of your code, it's not something you typically need to worry about, as the differences are extremely small.
>>
>im already unemployed
>Trump's election is causing a stock market crash

fuck!
>>
>>57447366
memes into miracles
>>
File: 1478664760620.png (14KB, 579x99px) Image search: [Google]
1478664760620.png
14KB, 579x99px
yes please fuck off out the country you traitorous leeching ass faggots

good riddance
>>
I finished my tic tact toe game. I need to add a gui to it now but I might just start learning something more tomorrow like chess or bit torrent client.
>>
>>57447452
what about mexico's?

fucking liberals. are they fucking hypocrites? no wait, we all know they are. even more so, they should have applied years ago to go to canada. do they really believe they can just move like that? if they apply now, it is possible that maybe they could get a visa before trump's second term.
>>
File: 2016-11-09_02-44-14-1.webm (386KB, 808x630px) Image search: [Google]
2016-11-09_02-44-14-1.webm
386KB, 808x630px
coolio
>>
>>57447478
>like chess or bit torrent client
Jesus, talk about a step up (assuming chess AI).
>>
>>57447222
You could try django with channels.
>>
File: output.webm (399KB, 526x310px) Image search: [Google]
output.webm
399KB, 526x310px
Working on my terminal emulator, fixed a couple tricky behavioral bugs and a plain crash.

One was a bug with how DECSC and DECRC were being handled, heatseeker (in the video after the fix) was doing a single DECSC and then multiple DECRC, and I assumed you could only restore once, so it would behave somewhat like a stack, but nope.

Another was a crasher when using Kakoune, after quitting the terminal would crash, for some reason it's sending a DECSTBM that ended up overflowing, so it's a bug in it but crashes are a bug in my terminal too.
>>
File: 1478361462975.jpg (67KB, 880x640px) Image search: [Google]
1478361462975.jpg
67KB, 880x640px
>>57447648
looks p cool. thx
>>
programming is DEAD
>>
>>57447860
Programming may be dead.. but can you fizzbuzz?
>>
>>57447860
trump will make programming great again
>>
https://news.ycombinator.com/item?id=12906019
>>
File: 2016-11-02_19-56-39-1.webm (330KB, 800x480px) Image search: [Google]
2016-11-02_19-56-39-1.webm
330KB, 800x480px
>>57447893
Fuck if i can. it's broken.
>>
>>57447906
post code
>>
>>57446892
Don't use inheritance.
>>
File: 1437610751230.jpg (26KB, 271x455px) Image search: [Google]
1437610751230.jpg
26KB, 271x455px
>>57447906
ur shits fucked senpai

import tornado.ioloop
import tornado.web
import tornado.httputil as httputil
import json
from tornado import version

#self.get_argument("name")

class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world!")
def post(self):
self.write("Hello, world!")

class JsonRequestHandler(tornado.web.RequestHandler):
def clear(self):
"""Resets all headers and content for this response."""
self._headers = httputil.HTTPHeaders({
"Server": "TornadoServer/%s" % tornado.version,
"Content-Type": "application/json; charset=UTF-8",
})
self.set_default_headers()
self._write_buffer = []
self._status_code = 200
self._reason = httputil.responses[200]

class TicketHandler(JsonRequestHandler):
def get(self):
self.clear()
response = {"status": "Success", "parameters": self.request.arguments}
self.write("%s" % json.dumps(response))
def post(self):
self.clear()
response = {"status": "Success", "parameters": self.request.arguments}
self.write("%s" % json.dumps(response))

class TimeHandler(JsonRequestHandler):
def get(self):
self.clear()
response = {"status": "Success", "parameters": self.request.arguments}
self.write("%s" % json.dumps(response))
def post(self):
self.clear()
response = {"status": "Success", "parameters": self.request.arguments}
self.write("%s" % json.dumps(response))

def make_app():
return tornado.web.Application([
(r"/", MainHandler),
(r"/ticket/", TicketHandler),
(r"/time/", TimeHandler),
])

if __name__ == "__main__":
app = make_app()
app.listen(8888)
tornado.ioloop.IOLoop.current().start()
>>
>>57447909
Don't make me commit sudoku pls sempai.

http://pastebin.com/X6Yxy0ym
>>
>>57447686
>There are people who actually use Kakoune
Man, I wish I was strong enough to abandon Neovim and use Kakoune. I just can't bring myself to do it.
>>
>>57447970
not sure what you're trying to do with the size. you know what tan(x) looks like right?
>>
Historic. It makes me want to cry.
>>
File: Capture.jpg (22KB, 505x191px) Image search: [Google]
Capture.jpg
22KB, 505x191px
>>57447996
Same dude
>>
>>57448013
what's /pol/'s nickname for him i forget
it was funny
>>
>>57447992
Neither do i, that should be a constant float.

Maybe i was trying to sin the size but i stopped trying to look what tan would look like.
>>
Breadth first search traversal for an adjacency list representation of a graph. Shit doesn't work.

void BFS(int s)
{
bool *visited = new bool[V];
for(int i = 0; i < V; i++)
{
visited[i] = false;
}

vector<int> queue;

visited[s] = true;
queue.push_back(s);

vector<pair <int,int > >::iterator i;
while(!queue.empty())
{
s = queue.front();
cout << s << " ";
queue.pop_back();

for(i = adj[s].begin(); i != adj[s].end(); i++)
{
if(!visited[i->first])
{
visited[i->first] = true;
queue.push_back(i->first);
}
}
}
}
>>
>>57447290
Because it is required by my shit course.
>>
>>57448093
>global variable V
>>
>>57448093
after <code> s = queue.front();
cout << s << " ";
queue.pop_back();</code>

don't you have to add that s to visited?
>>
>>57448208
Pretty sure I don't for BFS.

Either way moving from std::vector to std::queue fixed the issue, so it probably has to do with the insertion order.

Thanks for helping out though!
>>
>>57445335
>OCaml

Why are you so good OP?
>>
>>57445555
>>57445555
How do you prove someone with an opinion wrong? Especially on the supposition that what they've articulated is even cogent?

Programming languages can be verbose. The Developers Environment is bloated to abstractions pertaining to particular enterprise functions. If money needs a way to hide, it will make up many and any reason. Otherwise, the environment is formed over time and made to function for the particular company. But since most companies are treating CEOs like they're the latest polymer slammer in a game of pogs, then the whole idea behind a programming language functions like an argument between children. Words are thrown but only the emotion is prescient. And thus there is no argument but simply the bearer of an opinion that they did not form themselves.
>>
>>57448093
where does the "adj" array come from?
>>
Java:
I have a Swing window (Menu.java) which shows a main menu for a Pong game. This window has a button on it, and when it is pressed, it launches a JavaFX window (Lab4_5.java) which is the actual game. In the swing window, I also have text fields for player names and a spinner for ball speed.

I am doing all of this using model-view-controller design pattern, the problem is that the two windows use different instances of the Model class, which means that the text in the text fields in the main menu can't be used in the game (at least I haven't figured out a way to connect these two together).

How would you proceed? I've been at this for days and I'm out of ideas.

Pastebin:
Menu.java - http://pastebin.com/5E4Sufvm
Lab4_5.java - http://pastebin.com/aDswKehn
Model.java - http://pastebin.com/0CtMvPpZ
View.java - http://pastebin.com/Xxk9EGnM
>>
>>57448744
Forget Java and start over in C. Also make the model class a singleton if that's what you're looking for.
>>
>>57448744
Why aren't you using JavaFX for both windows?
>>
>>57449063
Thanks for the tip, I'll look into it and see if that's what I want.

>>57449072
I didn't know how to make buttons, textfields and stuff programmatically in JavaFX at the time, so I fired up the good old swing drag-and-drop project. I realize now that I dun goofed, cuz it's not that hard. Thinking of rewriting the program.
>>
>>57449141
yeah, you should rewrite the Swing part. I haven't used Java in a long time but JavaFx felt like a great improvement over Swing and Awt when I tried it out.
>>
File: IMG_2300.jpg (2MB, 3000x2000px) Image search: [Google]
IMG_2300.jpg
2MB, 3000x2000px
Did I do good? Please rate
>>
>>57449379
>Zed Shaw
On the road to becoming the average neo-4chan "programmer"
>>
File: IMG_2301.jpg (2MB, 3000x2000px) Image search: [Google]
IMG_2301.jpg
2MB, 3000x2000px
>>57449391
I do have this one, too. Just feel like I maybe need a different approach or something.
Someone on hackernews said "learn C the hard way" and "build your own lisp" were one of the 'best' books for learning C, so I just bought it.
>>
>>57449379
>>57449411
>learning C in 2016
>>
File: 1460067197713.jpg (84KB, 460x664px) Image search: [Google]
1460067197713.jpg
84KB, 460x664px
>>57445335

I'm planning to make a program in C using ncurses to show how stacks, queues and linked lists work.
>>
>>57449411

I think I have the same keyboard as you.
>>
Please no political discussion, this is a genuine request:

Does anyone know where I can find raw data on the demographics and other voters stats in this election?

I'm able to find pre-made charts, but I'm having trouble finding raw tables to form my own charts.

I'm looking to include it in a small visualization application I'm making, to test some BI things.
>>
>>57449572
steelseries 6gv2.
I like the feeling on it, but I fucking hate that there is no right windows key. Dont even fucking know why I bought this shit 4 or 5 years ago.
Too greedy to buy a new one though. Just werks :^)
>>
Is Go worth of learning for back end stuff?
>>
>>57449680
left*
lol, fuck me.
>>
>>57449411
I think there are too many programmers who focus on the specifics of a language. Syntax is very easy to learn in a language, and once you've learned a few languages and gotten a lot of experience under your belt, learning a new language is easy. Data Structures and algorithms are the important aspects of computer science. Focusing too much on the "right way" to learn C misses the point. You can micro optimize code in C all you want, but ultimately if you don't know good design or efficient algorithms or what data structures are used when then being a C expert means nothing.
>>
>>57449682
I've found it a little lacking but a lot of the standard library, especially the net/http stuff, "just werks". It's also super easy to learn if you use gofmt (a linter) and have experience with C. It has pointers (pretty much) just like C, most of the syntax is similar but backwards... The only confusing thing about getting started is setting up all the environment variables and such. I'd say it's decent for hobby projects and maybe microservices but if I had to build a scalable OOP backend I'd go for .NET.
>>
>>57449722
>Focusing too much on the "right way" to learn C misses the point.
That's not what I am doing.
I know how to programm. Programmed a shitton java. Just want to get behind all em concepts of C.
>>
>>57449755
Then worrying about K&R vs C the hard way is pointless. If you understand the concepts of programming, then almost any book will do
>>
>>57449805
There is no versus. C the Hard way is just an Addition for me to K&R, which I have already read.
>>
>>57449805
>>57449833
PS: I am just a fucking Autist when it comes to learning shit and I like to have different viewpoints from different persons.
>>
>>57449838
>>57449833

Well then I misjudged you; that's a perfectly fine strategy
>>
>>57449679
Do the graphs not provide links?
>>
>>57450094
Not that I've seen.

Every now and then they'll reference a poll site, but I haven't found raw data available.
>>
>>57449838
>>57449849
No this is retarded. Only the best opinion is worth learning. Everything else is trash and should be gassed.
>>
>>57449679
Don't really know, maybe look at cnn or fox's election page's js and snoop on their ajax?
Try reddit's dataisbeautiful page maybe you'll have better luck


>reddit
>>
>>57450144
>reddit
>>
>>57449679
Wikipedia has demographics stats for the 2012 election so they might get them eventually for the 2016 one. I'd be willing to bet you'll have to pay a pretty penny for full, in-depth stats though.
>>
I don't know how to think anymore, python has made me an idiot.

Without variable types or any sort of planning or logic being necessary I just type random shit into it and it works.
>>
>>57450332
>python has made me an idiot.
I fucking warned you
>>
File: 1454901285507.jpg (43KB, 408x439px) Image search: [Google]
1454901285507.jpg
43KB, 408x439px
>>57450116
How do you know who has the best opinion?
How's you're fizzbuzz werkin', m9?
>>
>>57450353
>How do you know who has the best opinion?
Not him, but I do
>>
>>57450332
>using only one language
>using only one TYPE of language
>not working in both strongly/weakly typed langaugeS (capital 's' for plural)
raped w/ ease
>>
Is it safe to learn various languages at the same time?
>>
>>57450505
Only if you wear protection
>>
>>57450468
Weak typing is easy in strongly typed languages
>>
Hey guys, does anyone here knows anything about mobile programming? I have an assessement coming soon and I have to know what are the main ways to storage data into android devices. Any advice is useful
>>
>>57450505
No, learning more than one language at a time is the leading cause of death in developed countries.

Of course its safe dummy.
>>
>>57450532
What type of protection?
I'm trying to learn c, c++, and python.
:o
Python seems a little bit tricky...I think..
>>57450538
Ah
>>
>>57450543
>https://developer.android.com/guide/topics/data/data-storage.html
>42 seconds in google

change careers if its not to late senpai
>>
Right now I'm learning JS (on React now) and am good at design. But I just want to make the most amount of money possible in this field. What area of programming or language should I focus on?
>>
>>57450610
You should focus on your people skills and hygiene habits.

Seriously. It's much more likely to win your a high-paying position than a particular programming language.
>>
>>57450610
angular 1 + node
well you did said money
jquery still ok to learn today
>>
File: 1469989001481.png (173KB, 500x758px) Image search: [Google]
1469989001481.png
173KB, 500x758px
>doing Java lab job
>student has something like this as toString()
String toString()
{
return accountNumber + amount;
}

>Hey, there should be a newline between accountNumber and amount
String toString()
{
return accountNumber
+ amount;
}

The shit I put up with
>>
>>57450635
Hey, I remember you. Don't worry, semester's almost over. Did the class size lower at all? Still got the retards who couldn't figure out assignment statements or whatever basic facet it was?
>>
https://news.ycombinator.com/item?id=12911870

so this... is the power of lisp
>>
>>57450675
This week it was trying to get him to use the correct constructor when making a new object.
He knows to do
objectType object = new
but then I had to lead him to what to put after new.
Not many people have dropped though
>>
>>57450635
show them
for(;;) { }

it will blow their fucking minds
>>
>>57450741
because it's dumb
>>
We need operators to distinguish clamped and wrapping mathematical operations.
>>
>>57450926
just use functions
>>
>>57450926
clamp(a + b, 0, 10)
>>
I'm making a python program that uses an API, and don't want to put my API key on github, so I'm learning config files.
Using configparser, is there a best practise for looking for existing config files in the standard places and creating one if none exist? Bonus points for platform-agnostic.
>>
Where to I start if I want to create a simple graphics engine that will be able to demonstrate a single scene ? Curently I'm thinking that the end product will be able to demonstrate a scene like a single island that you can walk(first person camera) with maybe some trees here and there and a house model and sun to light the scene. The past days I have been messing arround with opengl,shader programming etc but I can't seem to figure out how it all connects together to reach my goal. Do you think that this http://gamedevgeek.com/tutorials/managing-game-states-in-c/ Is a good starting point in figuring it out ?
>>
Hi /dpt/. Novice here. Is there something like a browser extension that I can use to get python to know what website a person is looking at? And maybe their mouse movement and scrolling?
>>
>>57451166
that tutorial looks ok to start with but it seems to only deal with the logic and not rendering and input

to learn opengl i think it's best to browse https://www.opengl.org/wiki for a broad overview of the different concepts and then to read the actual opengl and glsl specifications (not the whole thing at once, just the part you're focusing on at the moment)
>>
Is it true that most of programming is debugging and a lot of stress and frustration?
>>
>>57451110
PUT IT IN THE FUCKING INSTALL FOLDER
DON'T YOU DARE PUT THAT SHIT IN %APPDATA% OR SOMETHING STUPID LIKE THAT

PLAIN TEXT
SAME FOLDER AS THE EXE
CONFIG.TXT

FUCK YOU
>>
>>57451166
No, because game states are about multiple scenes.
>>
>>57451219
yes

once you've fixed something it will be smooth sailing in implementing new things for a short while and then you get stuck on one thing for days on end
>>
>>57451222
>Not projectname.config
>>
>>57451233
it sets up a rendering loop tho, he can use it with a single scene or with a menu, it should be really easy to figure out compared to learning opengl
>>
>>57451222
>>57451241
or $HOME/.config/projectname/config
So how do I check all these places for a nice portable solution?
>>
>>57451255
>it should be really easy to figure out compared to learning opengl
It's not going to get him any closer to what he wants.
>>
>>57451264
he needs basically a game loop and that's what the code does (+ it has a stack of game states), he just has to fill in the blanks with rendering code
>>
>>57451241
Call me a microshill but I use .txt so it opens by default on windows. On linux it doesn't make a difference so why not add the .txt for the windows users.

>>57451257
NO YOU FUCK
DON'T
STOP

YOU PUT IT
IN THE FOLDER
WITH YOUR PROGRAM'S MAIN BINARY

FUCK APPDATA
FUCK $HOME
FUCK THE WINDOWS REGISTRY

Nothing gets me madder than this shit.
When will we outlaw programs that put random crap all over your fucking harddrive, poluting the file system and making cleanup and uninstallation fucking impossible.
The aboslute is when they fill up my SSD with gigabytes worth of shit.

I SPECIFICALLY SELECTED A FOLDER ON MY HDD WHEN I INSTALLED YOUR SHITTY PROGRAM

PUT THE FILES THERE
IN THE FOLDER I SELECTED
>>
>>57451275
The game loop is the lowest hanging fruit and all the other stuff is just fluff and premature abstraction for his purposes.
>>
>>57451288
how is this fluff and premature abstraction

#include "gameengine.h"
#include "introstate.h"

int main ( int argc, char *argv[] )
{
CGameEngine game;

// initialize the engine
game.Init( "Engine Test v1.0" );

// load the intro
game.ChangeState( CIntroState::Instance() );

// main loop
while ( game.Running() )
{
game.HandleEvents();
game.Update();
game.Draw();
}

// cleanup the engine
game.Cleanup();
return 0;
}


it's not a lot of code and all of it is reasonable
>>
>>57451303
Because that's not all the code? Why do you need a fucking class (CGameEngine) that will be instantiated exactly once and has the same lifetime as the main function? Put it in the fucking main function. The article itself and its recommendation is accomplishing nothing but introducing and/or reinforcing bad habits.
>>
>>57451303
>>57451319
Also, singletons. And it doesn't even use RAII.
>>
>>57451285
Sometimes you want to retain settings and metadata between installations.

The only other way to do this would be to force an online account.
>>
>>57451319
>>57451325
go fuck yourself you insufferable dumb ass

enjoy your fizzbuzz retard
>>
@57451329
Glad you're more interested in pushing your cult than actually helping an anon.
>>
>>57451342
because you're so helpful

kys
>>
File: dith.png (64KB, 320x512px) Image search: [Google]
dith.png
64KB, 320x512px
I did a program that converts pictures to a 4 colour palette with cross hatching shading.
>>
>>57451356
Could you share?
>>
>>57451345
>kys
are you 12
>>
>>57451364
your mom
>>
>>57451377
*you're
>>
>>57451345
I'm telling him to not waste his time on that because it's not going to help him achieve his goal nor is it going to contribute to being a better programmer in general.
>>
I need to learn Java in 10 weeks (By learn I mean everything they teach in a Java I course)
Does anyone have any up to date resources (JDK7/8) that detail the "Java" way of doing things
Basically I am looking for a Java quick start for experienced programmers.
>>
>>57451222
>>57451285
Cringy as fuck but I agree. Please don't spread your cancerous softwares all over my SSD.
>>
>>57451303
do
{
game.state.run();
game.state = game.state.next();
} while (game.state);


this way, each state can have its own main loop.
>>
>>57451405
poo in loo
>>
>>57451419
This. You also don't need a state stack because e.g. a pause state can just store the state it should go back to like a linked list.
>>
>>57451419
ok that's fair but anon is literally just starting out he just needs a context for his opengl commands you insufferable autistis
>>
>>57451328
or to simply allow the user to say "don't delete the configuration files when i uninstall so i can reuse them"
>>
>>57451435
So why are you pushing the even more bloated and shittier option?
>>
>>57451414
Buy a Java book and read it. It should take 1 week max.
>>
>>57451444
he asked if the tutorial is a good starting point and it is

instead of sperging about the tutorial for an hour you could have learned the tutorial from scratch in an hour or less
>>
>>57449411
Learn C the Hard Way is a TERRIBLE book written by a TERRIBLE hack. Do not listen to Zed, he barelly even knows the language. Almost half of the book is dedicated to showing he doesnt understand C strings by shitting on them about how they need to be packed in his very special data structure to "make them safe", and responds angrily to any criticism.
hentenaar.com/dont-learn-c-the-wrong-way
>>
>>57451461
The tutorial has fuck all to do with OpenGL and most OpenGL tutorials will set up a minimal main loop anyways.
>>
>>57451471
i also explained how he could learn opengl

all you did was nitpick about a trivial game loop tutorial
>>
>>57451470
this

fuck zed shaw

also
>hackernews
>>
>>57451482
OP asked
>Do you think that this http://gamedevgeek.com/tutorials/managing-game-states-in-c/ Is a good starting point in figuring it out ?
and I said no and gave reasons.
>>
>>57451495
yeah you sure helped him get a better starting point for creating a graphics engine
>>
>>57451356
SHARE PLS I WANT MORE 4 COLOUR SEMEN DEMONS
>>
716744 join kahoot
>>
>>57445335
So 100000000 get is coming up on /pol/. Are there any good extensions for gets or do I have to write my own?
>>
>>57451506
I answered his question.
>>
>>57451362
I'm a bit shy about sharing it, since I only really started learning/getting into programming at the start of this year and the program code is quite messy, but I'll post it if you really want it.
>>
>>57451522
Please do, looks pretty nice.
>>
>>57451520
yes in the most literal sense you answered his question sperg now you'll get an extra chicken tendie for being such a good boy
>>
>>57451512
>gets
Why not just leave now you stupid faggot?
>>
New thread: >>57451547
>>
>>57451522
Don't worry. Most programmers here are just pajeets pretending to know computer science.
>>
>>57451535
Too bad there isn't an OO consortium to pay you for your efforts, you're literally shilling a programming paradigm for free.
>>
>>57451522
The same than >>57451531
>>
>>57451550
ok lets all put everything in the main function like a pajeet
>>
>>57451554
>ok lets all put everything in the main function like a pajeet
There is no problem with that. The oinly evil thing is copy/paste.
>>
>>57451554
Let's factor out code we wrote once and will never have to write again into an object without even using RAII so that we...feel good?
>>
New thread: >>57451610
>>
>>57451531
Here it is:
https://my.mixtape.moe/zrbyay.7z
>>
>>57451554
>everything else is OOP
holy shit
>>
>57446165
>57446219
>57446895
>57447262
>57447893
>57451329

fizzbuzzfaggot, plox

.lf  fzbz6502.lst    
.cr 6502
.tf fzbz6502.obj,ap1
.or $0f00
;------------------------------------------------------
; The main program
;
main ldx #Lower ;init LoopCt
lda #FizzCt
sta Fizz ;init FizzCt
lda #BuzzCt
sta Buzz ;init BuzzCt
next ldy #0 ;reset string pointer (y)
dec Fizz ;LoopCt mod FizzCt == 0?
bne noFizz ; yes:
lda #FizzCt
sta Fizz ; restore FizzCt
ldy #sFizz-str ; point y to "Fizz"
jsr puts ; output "Fizz"
noFizz dec Buzz ;LoopCt mod BuzzCt == 0?
bne noBuzz ; yes:
lda #BuzzCt
sta Buzz ; restore BuzzCt
ldy #sBuzz-str ; point y to "Buzz"
jsr puts ; output "Buzz"
noBuzz dey ;any output yet this cycle?
bpl noInt ; no:
txa ; save LoopCt
pha
lda #0 ; set up regs for IntOut
jsr IntOut ; output itoa(LoopCt)
pla
tax ; restore LoopCt
noInt ldy #sNL-str
jsr puts ;output "\n"
inx ;increment LoopCt
cpx #Upper+1 ;LoopCt >= Upper+1?
bcc next ; no: loop back
rts ; yes: end main
;------------------------------------------------------
; Output zero-terminated string @ (str+y)
; (Entry point is puts, not outch)
;
outch jsr CharOut ;output string char
iny ;advance string ptr
puts lda str,y ;get a string char
bne outch ;output and loop if non-zero
rts ;return
;------------------------------------------------------
; String literals (in '+128' ascii, Apple II style)
;
str
; string base offset
sFizz .az -"Fizz"
sBuzz .az -"Buzz"
sNL .az -#13
;------------------------------------------------------
; Variable Section
;
Fizz .da #0
Buzz .da #0
;------------------------------------------------------
.en
>>
How do i earn money making fizzbuzzes?
>>
>>57452131
You can't.
>>
>>57452131
Work as a researcher in PLT
>>
File: Selection_673.png (10KB, 364x105px) Image search: [Google]
Selection_673.png
10KB, 364x105px
>>57451541
>>
>>57452866
checked
>>
File: Selection_675.png (16KB, 498x135px) Image search: [Google]
Selection_675.png
16KB, 498x135px
>>57451329
>>
>>57452929
grade a autism
Thread posts: 334
Thread images: 31


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