[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: 329
Thread images: 20

File: anon joins the programming club.jpg (372KB, 1280x720px) Image search: [Google]
anon joins the programming club.jpg
372KB, 1280x720px
old thread: >>60781679

What are you working on, /g/?
>>
>he doesn't have a mechanical keyboard
>he hasn't even gone to best buy to try them out
>>
>>60788705
I don't know why you'd do this, but here's an example.
(defmacro caref (2darray cxn)
`(aref ,2darray
(realpart ,cxn)
(imagpart ,cxn)))

(caref (make-array '(2 2)
:initial-contents '((1 2) (3 4)))
#c(1 1))
; returns 4
>>
I wrote this program that crashes your computer and doesn't get caught by the linux OOM killer.
#include <stdio.h>
#include <stdlib.h>
int main(void )
{
size_t sz = 1;
size_t total = 0;
while (1)
{
malloc(sz++);
printf("%zu += %zu\n", (total += sz), sz);
}
return 0;
}
>>
>>60788873
so this is the power of c ...
>>
File: dlang_chan.jpg (70KB, 349x368px) Image search: [Google]
dlang_chan.jpg
70KB, 349x368px
Threadly reminder that dlang-chan has RAII; she's quite fast in execution and compilation; and she's super duper cute! Say something nice about her, /dpt/!
Also, Andrei's a cool guy.

>Tour
http://tour.dlang.org/
>Books
https://wiki.dlang.org/Books
>GC
https://dlang.org/blog/2017/04/28/automem-hands-free-raii-for-d/
https://wiki.dlang.org/Libraries_and_Frameworks#Alternative_standard_libraries_.2F_runtimes
>>
>>60788873
Well yeah. Try running it as a normal user now.
>>
>>60788882
>slut
yeah, great language you got there
>>
>>60788905
I did run it as a normal user.
>>
>>60788925
I don't believe you. Give me a root shell on your system so I can verify it.
>>
>>60788873
If you want to crash your computer there are easier ways
#!/bin/bash
cat /dev/urandom > /dev/fb0 &
cat /dev/urandom > /dev/mem &
cat /dev/port
>>
Trying to go in-depth with Python and the ecosystem after being deep in JS/Node for awhile. Am I missing something, or does Node actually get package management really, really right? Having package installation and dependencies handled by one tool (npm/package.json) and having all of your dependencies in a project-specific folder (node_modules) seems so easy and straightforward. Compare that to having a requirements.txt that may or may not specify versions, a package manager that is only kind of aware of this files existence, and a per-python-installation site_packages that requires you to set up all that virtual environment non-sense. I get that Node gets a lot of shit (deservedly so), but am I crazy to think that npm/package.json isn't so bad?
>>
File: interesting.png (19KB, 1024x768px) Image search: [Google]
interesting.png
19KB, 1024x768px
>>60788873
>>
>>60788856
>he categorically accuses everyone with the misfortune to read his post of not owning a mechanical keyboard
>he hasn't even met all these people
>>
>>60788856
I bought one in cherry mx red and I hardly ever use it because I don't have a proper desktop and I do all my programming on my thinkpad.

Really, it's my fault for falling for stupid memes, I could have bought a bigger SSD or maybe some girly clothes instead.
>>
>>60788856
The Surface Pro I ordered has a mechanical keyboard. Checkmate.
>>
i am building a webapp with django to serve as a leaderboard system for my shitty video game i'm developing in C + openGL

at this point i'm hardly learning anything and merely following tutorials to get done what i need
>>
>>60788994
is the malloc call being optimized out?
>>
>>60789034
>at this point i'm hardly learning anything and merely following tutorials to get done what i need
that's fine. web dev really isn't worthwhile. just do what needs to be done and prioritize your game dev
>>
File: nope.png (14KB, 1024x768px) Image search: [Google]
nope.png
14KB, 1024x768px
>>60789041
No, it is not.
>>
>>60788955
I know I shouldnt but I really want to run this.
>>
>>60789131
>write random junk to main memory
It's not catastrophic for you most likely.
>>
Is there an x86_64 instruction to move a byte to a specific address?
mov BYTE[0x12345678], 0xc3

can be successfully assembled but
mov BYTE[0x1234567812345678], 0xc3
can't.
>>
>>60789173
http://x86.renejeschke.de/html/file_module_x86_id_201.html
>>
>>60788852
What do you think of my solution.
(defvar coins
'((hundred . 1e4)
(twenty . 2e3)
(ten . 1e3)
(five . 5e2)
(dollar . 1e2)
(quarter . 25)
(dime . 10)
(nickel . 5)
(penny . 1)))

(defun make-change (money)
(loop :as (coin . worth) = (rassoc-if (curry #'> money) coins)
:as n = (floor money worth) :collecting (cons coin n)
:do (decf money (* worth n)) :until (zerop money)))

out
* (make-change 1488)

((ten . 1) (dollar . 4) (quarter . 3) (dime . 1) (penny . 3))
>>
>>60789041
I traced the process and it's exactly what I expected: malloc is failing to allocate memory due to my ulimits, but your program doesn't bother to check the return value. All it does after allocing 768MB is incrementing sz, adding it to total, and printing their values.
>>
>>60789212
nobody writes software expecting null pointers after a malloc call, does openbsd really let you get away with silent out of memory errors?

what a pile of shit
>>
>>60789235
Sorry, if you don't check that malloc(n) != NULL then you are an idiot and you shouldn't be allowed to write software.
>>
>>60789235
>nobody writes software expecting null pointers after a malloc call.
That's one of the most basic things you do if you want robust software. If you're gonna have this attitude just use Java, ocaml or some shit.
>>
>>60789248
>>60789253
What is even the point?
Can you even recover from an out of memory error without crashing?
>>
>>60789235
>nobody writes software expecting null pointers after a malloc call
Some people actually try to write robust software, you know.
If you're writing something, and there really is nothing sane you can do with an OOM error, it's usually a good idea to write a function which wraps malloc and does the check for you.
void *xalloc(size_t n)
{
void *ptr = malloc(n);
if (!ptr) {
fprintf(stderr, "Allocation of size %zu failed\n", n);
exit(1);
}

return ptr;
}


>>60789258
>Can you even recover from an out of memory error without crashing?
Some programs can just try fall back to their main loop and try again later.
>>
>>60789181
Thanks. Does that mean that there's no way to directly put an immediate at a specific 64bits address?
>>
>>60789258
Yes.
You simply don't allocate more memory and look for memory you can reuse. If you absolutely need more memory that is. If not you can select algorithms that work in place or simply thrash non-vital systems.

But it's usually the case that if you want really robust software you allocate all the memory you can upfront. And you do your memory management in full control.

Look into how space shuttle code is written. It's C.
>>
>>60789272
in the real world it's almost never necessary to check it
>>
>>60789258
Yeah a simple example; until malloc(n) != NULL: print a message, send yourself SIGSTOP. Wait for the user to add some swap space or raise their ulimits and send SIGCONT.
>>
>>60789297
how often does this actually happen in real software?
>>
>>60789288
That's a fucking shitty attitude to have when it comes to systems programming.
It's people like you that cause fragile software.
>>
>>60789305
Depends on the goal.
If you're perfectly fine with crashes all the time then sure, don't check for any errors. Just have everyone run your software through a bash script that's an infinite loop with your program doing blocking execution in the loop.
>>
>>60789318
PS
I hear the webdev crowd actually advocates similar strategies. They let their nodejs servers crash on error and just restart themselves.
>>
>>60789309
>>60789318
jesus christ the autism
>>60789323
kill yourself
>>
reminder that it's summer and you have programming101 newfags sperging off with their hot dunning-kruger opinions
>>
>>60789305
This would not be a common approach. This is the sort of behaviour that would be nice to see in a potentially long-running, non-interactive process. A linker, perhaps. The usual approach is to simply err(), as another poster mentioned above.
>>
>>60789331
Exceptionally useless post anon.
>>60789342
Its eternal simmer anon. We have newbies all the time.
>>
https://gustedt.wordpress.com/2011/11/05/chasing-a-phantom-checking-the-return-of-malloc/
>>
>>60789360
I don't know what to say. That author sucks so much at C.
>>
File: 1288234988621.jpg (62KB, 734x510px) Image search: [Google]
1288234988621.jpg
62KB, 734x510px
>>60789438
>>
>>60789438
if checking malloc for errors every single time (and checking everything else for errors because 99.99% of other things would be more important to check than malloc) is a valid concern to you then you're clearly working on less common applications with very specific requirement. you brought up the space shuttle for crying out loud.
>>
>>60789502
Filthy code monkey.
>>
>>60789511
>>
>>60789360
Don't understand me wrong, but he wrote an article to save one production line of code by doing the needful.
>>
>>60789511
i hope you don't put malloc everywhere in your code. especially since you're supposedly doing super reliable long running applications you should be using a custom allocation scheme to avoid memory fragmentation.
>>
File: 1492377858999.jpg (36KB, 599x337px) Image search: [Google]
1492377858999.jpg
36KB, 599x337px
>>60789518
>no smug loli tier
>>
>>60788873
I can do that without even trying in Haskell.
>>
>>60789701
1gb/s - 1gb/s = 0
>>
>>60789701
>no side effects
>crashes your computer
what did she mean by this?
>>
>>60789780
I do it by accident all the time. It happened most recently when I was trying to create an Arbitrary instance for a recursive data type.
>>
>>60789851
ahahahahahaha haskell is such useless trash
>>
hi guys, rooms all set up. Got all the furniture and put it in. Got some ethernet cables. Have plenty of desk space. Have my bong.

Oh btw, snack and drink on me.

I'm going to wait on plugging in the tower for now, yet again, because I don't want to be disappointed by something right now. I will be at this for a few hours, I hope.
>>
File: 1496112118319.jpg (13KB, 228x238px) Image search: [Google]
1496112118319.jpg
13KB, 228x238px
>>60789851
>recursive data type
>>
File: lens library.png (836KB, 790x1200px) Image search: [Google]
lens library.png
836KB, 790x1200px
Has programming gone too far?
>>
File: coolstorybro1.gif (346KB, 477x396px) Image search: [Google]
coolstorybro1.gif
346KB, 477x396px
>>60789873
>>
>>60789878
Yeah, I know, I should've defined it in terms of Fix instead of using explicit recursion.
>>
>>60789868
Actually, we have IO now.
>>
>>60789907
Only a complete shitlang would have IO, so obviously.
>>
>>60789701
I don't know if you're memeing or not, but I practically killed my linuxbox recently by using Emacs + Idris. I have 8GB RAM and on some particularly hairy code I had my emacs eating 3 or it and Idris, running inside emacs, another 5. As a result, I had no free memory left for my system, which switched to swap, meaning it became unbearable slow. I spent next 5 minutes starting a terminal and killing the Idris process. I don't know by which I'm more annoyed, by the leaks in Idris or by the inability of Linux to deal with it.
>>
>>60789518
>Posting the reddit version
>>
>>60789947
>memeing
Fuck off, retard.
>>>/v/
>>
>>60789918
It's optional. Nobody's forcing you to use it. Just be careful of accursedUnutterablePerformIO.
>>
>>60789960
So main is optional? I can compile and run an executable without it?
>>
>>60789947
No memeing. This happens to me all the time. Currently running this and hopefully it works: https://github.com/tobixen/thrash-protect
>>
>>60788834
Just finished v0.1 of a nice little graph database API thing and came to /g/ to brag about how cozy I am now.
>>
>>60789974
>memeing
Use >>>/v/
>>
>>60789963
>So main is optional?
Yes

>I can compile and run an executable without it?
No
>>
>>60789963
an executable is an io
>>
>>60789984
I prefer >>>/vg/ desu.
>>
>>60789986
>No
In other words it's not optional? I see, so the language is shit indeed.
>>60789990
Nope.
>>
>>60789998
Did you not read the other half? Main is optional.
>>
>>60789992
I don't want your kind nearby. Piss off.
>>>/v/
>>
>>60789998
It is optional.
You can compile a library.
>>
>>60790004
Not being able to run a program without it is hardly "optional" by any sane person's judgement.
>>60790009
I don't care about what you ""coders"" call "libraries". I use executables.
>>
>>60789984
>memeing
Use >>>/v/
>>
>>60789974
Interesting, I'll try it too.
>>
>>60789963
did you know that main is optional in C too!?
>>
>>60790016
An executable performs IO.
>>
>>60790033
I couldn't care less about C. Don't mention that garbage ever again.
>>60790040
This is blatantly wrong and retarded.
>>
>>60790016
Now you're shifting the goalposts. You can write pure function and evaluate them in the repl without any IO. In fact, that's what Haskell programmers did before they got IO.

Why do you hate IO so much anyway? Did `launchMissiles` kill your parents?
>>
>>60790048
He has nothing better to do.
Every day he logs onto the basement computer and posts the same fucking thing.
>>
>>60788873

>exited with non-zero status

Try harder next time.
>>
>>60790048
>You can write pure function and evaluate them in the repl without any IO
I'm pretty sure the REPL executes everything in the IO monad. That would mean every single program I write will instantly get defiled.
>Why do you hate IO so much anyway?
It's what shit programmers use as a crutch. I don't want to be associated with them.
Also I despise the way every single platform handles it.
>>
Is this Pythonic

def fibonacci(n):
l = n
ln = [0, 1]
while l:
ln.append(sum(ln[-2:]))
l -= 1
return ln[:n]
>>
>>60790156
>pythonic
>>
>>60789888
thanks dude. I just finished taking a few rips and I'm now I'm contemplating whether I should work on some guis on eclipse or maybe make some part of my game on unity.

Of course I may also turn on the tv and play my xbox one or ps4. I'm not sure yet. I was playing street fighter 3 3rd strike from my ps4 yesterday through the playstation now system. It lets me play some of the popular ps3 games.

I bought some xbox money and ps money earlier today. I'm hoping to buy Hyper Light Drifter for ps and maybe subscribe to an mmo or something on the xbox. If I want anything from these consoles, it's satisfaction.

Also, ran into this most beautiful woman at target again today and she was especially helpful and not just pretty. Turns out I see her there because she works there. I always just figured it was lucky timing. But to think that worked there the whole time...I really should've made some small talk.
>>
>>60790156
while loops, short variable names, and increment/decrement operations aren't pythonic
>>
>>60789879
What the fuck is even the use of this.
I'd seriously like to see a moderate example with explanations.
>>
>>60790221
Functional references

https://hackage.haskell.org/package/lens
scroll down
>>
File: 1478365617617.jpg (51KB, 600x600px) Image search: [Google]
1478365617617.jpg
51KB, 600x600px
>>60790203
>loops
How does it feel to be a barely sentient being?
>>
So, is functional programming in Haskell far superior to Scheme's?
>>
>>60790278
Yes
>>
>>60790278
What is ``Functional programming"?
>>
>>60790282
please stop ruining the frob meme when you probably weren't even there
>>
https://github.com/ekmett
>you will never be this guy
>>
>>60790278
Scheme isn't even FP language tho. And don't forget FP in Idris is far superior to FP in Haskell.
>>
>>60790295
Good, he's a liberal cuck
>thinking programming skills are the only desirable feature
>>
>>60790281
What is ``Functional programming" though?
>>60790294
>meme
Kill yourself, you fucking shit smear.
>>60790298
What is a ``FP language" though? How can you even claim anything about it if you can't answer this question?
>>
>>60790295
>you will never use cripplelang
Good.
>>
>>60790325
But, it seems to me like abstractions are too high a level in Haskell.
Seriously, if you can understand lens, and all the high level shit, I'm pretty sure you'd feel like a God with Haskell.
>>
What torrent clients are easy to use programmatically? I'm planning on hosting a web site on my VPN that would let me submit magnet links that get automatically torrented to a specified folder. So now I just need a torrent client with a good api. Any ideas?
>>
>>60790338
>Seriously, if you can understand lens, and all the high level shit
It's not a matter of understanding something. I just have higher standards.
I will never use a language without dependent types (except C(ancer)). That simply isn't happening.
>>
>>60790346

rtorrnt does that IIRC
>>
>>60790353
Tell me why dependent types are a must.
What can you do with it?
>>
>>60790156
This dumb, why do you need to store all the fibonacci numbers in a list when you aren't even using them all?
>>
>>60790346
Why don't just use web interface many clients already have?
>>
>>60790368
>Tell me why dependent types are a must.
A language which can't do computation at the type level is a joke. I don't use joke languages.
>>
>>60790380

What useful computations can you do over types? Help a brainlet understand.
>>
>>60790380
This is very vague, please expand and give examples so that you may win me over.
>>
>>60790368
Well, you can have properties of your code formally proven.
>>
>>60790376
Cause that's babby mode. Besides I haven't had very much luck with Transmission's web interface. It's always really slow/buggy so I'd rather home brew a solution. That way when it's slow and buggy I know who to blame.

>>60790359
I'll look into it, thanks
>>
ITT: Comfy Languages.
>Lisp
>>
>>60790398

>(((comfy)))
>>
>>60790380
I think I should have said "non-trivial computation". As in the same kind of computation you would do on the term level.

>>60790384
Anything you can do on the term level.
Here is a simple example
a : (b : Bool) -> if b then Nat else (String, Int)
a True = 3
a False = ("t", 6)


>>60790387
>so that you may win me over
Why would I ever want to do that? You can stay with Haskell. I don't need your kind shitting up better languages.
>>
>>60790404
Jews are compfy, they are really smart too!
>>
>>60790387
You can implement the Hangman game with just 7 types and 11 functions: https://github.com/edwinb/TypeDD-Samples/blob/master/Chapter14/Hangman.idr . It's gonna be a very reliable Hangman game.
>>
>>60790429
>7 types
6 types. One of those is basically a bool.
>>
>>60790417

So the return type can differ depending on the input value?
>>
>>60790437
And every enum-like type is basically an integer. It's still a type tho.
>>
>>60790441
Yes. Here is another example.
counter : Int -> Type
counter 0 = Nat
counter n = counter (n - 1) -> Nat

counter 5 => ((((Nat -> Nat) -> Nat) -> Nat) -> Nat) -> Nat : Type
>>
>>60790373

only if n < 2
>>
>>60790450
It's isomorphic to bool. Which means it's equal to bool in any good type system.
>>
>>60790465

That seems pretty useful. What makes it more powerful than emulating it with unions?
>>
>>60790490
>What makes it more powerful than emulating it with unions?
I don't think you can emulate an array with the length being part of the type.
>>
>>60790490
Types can depend on terms

>>60790417
Why isn't Idris' standard if-then-else dependent?
>>
File: tdd.jpg (36KB, 398x499px) Image search: [Google]
tdd.jpg
36KB, 398x499px
>practical use of dependent types
It's funny tho. I'm finishing the Idris book, I had no problems with the exercises, I believe I have a pretty good understanding of the language, and I like it. So I was thinking of doing some small project to improve my Idris skills, some way to apply formal proofs, dependent-typed state machines, all that stuff, and I couldn't think of one. Whatever stuff I'm interested in doing (a simple CPU emulator, an interpreter, network stuff) have no obvious use for DT, formal proofs and formalized state machines, and I'd be better off with more traditional languages like Rust.
>>
I started today learning
>Go
What should i expect?
>>
>>60790573
Write a O(n*ln(n)) proved sort algorithm.
>>
>>60790465
This is useless.
>>
>>60788865
Any reason why you wrote a macro? A function would do perfectly fine. Interesting nonetheless.
>>
File: 1496511626714.png (69KB, 400x400px) Image search: [Google]
1496511626714.png
69KB, 400x400px
>>60790573
>I had no problems with the exercises
It's a simpleton's language, of course that would be the case.
>>
File: go_keyboard.png (427KB, 770x478px) Image search: [Google]
go_keyboard.png
427KB, 770x478px
>>60790576
That's probably the worst choice you could've made, and I'm not even meming: https://github.com/ksimka/go-is-not-good
>>
>>60790586
>computation is useless
Wrong thread.
>>
>>60790594
>Source: Github
AAAAAAAAAAAAAAAAAJJJJJJJ
>>
>>60790585
I'm not a researcher tho, I want to write something actually useful and use DT to improve the quality of core, reliability and all that stuff. I mean, Idris is supposed to be a general-purpose language, not an academic circle-jerk like Coq and Agda.
>>
>>60790617
>I'm not a researcher tho
So? Does that somehow stop you from using your brain?
>>
>>60790609
It's just a collection of links, m8, no need to be autistic.
>>
>>60790599
You're still an autist that can't explain why your dependent types are good.
Have fun with no IO.
>>
>>60790156

kill yourself for using short variable names

kill yourself for not writing a generator
>>
>>60790643
>Have fun with no IO.
No! You're going to summon the no I/O programming language autist! Turn back before it's too late!!!
>>
>>60790156
no that's fucking disgusting. try while l > 0 for starters and don't use a fucking l as a variable name
>>
>>60790643
Computation is good and useful. Therefore computation at the type level is also good and useful.
If you disagree, programming threads are clearly not for you.
>Have fun with no IO.
Sadly my language allows IO.
>>
>>60790627
>>>I want to write something actually useful
I mean, maths is fun, but my point in learning Idris was to explore possibilities for the real-world uses of DT. If I wanted to be an useless autist I would've read Software Foundations and learned Coq instead.
>>
>>60790660
Ok, please explain why dependent types are good.
What are dependent types.
>>
>>60790684
Where did I ever claim this, you faggot?
>>
>>60790689
>shills for dependent types
>doesn't claim they're good
snake oil, thanks for letting me know
>>
>>60790682
What is "real-world use" even supposed to mean? How can you use something outside of the real world?
>>
>>60790701

lots of shit exists purely for jerking yourself off about how hip it is
>>
>>60790700
Do you enjoy just making shit up?
>>
>>60790710
How is that not a "real-world use"?
>>
>>60790726
Autism.
Real world means you can use it to do useful things that companies would pay for.
>>
>>60790701
>Not real-world use
Map painting proofs, HoTT, any formalization of pure math for math's sake.
>Real-world use
Network servers, databases, OSes, compilers, emulators, games.
>>
>>60790746
>Real world means you can use it to do useful things that companies would pay for.
Nope. This is a thread about programming, job-related posts belong on some other board.
>>
>>60790759
You just listed some things which are all non-fictional, you didn't answer "what is a real-world use?"
And is this the full list? If not, it has literally no value.
>any formalization of pure math for math's sake
For what other reason would someone formalize "pure" math?
>>
>>60790790
>You just listed some things which are all non-fictional
So you're an autist who insists on the literal meanings of words?
>For what other reason would someone formalize "pure" math?
To prove a practical application if that math is correct, for example in cryptography.
>>
>>60790831
>So you're an autist who insists on the literal meanings of words?
I'm asking for a definition of "real-world use". I'm assuming it means "non-fictional use"? Any other interpretation doesn't seem to make much sense.
>To prove a practical application if that math is correct
Formalization has literally no direct use outside of foundations of math.
>>
>>60790902
> Formalization has literally no direct use outside of foundations of math.
Again, with formalized math you can prove properties of cryptographic algorithms based on that math, that's pretty useful.
>>
>>60790927
Using formalized math isn't the same as formalizing math though.
So is it the intent that somehow determines the "real-world use"?
>>
>>60790961
>So is it the intent that somehow determines the "real-world use"?
Yes. But I'm not going to argue with you about semantics, everybody here knows perfectly well how "real-world" is different from "academic circle-jerk".
>>
>>60790986
>But I'm not going to argue with you about meaning
That seems like the right way to go when you're not making any sense.
>everybody here knows perfectly well how "real-world" is different from "academic circle-jerk"
A place is obviously different from a group. Why did you mention this? How is this relevant?
>>
Guys can someone tell me what i did wrong?
Its doing its stuff but in reverse...
#include <stdio.h>
#include <string.h>

int number;
int result;
int loop = 0;
char qloop[100];

int main() {

int calc() {
printf("Please enter your number\n");
scanf("%d", &number);
result = number & 2;
if(result == 0) printf("\nThis number is even\n");
else if(result != 0) printf("\nThis number is odd\n");

return 0;
}


while(loop == 0) {
start:
calc();

printf("\nAgain? y/n ");
scanf("%s", qloop);

if(strcmp(qloop, "y")) goto start;
else if(strcmp(qloop, "n")) loop = 1;
else printf("\n\ninvalid input\n\n");

}

return 0;
}
>>
hey /dpg/
Pls be nice to me in this cause I am retarded when it comes to this, I just wanted to know something:

Is it possible to take the sims, extract the main sim file, you know how a sim is 3D and walks around and make it a desktop application?

Then, make it something like a net navi? Voice command and everything.

With today's programming skill is this possible?
>>
File: 1480574628504.jpg (274KB, 750x750px) Image search: [Google]
1480574628504.jpg
274KB, 750x750px
>>60791128
>>
>>60791149
I know I'm a c noob but I thought I'd ask here before going to /sqt/ or make a new thread
>>
Can someone who understands lambdas read this and tell me if this badly explains lambdas as I think it does (I literally am trying to understand why you would want to use them and cannot)

http://www.nullptr.me/2011/10/12/c11-lambda-having-fun-with-brackets/#.UJmXu8XA9Z8
>>
>>60791186
>C++
Ignored.
>>
>>60791146
I'm not sure how that game works, but you could extract a game character model and write a program that uses it.
>>
>>60791234
I asked this a few days ago and /g/ went on a rampage.
>>
>>60791186
>(I literally am trying to understand why you would want to use them and cannot)
that's because a reasonable person would never want to use them. lambdas are a complete joke. lambdas are only shilled by brainlets such as the haskelltards ITT.
>>
>>60791186
>tell me if this badly explains lambdas
This. Sepples probably overcomplicates it, but lambdas are simply functions without a name.
>>
>>60791250
What are these "lambdas"?
>>
>>60790156

def fib(n):
return 1 if n in [1,2] else fib(n-1)+fib(n-2)


>inb4 "muh precious stack"
>>
>>60791251
Okay, but why would you want to use them? What inconvenience do they eliminate or problem do they solve?
>>
>>60791186
A lambda is a function.
in C style languages (excl. C) a lambda specifically means an anonymous function or a function literal, i.e. one not defined using the standard

result name(parameters) { ... }
>>
>>60791271
>Not using the O(log n) algorithm
>>
>>60791275
>Okay, but why would you want to use them?
The same reason you would want to use functions.
>What inconvenience do they eliminate or problem do they solve?
You just don't have to name them. They are literally functions without a name.
>>
>>60791275
they are more general
constexpr auto function = lambda_expression;

you can use them as local functions

and you can pass them as arguments to higher order functions (functions taking functions as parameters) and then you don't need to have an explicitly named function that you only use once
>>
>>60791275
I typically use them when passing functions to a another function. Have an example in lisp:
> (remove-if (lambda (x) (zerop (mod x 3))) '(1 2 3 4 5 6))
(1 2 4 5)
>>
>>60791306
in haskell this is just

filter (not . \x -> x `mod` 3 == 0) [1..6]
>>
>>60791306
>>60791327
aka the exact same but prettier
lisp is not a pretty language
>>
>>60790278

They are different.

homoiconic langauge with dynamic typing and great metaprogramming vs. functional language with beautiful syntax, immutable values and a great type system


LISP is very fluid, you CAN programm "funtional style, but you're not supposed to.


But why not both?
>http://www.defmacro.org/ramblings/lisp-in-haskell.html
>https://gergo.erdi.hu/blog/2013-02-17-write_yourself_a_haskell..._in_lisp/
>>
>>60791374
>you're not supposed to.
What makes you think this?
>>
>>60791306
>>60791327

Ruby has the best lambdas in my opinion..

(1..6).reject {|i| i%3 == 0}
>>
>>60791327
>. \
you're supposed to write it like .\ so it resembles a lambda sign
>>
>>60791403
>.r
Opinion discarded.
>>
>>60788873
Um all you need is literally:
    while(1)
malloc(1024);
>>
>>60791407
>An anonymous function is a function without a name. It is a Lambda abstraction and might look like this: \x -> x + 1. (That backslash is Haskell's way of expressing a λ and is supposed to look like a Lambda.)
i guess the dot is something else in haskell
>>
>>60791389

Things like "setf" and "setq"..
>>
>>60791426
The existence of the setf macro and setq operator does not mean you're not supposed to program in a functional style.
>>
>>60791186
Try implementing this example program.

Give the user a text field, a number field and a button. When the user clicks the button, schedule an alert to be displayed to the user. Use the text field as the message for the alert and the number field as the number of seconds delay for the alert. After the alert is scheduled, clear both fields. Your program must allow multiple alerts to be scheduled in the background at once.
>>
>>60791327
(remove-if (compose #'zerop (rcurry #'mod 3)) '(1 2 3 4 5))
>>
>>60791403
that's hideous

>>60791407
>>60791425
yes, the . is function composition
not . f
where f = \x -> x `mod` 3 == 0

>>60791463
filter ((/= 0) . (`mod` 3)) [1..5]

just uglier
>>
>>60791491
compare>>60789206 to who it quotes to see that haskell is only pretty in the short.
>>
>>60791497
What do you mean?
He used custom data-types, the new one doesn't
He used type signatures
He didn't use a loop
>>
>>60791497
Yes, Haskell quickly becomes ugly for anything other than toy programs.
>>
>>60791463
The problem with lisp is that it considers the following code valid too:
(remove-if (compose #'zerop (rcurry #'mod 3)) '(1 "A" (3 4) 5))
>>
>>60791497
>>60791520
and even without that, that's just length
(, sorry ((but lisp) (will (never be) pretty)))
>>
>>60791525
Functions will give you a type error though.
>>
>>60791547
Only at the run-time tho.
>>
>>60791527
I think it is pretty. Fitemeirl
>>
>>60791560
Why the fuck would you apply a function you know will only need numbers to a list which may have non numbers.
>>
>>60791560
>>60791577
Do you really need your compiler telling you common sense.
>>
>>60791577
This is exactly that a compiler of a functional language would ask you if you feed it this code.
>>
>>60791128
strcmp returns 0 if the strings are equal, so thats probably your problem

not sure what you mean by "in reverse", though.
>>
>>60791520
Because it can't use loop or iteration without recursion, thus hack code.
>>
How good is Vagrant? I try to build and customize an app and noticed that I might fuck up my system because the maintainers want me to use 3 different package managers to gather all the stuff they use for their app. Might Vagrant be the right thing to contain this mess or should I keep looking for a better solution?
>>
Earlier in the thread was a discussion about the level of robustness one should take their programs up to, which basically devolved into a flame war. Anybody have any fresh opinions on this? I rarely check for exceptions any further than making sure I've opened a file correctly. Also, I've heard bad things said about try/except/catch statements in c++ and higher level languages, does this mean we should avoid using them?
>>
How to get into OS programming?
Assembly?
>>
>>60791742
you don't need to worry that much. your time is better spent being productive and making sure other parts of your code are safe and robust. unless you're writing mission critical fly-by-wire or someshit you literally don't need to check that malloc returned non-null, you'll still be a shit ton more robust than the average app/webapp. there are other things than malloc you should prioritize like checking to make sure you don't run out of file descriptors (like when opening a file but also when using pipes) because those can be a very limited resource.
>>
>>60791412

>.r
>not .rb


>>60791442

"Multi-paradigm: functional, procedural, reflective, meta"
"Often, the same algorithm can be expressed in Lisp in either an imperative or a functional style."
>https://en.wikipedia.org/wiki/Lisp_(programming_language)


"One of the most common mischaracterisations of lisp is calling it a functional programming language. Lisp is not functional. In fact it can be argued that lisp is one of the least functional languages ever created."
>http://letoverlambda.com/index.cl/guest/chap5.html


>>60791491

>that's hideous

Why?
You can clearly see where the lambda is happening.

But maybe you prefer:

(1..6).select {|n| not (n%3).zero?}
>>
>>60791802
and you should avoid calls to malloc in the first place. depending on the application it could all be static with not a single call to malloc or you only call malloc when loading a file or once in a while as part of a custom allocation scheme.
>>
>>60791806
It is perfectly fine to write Lisp in a functional style. There is nothing that suggests doing so is wrong.
>>
import Control.Monad.State
count' = fst . count
count = head . runStateT (mapM choose coins)
where choose (s, i) = state (`quotRem` i) >>= tell s
tell s x = lift [(s, x)]
(.=) = (,)
coins =
[ "twenty" .= 2000
, "ten" .= 1000
, "five" .= 500
, "dollar" .= 100
, "quarter" .= 25
, "dime" .= 10
, "nickel" .= 5
, "penny" .= 1 ]


count will give you back the remainder (0 because penny is there, without penny it will have a remainder)
count' will ignore the remainder
>>
>>60791759
Assembly, C/C++
>>
>>60788834
I have been using Haskell for awhile now, and this is what I have found wrong with the language:
>horrid macro system
>modules are deficient compared to the module system of OCaml or the package system of Common Lisp
>partial functions pervade the language
>broken records (ugly hacks are needed to get around their deficiencies, leading to overengineered libraries like lens)
>most libraries are in alpha and look like a college student's summer project
>library authors tend to pepper their libraries with ugly, meaningless, custom operators, contributing to the overall ugliness of the ecosystem
>String as [Char]
>easily subverted type system with unsafe functions
>laziness makes it a chore even for experienced programmers to reason about algorithmic complexity
>in 30 years of existence, Haskell has yet to become a proven asset in industry
>>
>>60791911
Haskell has and always will be just academic wank.
Theres better FPL's to use that are actually enjoyable.
You also forgot Xtensions fragmenting any chance at a real standard.
>>
>>60791858
What is the point of using the list monad here?

Replace:
head . runStateT
with:
runState

and:
tell s x = lift [(s,x)]
with:
tell s x = pure (s, x)
>>
>>60791998
Whoops, I might have messed it up refactoring, I was using the ((,) a) monad
>>
>>60791998
>>60792012
I guess I don't need the (,) a
>>
>>60791858
Unreadable.
>>
>>60792101
by a brainlet
>>
>>60792113
>tripfag
opinion discarded
>>
>>60791451
Spawn off separate threads passing the text and time and using sleep_for() to wake up and display the message?
>>
>>60791998
>>60792101
The much improved edition

coins = 
[ "twenty" .= 2000
, "ten" .= 1000
, "five" .= 500
, "dollar" .= 100
, "quarter" .= 25
, "dime" .= 10
, "nickel" .= 5
, "penny" .= 1 ]
where (.=) = (,)

count = mapM (mapM $ state . flip quotRem)
count' = evalStateT (count coins)
>>
>>60792113
for*

Take your English classes, dumb fucking mongoloid.
>>
>>60792162
oh

import Control.Monad.State
>>
>>60791806
Why are you putting 3 lines for paragraph breaks?
>>
>>60792162
I like Haskell, too bad IO a shit in it.
>>
Do you think C++ should be called C+++, for having 3 standard libraries?
>>
>>60792269
Oh, look, it's this bait again.
>>
>>60792269
I'd just like to interject for a moment. What you’re referring to as C++, is in fact, C/Feces, or as I’ve recently taken to calling it, C plus Feces.
>>
>>60792286
Please don't insult the C/Feces language by comparing it to C++
>>
>>60792282
He's got a fair point
>>
>>60792269
Dont worry, by C++50, Boost will be the new std.
>>
>>60792302
So when does Qt becomes the fourth standard library guys? C++75?
>>
>>60792259
Wasn't someone working on an effects system for it?
>>
>>60792299
No, he hasn't, he's probably a projecting D-fag.
>>
>>60792316
Isn't Phobos C++'s third standard library?
Just link it up and go

I mean it's not like anyone's using D
>>
>>60792316
>Being a worse language than Deadlang
lol
>>
>>60792307
You dont understand.
There will be no QT or anything else.
Boost will EEE everything.
>>
Can someone give me tips for creating nightmare scenarios in git? It should look accidental. Something like a merge conflict that would take hours to resolve.
>>
>>60792320
I believe C++'s third standard library is called "POOst"
>>
>>60792333
Install Gentoo
>>
>>60792333
Its better to just admit you fucked up lad.
>>
>>60792333
Don't forget to use
--force
!
>>
>>60792333
Replace git with SVN.
>>
>>60792347
Just for fun anon. Like is there some character I can add to each line of code to cause like 100 merge conflicts in one file?
>>
>>60792333
git <cmd> && timeout 10800 /NOBREAK
>>
>>60792269
No I think C++ is justified. The two pluses imply that there are two "upgrades" from C:
They mean the two different implementations of modules.
>>
whats the best programming language to start with if my interests lay in MCU's (mainly le arduino for now), writing scripts to automate things in linux and for the web (like spamming votes etc) and blockchain.

just something that will teach me the basics, make it easier to pick up another language depending on where life takes me. thanks for your time.
>>
>>60789286

Where can you find that code?
>>
>>60792388
uLisp
>>
>>60792388
node.js
>>
>>60792388
shitkell
>>
>>60792388
>le
>>>/v/
>>
>>60792462
> >>>
>>>/trash/
>>
>>60792462
i think hes just a dirty frog, gt-kun
>>
>>60792388
>MCU/arduino
C/C++
>Writing scripts
Python
>...for the web
JavaScript
>BlockChain
Literally 0 idea.

C++/python have a lot of tech, most of which is more low level/non-web focussed, where as JS is web/very high level focussed.

So pick an area and a language, grab whatever books whose intro chapter you can understand related to said language and start grinding.
>>
>>60788834
Why does Haskell produce 1 GB of garbage per second?
>>
File: Hare4.jpg (12KB, 201x250px) Image search: [Google]
Hare4.jpg
12KB, 201x250px
>>60792555
thank you
>>
>>60792634
>>>60792363
>>
>>60792634
Because it's 1000 times slower than other languages
>>
>>60792634
Because thats how much shit is put in it
>>
File: 16427455.jpg (62KB, 960x864px) Image search: [Google]
16427455.jpg
62KB, 960x864px
Excuse me I got a question


If hasklul is garbo collected, why doesn't it collect itself?
>>
>>60792746
because it isn't garbage

any more questions?
>>
>>60792746
Even the garbage collector produces 1 GB of garbage per second.
>>
>>60792746
Because GC is a meme
>>
>>60792282
>>60792299
>Hurr this language is so popular it has several libraries
>this is somehow bad
The shills are getting desperate.
>>
>>60792754
If hasklul isn't a bag of garbage why does it collect its garbage?
>>
>>60792783
Haskell is a programming language that uses a form of automatic memory management in which now-redundant allocated memory is referred to as "garbage", which is released ("collected") by a routine that is included with all Haskell programs.
>>
>>60792777
STD strings
BOOST strings
QT strings

Which standard library is better?
>>
>>60792804
None.
>>
>>60792804
If someone asked you to choose between a QT and an STD which would you pick?
>>
>>60792801
>Haskell is a programming language
Hasklul is a just a scripting language that collects garbo, except for itself
>>
>>60791816
>it could all be static with not a single call to malloc
>ulimit -s 9001GB
>>
>>60792821
Any of three, all three are standard libraries
>>
>>60792831
that's the wrong choice
>>
>>60792837
>Using standard library is a wrong choice
I guess C+++ was a mistake then
>>
>>60792804
>Qt
>standard library
I wish.
>>
>>60792854
It's going to be added as a standard library in the upcoming C++67, anon
>>
>>60792871
*C+++67
>>
>>60792906
see >>60792375
>>
>>60792906
By '67 C++ and Rust will merge, so it's gonna be Qt-CRust+++67/Boost.
>>
>>60792804
>people who willingly contract STDs
Ew. Gays are disgusting.
>>
>>60793064
You are in a thread full of literal real life faggots
>>
>>60793072
DON'T FUCKING TRIGGER ME REEEEEEEEEEEEEEEEEEEEEEEEE
>>
>>60792848
std::string is part of the c++11 this is the default.
Converting the string to a Qstring is done when you work with graphical interfaces.
I don't think boost has their own string type anymore.
There is about as much confusion about this as there is confusion about which language you speak to your own parents.
>>
>>60793259
rolling release language, everyone
>>
>>60792804
QString is UTF-16 tho, so std::string.
>>
>>60793340
t. UTF-underage
>>
>>60793292
>he doesn't know that `rolling release` means
Why do C++-haters have to embarrass themselves all the time?
>>
>>60793367
Have you heard about our lord and savior UTF-8? Please consider reading http://utf8everywhere.org/ .
>>
>>60793378
Don't give idiots attention. That's the main reason dpt is in this state.
>>
>>60793378
What? Do you mean on of the three standard libraries aren't being updated constantly?
>>
>>60793439
So you really don't know that `rolling release` means. Sad.
>>
>>60789283
mov reg, imm64
and
mov rax, [moffs64] (special encoding only for rax)

Are the only full 64 bit addressing modes, so you need to do:
mov reg, 0xAddr
mov byte [reg], 0
>>
>>60793292
It is not rolling release you luddite.
The 11 means the standard is from 2011 which means there is different versions.
Rolling release is when there just is one thing and updates happen all the time.
C++11 is still used because it is the most critical update to the language.
Using older versions or newer versions never affects the user, only the programmer.

Qt is not part of the standard library, so they want to have something that works regardless of what version of the standard library you use.
It makes sense that if you want specific features in your toolkit that you implement your own.
It is trivial to convert between the string types, so using the std::string is always the right thing to do unless you find it more efficient to use something else.
There is never any confusion.
>>
>>60793475
Don't be, pretty sure by C+++43 you will actually have a have a stable ABI

also, posting le `ebic 1337``` backtick maymay like the c00l koderz
>>
>>60793492
>Using older versions or newer versions never affects the user, only the programmer
Neither does using a completely different language. What `point`` are you trying to prove here?
>>
>>60793509
Scripting languages rely on the version the user has installed.
I assume you come from a scripting language since a library with features that is now part of the language confuses you.
>>
>>60793546
I come from a language that actually has a `thing``` called `stable""" API
>>
>>60791271
>tree recursive algorithm
>recomputing every fibonacci number over and over again
how does it feel being retarded?
>>
>>60793576
ABI*
>>
New thread:
>>60793579
>>60793579
>>60793579
>>
>>60792333

You want to commit and push with a wrong user/email:

1) modify a few dozen files
2) git commit -m "minor bugfix"
3) git push --force
4) git rebase -i --autosquash master my-unstable-branch
>>
>>60793405
https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/
This was nice. Very informative
>>
>>60793576
>no new features allowed
There is no such thing as a final version.
There will always be new features you are bitching about problems that does not exist in other places than your head.
>>
>>60793686
Re inventing strings is not called adding features, brainlet
>>
>>60793698
std::strings are better than char arrays in every conceivable scenario.
Qstrings are older and still exists because of legacy reasons, adding basically the same functionality to the standard library is adding features as qt is not used by every project.
>>
>>60793770
Strings ARE char arrays, brainlet
>>
>>60793797
std::string is a vector of chars.
You can resize it, use it in functions etc.
C style strings are terrible for anyone who uses them unless you have to account for every single byte in your application and in that case, you wouldn't use strings anyway
>>
>>60793679
That's actually a really bad article on UTF8
>>
File: 1496815596403.png (217KB, 427x640px) Image search: [Google]
1496815596403.png
217KB, 427x640px
do manga hosting website simply stores the image file or are they more clever than that?

since most manga pictures are blank white pixels wouldn't it be a waste to store them as is? instead just store where the black dots are and populate a canvas with it

even better use huffman compression

pic: the only image in my pc that isnt wojak
>>
>>60792804
STD in an STD project
BOOST in a BOOST project
QT in a QT project

How is this a question?
>>
>>60793950
how far back do you have to go until boost strings are not the same as std::strings?
>>
>>60793950
All are standard libraries
>>
>>60793980
the first two are.
>>
>>60793879
Did you read the bit where it makes it clear it's going to be slighly inaccurate?
>>
>>60793897
I'm quite confident that most Manga sites just store the compressed images. Image compression is quite good.
Consider that people have video on demand sites and that a video (even shitty quality) would be hundreds of Manga chapters given the quality you get on these sites.
>>
>>60788974

I haven't used json but pythons package management sucks. I've crashed many a program because of wrong dependencies
>>
>>60789052why do u say that? I want to get into web dev
>>
>>60794272
>>60794272

i guess that makes sense. any idea what image compression they use specifically?
>>
>>60794355
See what formats they deliver. I imagine it's just png or jpg.
I doubt they'd have an internal compression which they undo then make pngs/jpgs out of.
Thread posts: 329
Thread images: 20


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