[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: 315
Thread images: 26

File: hime c.png (1MB, 1280x720px) Image search: [Google]
hime c.png
1MB, 1280x720px
old thread: >>61061513

What are you working on, /g/?
>>
Rewriting Rust in B
>>
Nothing.
>>
I just wrote a dynamic chat without JS (you can block JS and use it)
>>
>>61070913
B as in the predecessor to BPCL?
>>
>>61065420
thanks dud
>>
What if the Linux kernel was rewritten in Python?
>>
>>61071000
it would be painful slow
>>
Rewriting Bust in R
>>
>>61071004
4 u
>>
>>61070891
cluster server for a bideogame
>>
> learn Java
> get a job
> 300k starting

Why don't you NEETs do this?
>>
>>61071425
rather kill myself than willingly write pajeet shit.
>>
Why does the following work as expected (inputting '0' fires an interrupt signal which is handled before anything else happens) when I 'run' a thread, but when I 'start' it so I can have multiple threads running in parallel, it doesn't?

#!/usr/bin/python

import time, os, threading, signal

def int_handler(args):
print "Interrupt routine"

def thread():
while True:
cmd = raw_input(">")
if cmd == "0":
os.kill(os.getpid(), signal.SIGUSR1)

def main():
t = threading.Thread(target=thread)
signal.signal(signal.SIGUSR1, int_handler)
t.run()
return 0

if __name__ == "__main__":
main()


All threads have the same pid (that of the underlying process) and the signal is registered in the main thread.
>>
File: chelsea_on_rust.png (309KB, 560x1069px) Image search: [Google]
chelsea_on_rust.png
309KB, 560x1069px
T-thanks, Chelsea.
>>
>>61071505
I wonder how extensively Mozilla train their PR """""""""""""""""""""""""""""""""""""programmers""""""""""""""""""""""""""""""
>>
>>61070891
Why do you sexualize children, are you some kind of pedophile?
>>
>>61070948
Do you just refresh after some x seconds?
>>
File: 1498379263823.jpg (895KB, 700x9195px) Image search: [Google]
1498379263823.jpg
895KB, 700x9195px
>writing a print statement in the class instance
>its the only thing the class does
>no newline
>class has a return statement
>naming a function after a reserved builtin
>>
>>61071625
public class love {
system.out.pritn(iloveyou)
return true(love)
}

Would dump he immediatly.
>>
>>61071625
That picture.
>>>/v/
>>
>>61071648
you got me
>>>/v/381755143
>>
>>61071655
Why am I not surprised we would be in /dpt/ and that thread at the same time?
>>
dynamic typing is a compelling argument for eugenics
>>
File: 1496202409627.png (275KB, 600x888px) Image search: [Google]
1496202409627.png
275KB, 600x888px
>>61070891
C influenced languages get an automatic F in my book.
>>
>>61071694
what language(s) do you use, pasta-kun?
>>
>>61071681
dynamic typing doesn't exist
>>
>>61071704
you just lost your reproduction license
>>
File: 1497492419818.jpg (86KB, 544x600px) Image search: [Google]
1497492419818.jpg
86KB, 544x600px
>>61071681
I will be wiping it out very soon. Don't worry, anon.
>>
>>61071694
the language i'm building is imperative, no object orientation, has an assembly-like syntax mixed with prefix notation and a type system inspired by idris (haven't started on the type system yet)

how did i do
>>
>>61071704
This, it's a property of the implementation, not the language.
>>
>>61071704
Then what is JS's type system?
>>
>>61071734
Bad
>>
>>61071739
unityped
>>
>>61071735
if it's a property of the implementation it's something and it also exists

you just lost your programming license, your logic license and your reproduction license
>>
>>61071720
He is correct. Please don't conflate "dynamic type-checking" with "dynamic typing".
>>61071735
How can something non-existent be a property of an implementation?
>>
>>61071694
The language I'm building is literally untyped lambda calculus with IO. How did I do?

>>61071739
Weird
>>
>>61071754
I should have been more clear then, I assumed that the person I was replying to said "dynamic typing in programming languages doesn't exist", as most people who use the term dynamic typing tend to use it in a context of a programming language instead of an implementation.
>>
>>61071589
No refresh, I use a persistent HTTP connection and send more HTTP body everytime there's a new message with some CSS hacks so it looks like on a JS chat, dynamic and all
>>
>>61071767
>dynamic typing in programming languages doesn't exist
*dynamic type checking
There
>>
File: 1497803651645.png (548KB, 908x658px) Image search: [Google]
1497803651645.png
548KB, 908x658px
>>61071734
>the language i'm building is imperative
Fine.
>no object orientation
Very good.
>has an assembly-like syntax mixed with prefix notation
Acceptable.
>type system inspired by idris
Good.

>>61071757
>untyped lambda calculus
Acceptable.
>with IO
Bad.
>>
>>61071739
Garbage.
>>
>>61071778
>>with IO
>Bad.
B-b-b-b-but the guy above literally said that he is making an imperative language.
Also, how am I supposed to print to the screen if I have no IO?
>>
You could have pure IO.
>>
File: 1497246740034.png (377KB, 845x759px) Image search: [Google]
1497246740034.png
377KB, 845x759px
>>61071778
what would be the best combination in your opinion?
>>
>>61071799
>pure IO
Monads?
Unique/linear typing?
>>
File: 1495391254609.png (3MB, 1920x1080px) Image search: [Google]
1495391254609.png
3MB, 1920x1080px
>>61071790
>B-b-b-b-but the guy above literally said that he is making an imperative language.
So? An imperative language doesn't imply IO.
>how am I supposed to print to the screen if I have no IO?
The language shouldn't bother itself with that. Your REPL or runtime should handle it.

>>61071799
Why even have IO?

>>61071802
The best combination of what?
>>
>>61071812
>Your REPL or runtime should handle it.
You need a way to tell your "REPL or runtime" to handle it.
Something like >>61071809 maybe? It seems that you are implying the use of monads.
>>
>>61071809
monads as a start.
linear typing is trash.
>>61071812
Why not have IO?
I want to program things, not wank to /sci/ theory.
>>
File: 1481568519743.jpg (160KB, 1920x1080px) Image search: [Google]
1481568519743.jpg
160KB, 1920x1080px
>>61071812
>The best combination of what?
retard
>>
>>61070891
Post your confessions. Here's mine: I enjoy C++.
>>
>>61071832
I enjoy C, but hate C++
Ma favourite language is Java and I am not even a pajeet.
>>
>>61071832
There's no shame in that. There's a reason nothing can replace it.
>>
>>61071827
>linear typing is trash.
What is your reasoning?
>>
>>61071827
>I want to program things, not wank to /sci/ theory.
>The language I'm building is literally untyped lambda calculus
>>
File: 1492612436147.jpg (82KB, 408x600px) Image search: [Google]
1492612436147.jpg
82KB, 408x600px
>>61071821
>You need a way to tell your "REPL or runtime" to handle it.
That should be an interesting challenge.
>It seems that you are implying the use of monads.
I am outright stating that IO should be strictly forbidden. Making it pure doesn't avoid the main problems with it.

>>61071827
>Why not have IO?
Why introduce unnecessary things into the language?
>I want to program things
You can do that without IO.

>>61071831
>retard
What's with the rudeposting?
>>
>>61071852
I think you are confusing us anon, he is not me.
>>
>>61070891
Trying to find a clever way of calculating and storing a preconditioner without using a terabyte of memory or writing it to disk...
>>
>>61071844
Theyre a contradiction to FP, and a shitty way to solve data races and GC.
>>61071852
im not the OP, m8.

people against IO are either mt. stupid or delusional.
>>61071860
Why is IO unnecessary?
>>
>>61071860
i want to put my dick in lain but ejaculating inside it requires IO.
>>
>>61071868
>Why is IO unnecessary?
There isn't really anything useful you can't do without it. I'm sure it has some applications, but general purpose programming doesn't require it.
>>
>>61071872
her
>>
>>61071872
Don't know why but for some reason I can't portray Lain in a sexualized way
>>
>>61071878
>saving a file
>printing to screen
>but general purpose programming doesn't require it.
>>
File: 1497903834813.png (693KB, 713x837px) Image search: [Google]
1497903834813.png
693KB, 713x837px
>>61071892
>saving a file
That isn't general purpose programming. Just have everything you need at compile time.
>printing to screen
You could do that without the language itself supporting IO.
>>
File: Connected.jpg (311KB, 850x1228px) Image search: [Google]
Connected.jpg
311KB, 850x1228px
>>61071890
Lain is for hugs. Possibly lewd hugs, but never fugs.
>>
>>61071890
because she is a pure.
still, lain a good https://exhentai.org/g/491191/3537d079b9/
>>
>>61071902
>Just have everything you need at compile time.
This severely cripples you, but since youre already severely autistic, youll be right at home.
>you can do output without output
wew lad
>>
File: TWO_NUKES_DID_NOTHING.jpg (592KB, 4050x750px) Image search: [Google]
TWO_NUKES_DID_NOTHING.jpg
592KB, 4050x750px
Why aren't you studying/working on the neato project anon kun?
>>
>>61071902
by IO I mean "external impure bullshit" in general

>That isn't general purpose programming. Just have everything you need at compile time.
how about a program that does network communication?
>>
>>61071927
I have no neato project.
>>
>>61071927
Im taking a break and studying more idris-sama!
>>
>>61071927
because I'm a novice
and all I have in mind is a shitty web project anyway
>>
>>61071919
>This severely cripples you
Not really. I'm interested in general purpose programming.
>wew lad
Are you damaged in some way? You can output to the screen without the language itself even knowing about IO.

>>61071929
>by IO I mean "external impure bullshit" in general
That should be strictly forbidden.
>how about a program that does network communication?
Not general purpose.
>>
>>61071949
>general purpose programming
I'm gonna need a definition for this or you'll just continue to claim that everything everyone programs on an everyday basis isn't general purpose enough.
>>
File: 1469443282312.jpg (37KB, 853x480px) Image search: [Google]
1469443282312.jpg
37KB, 853x480px
>>61071949
>That should be strictly forbidden.
>Not general purpose.
>>
>>61071949
>You can output to the screen without the language itself even knowing about IO.
So you just want another Scala disaster then.
>>
File: 1492453398616.jpg (440KB, 768x1053px) Image search: [Google]
1492453398616.jpg
440KB, 768x1053px
>>61071927
But I am. It's a program to wipe out every compiler which does dynamic type-checking.
>>
>>61071962
It's defined in terms of the words "general", "purpose", and "programming". All of which are standard words with well known definitions.
>>61071967
No. Scala should be strictly forbidden.
>>
>being able to communicate with a general interface your computer uses every day isnt GPP
Im pretty sure you are literally the same autsist who has been getting into pedantic arguments like this for weeks now.
>>
>>61071973
I can think of SBCL, Java compilers, glib, Vala, C# compilers and Javascript bullshit
>>
File: 1498026682269.png (72KB, 185x204px) Image search: [Google]
1498026682269.png
72KB, 185x204px
Why so mad anon-kun?
>>
>>61072005
indeed, the same guy who is unable to comprehend simple questions like >>61071802 and refuses to point a good language when he whines about C derivatives.
>>
>>61071989
>It's defined in terms of the words "general", "purpose", and "programming". All of which are standard words with well known definitions.
Network programming definitely fits that definition then.
>>
>>61072046
It doesn't. It's very specific as it actually requires a "network".
>>
>>61072040
>refuses to point a good language
What if that's impossible?
>>
>>61071878
You got it the other way around.
Without io there's nothing useful you can do with a programming language because all programs would be equivalent to a no-op program.
>>
type state = { cheat : bool; player : int; count : int; }
type command = Stop | Count of int
let print state =
Printf.printf "%s (%d)" (String.make state.count 'I') state.count;
print_newline ()
let player_prompt = function
| 2 -> "1, 2? "
| _ -> "1, 2, 3? "
let ask c m =
let rec loop () =
print_string (player_prompt m);
flush stdout;
let line = read_line () in
let n = try Some (int_of_string line) with Failure _ -> None in
match n with
| None -> loop ()
| Some n when not c && (n < 1 || n > m) -> loop ()
| Some n -> Count n in
loop ()
let player_play state =
print_endline "Your turn.";
if state.count = 1 then
begin
print_endline "You take the last one...";
Count 1
end
else
ask state.cheat (min state.count 3)
let poisson lambda =
let rec unit () =
let u = Random.float 1.0 in
if u <= 0.0 || u > 1.0 then
unit ()
else
u in
lambda *. (-. log (unit ()))
let ai_play state =
print_endline "Thinking...";
Unix.sleepf (poisson 1.0);
let r = (state.count + 3) mod 4 in
let n =
if r = 0 then
Random.int (min state.count 3) + 1
else
r in
Printf.printf "I'm taking %d." n;
print_newline ();
Count n
let report_victory = function
| 0 -> print_endline "You won."
| 1 -> print_endline "You lost."
let play () =
let rec loop state =
print state;
let cmd =
match state.player with
| 0 -> ai_play state
| 1 -> player_play state in
match cmd with
| Count n ->
let state = { state with count = state.count - n; } in
if state.count = 0 then
report_victory state.player
else
loop { state with player = 1 - state.player; }
| Stop -> () in
let c =
Array.length Sys.argv >= 2 && String.length Sys.argv.(1) = 0 in
loop { cheat = c; count = 16; player = Random.int 2; }
let () =
try
Random.self_init ();
play ()
with
| End_of_file ->
print_endline "bye"
>>
File: 1475558003510.jpg (37KB, 422x500px) Image search: [Google]
1475558003510.jpg
37KB, 422x500px
>>61072063
>all programs would be equivalent to a no-op program
Think about why that makes no sense.
>>
>>61072054
>It doesn't.
It does.
> It's very specific as it actually requires a "network".
It's very general and networks exists almost everywhere.
>>
>>61072060
he could point out what makes a language good or what is required by a language in order to be good
yet we are here, assuming what he means by GPP languages, it seems like leaving people to assume helps his trolling/feeling superior scheme
>>
>>61072069
I really hope you found that on some poor soul's github
>>
File: 1490998298253.jpg (154KB, 1280x720px) Image search: [Google]
1490998298253.jpg
154KB, 1280x720px
>>61072069
>printf
>>
>>61072070
Think about why it does.
Without IO how can you even tell what program A did vs program B?
>>
>>61072084
No. I just code it.
>>
>>61072063
This
>>
>>61072087
>muh theorems
>>
>>61072069
OCaml?

>>61072074
Also, you do not need a network to have sockets or do IPC in general.
>>
>>61072108
>OCaml?
Yes.
>>
>>61072087
Either you don't understand what "equivalent" means or you're simply delusional.
A program which halts immediately and a program which actually performs some computation (which can be easily detected without the language having IO) can't possibly be """equivalent""".
>>
File: emulator.png (3MB, 2824x1224px) Image search: [Google]
emulator.png
3MB, 2824x1224px
Any anon's interested in emulation development?
>>
File: 1497156053743.jpg (163KB, 800x668px) Image search: [Google]
1497156053743.jpg
163KB, 800x668px
>>61072087
Assuming that programs = functions then she can just return things.
>>
>>61072087
>Without IO how can you even tell what program A did vs program B?
Execution time. The change in room temperature.
You wouldn't be able to distinguish them if this was truly impossible.
>>
>>61072127
Always.
I really want to contribute somewhere.
>>
>>61072117
This is an implementation detail, in most languages unless there is IO the implementation is free to get rid of useless shit.
>>
>>61072117
>which can be easily detected without the language having IO
Except it can't.
>>
>>61072127

I'd like to learn the basics of emulation. I was thinking of trying to write my own Game Boy emulator just to become familiar with what emulators actually look like under the hood.
>>
>>61072127
*raises paw*
>>
>>61072137
>The change in room temperature
Heat would be an output obviously.
>>
>>61072146
>This is an implementation detail
It applies to every language. You can tell the difference between two programs which perform no IO, therefore they are not equivalent.
>>61072150
Why does a language need to have IO if you merely want the OS to tell you something about the program?
>>
>>61072176
>You can tell the difference between two programs which perform no IO
False, as I said, the implementation is free to remove things which are not used in IO.
>>
>>61072176
>Why does a language need to have IO if you merely want the OS to tell you something about the program?
How is the OS gonna tell you anything about the program without the program providing output to the OS?

No IO = your program exists beoynd the event horizon of a black hole.
>>
>>61072187
Only assuming you optimize the code.
>>61072200
So a no-op program is simply undetectable to the OS? Are you genuinely this retarded?
>>
>>61071625
fuck this picture reeks of 9fag
>>
>>61072187
>>61072200
Are you the same?

Why are you arguing with that anon? He/She won't understand, too abstract for a that noob.
>>
>>61072229
>So a no-op program is simply undetectable to the OS?
Without IO, yes.
>>
>>61072229
A program with no IO has no practical uses, can you agree with that?

>>61072238
>Are you the same?
No
>>
File: 1496917881508.png (2MB, 2560x1440px) Image search: [Google]
1496917881508.png
2MB, 2560x1440px
>>61070891
Good programmers don't require I/O.
>>
>>61072145
If you are wanting to work on server emulation, World of Warcraft is a good place to start since it has a large emulation community with many resources, check out Trinity Core on GitHub.
>>
@61072240
So it doesn't even use the CPU when executing?
>>61072241
>can you agree with that?
No.
>>
>>61072240
>>61072259
>>
/dpt/ has gotten really bad lately.

We now have people unironically pushing "programming languages" with no IO. You literally cannot get as useless as that in a PL.
This is a new low.
>>
>>61072259
>No.
Can you give an example of a program without IO which has any practical uses then?
>>
>>61072272
Its literally one very attention starved guy.
>>
>>61072272
It's the proof checker troll, ignore him.
>>
>>61072259
>So it doesn't even use the CPU when executing?
It uses the cpu when executing.
>>
>>61072163
Heat is not restricted to output.
>>
>>61072265
>>61072259

>>61072274
I'm pretty sure sin() is used pretty often.
>>61072286
Then it's detectable.
>>
>>61072294
>I'm pretty sure sin() is used pretty often.
This is a function, not a program.
>>
>>61072294
>Then it's detectable.
Not without IO.
>>
>>61072272
I/O is mainly a tool used by below average programmers to justify their incompetency.
>>
>>61072300
It's a function implemented by a program.
@61072303
18+ please.
>>
>>61071625
The potato at the end was great because the boyfriend is obviously a potato.

He's the kind of person to cry after getting mugged but the mugger gives him back his shit because it's so cringeworthy.
>>
Code which produces no side effects and is not necessary can be optimized away.
Since you have no IO, then the entire program has zero side effects, it's just a bunch of useless computations going nowhere.
It can all be optimized to a single nop or ret.
>>
>>61072294
>C influenced languages get an automatic F in my book.
>uses the C function notation

>>61072305
>literally no useful program exists that makes no use of IO

>>61072314
Still not a program.

>>61072303
>>61072314
>>
>>61072294
>I'm pretty sure sin() is used pretty often
Not without getting some form of input and ultimatetly showing the result (be it in a composed form or on it's own)
>>
>>61072314
>18+ please.
Not an argument.
>>
>::
why didn't rust get rid of this crap?
>>
How can I find something really simple to contribute to some open source project?
I can just do school assignments now.
I mostly know java but if the project is simple enough it shouldn't be too hard to just learn enough syntax in another language.
>>
>>61071505
>"""powerful new operative"""
>"""""it isn't designed for hello world programs"""""
TIL that rust evanglists aren't programmers.
>>
>>61072368

I don't love it or hate it.
You can use . for the same job but I find it harms readability a little.
>>
>>61072333
That's not tied to the program which implements sin().
>>
>>61072373
just look on github for a while
>>
>>61072389
>manning
How much did they fuck up his brain in jail ;_;
>>
>>61071799
Why have I/O when you can consider the entire universe as arguments to your program, entirely described by your glorious typesystem.

The only downside is no-one can read it.
>>
>>61071505
I don't know what the fuck they're talking about. I'm not even a Rust programmer and HelloWorld in Rust is simple as fuck. Fucking retards.

fn main() {
println!("Hello world!");
}


The fuck is so complicated about that?
>>
File: 1495568438146.png (410KB, 600x874px) Image search: [Google]
1495568438146.png
410KB, 600x874px
>>61070891
Writing a programming language in which any use of I/O is undefined behavior.
>>
>>61072408
We were talking about uses of sin().
>>
>>61072431
You were claiming there is no useful program without IO. I showed you one.
>>
>>61072426
It should be pretty easy then in that case to make it an optimizing compiler.
Just ignore the source code and output a ret every time.
>>
>>61072414
>linear typing
lmao
>>
In C all IO is implementation defined, so I guess you could make a C implementation without any IO.
>>
>>61072439
>Just ignore the source code and output a ret every time.
I will just insert subtle bugs.
>>
>>61072436
Well, you did not. Sin() is not a program.
>>
>>61072436
sin() is not a program. It is a function.
>>
>>61072436
No you didn't. Just shut the fuck up, you don't understand what those anons explain to you. You lack abstraction. You failed to understand that a program is a sequence of IO. So there is exactly one program which do 0 IO and we call it nop. STFU.
>>
>>61072436
I don't see any program.
>>
>>61072416
The ! really bugs me.
whats the deal with Rust macro rules?
>>
A language where each "impure" function is a different program and the repl/os/whatever uses the output of the previous program as instructions for input/output/other impurities and passes the result to the next?
>>
>Sin() is not a program.
>sin() is not a program.
A program which simply implements sin() is a program with no IO.
>You failed to understand that a program is a sequence of IO.
This is blatantly retarded.
>I don't see any program.
Maybe you should stop being retarded then?
>>
File: this_thread_is_cancer.jpg (182KB, 857x1202px) Image search: [Google]
this_thread_is_cancer.jpg
182KB, 857x1202px
>>61071949
>>
>>61072470
Whom are you talking to?
>>
>>61070891
What are some good languages with fully optional IO?
>>
>>61072466
dunno, feels like the quotation marks should be enough to say it's not a function but nope
>>
>sin(): gets an input and gives an output
>magical mystical sin() program: ??? somehow gets an input (from the compiler?) and gives no output
lol
>>
>>61072470
>A program which simply implements sin() is a program with no IO.
That would be a useless program since you couldn't input an argument to get the sine of and you couldn't see the results either.
>>
C macros are not that bad, the biggest problem is how C lacks lambdas.
A similar thing but in Lisp would be quite good actually.
>>
>>61072484
C
>>
>>61072468
Or just disallow impure functions in the first place.
>>
>>61072470
>A program which simply implements sin() is a program with no IO.
I see.

#include <math.h>

int main() {
double angle; // Intentionally uninitialized, IO is impure.
sin(angle);
// Don't print result, IO is impure.
}


$ gcc main.c -o sin
$ ./sin 1
$ ./sin 90
$ ./sin


Very useful.
>>
>>61072522
They are not impure functions, learn to read.
>>
I have no ideas what to code, help
>>
>>61072501
>since you couldn't input an argument to get the sine
How does it feel being a double-digit?
>you couldn't see the results either
You could do your cancerous IO in your own program. You're still using a non-IO program, which by definition makes it useful.
>>
>>61072537
Code a game anon.
>>
>>61072527
#include <math.h>
#include <stdlib.h>

int
main (int argc, char *argv[])
{
return sin(atoi(argv[1]));
}
>>
>>61072537
Write a deference system that takes an action and a conditional function to evaluate if the action is to be taken.

Write a program that aside from an initialization step runs inside that system.
>>
>>61070948
>chat
IO garbage.
>>
>>61072551
That's IO anon. STFU.
>>
>>61072539
There is no sin() program.
>>
>>61072518
>lambdas
Why is this a problem?
Why not just use functions at file scope?
>>
>>61072567
>That's IO anon
I'm really thinking right now...
>>
>>61072539
>How does it feel being a double-digit?
sin() (assuming we mean the sine function) requires an argument - in other words at least one input.
If you can't even input that, it is by definition a useless sine program.
>>
>>61072567
No
>>
>>61072551
>Returning values from main
That's IO.
>Accepting parameters in main
Also IO.
>>
>There is no sin() program.
18+ please.

>>61072575
>in other words at least one input.
Arguments aren't ""input"".
>>
>>61070891
I'm C beginner (at best), but are you not supposed to cast the result of malloc?
>>
>>61072573
argv[1]
Taking input from the outside world => INPUT

return
Giving information to the outside world => OUTPUT

That program does IO. IO means communication with the poutside world
I for INPUT (argv, sscanf...)
O for OUTPUT (print, return...)
>>
>>61072584
>the result of a function is io
>the input of a function is io
????
>>
>That's IO.
Nope.
>Also IO.
Nope.
>>61072591
You shouldn't really be using malloc. It's cancerous (it performs IO).
>>
>>61072597
Yes, when that function is main.
>>
>>61072539
>You're still using a non-IO program,
How can you use it without providing it with an argument and then getting the result back?
The *only* purpose of a 'sine program' is IO, otherwise it would be useless.
>>
>>61072568
>>61072586

>>61072584
>>61072598

>>61072586
>>61072598
Why do you never quote properly? holy shit
>>
>>61072586
>Arguments aren't ""input"".
Yes, they are.
>>
>>61070891
I want answer on question from the op pic.
Why does gcc lets it go without warnings when I don't cast void pointer to the needed type but msvc goes full banana in this case? What does standard say?
>>
>>61072586
>18+ please.
It literally isn't.
>>
>>61072598
>You shouldn't really be using malloc. It's cancerous (it performs IO).
No it doesn't.
>>
Do you faggots not realize he literally does not care about right or wrong. Only perpetuating the conversation.
Stop replying.
Not even to tell him hes an autist.
just stop.
Id rather let the thread die then read this actual inane bullshit.
>>
>>61072591

In C, void* will automatically be converted to any other pointer type. If you're writing plain C, don't bother with the cast because it complicates things and may hide unexpected errors.
In C++, void* is not implicitly converted to other pointer types. If you want your C to compile as C++ then you want to include the cast.
>>
Ignore (((him))), literally no proper scientist agrees with (((his))) bullshit. (((He))) is either a 16 years old who just learned about FP or a troll. No need to help (((him))) shit this thread with (((his))) bullshit.
>>
>>61072617
In C you don't need to cast, in C++ you do.
>>
>>61072648
Cool.
>>
>>61072627
Indeed, after all
void *malloc(size_t size) {return 0;}
is a valid malloc.
>>
>>61072586
>Arguments aren't ""input"".
Well aren't you """autistic""". By definition an argument is an input, and a return is an output. It's not "IO" in the common use of the term, but if you're going to create a "sin program" then it has to be able to exchange information with its caller -- which is known as IO.
>>
>>61071072
If I take off the bloatware, will it be painful?
>>
>>61072069
My eyes hurt that was so ugly.
>>
>>61072598
> It's cancerous (it performs IO).

It stores global state, and it maps memory. While you could construe a fairly sketchy argument that those constitute "IO", I think it's more likely that you're someone who read "Learn you a Haskell" two hours ago and is now convinced that the word "IO" is evil.
>>
>>61072680
>Shitlell
I don't use IO-ridden languages.
>>
>>61072551
a) That's IO.
b) Now, show me how to return a string (or other data) outside of the 1-byte space of return values (actually it's 7-bits under POSIX from memory) """without doing IO""".
>>
>>61072680
He supports the proof checker meme but if you ask him anything about them he will give you a "I have no idea what you could possibly mean!" meme.

>>61072706
>a) That's IO.
No

>b) Now, show me how to return a string (or other data) outside of the 1-byte space of return values (actually it's 7-bits under POSIX from memory) """without doing IO""".
Idk man, you probably can't.
>>
>>61072696
Ah yes, because you engage in imaginary programming where none of your programs are usable because they don't accept input or provide output.

Well done Anon, you deserve a medal.
>>
>proof checker
I don't use IO-ridden garbage.
>because you engage in imaginary programming
It's quite real though. I just don't use IO.
>>
>>61072551
>return sin(..);
>return type of main is int
>casting double to int
>literally any value you enter, you will only ever get back either a 0 or a 1.

Wow, so useful.
>>
>>61072711
>>b) Now, show me how to return a string (or other data) outside of the 1-byte space of return values (actually it's 7-bits under POSIX from memory) """without doing IO""".
>Idk man, you probably can't.

> "General purpose programming" only includes programs that return one of 127 possible values.
Glad we cleared that one up.
>>
>>61072726
Yeah, does not seem too useful under POSIX. It would be more useful under a system where main could return a pointer or something.

>>61072728
>> "General purpose programming" only includes programs that return one of 127 possible values.
Wut? I never claimed that you retard.
>>
>>61072737
> Yeah, does not seem too useful under POSIX. It would be more useful under a system where main could return a pointer or something.

And how would returning a pointer to mutable memory (in a different program's address space) not be considered IO? That's basically what a pipe is...
>>
>>61072747
The register where the return value of main is stored is a mutable register.
>>
>>61072470
Mofo, memory access is also I/O.
Gtfo
>>
>>61072758
>mutable register.
Impure garbage.
>>
>>61072725
What's your definition of a useful program, and what's your definition of IO ?
>>
>>61072825
You are 10x times dumber than him for falling for his troll. Ignore him.
>>
>>61072409
But is there anything I could keep an eye out for to find something that a beginner could do?
The vast majority is for people who can already program real stuff.
I only know basic stuff and real stuff seems to be pretty different from school assignments or text book exercises.
>>
I'm in need of a project /dpt/, wat do?
>>
>>61072921
Make a programming language that doesn't use IO.
>>
>>61072934
NOP
>>
>>61072921
Find an existing project you like and contribute.
>>
>>61072921
Learn sepples
that's a project in itself
>>
>>61072979
This. There's an endless sea of projects that are in need of solid contributors.
>>
Why isn't C classified as object-oriented? You can do all the things you could do with an object-oriented language with structs, function pointers, etc.
>>
>>61073034
because modern POO = classes
>>
>>61073034
It doesn't integrate those features into its language. Most decently powerful programming languages let you emulate other styles if not outright supporting them.
>>
>>61073034
Try implementing message passing. You don't have lambdas so it will be crap.
>>
>>61073034
It still misses out on functionality like inheritance.
>>
>>61073061
... what does that have to do with OO? First-class functions and lambdas aren't part of OO.
>>
>>61073076
Sure they are. Message passing is what OOP is about.
>>
>>61073066

struct Base
{
int base_var;
};

struct Derived
{
struct Base inherited_base;
char derived_var;
};

int main(int argc, char **argv)
{
struct Derived d;
((Base*) &d)->base_var;
};
>>
>>61073061
You can directly invoke a function pointer?
>>
>>61073103
You can but it lacks tons of features related to functions and lambdas which this does not solve.
>>
>>61073079
I was responding to:
>You don't have lambdas so it will be crap.
Lambdas aren't necessary for an OOP language.

Also by your definition any turing-complete language implements OO, because "message passing" is a concept implementable by any turing machine.
>>
>>61073113

Objects and lambdas are equivalent.
>>
>>61073099
Eh, that's more like composition.
>>
>>61073113
>Lambdas aren't necessary for an OOP language.
Lambdas are necessary for a Message Passing system.

>Also by your definition any turing-complete language implements OO, because "message passing" is a concept implementable by any turing machine.
Also by your definition any turing-complete language implements OO, because "OO" is a concept implementable by any turing machine.
>>
>>61073119
What does "inheritance" mean in the context of lambdas? [No, composition is not the correct answer.]
>>
>>61073130
Good point. Objects are superior to lambdas then.
>>
>>61073124
> Also by your definition any turing-complete language implements OO, because "OO" is a concept implementable by any turing machine.

Right, so we agree that the term "OO" is bullshit that doesn't actually mean anything. Cool.
>>
literally why did bjarne even add classes.
>>
>>61073121
Fixed
struct Base
{
int base_var;
};

struct Derived
{
struct Base inherited_base;
char derived_var;
};

struct Derived2
{
struct Base inherited_base;
int derived_var;
};

void
penis (struct Base *b)
{
/* something with b->base_var */
}

int
main (void)
{
struct Derived d = {0};
struct Derived2 d2 = {0};
penis(&d);
penis(&d2);
}
>>
>>61073136
Sure it does, it's a specific way to program by using message passing. Just because you can achieve the same results by other methods does not mean that it means nothing.
>>
>>61073144
Does it also do virtual methods?
>>
File: 1479208724334.jpg (266KB, 750x738px) Image search: [Google]
1479208724334.jpg
266KB, 750x738px
>>61073034
no. you are probably doing the usual confusion between ADTs and objects

>>61073099
no oop.
>>
>>61073180
Sure
>>
>>61073183
Cute bear
>>
>>61070891
Someone should make a popular Rust project that is offensive as possible.
>>
>>61073223
You only have to embed the word 'bad' in it and you're good to go.
https://github.com/rust-lang/rust/issues/41646
>>
>>61073239
>styling your code as you want is a bad thing
Thanks rust
>>
I wish D had pattern matching like Rust :^(
>>
>>61073250
*I wish D was any good
>>
>>61073256
Than what language?
>>
>>61073273
what?
>>
>>61073273
Like*
>>
>>61073279
what do you mean "like what language"?
>>
>>61073273
sepples
>>
>>61073302
Ctrashtrash is worse than Java in every aspect. C++ programmers are indians.
>>
File: 1466200944492.jpg (110KB, 884x903px) Image search: [Google]
1466200944492.jpg
110KB, 884x903px
>>61073302
>sepples
>any good
>>
>>61073306
Wrong.
https://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=gpp&lang2=java
>>
>>61073306
Both are shit but saying that C++ is worse than Java is incorrect.
>>
>>61073329
What is that benchmark supposed to imply, pajeet?
>>
How can i run trigger 15 minutes after data insert in Mysql.
example:
I insert some data in database and after 15 minutes i want some field to be updated
>>
>>61073329
Irrelevant
>>
>>61073331
I'd actually smear feces all over my body rather than touching *++ ever. EVER.
>>
>>61073180

#include <stdio.h>

void base_say_hello()
{
printf("Hello from Base\n");
}
void derived_say_hello()
{
printf("Hello from Derived\n");
}
void derived2_say_hello()
{
printf("Hello from Derived2\n");
}
struct Base_vtable
{
void (*say_hello)();
};
const struct Base_vtable base_base_vtable = {base_say_hello};
const struct Base_vtable derived_base_vtable = {derived_say_hello};
const struct Base_vtable derived2_base_vtable = {derived2_say_hello};

struct Base
{
const struct Base_vtable *const vptr;
int base_var;
};

struct Derived // final
{
struct Base inherited_base;
char derived_var;
};

struct Derived2 // final
{
struct Base inherited_base;
int derived_var;
};

int main (int argc, char **argv)
{
struct Base b = {&base_base_vtable};
struct Derived d = {{&derived_base_vtable}};
struct Derived2 d2 = {{&derived2_base_vtable}};
struct Base *bptr;
bptr = &b;
bptr->vptr->say_hello();
bptr = (struct Base*) &d;
bptr->vptr->say_hello();
bptr = (struct Base*) &d2;
bptr->vptr->say_hello();
}

so clean, so pure
>>
>>61073348
Sounds gay
>>
>>61073355
I'd rather become faggot and kill myself rather than touching *++ ever. EVER.
>>
>>61073329
Boycott this bullshit, fuck off nigger I wish that you get cancer. You mother never loved you, she made you with an indian rapist and she sold your kidney so she could buy drugs. Everyone you love will die tomorrow and all this because you linked that bullshit link.
>>
>>61073354
It works, so you can do OOP in C.
>>
>>61073362
Would make sense if you said that about Java.
>>
>>61073370
That's a little bit of overreaction
>>
File: 1487608084850.jpg (53KB, 312x312px) Image search: [Google]
1487608084850.jpg
53KB, 312x312px
>>61073144
>
int
main(void)
>>
>>61073372
No, you can not. This is not message passing.
>>
>>61073393
What do you mean by message passing?
>>
>>61073383
At least with Java I'd think twice. But when it comes to *++ I'd jump off a cliff without any hesitation rather than touching it.
There is nothing in the world I hate more than *++. I'm serious.

Why does *++ exist? B*arne is a God's mistake.
>>
>>61073389
You forgot the space anon.
And yes, this is the best coding style, both GNU and BSDs use it.
>>
>>61070891
C++ is amazing. Completely demolishes Java, and exterminated C.
>>
>>61073400
I would say the exact reverse. C++ is shit but it's shit that I could live with. Java is a cancer that eats your brain from the inside.
>>
>>61073393
If you say it long enough, someone will make it in C>
>>
C++ is for substandard indian programmers that think they are too smart for Java.
>>
>>61073395
The same that Alan kay, SICP and the Erlang creators mean by it.
>>
>>61073372
that's not oop.
>>
There's no reason why C should not have namespaces. Also there's no reason why namespaces would require name mangling.
>>
*++ should never have existed. It enables bad programmers to come to system programming.
>>
>>61073415
People who complain about programming languages are usually bad programmers.
>>
>>61073408
>>61073432
>>
>>61073419
who care? also oop was first introduced by Simula and was class based. also, java, c++ and co can be viewed as static messages passing.
>>
>>61073420
It's literally exactly what C++ does under the hood.
>>61073410
This. Java gives you brain damage, and makes it difficult to learn a real language like C.
>>
C++ is for people that do not understand C. Plain and simple. I look down upon a C++ programmer the same way I look down upon a Javascript programmer.
>>
>>61073435
That was not a complaint, but rather, praise. Irrelevant.
>>
>>61073354
class Base:
def __init__(self):
self.classtype = "Base"
def say_hello(self):
print "Hello from %s!" % self.classtype

class Derived(Base):
def __init__(self):
self.classtype = "Derived"

class Derived2(Base):
def __init__(self):
self.classtype = "Derived2"

b = Base()
d = Derived()
d2 = Derived2()
for o in (b, d, d2):
o.say_hello()


Once again proof that Python is superior.
>>
>>61073439
>under the hood.
there is a big difference between a programming language and its implementation. under the hood, c++ is translated into assembly; assembly is object oriented!!!
>>
>>61073437
False, OOP was first introduced by SmallTalk. As Alan Kay, the creator of OOP said, "I invented the term object-oriented, and I can tell you that C++ wasn't what I had in mind".
>>
C++ is for indian brainlets
>>
>>61073458
you are in the wrong, even alan kay admits simula did it first and was his main influence with lisp.

https://en.wikipedia.org/wiki/Simula
1965

https://en.wikipedia.org/wiki/Smalltalk
1972
)
>>
>>61073447
C++ is for advanced C programmers. When people who don't know C write C++, the result is garbage.
>>
>>61073458
argument from authority
opinion discarded
>>
>>61073500
When people write C++, the result is garbage.

FTFY
>>
>>61073498
Except that the Simula did not use the term OOP. Alan Kay was the one who defined the term.

>even alan kay admits simula did it first
No he did not admit such a thing.
>>
>>61073500
C++ is for brainlets that feel restrictive with C
>>
>>61073511
>__init__(self)
Yes, that's called a "constructor" and it's one of the fundamental methods of any object oriented language.
>there is no say_hello for Base
Yes there is, can you read? Did you even run the script?
>>
>>61073500
C++ is a garbage itself
>>
>>61073539
Java a poo
>>
>>61073452
>__init__
Lmao
>>
rate
"Choose an option" println
"1. Rock" println
"2. Paper" println
"3. Scissors" println

rand 3 %
getln 1 -
- 3 %
dup 0 = "You have tied!" "" ifelse swap
dup 1 = "You have lost!" "" ifelse swap
2 = "You have won!" "" ifelse swap
print print println

>>
>>61073549
C++ is the liquid feces that comes out of your ass after eating spicy food that expired a month ago.
>>
New thread:
>>61073559
>>61073559
>>61073559
>>
>>61073554
trash
>>
>>61073552
What? The builtin class functions have leading and trailing __ to seperate them from those you wrote yourself.
Now write a program in C that does the same as the following Python script, in less than 50 lines.

import random

class Human:
def __init__(self):
self.names = ()
self.pronoun = ""
self.lastwords = ""
self.name = ""
print "A human is born."
def __str__(self):
return "Name: %s\nPronoun: %s\nLast words: %s" % ( self.name,
self.pronoun,
self.lastwords)
def __del__(self):
print "A human dies."
print "%s says %s last words: '%s'" % ( self.name,
self.pronoun,
self.lastwords)

class Man(Human):
def __init__(self):
Human.__init__(self)
self.names = ("John", "Paul", "George", "Ringo")
self.pronoun = "his"
self.lastwords = "I like boobies."
self.name = self.names[random.randint(0, len(self.names)-1)]
print self

class Woman(Human):
def __init__(self):
Human.__init__(self)
self.names = ("Scary", "Sporty", "Ginger", "Baby", "Posh")
self.pronoun = "her"
self.lastwords = "I like dicks."
self.name = self.names[random.randint(0, len(self.names)-1)]
print self

someHuman = Man()
anotherHuman = Man()
aWoman = Woman()
aFaggot = Human()
aFaggot.name = "OP"
aFaggot.pronoun = "xer"
aFaggot.lastwords = "I am a huge faggot thank you for raping my face."
>>
>>61071482
>Some care must be taken if both signals and threads are used in the same program. The fundamental thing to remember in using signals and threads simultaneously is: always perform signal() operations in the main thread of execution. Any thread can perform an alarm(), getsignal(), pause(), setitimer() or getitimer(); only the main thread can set a new signal handler, and the main thread will be the only one to receive signals (this is enforced by the Python signal module, even if the underlying thread implementation supports sending signals to individual threads). This means that signals can’t be used as a means of inter-thread communication. Use locks instead.

also, int_handler should take two args: signum, frame
Thread posts: 315
Thread images: 26


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