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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 325
Thread images: 29

File: (You).jpg (14KB, 480x360px) Image search: [Google]
(You).jpg
14KB, 480x360px
Old thread: >>>61346107

What are you working on, /g/?
>>
File: gdi.png (2KB, 141x91px) Image search: [Google]
gdi.png
2KB, 141x91px
1st for winapi headers are a shit
>>
>>61353960
One faggot forgets the title, another posts a non-programming related pic
Congrats dumbasses
>>
>>61354003
because the trap faggot anime pictures are programming related
>>
>>61354003
>non-programming related
Lies
>>
>>61353997
You were just in the last thread saying macros in general are bad
That is wrong
Macros are great because you can solve problems before compilation and pre-bake the solutions into the resulting program
I only wish C's preprocessor was independently Turing complete
>>
>>61354021
I don't recall saying I liked those either
>>
Dropping parens is retarded, and it becomes even MORE retarded when your language allows shit like fn arg instead of fn(arg)
>>
>>61354061
(fn arg) master race
>>
>>61354080
what does
f a, b c, d, e, h
mean?
>>
>>61354048
Sounds like you actually want metaprogramming and not a preprocessor.
>>
How de we revive /prog/, lads?
>>
File: gee.webm (606KB, 438x368px) Image search: [Google]
gee.webm
606KB, 438x368px
>>61354126
create it
>>
>>61354048
seems like you want to upgrade to c++17
>>
>>61354100
In an (fn arg) language, that looks like ass. Here's how it should be written:
f a ,b c ,d ,e ,h

It's only valid in a quoted list. And here's what it means: the list should contain the symbol f, the symbol a, the value of b, the symbol c, the value of d, the value of e, and the value of h.
>>
>>61354136
C++17 doesn't have a Turing complete preprocessor either
>>
>>61354150
>(fn arg) language,
Nope
https://forum.nim-lang.org/t/3046
>>
>>61354173
That's not an (fn arg) language. That's an fn arg language.
>>
i dont understand non-c style syntaxes
am i a brainlet?
>>
>>61353960
What is the popsicle meme
>>
>>61354168
because it has a superior alternative
>>
>>61354185
That's what I said though

>>61354186
Probably because you are used to exploit whitespace insensitivity. It's not a bad thing.

Shit like Ruby gives brain damage
>>
>>61354168
He's thinking about templates. Which is pure madness. Macros are much better for that kind of stuff. Sure they're not Turing complete but they solve most non-generics tasks better.
>>61354216
Fucking moron.
>>
>>61354216
No it doesn't.
Given that templates, constexpr, auto, decltype, and all those things combined are not Turing complete, how can they be superior to a hypothetical preprocessor that IS Turing complete?
>>
>>61354231
>Fucking moron.
Fucking brainlet.
>>
>>61354228
>Shit like Ruby gives brain damage
Can your language do this>
30.times { 
# do something
}
>>
>>61354186
Nah it's just something you need to learn all over. Declarative languages can be especially confusing.
>>
>>61354228
>That's what I said though
No, you said an (fn arg) language. And then you linked to an fn arg language. You can't treat them interchangeably, they're two completely different things.
>>
>>61354245
>Given that templates, constexpr, auto, decltype, and all those things combined are not Turing complete,
what makes you believe so?
>>
>>61354263
>>(fn arg) language,
>Nope
>>
>>61354245
Templates are Turing complete and it's awful what people force them to do.
And the compile times for that shit makes you think you should sit down and spend that compile time on writing actual metaprogramming replacements for your templates.
>>
>>61354126
Stop bitching about how terrible it is and make an actual effort to make good posts.
>>
>>61354271
I misunderstood you. I thought you were saying "Nope" as in "yes it is an (fn arg) language, and no that is not what it means," not "no it is not an (fn arg) language." But given that you meant "no it is not an (fn arg) language," your prior response (>>61354100) makes no sense as a response to the post it was responding to ("(fn arg) master race").
>>
>>61354270
Well I mean they aren't
>>61354280
>Templates are Turing complete
No


(just kidding lads i am troll)
>>
>>61354255
for (int i=0; i<30; i++) {
printf("Yes.\n");
}
>>
>>61354255
HURR HURR DURR
forach(_; 0..30)
//do shit
>>
>>61354255
You're clearly not asking if other languages have for loops.
What is it you're looking for?
>>
>>61354344
Thanks for proving his point
>>
>>61354377
Expressiveness
>>
>>61354444
See
>>61354344 then
for(expression;condition;expression) {block}
>>
>>61354469
>condition
Well actually that's an expression as well it just should evaluate to something that's a condition realistically.
>>
>>61354255
30 `times` do
something
>>
>>61354469
>See
>>>61354344
That's the exact opposite of expressiveness, mongrel
>>
>>61354255
Yes.
#define times(x) for (int i = 0; i < x; i++) 

times(30) {
/* Do something */
}
>>
>>61354453
emoji get stripped reddit cuckboy
>>
>>61354508
>opposite
It's easy for the machine to read.
It's easy for real humans to read.
What's your problem?
Especially when it's not the trivial circumstance of an indexed loop.
>>
>>61354453
>>61354475
Thought this was a joke because rub sounds a little like love and y can imply you.
>>
>>61354503
times n io | n > 0 = io >> times (n - 1)
| otherwise = return ()

main =
30 `times` do
putStrLn "Hello"
putStrLn "World"


Could make it have an index parameter, maybe possible to make that optional using type classes
>>
>>61354566
>It's easy for real humans to read.
As opposed to that example? Stop reaching for the straw, dude
>>
>>61354344
>>61354345
Okay, now can your language do this? (this language is still Ruby btw)
define_method(:can_your_language_do_this?) {
Trait = Class.new(Module) {
define_method(:state) {|&block|
old = method(:extended)
define_singleton_method(:extended) {|obj|
old.call(obj)
obj.instance_eval(&block)
}
}
}
has_a = Trait.new {
attr_reader :a
state {
@a = 1
}
}
has_b = Trait.new {
attr_reader :b
state {
@b = 1
}
}
has_c = Trait.new {
define_method(:c) {
return @a + @b if @a && @b
}
}
obj = Object.new
obj.extend has_a
obj.extend has_b
obj.extend has_c
puts obj.a.to_s + ' + ' + obj.b.to_s + ' = ' + obj.c.to_s
}
can_your_language_do_this?
>>
>>61354618
I don't know what trait is, also I may have a different concept of Modules than Ruby's
>>
>>61354566
>>61354612
>It's easy for real humans to read.
Perhaps that could be a subjective matter.
There's plenty of brainlets that post here on the regular. :^)
>>
>>61354612
>as opposed to that example
That example could imply any number of things. The for construct in C is very explicit. But sure, you could assume that 30.times doesn't mean you've declared a multiplication on the result of the block.
If I wasn't quite sure you were aiming to do something like a for loop that could easily be the case.
It'd be quite a nice feature actually.
>>
File: disgrace.png (154KB, 476x345px) Image search: [Google]
disgrace.png
154KB, 476x345px
>>61354618
>OOP
>>
>>61354632
Ruby doesn't actually have (stateful) Traits, Ruby has Modules which are basically Traits but stateless. A Trait, as I've defined it here, is pretty much just a mini-class that supports multiple inheritance and is written with this in mind by being minimal and modular in what functionality it supplies to the derived class.

What I've done here is I've implemented traits in Ruby as an extension of modules, and then I proceeded to use them to say 1 + 1 = 2.
>>
File: 1478584909202.jpg (12KB, 426x382px) Image search: [Google]
1478584909202.jpg
12KB, 426x382px
>>61354644
When I speak to "brainlets" they say 30 times this or 30 times that, maybe only mentally ill Cpeepee autists say for int i 0, if i less than 30 do this and increase i
>>
>>61354685
u r dum
>>
>>61354656
To be more clear. What you wrote could be:
 
argument1.operation {
expressions;[...]
return argument2
}

Maybe even allow for multiple returns. I'd really like that actually.
I'm sure anyone with half a brain can see how useful this is for reducing mental overhead. It's very clear where the effects of this piece of code will be.
>>
>>61354707
lol autist
>>
>>61354665
>"can your language do [simple thing]?"
>yes! yes it can! btfo lol!
>"can your language do [complicated thing]?"
>WAAAAH ITS OOP NO FAIR WAAAAAAAH MUH PURE-A-TEE WEHHHH BLUB BLEB BLURB BUH HUH HUH
>yfw
>>
>>61354618
It can but I'd never do that. That's horrible.
>>
>>61354537
>normal-order evaluation
please, don't.

times(--x) { }
times(f()) {}
...
>>
>>61354681
I don't even know what inheritance is. Try again.
Try avoiding these shitty concepts:
Interface, Encapsulation, Inheritance, Polymorphism etc
>>
>>61354752
>It can
I don't believe you.
Unless you're talking about C++. C++ can do anything, and that's both the best and worst thing about the language.
>>
>>61354779
>I don't even know what inheritance is. Try again.
Inheritance is when a record that contains a record of another type can be treated as directly containing all of that type's fields, and can be non-mutatively cast to that type.
>shitty concepts
See: >>61354727
>>
>>61354788
It is C++ and I agree. But you could do the same in C actually. It's a very large piece of code though.
>show me how
It's just too much to explain. But it's certain within reach since we don't have implementation constraints.
>>
>>61354727
OOP is bloatware plain and simple.
Pretty much everything OOP can accomplish can be implemented with purely imperative structures that fundamentally runs with less overhead.

But sure, you keep using your script kiddy language and hope people will take you seriously.
>>
>>61354809
>shitty concepts
Yes they are, your language is written without it
>>
>>61354816
>OOP is bloatware plain and simple.
Abstraction is bloatware plain and simple.
>Pretty much everything OOP can accomplish can be implemented with purely imperative structures that fundamentally runs with less overhead.
Pretty much every limb on my body can be cut off to make me lighter.
>But sure, you keep using your script kiddy language and hope people will take you seriously.
I don't have to hope, I live off merit scholarships.
>>61354818
>Yes they are, your language is written without it
see: >>61354727
>>
Does this mean the package is unusable right now?
>>
>>61354816
oop is neither about imperative nor declarative
>purely imperative structures that fundamentally runs with less overhead.
wrong, oop actually gives more optimization rooms for when dynamic resolution is involved.
>>
>>61354841
>see: >>61354727
>>61354818
>>
>>61354618
Why should someone "solve" a problem that simply does not exist in the first place?
>>
>>61354844
the master branch yeah
but there's probably a stable tag/branch that you can checkout
>>
>>61354853
>>>61354818
see: >>61354727
>>
>>61354894
>>61354853
>>
File: 1466901665251.png (35KB, 537x515px) Image search: [Google]
1466901665251.png
35KB, 537x515px
>>61354893
Simply ebin.
Why would someone accept a commit that actually breaks shit?
>>
c-can I get free (you)s too?
>>
File: 15822597.jpg (5KB, 370x334px) Image search: [Google]
15822597.jpg
5KB, 370x334px
No
>>
>>61354922
because some people use the master branch as a development branch so it might be a partial progress
don't ask me
>>
>>61354905
see: >>61354905
>>
Deferred ARC
>>
>>61354860
It's all a matter of what you consider a problem. Go right ahead and continue using assembly if you don't like the changes introduced in C. Same story with OOP vs pure imperative, same story with traits vs OOP.
>>
>>61355076
>if you don't like the changes introduced in C
Doesn't apply to me.
>Same story with OOP vs pure imperative, same story with traits vs OOP.
Neither do these
>>
I struggled for two days with k&r's exercises 1-13 and 1-14. Am I literally retarded or is the book hard?
>>
>>61355109
Why is meme?
>>
>>61354537
Now can your language do this?
int i = 60;
times(30) {
i--;
}
printf("%d\n", i); // should be 30
>>
>>61355114
Learn to use libraries faggot
>>
Can anyone tell me why the fuck one would do smth like this in Java.

public class Person extends ArrayList<Person>

An object that at the same time is a list of objects of its same type?
This kind of brainfucks me.
How would one use this?
>>
File: scr.png (42KB, 1680x1050px) Image search: [Google]
scr.png
42KB, 1680x1050px
>>61353960
>What are you working on, /g/?

Exploring the deepest, darkest corners of Racket (0﹏0 ;)
>>
>>61355169
#include <cstdio>

template <typename F>
void times(unsigned n, F f)
{
while (n --> 0) f();
}

int main(int, char **)
{
int i = 60;
times(30, [&]() { --i; });

std::printf("%d\n", i);
return 0;
}


https://ideone.com/RHrUew
>>
>>61355180
>a person is several people
Sounds like an abuse of inheritance personally.
>>
File: 3kL3N1x.png (603KB, 630x630px) Image search: [Google]
3kL3N1x.png
603KB, 630x630px
>>61355197
kek
>>
>>61355180
What the fuck?
It compiles?!

I didn't expect it to work but given that it does work I can tell you people probably use it as a simple way of implementing a tree data structure. Think about this: each Person is an ArrayList, and each member of that ArrayList is also an ArrayList, and so on. So it forms a tree.
>>
>>61354977
How dare you.
You're just (You)sing me.
>>
>>61355197
>while (n --> 0)
This is fucking brilliant
>>
>>61355395
yeah it's the "goes to" operator :^)
>>
>>61355416
my heart goes out to all the survivors of _____
and then my heart goes out to mcdonalds
and then my heart has an attack
>>
>>61354977
are nice person
>>
>>61355395
if you prefer you can use the "slide to" operator
while (x --\
\
\
\
> 0)
printf("%d ", x);
>>
>>61355197
>while (n --> 0)
what the fuck
what language is this?
>>
>>61355500
back to shitternews, faggot
>>
>>61355504
Cuck++
>>
>>61355504
Ignore whitespace. It is parsed as
while (n-- > 0)
>>
>>61355500
what the fuck am i looking at
am i being trolled
>>
>>61355509
back to réddit, faggot
>>
>>61355524
#include <stdio.h>

int main()
{
int x = 10;
while (x --\
\
\
\
> 0)
printf("%d ", x);

return 0;
}


output
9 8 7 6 5 4 3 2 1 0


the back slash is to break the text in multiple lines
>>
>>61355504
Shit++
>>
>>61355504
C and C++
>>
>>61355532
báćķ ťó śťóŕmfŕóńť méméĺóŕď
>>
>>61355197
>>61355500
>>61355549
This is why C++ is bae :3
>>
File: photo.jpg (78KB, 900x900px) Image search: [Google]
photo.jpg
78KB, 900x900px
>>61355570
>templates
>c
>>
>>61355570
that doesn't work with good C compilers
>>
>>61355582
technically it works in both
>>
>>61355575
C pee pee is garbage, kys faggot
>>
>>61355582
we're talking about the --> operator, dog

>>61355573
>stormfront outta nowwhere

back to plebbit , librul
>>
File: 1445705986467.jpg (31KB, 853x480px) Image search: [Google]
1445705986467.jpg
31KB, 853x480px
>>61355582
>banana dog
>c++
>>
>>61355570
that only works in C you stupid nodev
>>
File: index.png (4KB, 225x225px) Image search: [Google]
index.png
4KB, 225x225px
I bought a new bike, and the front wheel doesn't spin only the rear wheel.

that is i can move backwards but not forwards.

is there something in the bicycle that is blocking the movement of the front wheel?
>>
C++ is the best example of second-system effect since OS/360. – Henry Spencer
>>
>>61355570
Good C compilers don't ignore whitespace.
>>
>>61355615
>nodev
back to the "game development" general homodev
>>
>>61355607
bąçķ țô țhę ļąb ąşşhôļę
>>
>>61355628
fuck off nodev
>>
>>61355659
fuck off godev
>>
File: BIRTHDAY HAMSTER.jpg (40KB, 431x415px) Image search: [Google]
BIRTHDAY HAMSTER.jpg
40KB, 431x415px
WARNING: AUTISTIC POST INCOMING!
I want to take twm, the default window manager included with x (or x11 or xorg or whatever the fuck you want to call it) and make a sort-of extended version with taskbar and login screen and shit like that. I have absolutely zero programming experience (unless you count basic) and I'm going to be using this as an exercise to learn C, which I've been told is absolutely fundamental for low-level programming. So my questions are:
>what are some good resources for learning what im reading when i eventually open up the source for twm?
>what ide/text editor do you recommend? (im using FreeBSD right now pls no bully)
>how autistic am i?
>>
>>61355649
back to business bertha
>>
>>61355668
fuck off iodev
>>
>>61355669
Programming with x11 is the purest form of pain. And it's multiplied by the fact that you will be using C.

And amazingly, X11 itself is garbage collected
>>
>>61355669
just drop the idea before you start
working with x api is pain in the ass
>>
>>61355696
>>61355726
I'm pretty determined to do this. Although if you recommend I do some other C related things before cracking open 80 year-old code I'm more than open to suggestions.
Thanks for answering my third question though.
>>
>>61355733
30 year old code*****
>>
>>61355733
>80 year-old code
computers haven't even existed for 80 years you stupid nodev
>>
>>61355774
code has existed for hundreds of years, be it in pseudo code or not

fucking brainlet, i swear
>>
>>61355733
Why do you want to do this? To learn programming? If so, there are languages that are more beginner friendly than C.

C itself is not hard. It's just happens to be so tedious that it gives you a wrong impression that programming is boring.

(Also stay the fuck out of C++ at the cost of your life, it's a literal piece of garbage)
>>
>>61355783
>Why do you want to do this?
they are killing my family if I don't do it
>>
>>61355782
oh yeah? go ahead and compile pseudocode you pseudodev
>>
>>61355795
Write your own WM, it's easier
>>
from time import time

class Timer():
def __init__(self, message):
self.message = message

def __enter__(self):
self.start = time()
return None

def __exit__(self, type, value, traceback):
elapsed_time = (time() - self.start)*1000
print (self.message.format(elapsed_time))

with Timer("elaped time to compute some prime numbers: {}ms"):
primes = []
for x in range(2,100):
if not any(not x%p for p in primes):
primes.append(x)
print ("Primes: {}".format(primes))
>>
>>61355826
> elaped time
>>
I'm becoming a trap because of these threads
https://www.amazon.com/ZANZEA-Thigh-Striped-Stocking-Colours/dp/B00OAXERZW/ref=sr_1_1?ie=UTF8&qid=1499963084&sr=8-1

I fucking hate you guys
>>
>>61355826
>2 months in
>STILL stuck with prime sieve
Pyshitters are called brainlets for a reason
>>
The unix timestamp is almost reaching 1500000000

>print (int(__import__('time').time()))
>1499963203



does that mean 4chan file names are also going to change?
>>
>>61355862
yes?
>>
>>61355844
yes?

>>61355845
kys disgusting faggot
>>
>>61355783
what language would you recommend for someone to learn programming with?
>>
>>61355783
To learn advanced programming. I know some BASIC and I once made a text-based adventure game in Microsoft batch programming on a windows Vista machine I had a while ago in notepad. THAT is painful and tedious. I just figure i want to jump down to lower level programming and giving myself a real project right off the bat instead of just learning for the sake of learning is better motivation.

>>61355774
see >>61355755

>>61355795
nice try but im a massive cock sucking tripfag now
>>
>>61355862
the 4chan filenames change every millisecond, so they are going to change, but they would have changed anyway
>>
>>61355826
> from time import time
Makes complete sense.
>>
>>61355876
'Elaped' isn't a word, my man.
>>
>>61355891
oh shit
>>
>>61355883
whats wrong fuckboy
>>
>>61355877
I would actually tell them to learn D
>>
>>61355883
Yes, because a module can have something in it with the same name as the module itself, and there is nothing nonsensical about that, dumb friend.
>>
vptrs are unnecessary, even for virtual functions
>>
>>61355907
based

http://forum.dlang.org/thread/[email protected]
>>
>>61355909
Functions having the exact same name as modules? Terrible.
>>
>>61355909
not him but:
there's nothing nonsensical about it but it sure is a bad idea
>>
>>61355947
the fact that people with common sense in a tech community is a surprise is horrifying.

also dlang forums are the fastest forums I have ever used
>>
File: 1457420364603.png (2MB, 1000x967px) Image search: [Google]
1457420364603.png
2MB, 1000x967px
>>61355947
>No. People who need to be told what decent behavior is won't pay attention to such a document.
>>
>>61355970
how is it a bad idea? how are you going to confuse a module with a function? whatever you might do with it, static analysis or testing would catch it, and there is no possibility of subtle errors.
>>
>21 posters
>159 replies
why is this thread a poo assthread filled with fags of same
>>
>>61356007
people are actually talking to each other in here
>>
>>61355998
>how is it a bad idea?
It implies the datum that shares a name with the module is somehow more pertinent to the module than the rest of its contained data
This, however, should be decided by the users of the module
>>
>>61356027
Wew the FSF sure is out in full force today
>"don't do it that way"
>"why"
>"muh gommunism"
>>
how big is big data?
>>
>>61356148
The fuck are you on about?
>>
>>61356177
bigger than 64 bits
>>
>90% of cs graduates cannot answer this question. Let's see who's the brainlet here.

This pseudocode:
while 1 {
arr[rand(0, 101) / 100] = 7
}

puts 7 to arr[0] most of the time, and arr[1] once in a while.

can this code cause a branch misprediction?
>>
Why is the OP pic ... that?
Is Alfred's Playhouse considered anime now?
>>
>>61356216
Pseudocode does not provide sufficient information to describe whether or not something can cause a branch misprediction.
We need to know specifics. What language's equivalent of this code are we looking at? What implementation of the language? What architecture? There are probably languages out there that were made with so much abstraction, and so little concern for efficiency, that something as simple as a variable assignment to a literal could cause a branch misprediction.
>>
https://www.youtube.com/watch?v=ztaoydH7Z54
>>
>>61356285
assume this the assembler output loads a random value from 0 to 101 inclusive and divides it by 100, storing it in register N. No branches here. Then it assignes it to either the Nth element of the array with a single MOV.
>>
File: 1499965176430.png (47KB, 1045x440px) Image search: [Google]
1499965176430.png
47KB, 1045x440px
>>
File: 2345ery6fuhjgfdefcgbn.jpg (48KB, 640x364px) Image search: [Google]
2345ery6fuhjgfdefcgbn.jpg
48KB, 640x364px
post your github
>>
>>61356404
no
>>
>>61356401
http://nogenerics.info

>>61356404
http://github.com/
>>
>>61356404
hahaha what a fucking bunch of cucks you are!
I am an uncucked white aryan myself so I don't have SJWhub FAKENEWS MAGA KEKISTAN TOP KEK
>>
File: 1498318563621.png (488KB, 1000x1050px) Image search: [Google]
1498318563621.png
488KB, 1000x1050px
>>61356435
kek
>>
>>61356426
https://appliedgo.net/generics/
>>
Is there a way to do stuff within one for loop, but the for loop changes depending what the if statement returns?

If that didn't make any sense, say I am scanning something

for ( int i=0; i<5; i++ ) 


in a positive direction, this is fine, but for a negative direction, I would like to go

for ( int i=5; i>0; i-- ) 


I can easily do an if statement, and then within each if statement put the corresponding for loop. But, the code I want to run in the for loop is the same, is there a way I only need to type this code once, and depending what the if returns determines which for loop is ran?
>>
>>61356476
yeah interface{} thanks interface{} for interface{} the interface{} suggestion interface{} m8 interface{} seems interface{} like interface{} it interface{} solves interface{} the interface{} problem
>>
>tfw clang is taking suspiciously long to compile
>tfw you forgot -j16
>>
>>61356476
>https://appliedgo.net/generics/
That pathetic excuse of a """code generation"""
OMG ahahahahaha
>>
File: 17 - 1 (2).gif (505KB, 1080x1080px) Image search: [Google]
17 - 1 (2).gif
505KB, 1080x1080px
>>61356476
>Who needs generics, use interface{}
>Who needs generics, use void *
hmmmm
>>
>>61356501
alias make='make -j`nproc`'
>>
>Make a half assed brainlet language
>STILL slower than Java
What did google mean by this
>>
>>61356490

bool forwards = predicate();
for (int i = forwards ? 0 : 5; forwards ? (i<5) : ( i>0); forwards ? i++ : i--)
{}

Something like that? It's messy as fuck though. Might be nicer with a range-based for?
>>
>>61356545
>make a half assed corelet language
>STILL less powerful than CPL
What did Dennis Ritchie mean by this
>>
At uni o learned a bit of assembly to program a pic and the 8051. When looking for a job, could I say that I know a bit of assembly? I mean, I wouldn't be able to program in assembly for modern processors, I don't understand shit from the output of Gcc (but I get the general idea)
>>
>>61356490
int step, goal;
if (c) {
step = 1;
goal = 5;
} else {
inc = -1;
goal = 0;
}
for (int i = 0; i != goal; i += step) {
// Do things
}
>>
>>61356523
This is the first time /dpt/ suggested something useful to me. Thanks, anon.
>>
>>61356622
Or a bit more compact
int step = c ? 1 : -1,
goal = c ? 5 : 0;
for (int i = 0; i != goal; i += step) {
// do things
}
>>
>>61356624
Why don't you just add -j16 to you makefile flags?
>>
>>61356613
yea and then just explain it pretty much how you did in that post, sounds good to me.
>>
>>61356737
it's not my makefile, it's clang. It's handier to have it in an alias, so i don't have to edit all my makefiles.
>>
>>61356699
Or if you're using C++11
auto do_things = [](){
// do things
}
if (c)
for (int i = 0; i < 5; ++i)
do_things();
else
for (int i = 5; i > 0; --i)
do_things();
>>
how do i learn "lamb the calculus"
i would like to learn "lamb the calculus" but i am wrapped up in "in pear at I've"
>>
>>61356699
or a bit more compact (and shit)
 
for (int i = 0; i != c ? 5 : 0; i += c ? 1 : -1) {
// do things
}
>>
>>61356827

I would suggest getting your toes wet with Haskell. That's what I'm doing. It's just math. Also monads and lining up types.
>>
>>61356826
You know what would really tie everything together for sepples?
Duck typed interfaces.
// accepts anything with a void nullary call operator
void call_thunk(interface {
void operator();
} const &thunk) {
thunk();
}
>>
>>61356930
fixed:
// accepts anything with a void nullary call operator
void call_thunk(interface {
void operator()();
} const &thunk) {
thunk();
}
>>
>>61356930
Works already for templates. I don't see how it would work for runtime dispatch though.
>>
File: 1492118315246.png (831KB, 1280x1381px) Image search: [Google]
1492118315246.png
831KB, 1280x1381px
>applying for work
>had two phone interviews everything went well
>tell me they want to do a face to face next week
>get back from camping Tuesday afternoon
>they sent me an email Monday asking me to call them
>call them Wednesday and they don't answer
>>
>>61356972
was camping worth it
>>
>>61357027
Yeah
I-I didn't want to be an enterprise engineer anyways
>>
>>61356972
>frogposter

you had it cumming
>>
I'm trying to create a LaTeX input on a website with a little pop-up keyboard that has basic LaTeX options in it (users can click the options and then fill in the parts that matter themselves). It's being a bitch.
>>
>>61357123
so basically what /sci/ does
>>
>>61357123
Well latex is a bitch so color me surprised.
>>
>>61357081
>enterprise engineer

java EE bullshit?
>>
I have a question for you /dpt/.

I'm a neurobiology researcher, currently doing my phd. I want to start learning a programming language, and I don't know if I should go with python or matlab.

Can someone provide an objective comparison of the 2 or point me to one? Since matlab is a product and not open-source, i cannot be sure if a critique is shilling or not.

thanks
>>
>>61357237
Go with the one that is used more by your peers
>>
>>61356972
>>61357081
This is not a difficult problem to solve.

Call again, or send and email and explain that you were out on a camping trip on Monday, and that you'd love to set up that in-person interview.
>>
>>61357143
yeah but this is for people who are actually getting an education instead of retards who pretend to be smart.
>>
File: 1488548235144.jpg (166KB, 850x509px) Image search: [Google]
1488548235144.jpg
166KB, 850x509px
>>61357237
pros of matlab

>widely used
>designed specifically for scientific computing
>easy to find documentation
>>
>>61357224
Yeah basically
I'm noticing a lot of people arent hiring right now
>>
>>61357237
python.

In short, matlab is a shit language, and in some areas (deep learning, machine learning, artificial neural networks), the python ecosystem blows matlab out of the water.

No programmer would reasonably prefer programming in matlab compared to python.
>>
>>61357255
both python and matlab are used, plus matlab costing 2000 euros makes comparing usage an unreliable measurement
>>
>>61357276
>is working with latex
>thinks he's smart

kys
>>
How does this indentation make you feel?
 };
};
};
(*totEdges) = 0;
while (!infile.eof () && !error) {
getline (infile, inputStr);
lineNum++;
strcpy (pch_str, inputStr.c_str ());
pch = strtok (pch_str, " ,:");
if (pch != NULL) {
sourceID = string (pch);
error = ((*nodeLst).find (sourceID) == (*nodeLst).end ());
if (!error) {

How does this indentation make you feel?

I have about 300 lines of this to go through
>>
>>61357302
emacs
>>
>>61357288
>outer product
>np.dot()

that's not the outer product. whoever made that image is a fucking idiot.
>>
>>61357302
>be me
>open my text editor
>ctrl + alt + f
>formats the code automatically
>>
>>61357308
What about it

Does coding in emacs create this kind of indentation? I know the guy who wrote it does is emacs lel
>>
>>61357288
that image is so dumb...
first, the fact that you have to ask about the result of an assignment is just a quirk of the python shell. Most scientists using python use IPython notebooks, better than matlab in any way.

Second, the fact that the names are more explicit than the operators is a design choice. You can overload the operators in python too if you want, but it's not worth it, so numpy being a sane library, it's not done.
>>
>>61357300
i'm not using it, i'm just making the feature. other people are using it.

you might want to work on that reading comprehension, retard.
>>
>>61357329
it will fix your indentation pb
>>
>>61357312
you don't know that
maybe matlab is just so shit that the name of the variable to which you assign changes the function it uses
>>
>>61357331
>thinks he's smart for making a latex feature
>not a retard
kys
>>
>>61357288
>>widely used
python is more used than matlab, and used a lot in scientific computing too

>>designed specifically for scientific computing
there are python libraries specifically designed for scientific computing too

>>easy to find documentation
matlab docs are horrible compared to scipy docs:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.fftpack.fft.html#scipy.fftpack.fft
>>
>>61357347
No, I mean the dot product of two vectors is not the fucking outer product of those two vectors. Whoever wrote that python code needs to take babby's first linear algebra again, cause all they did was just compute the inner product twice.
>>
>>61357406
maybe matlab is just so shit that the name of the variable to which you assign changes the function it uses
>>
>>61357288
>widely used

python is much more widely used i believe, and it's open source.

>>61357294
another plus for me is that the C.Sc faculty offers 2 semesters of python i can attend to learn the basic shit.
>>
>>61357419
or maybe you're a retard and don't understand the difference between matrix multiplication and the dot product of two vectors.
>>
>>61357463
maybe matlab is just so shit that the name of the variable to which you assign changes the function it uses
>>
>>61357473
yep, you're retarded.
>>
>>61357484
or maybe you have no understanding of the english language and constrain everything to your small mind

inner = np.dot(x,y);
outer = np.dot(x,y); // dot is a different function because "outer" has a different name
>>
>>61357513
To calculate the outer product of two matrices with numpy, you use numpy.outer() you fucking triple nigger.

numpy.dot() is used to calculate the inner (dot) product.

The variable name doesn't matter, and it doesn't dictate the function that is called.

besides, the code that i am talking about, and the code that you just posted, is not MATLAB. It's Python. I was never even talking about matlab in the first place.

You. Are. A. Retarded. Person.
>>
I'm designing a spesified precision bigdecimal implementation in C would it be stupid to have the right hand digits be a linked list with each link containing 4 digits?
>>
>>61357591
jesus christ you fucking autist
it was a joke
i repeated it three fucking times because you're so retarded and can't take a fucking hint
i know it doesn't make a difference
no shit the inner product isn't the outer product

calm down you fucking obnoxious faggot
>>
>>61357617
Implements bigint, and after that use a couple of bigints to represent a rational.
>>
>>61357626
>"HAHA GUYS I WAS JUST PRETENDING TO BE RETARDED"

sure you were, kiddo.
>>
>>61357637
If you can't fucking grasp that it's a joke from the fucking premise of >>61357347, then you should just kill yourself now and never fucking breed
>>
>>61357664
The only thing that's funny is your profound retardation.
>>
>your language never had its own dedicated hardware
>>
>>61357684
retard
>>
Test results for animebikini2nude neural network: http://imgur.com/lU1MrqI
The smaller the bikini, the better the network does. Output image sizes are tiny because larger sizes would require days of training.
Not worth pursuing further but a fun small experiment.
>>
File: 1499178532486.jpg (681KB, 1971x1971px) Image search: [Google]
1499178532486.jpg
681KB, 1971x1971px
>>61357792
Pretty cool. How big was your training set?
>>
>>61357792
nice, but how did you make the training set?
>>
>>61354126
there's already one, but /prog/ has always been shit.
>>
>>61357820
>>61357935
9.6k bikini
8.9k nude
Scraped images off boorus. Only looked for images with simple backgrounds and exactly 1 solo female character to make training easier.
NN learned in an unsupervised manner. So the dataset didn't have an image of an anime girl in a bikini paired with the same image but with the girl naked; the 9.6k bikini images and 8.9k nude images had no relation to each other.
Oversimplified explanation: call A a NN that will learn to translate bikini->nude, and call B a NN that will learn to translates nude->bikini. Training is done like so:
If the input I is a bikini image:
Input I into A, and the output of A into B. So bikini->nude->bikini. Compare I with output of B to get the error. Learn from error.
If the input I is a nude image:
Do the above except B then A. So nude->bikini->nude. Learn from error.
(Name of NN is CycleGAN if you want to research more)
>>
>ld starts swapping and freezes my system
>I have 32GB of ram

seriously, what the fuck is it even doing

>>61358090
>GAN
From the first goodfellow paper, I just knew GAN was going to be a new chapter in the history of waifus.
>>
I’m currently looking at some assembly code I get from writing some lines in C and gcc -S-ing it, learning how to do small easy stuff in assembly (on a x86-64 CPU).
Can anyone explain this line to me please?
movl    -48(%rbp,%rax,4), %eax

it’s especially the
-48(%rbp,%rax,4)
that I do not understand very well

The full ASM code (with said line at line 52):
https://pastebin.com/m5yi1TFC

The original C code:
#include <stdio.h>

int square(int i) { return i * i; }

int main() {
int test[10] = {45, 64, 78, 24, 798, 435, 10000, 7894, 154, 1};
for (int i = 0; i < 10; ++i)
printf("square(%5d) = %10d\n", test[i], square(test[i]));

return 0;
}
>>
>>61357792
10/10, anon
>>
>>61358090
Pretty interesting thanks m8
>>
>>61355180
>>61355260
That's the design pattern "composite". Using inheritance to implement it is not a very good idea, though.
>>
Learning Haskell using the Wikibook.
Clojure is a joke compared to Haskell. So far, Haskell looks like a good candidate for my pet projects. Second in line would be Rust or Python in case of certain libraries.
>>
File: macromagic.png (5KB, 275x104px) Image search: [Google]
macromagic.png
5KB, 275x104px
bravo microsoft
why can't they pay a pajeet intern to clear this shit up
>>
Silly question...
Is there a way to "catch" a javascript function call? I have this big HTML page with lots of js functions. I need to make something happen when one of those functions is called, BUT, I'm not allowed to insert code into the function itself.
>>
>>61358392
We get it. You've posted about this same thing multiple times in one day.
>>
>>61358413
No I haven't
>>
>>61358392
Funny thing is, if you delete that block, it will probably break everything
>>
>>61358401
https://stackoverflow.com/questions/5409428/how-to-override-a-javascript-function#5409468
>>
Can someone explain to me how C++ header files work?

I'm looking through a project by somebody else and it's in two parts, part_a and part_b. There are files
part_a.cpp
,
part_b.cpp
and
part_b.h
.
part_a.cpp then
#include "part_b.h"
.

Now the header file only contains function declarations with no definitions, so why is it included? I'm assuming you need the definitions as well when compiling, so why not just include the cpp file? Or is this how dynamic linking works - you include a header file into your project, and then it dynamically loads the corresponding precompiled library that already exists on the target system when it's run there?

I know I'm probably stupid but we don't have an /sqdpt/ unfortunately
>>
>>61358215
nevermind, I figured it out:

-48(%rbp,%rax,4)
means I’m looking into an array beginning at -48(%rbp), and %rax here is used as the index once multiplied by 4 (the size of an int).
So, with %eax = 0, the code above is the equivalent of foo[i] (i represented by %eax), foo[] being the array that is stored at -48(%rbp)
>>
>>61358574
you need the declarations so the source unit knows about function signatures
the definitions are actually put together in the linking phase once all source units have been translated
>>
>>61355180
Its not a "list of objects of its same type" its just a list of objects:
Person p = new Person(); // p = [] 
p.add(1); // p = [1]

for (Object i : p) {
System.out.println(i); // prints "1"
}

That said, I'd never extend ArrayList
>>
>>61355180
>How would one use this?
You wouldn't.
>>
In the Java Language Specification, it says
>An integer or floating-point expression x can be converted to a boolean value, following the C language convention that any nonzero value is true , by the
expression x!=0 .
>An object reference obj can be converted to a boolean value, following the C
language convention that any reference other than null is true , by the expression
obj!=null .

What did they mean by this? Writing something like
boolean bool = (boolean) 1;

gives a compile error for me.
>>
>>61358654
Does this work?
Boolean.parseBoolean("1");
>>
>>61358574
C and C++ use a dated compile and link model.

Each .c/.cpp file is compiled to object code, a .o file. part_a.o contains the compiled version of functions that were defined in part_a.cpp, and part_b.o contains the compiled version of functions that were defined in part_b.cpp.
A header file contains just declarations for functions for its corresponding "implementation file". When part_a.cpp is compiled to object code, those declarations included from part_b.h are just stubs - a note to the linker that says "Go find the compiled function which matches this signature elsewhere". The linker will find the target of those stubs in the other object code files and piece them together, resulting in a complete executable.
>>
>>61354255
It's different, but here goes.
fn do_times {n: nat} (count: int n, proc: () -<cloref1> void): () -<cloref1> void =
let
fun loop {n: nat} .<n>. (count: int n, proc: () -<cloref1> void): void =
if count > 0 then
let
val _ = proc()
in
loop(count - 1, proc)
end
else ()
in
lam () => loop(count, proc)
end

macdef repeat(n, x) = do_times(,(n), lam () => ,(x))()

val _ = repeat(30, print "test\n")
>>
>>61358654
booolean boool = 1 != 00;
>>
File: anal beads.png (1017B, 157x41px) Image search: [Google]
anal beads.png
1017B, 157x41px
>>61354255
Yeah.
>>
>>61358654
boolean bool = 1 != 0;
>>
>>61358444
I love you
also tight trips
>>
>>61358675
Yes it does (and produces false). Thanks
>>
>>61358690
If only ASTs syntax wasn't poop
>>
>>61357293
they do design and testing in-house and outsource code-monkeying. information security is where it's at now
>>
>>61354255
times = replicateM

30 `times` (do { ... })

Returns the results in a list too
>>
>>61358639
>>61355180
my bad, my browser cut off the ArrayList<Person> bit. Here's how you use it.
Person p  = new Person(); 
Person p2 = new Person();
Person p3 = new Person();

p2.add(p3);
p .add(p2);

System.out.println(p); // prints [[[]]]
>>
>>61358718
Oh, that's easier than what hwxi would have written. He'd probably take up another hundredful of lines to prove exactly what effects do_times does have, implementing it with a generic (covariant) return t@ype- and an universal enumeration of types for the closure.
>>
>>61354255
trait Times {
fn times<F>(self, f: F) where F: FnMut();
}

impl Times for usize {
fn times<F>(mut self, mut f: F) where F: FnMut() {
while self > 0 {
f();
self -= 1;
}
}
}

fn main() {
5.times(|| println!("Hello /dpt/"));
}
>>
>>61358862
what's that lambda syntax
>>
>>61358920
The lambda syntax in Rust is retarded.
>>
>>61354255
(define-syntax repeat (syntax-rules () ((_ n body ...) (letrec ((loop (lambda (cur) (when (> cur 0) body ... (loop (- cur 1)))))) (loop n)))))


#define repeat(n) for(int i = 0; i < n; i++)
>>
File: HoneyView3_2017-07-13_16-24-59.png (1MB, 858x858px) Image search: [Google]
HoneyView3_2017-07-13_16-24-59.png
1MB, 858x858px
what's filter map and reduce supposed to do in a real language, i don't really get it since i'm using go
>>
>>61359090
Filter filters and reduce reduces.
>>
>>61359090
Make it really easy to transform a list at once. Make it really easy to write new functions through combinations of them.
>>
>>61355169
Why did anon ask this?
It's it's very obviously an easy thing to do.
Realistically if you'd use a macro like >>61354537 you'd choose your index value to use a very uncommon symbol. Perhaps even using the standard predefined macro __LINE__ to make it possible to nest these.

Am I missing something here?
>>
>>61359148
He's probably a smug scheme weenie flexing scheme's hygienic macros. I agree with him though.
>>
>>61359090
Instead of doing something like this.
int acc = 0;
for (x in arr)
{
if (mod(x, 2))
acc += sqrt(x);
}
return acc;

You can write something like this.
return arr.filter(mod).map(sqrt).reduce(sum);


That's it really. Some languages can use it for effective parallelization e.g. Java parallel streams. Some people also argue that it's also easier to read, since a map is more specific than a for loop, a filter is more specific than some conditional, a reduce is more specific than a manual accumulator etc.
>>
File: thinkperl6.jpg (63KB, 500x656px) Image search: [Google]
thinkperl6.jpg
63KB, 500x656px
Would Perl be a good first language? I have no programming experience.
>>
>>61359193
Perl is a bad beginner's language IMO, it's very dense and has a lot of syntax to worry about. Try Python.
>>
>>61359090
>what's filter map and reduce supposed to do in a real language

See: C#'s LINQ
>>
>>61359090
Theyre the bread and butter of FP.
Dlang has some simple examples to demonstrate.
https://dlang.org/phobos/std_algorithm_iteration.html#filter
https://dlang.org/phobos/std_algorithm_iteration.html#map
https://dlang.org/phobos/std_algorithm_iteration.html#reduce
>>
File: ThreeColorResultOne_0.png (22KB, 518x311px) Image search: [Google]
ThreeColorResultOne_0.png
22KB, 518x311px
>>61359124
make it really easy to fuck your performance
>>
>>61359287
Not everything is performance critical baka. You can mix C and Lisp you know.
>>
>>61359287
of course, FP will always be slower than anything else due to immutable data
>>
>>61359287
Immutability is what fucks that up.
map, reduce, filter constructs make automatic paralleization a cinch. They're big boons for performance, that's why just about every procedural/OOP language under the sun has adopted these particular FP constructs.
>>
>>61359329
You can't parallelize map filter and reduce without immutability. Consider

(define a 0)
(map (lambda (x) (set! a (+ a 1)) (+ x a))) (list 1 2 3))
>>
Friendly reminder that we have a discord that sometimes talks about programming:

https://discord.gg/5QnAFx
>>
I want to be able to help with Libreboot and hacking the Nintendo Switch. Maybe some other things as well, but mainly I want to gain the knowledge to help people. What should I start learning if I have very little experience? C? Can anyone recommend a specific book or course? Should I read SICP just to get a basic understanding of programming? I heard it's a bit rough on beginners.
>>
>>61359386
If your aim is to do low level shit and find exploits, C is a must. That's a long way away if you've never programmed before.
>>
>>61359386
SICP is abstract programming, not hacking. Read an assembly book to get a start on learning how to hack.

I read:
https://www.amazon.com/Introduction-Bit-Assembly-Programming-Linux/dp/1484921909/
>>
>>61359357
What esoteric programming language is that?
>>
>>61359357
>you can't parallelize map/filter/reduce without immutability
Not unless you track function effects!
fun{A: t@ype+}{B: t@ype-} map {n: nat} .<n>. (lst: list(A, n), func: A -<cloref1> B): list(B, n) =
case+ lst of
| nil() => nil()
| cons(x, xs) => cons(func(x), map(xs, func))

fun{A: t@ype+}{B: t@ype} reduce {n: nat} .<n>. (lst: list(A, n), func: (B, A) -<cloref1> B, init: B): B =
case+ lst of
| nil() => init
| cons(x, xs) => fold(xs, func, func(init, x))

fun{A: t@ype+} filter {n: nat} .<n>. (lst: list(A, n), test: A -<cloref1> bool): listLte(A, n) =
case+ lst of
| nil() => nil()
| cons(x, xs) =>
let
val rest = filter(xs, test)
in
if test(x) then
cons(x, rest)
else
rest
end

These would be parallelizable, if list() wasn't implemented like a linked list, but you could massage them to accept arrayviews anyway.
>>
>>61359329
you cannot parallelize map, filter or reduce without immutability and a guarantee that there is no global state and no I/O
>>
>>61359511
What esoteric programming language is that?
>>
>>61359420
Is it fine to start this before C? I think i heard once that learning assembly first breaks your mind.
>>
New thread:
>>61359546
>>61359546
>>61359546
>>
>>61359384
Seriously? Why not IRC?
>>
>>61359536
>>61359480
Why are you spamming this, exactly?
>>
>>61359554
0/10
>>
>>61359555
IRC is cumbersome, and has a pretty big barrier to entry.

Discord is an extremely popular server-based chat system that is very easy to jump in and out. It has nice features, such as code markdown for a bunch of languages, and you can share images and small files without uploading to another source.
>>
File: DEW5lLfUMAEdZNe.jpg (346KB, 1764x2363px) Image search: [Google]
DEW5lLfUMAEdZNe.jpg
346KB, 1764x2363px
>>61359184
thanks
>>
>>61358689
Oh ok, the linking thing makes sense. Thanks!
>>
>>61355180

That's the 'composite' pattern, like for example if you want to represent a tree with child nodes. And as >>61358290 said, it shouldn't be inherited.
>>
>>61359592
>It has nice features
Such as recording and permanently storing all your chat history, and possibly voice communications, under the safety of your agreement to their T&Cs.
>>
>>61359862
I don't see how that's relevant, or why you think IRC hosts and listeners don't do exactly the same thing.

No one uses voice anyway.
>>
>>61359980
You can literally make your own IRC server that won't do the same thing. Or you can shop around and choose an IRC server that you believe won't do this.

With Discord you are forced to use their centralised servers, and you sign away any right to complain or protest right when you accept those T&Cs.

Do you also proudly use google chrome and windows 10?
>>
>>61360126
>You can literally make your own
Why in the world would anyone connect to some random anon's server?

>With Discord you are forced to use their centralised servers, and you sign away any right to complain or protest right when you accept those T&Cs.
Who cares?

>Do you also proudly use google chrome and windows 10?
No to the former, yes to the latter, and pride has nothing to do with it; it's a good product.
>>
>>61360519
>it's a good product.
I'm not even going to respond to the rest of your idiotic post. I use windows 10 myself by the way because I'm extremely lazy, and let me tell you, it's NOT a good product in any way.
>>
>>61360880
It is relatively a good product, for the same reason that you use it.
Thread posts: 325
Thread images: 29


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