[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: 317
Thread images: 40

File: PLP.jpg (57KB, 406x500px) Image search: [Google]
PLP.jpg
57KB, 406x500px
What are you working on, /g/?

Old thread: >>58816435
>>
>no cat op
shit thread
>>
how do i only take the parts of a library i want from a bigger library so i can use only those files

for example, i want to take only the boost filesystem library, is there an easy way to do this without copy pasting all the files by hand?
>>
>>58820571
For what purpose, anon? Why can't you use regular boost installation?
>>
>>58820530
actually screw that

I'm a rust missile now since it can be FFI'd in Haskell easily

https://mgattozzi.github.io/2016/10/01/haskell-rust.html

right your low level shit in rust
>>
>>58820583
i don't want my program to be 1.5gigs
>>
>>58820591
Do you understand how compilers and linkers work?

>>58820587
>I'm a rust missile
>right your low level shit in rust
>right
>>
>>58820599
i started c++ today. am i misunderstanding this entire thing? is c++ smart enough to figure out that i'm only using certain parts of the boost library?
>>
>>58820613
>is c++ smart enough to figure out that i'm only using certain parts of the boost library?
Only functions and classes you actually use will be compiled (and linked) into your binary, yes.

If you don't believe me, try including a bunch of headers and see that the binary size doesn't begin to grow until you start calling functions defined in those headers.
>>
What's the best book for learning programming as a concept using languages as a tool, rather then just a quick rundown © of a language's documentation?
>>
>>58820613
C++ is a language, it's not smart at all. You should ask your compiler.
>>
>>58820623
that's great news but now i'm really confused. what's the point of DLLs? and why can i download a library in binary format? i thought those formats existed to be shipped alongside an .exe?
>>
>>58820669
>that's great news but now i'm really confused.

>what's the point of DLLs
Because in some cases, it's redundant to include even that stuff. glibc, for example, GNU's implementation of the C standard library, is usually dynamically linked, because it's the same for ALL C programs you might use and therefore redundant to statically link with all your binaries.

For C# and other .NET stuff, all the .NET stuff is always the same and usually present on most Windows installations, so instead of creating a binary with those statically linked, they just dynamically load those DLLs.

>and why can i download a library in binary format?
You can. And these may be dynamically linked libraries, or they may be object files that you link in statically.

>i thought those formats existed to be shipped alongside an .exe?
Not usually to be shipped, they exist so in order to make your .exe smaller.
>>
>>58820697
>>58820669
Look at it this way: Dynamic linking has the upside of multiple binaries being able to share the same code, so you save disk space (and in some cases, memory space). The downside is that it's clunky to use and you need to make sure that the correct version is present.

Static linking has the benefit of you not needing to declare any dependencies to external library files (such as DLLs), but the downside is that your binary might grow and if you have many programs that use the same routines, you duplicate that routine multiple times unnecessary and "waste" disk space.
>>
>>58820669

There's no point in DLLs. Dynamic linking was a mistake.

http://wayback.archive.org/web/20090525150626/http://blog.garbe.us/2008/02/08/01_Static_linking/

https://web.archive.org/web/20081228101359/http://9fans.net/archive/2008/11/142

https://web.archive.org/web/20091107230144/http://9fans.net/archive/2002/02/21

http://www.nth-dimension.org.uk/pub/BTL.pdf
>>
File: ella-freya-001.jpg (44KB, 670x960px) Image search: [Google]
ella-freya-001.jpg
44KB, 670x960px
I know none of you bitches can answer this, cuz I'm the only real programmer here even though I've been graduated for 9 months and am still unemployed, but:

I'm trying to enable my custom Windows shell extension by adding the appropriate keys to the registry. I want to enable it for text files, so I want to put the key in

>HKEY_CLASSES_ROOT\txtfile\ShellEx...

BUT since I have txt files associated with Notepad++, I have to put the key in

>HKEY_CLASSES_ROOT\Notepad++_file\ShellEx...

Otherwise, the shell extension won't be enabled for my txt files, which is ridiculous, because if I then associate txt files with a different program, my extension will stop working. So, where the fuck can I put my key so that my extension will work for text files no matter what program they are associated with?
>>
>>58820587
>it can be FFI'd in Haskell easily
nice
>>
>>58820587
>>58820990
>Still using the C ABI
Why don't you try write a Haskell module or whatever that directly interacts with the Rust ABI?
>>
Bruteforce calculator in python3, did try to make it tell you in seconds how long it'd take the average pc but it got buffer overflows
#!/usr/bin/python3
charsetlen = 0
print("Does your password contain lowercase letters? [y/n]")
choice = input(">>> ")
if "y" in choice:
charsetlen = charsetlen + 26
if "n" in choice:
charsetlen = charsetlen

print("Does your password contain uppercase letters [y/n]")
choice = input(">>> ")
if "y" in choice:
charsetlen = charsetlen +26
if "n" in choice:
charsetlen = charsetlen

print("Does your password contain numbers? [y/n]")
choice = input(">>> ")
if "y" in choice:
charsetlen = charsetlen + 9
if "n" in choice:
charsetlen = charsetlen

print("Does your password contain special characters? [y/n]")
choice = input(">>> ")
if "y" in choice:
charsetlen = charsetlen + 33
if "n" in choice:
charsetlen = charsetlen

print("How long is your password?")
length = input(">>> ")
length = int(length)
charsetlen = int(charsetlen)
for i in range(length):
charsetlen = charsetlen*charsetlen

print("Number of possible combinations")
print(charsetlen)



please tell me how I could improve
>>
>>58821028
Actually, looking it up, Rust doesn't even have a defined ABI.
What a joke.
>>
>>58820349
>pipe operator
>Haskell

You could remove a pair by using apply prior to many'.

I also suspect that you missed the sarcasm in my post.
>>
>>58821051
depend of the cpu ?

doing some request to test reactivity of the hardware
>>
>>58821051
if "n" in choice:
charsetlen = charsetlen

This does nothing, and answering something other than y or n just skips both blocks.

>Does your password contain special characters?
Needs some definition of which special characters you count. Do you count ¿ for instance?

for i in range(length):
charsetlen = charsetlen*charsetlen
Just wrong. This results in a value of charsetlen^(2^length), when what you want is charsetlen^length. Python has the ** operator for powers, so no reason to use a loop.
>>
>>58821086
x |> f = f x

think it's & in Data.Function
(imho Data.Function shold be put in Prelude)
>>
>>58821118
Oh fuck, I killed the formatting. Ah well.
>>
>>58820571
yes? boost is a collection of libraries, you can link only the parts you need
>>
>>58821121
You mean '&'. And why on earth would you use that instead of apply? I think F# has been rotting your brain.

Here, more words.
f x y = liftA2 selfCons (fmap pure x) $ many' $ liftA2 (on mappend pure) x y
selfCons = (join .) . (:)
>>
>>58821144
>why on earth would you use that instead of apply
because it's an operator and parses differently
>>
>>58821165
(&$&$&$)
is an operator that parses differently, if you choose to define it.

'|>' is not in Data.Function: you would have to define it yourself. Whereas '$' is exactly the same with the arguments in a more logical order, and '&' is in Data.Function if you're desperate to have the arguments flipped.

I'd recommend using the defaults.
>>
>>58821118
So I should use def whatever(): then add an else so if it doesn't have y or n it sends them back to the def

>powers
fuck I didn't know the name, I was googling how to do ^ in python and that didn't help

thanks for all the help anon
>>
I have a 2d array of button in c#

how would I write a method that takes the currently pressed button as a parameter and performs some code using that buttons position in the array

say the button that was pressed is array[4,3]

I want to check if the background colour of array[x+1, y+1] is a certain colour and return true if it is

thanks
>>
>>58821195
Wow, thanks for the info!
>>
>>58821237
No worries. You're right that you could consider apply to be a kind of 'pipe' with its arguments flipped, but it's best to be idiomatic (rather than using F# concepts).
>>
>>58821252
>>58821121

You are just butthurt that it is used in F#.
& is not very different to $
>>
>>58821281
lolwat
Are you the guy who thought |> was in Data.Function?
>>
>>58821333
Look, I get it, it's your first day outside of reddit, you've just come here from r/Haskell and you want to show off that everything done in F# is inferior.

But you're expected to actually read posts before replying to them
>>
>>58821055
c++ might just as well not have a defined abi
>>
>>58821347
>>58821281
f x y = liftA2 (on (<>) pure) x y |> many' |> liftA2 ((join .) . (:)) (pure <$> x)
where (|>) = flip ($)


There's nothing wrong with F# idioms, there's just no point wasting a line.
>>
>Year of Our Lord 2017
>still can't infix arbitrary expressions in Haskell
bloody roundhead traitors
>>
i've been trying for an hour to get including external files in qt working

garbage like this is literally 99.9% of trying to learn c++, it's all terrible, terrible garbage
>>
File: 1486336019788.png (51KB, 359x409px) Image search: [Google]
1486336019788.png
51KB, 359x409px
>>58821365
Maybe we shouldn't use haskell
>>
>>58821372
seriously, why can't it be as easy as putting the path to a header file into include? what am i doing puting paths in some places and running qmake and then editing some .pro file? what the fuck is this?
>>
>>58821437
it's called c cruft needed to backwards compatible bullshit, notice how new languages basically include all the normal shit for you officially now (rust, go, swift, etc.)
>>
File: 1477570612660.png (339KB, 1000x800px) Image search: [Google]
1477570612660.png
339KB, 1000x800px
>>58820533
I'm making a gaem
>>
>>58821511
>v/v/>>/v/ ebin mandcchild xd :^)
>>
File: 1486249145922.jpg (55KB, 957x621px) Image search: [Google]
1486249145922.jpg
55KB, 957x621px
>>58821523
pls
>>
>>58821511
>>58821532
no help for frogposters
you probably can't even program
bet you're using unreal or unity or game maker or something
>>
File: 1485374843913.jpg (69KB, 699x485px) Image search: [Google]
1485374843913.jpg
69KB, 699x485px
>>58821565
no, i'm making a gaem in C with opengl
>>
>>58821596
Stop posting frogs and start posting code you fucking homosexual
>>
Is there a way to search for projects on GitHub via one of project's files (kinda like a reverse image search on Google) or partial blocks of text (like a function, or anything) from one of the files?
>>
File: 1454274715741.jpg (72KB, 487x549px) Image search: [Google]
1454274715741.jpg
72KB, 487x549px
I'm finally going to start my CS course in March. Any tips for a freshman?
>>
>>58821635
You won't learn anything unless you program as a hobby.
>>
>>58821640
I'm actually studying Python by myself until March and I already know the basics of C. I have some future projects I plan on doing as a hobby once I get good enough.

Besides programming in general, is there anything I can do so I don't become a shitty computer scientist?
>>
Currently going through Cracking the Coding Interview.
>>
File: 1485284962966.jpg (34KB, 576x640px) Image search: [Google]
1485284962966.jpg
34KB, 576x640px
whats an easy way to know when you're over-engineering something
>>
File: 1472098763816.png (244KB, 986x810px) Image search: [Google]
1472098763816.png
244KB, 986x810px
What's the type signature of anime?
>>
>>58821732

Your code has empty lines to separate "sections" of code.

http://www.yegor256.com/2014/11/03/empty-line-code-smell.html
>>
>>58821635
Read the textbook. Yes, it's expensive. Yes, you should get it if you can. Yes, it's fine to pirate it so long as you read it.

No one cares that you know something before the professor explains it; exploding about it makes you look like THAT KID. This has become a personal grievance because I'm taking night classes after work and there's THAT KID who is the embodiment of neo-4chan (2012+) autism and plebbit's shitty "le random" humor who spouts random technobabble about Gentoo and programming concepts. Waves around some Japanese LN about Trump he bought because it's "so random". Fuck him. Don't be that guy.

If the professor wants you to do something a certain way even though there are better ways of doing it, he's got good reason for having you do them. Well, most of the time - it depends on how good your professor is at teaching. He's the one giving you a grade at the end of the day.

If you're a student without responsibilities, please do yourself a favor and start grinding projects. If you have an idea that you like and its reasonably doable, spend some time and make it real. Build a portfolio now.
>>
>>58821773
Thanks for the tips. I already studied Calculus by myself, so I'll be skipping that as I already have the books, etc. I'm not an attwhore, so I'll not be THAT KID.

About the textbook, I should buy only two in the first semester: Introduction to Algorithms and any book about C I find good (I'm thinking about Modern C, by Jens Gustedt).
>>
>>58821764
Nice one
>>
>>58820533
Working on an implementation of a paper on a fast Bounding Volume Hierarchy builder called Bonsai.
Wanted to parallelize it neatly so I started out making a thread pool, then building various task schedulers on top of that to do different things, and eventually I realized they were doing mostly the same to I was able to reduce it to a single generic parallel for loop (replacing the concurrency::parallel_for from the PPL) and a multiple producer/multiple consumer job scheduler.
It's the best feeling when you're able to unify massive slabs of almost identical code into a single generic implementation that leaves you with only a fraction of the LOC you had before.

And it's pretty cool to fully rebuild the BVH of an entire scene in real time. Currently at ~30ms for a ~330K triangle scene.
Real time path tracing will soon be reality I hope.
No more ugly rasterizers. Only elegant light simulation.
And it's funny because with the ever increasing amount of triangles they want to push, ray tracing will eventually be theoretically more efficient than rasterizing because of a lower complexity bound.
>>
>>58821754
CuteT Pi ()
>>
File: 1486349978358.jpg (91KB, 1280x720px) Image search: [Google]
1486349978358.jpg
91KB, 1280x720px
>>58821864
>>
File: IMG_0531.png (153KB, 750x1334px) Image search: [Google]
IMG_0531.png
153KB, 750x1334px
explain to me why this fag thought I was trolling in pic related.

Context is a guide on C++
>>
>>58821849
On an i5 2500K that is, so on modern CPUs it will run significantly faster. It also scales pretty well with the number of cores (heaviest part of the algorithm even scales linearly)
>>
>>58821899
probably because 19 out of 20 times its a sign of design issues with your code
>>
>>58821764
Holy shit this is retarded.
>>
>>58821912
>a constant is a design issue
>>
>>58821764
that has nothing to do with what i asked about tho
>>
I have a problem in SQL that is probably common.

The group "Administrators" has an entry in alist.
I want to replace this entry with entries for every member of "Administrators" (there is, of course, a table which assigns members to groups).

E. g., what I have now is :
Administrators   CanRead

What I want is :
Paul  -  CanRead
Jessie - CanRead
Martin - CanRead

I have to do so through the table:
Paul  -  Administrator
Jessie - Administrator
Martin - Administrator

Probably, there is a term for such problems, like "recursive query".
>>
>>58821899

the cpp / h split is, hands down, the most retarded forced feature of any popular language.

>inb4 "no, its OOP"
>>
>>58821764
static void allocPages(int page, int n)
{
assert(n > 0);
u32 addr = page * 4096 + KMALLOC_OFFSET;

for (; n > 0; n--, page++, addr += 4096)
{
virtualMapKernel(addr, physAllocPage(), PAGE_PRESENT | PAGE_WRITE);
heap.setUsed(page);
}
}


>HUR DUR DUR DUR MUH EMPTY LINE DUUUUUUUUUUUUUUUUUUUUUUUUUUR
It's called making your code neat you fucking poo in loo
>>
>>58821941
ftfy
static void allocPages(int page, int n)
{
assert(n > 0);
u32 addr = page * 4096 + KMALLOC_OFFSET;
for (; n > 0; n--, page++, addr += 4096) {
virtualMapKernel(addr, physAllocPage(), PAGE_PRESENT | PAGE_WRITE);
heap.setUsed(page);
}
}
>>
>>58821922
>creating global variables for no reason isn't a design issue

Why in god's name would you try to correct a C++ guide if you're this much of a C++ novice?
>>
>>58821941
If you cared about neat code you wouldn't put braces on a new line, NEET.
>>
>>58821948
I advise you to take a ten minute break, and reread your post with a glass of water to ensure you don't die of embarassment.


>extern const double PI;

>>DESIGN ISSUE! NOT ENOUGH OOPATTERNS!
>>
>>58821947
Fucking disgusting

>>58821950
I put braces on a new line BECAUSE I care about neat code.
Get your disgusting taste out of here nigger.
>>
both fags
>>
>>58821963
If you're not using extern there to make that variable accessible from other modules, you're using extern wrong.

This has nothing to do with "OOP patterns" or whatever, it's about you polluting the global namespace for no god damn reason.
>>
>>58821986
What about the non-retards who use "//" for single line comments?
>>
>>58821986
if (
condition
) {
Statement
>>
>>58821990
.h
namespace constants {
extern const double e, pi, sqrt2, ...;
}


.cpp
namespace constants {
const double e = 2.71, pi = 3.15, sqrt2 = 1.41, ...;
}
>>
>>58821764
It's not always true.
Sometimes you need a function to do several things at once.
>>
>2017
>Not going full Martin
>>
>>58821051
You repeating the same thing a lot, I would change the "Do you have a X? if so +Y", into a function, and then sum over the results.
so this is how i made it


def get_inc (char_inc):
print("Does your password contain {} [y/n]".format(char_inc[0]))
return (input (">>>") == 'y') * char_inc[1]
def main():
characters =(("lowercase letters", 26),
("uppercase letters", 26),
("numbers", 9),
("special characters", 33)
)
charsetlen = sum(map(get_inc, characters))
print("How long is your password?")
charsetlen = charsetlen ** int(input('>>>'))
print("Number of combinations {}".format(charsetlen))

if __name__ == '__main__':
main()
>>
>>58822010
Now you're making a namespace for no reason.

Why are you so against just declaring the member variables of a class within the header? Everything just works and you don't have to constantly pull bullshit out of your hat to cover up all the issues you're causing.
>>
>>58822010
Unless C++ is different from C you don't need to declare them to be extern (the are implicitly extern).
>>
>>58821941
>code full of magic numbers
>using assert guards instead of declaring your parameter as unsigned
>for with several increments on the same line
>talking about "neat code"
This has got to be a troll.
>>
>>58822039
What is wrong with the example I gave?

>>58822045
if that's correct then nevermind
>>
>>58822045
C++ const does imply internal linkage by default.
>>
>>58822046
>Magic numbers
Which one? 0 or 4096?
Any experienced programmer should have no trouble figuring out that 4096 is the size of a page.
If it's 0 your talking about, then you should just quit programming now.
>>
>>58822073
Welp.

>>58822054
It doesn't really matter whether you define the stuff in the header or not. If people need to know the exact value for whatever reason it should be in the header file though. If the exact value is not really necessary it might be good to keep the stuff out of the interface file.
Opening an issue on Github about it is a waste of time though.
>>
>>58821695
Actually, I would say that as long as you are honestly interested in the topic and pursue both 1) reading and 2) programming in your spare time, you can't really go wrong.
Make sure you finish your projects, and do your best to be well-rounded. Personally I find tooling boring as hell, but you can't neglect areas like this.
>>
>>58822104
If it's in the header it can cause linking issues
>>
File: 1486076543291.jpg (339KB, 1200x900px) Image search: [Google]
1486076543291.jpg
339KB, 1200x900px
>>58821909
>tfw your 2500K is no longer felt to be modern
>>
What Rust can do that other languages can't:
struct X {
y: Y
}
impl X {
fn y(&self) -> &Y { &self.y }
}


This defines an aggregate type containing a field y of type Y directly (not as a separate heap object). Then we define a getter method that returns the field by reference. Crucially, the Rust compiler will verify that all callers of the getter prevent the returned reference from outliving the X object. It compiles down to what you'd expect a C compiler to produce (pointer addition) with no space or time overhead.

As far as I know, no other remotely mainstream language can express this, for various reasons. C/C++ can't do it because the compiler does not perform the lifetime checks. (The C++ Core Guidelines lifetime checking proposal proposes such checks, but it's incomplete and hasn't received any updates for over a year.) Most other languages simply prevent you from giving away an interior reference, or require y to refer to a distinct heap object from the X.

This is my go-to example every time someone suggests that modern C++ is just as suitable for safe systems programming as Rust.
>>
>>58822199
I know man. Can't believe my system is 5 years old already. It's getting time to upgrade.
>>
>>58822221
To be honest, is it really worth it? Moore's law is dead.

Maybe just one more upgrade...
>>
>>58822205
Nobody cares.
>>
why does this work perfectly fine


void btnEvent_Click(object sender, EventArgs e)
{
if (((Button)sender).BackColor == Color.CadetBlue)
{
((Button)sender).BackColor = Color.Red;
}
//Console.WriteLine(((Button)sender).Text);
}


but this doesnt do anything?


void btnEvent_Click(object sender, EventArgs e)
{
if (((Button)sender).BackgroundImage == Properties.Resources.banana)
{
((Button)sender).BackgroundImage = Properties.Resources.apple;
}

}


i have both an apple.jpg and banana.jpg in the Resources folder and my buttons have banana images on them but they dont change to apples when clicked
>>
>>58822205
neat
>>
>>58822205
Literally copypasted: http://robert.ocallahan.org/2017/02/what-rust-can-do-that-other-languages.html
>>
>>58822274
I'd guess that assigning a BackgroundImage will generate a new bitmap from the resource, so when you compare the resource with the assigned BackgroundImage they will always be different.
>>
>>58822199
>>58822221
AMD Athlon 64 X2 4800+ masterrace ITT.
>>
File: jumps.webm (1MB, 1920x1080px) Image search: [Google]
jumps.webm
1MB, 1920x1080px
I have labels and jumps in my assembler now.
>>
>>58822339
That seems to be it. Using btn.Tag to tag all bananas as bananas fixed it

thanks
>>
>>58822364
Is that good?

I just bought what the falcon guide told me to last time. I cannot into hardware...
>>
>>58822382
After you finish it, write a WASM transpiler.
>>
>>58822411
The platform I'm making for doesn't even have a working multiply instruction(or MMU), let alone a web browser.
>>
>>58822432
Get working on the browser first then, dude.

What are you writing it for?
>>
>>58822443
*What platform
>>
>>58822443
An architecture I came up with, called R(feel free to come up with a better one).
>>
>>58822457
Cool. Learning exercise?
>>
>>58822466
I guess.
>>
>>58822472
I was thinking about writing a CHIP-8 emulator. I know nothing about low-level stuff, very interesting though.
>>
Anyone understand MMU design and how things like pages work?
>>
>>58822405
It's top tier if you still live in 2005 like me.
I also have 2 Gb RAM and 512 Mb VRAM.
>>
>>58822501
Fuck yeah, master race.
>>
File: 1480291803432.gif (471KB, 300x300px) Image search: [Google]
1480291803432.gif
471KB, 300x300px
>>58821849
>think my custom parallel loops and task schedulers are hot shit
>works seemingly perfectly for days
>mfw it just deadlocked
oh jesus fuck, kill me now
>>
>>58820911
right click on text file -> open with -> other application -> your shitty .bat file -> set as default
>>
>>58821899
Telling him that variables could be declared outside of classes is basically telling him that the object model of C++ is redundant, and this triggers the OOP-fag, because that reminds him he's as useless and redundant than OOP.
>>
Is it just me, or are monoids everywhere?

Ever since I read this:
>a monoid is an algebraic structure with a single associative binary operation and an identity element
everything I write turns into a mess of mappend.
>>
>>58822274
>>58822339
This is an excellent example on how operator overloading is fucking trash by the way.
>>
>>58822808
The way C++ handles operator overloading is indeed dire, but in principle it can work.
>>
>>58820571
another aproach http://stackoverflow.com/a/6770305
>>
>>58821899
C and C++ treat these things differently, retard. Go lurk the difference.
>>
>>58821986
how about godlike:
if(condition)statement();
>>
>>58822087

Page sizes are platform specific, you obvious beginner.

#define PAGE_SIZE 4096


Was that so hard?
>>
>>58822834
That was C#.
Of course it can work - if you don't let idiots do the design. And this example is a perfect showcase on how NOT to do it. Everyone would assume that when you do an assignment then it is actually equal and not warped in some way that the regular comparison doesn't work any more.
>>
>>58822971
My bad, should have looked at the code. I hear people decry operator overloading and I assume they're talking about C++.

I'm surprised C# is as bad, people usually praise it. Never used it myself, though.
>>
>>58822205
Rust needs to be destroyed at all costs. It is an abomination.
>>
>>58822991
>I'm surprised C# is as bad

It's not 'as bad', in that there are fewer foot-guns, but there are some things that could use work.
>>
>>58820533
>What are you working on, /g/?
Patriotic units for file sizes
>>58823229
>>
Hm, "thoubyte" is redundant.
Better:
32768 byte =
2 footbyte 8 inchbyte 768 byte
>>
>>58821941
>undefined behavior
anon...
>>
Why isn't this memoization function working in Python?

def fib(n):
if n in (0, 1):
return n
else:
return fib(n-1) + f(n-2)

def memoize(f):
memo = {}
def helper(x):
if x not in memo:
memo[x] = f(x)
return f(x)
return helper

fib = memoize(fib)


Then I call fib(30), and it takes quite some time to return the result (as if I didn't even "memoize" it). If I call fib(50), it just stays computing forever and doesn't return anything.

Why isn't the memoize function taking any effect over f?
>>
>>58821963
um anon, consts must be defined immediately.

That code wouldn't work.
>>
>>58823345
>>58823409
ASAN will catch these.
>>
>>58822960
I'm only supporting x86. I don't care about other platforms.
>>
>>58820911
for "I'm the only real programmer here" in post:
for "notepad++" in post:
post False
>>
>>58823345
Where?
>>
>>58823409
completely wrong
>>
>>58823398
def memoize(function):
cache = {}
def helper(*args):
if args in cache:
return cache[args]
else:
cache[args] = function(*args)
return cache[args]
return helper

@memoize
def fib(n):
if n in (0, 1):
return n
else:
return fib(n-1) + fib(n-2)
>>
>>58823548
That... doesn't clarify what's wrong with the original code.

I want to know why it doesn't work. It seems logically and syntactically correct to me, but for some reason it's not working.
>>
>>58822205
i think the idea with C++ is that the programmer can alleviate compiler's need to do such checks by not being retarded
>>
>>58821899
I just looked at the guide, and you fucking retard should post issues with a langage you don't know two shits about.
>>
>>58823715
Shouldn't*
>>
>>58822808
Why don't languages make it explicit like scheme does?
(equal? A B) does a deep structural equality check
(eq? A B) compares references to see if they refer to the same object.
Then types have specialized comparison functions, e.g.
string=?, symbol=?, char=?, which operate on specific types of data and error otherwise
(= N M) works only on numbers
>>
>>58823773
As I recall, Python has both '==' and 'is'. There are other languages that make this distinction, which as you point out is pretty much essential with mutable objects.
>>
Why is Sepples so well designed, /dpt/?
>>
>>58823784
Sure but 'is' is the most ambiguous thing ive ever heard
>>
>>58823787
>Does your mother know you're gay?
>>
>>58823807
The name is just syntax. The most important thing is that languages have both and equal-value and same-object check.

Actually, I hate that ugly checks like these are required. If everything is immutable, the problem evaporates.
>>
Is SICP a meme or actually a good book?
>>
>>58823928
Yes
>>
>>58823928
No
>>
>>58823864
>If everything is immutable, the problem evaporates.
Right, because then you can't do cheap same-reference checks any more and you'll always have to do the expensive one.
>>
>>58823951
You seem upset. Maybe you should talk to someone who wants an argument :)
>>
I got offered a position for 45 dollars an hour working on Java legacy code... is it a trap?
>>
>>58823928
Maybe
>>
>>58823969
That's insanely good pay no matter how you slice it.

Go for it.
>>
>>58823960
Considering this is my first post in this thread and I didn't use a single swear word I wonder why you think that I would be upset.
>>
File: spain-fs8.png (582B, 402x402px) Image search: [Google]
spain-fs8.png
582B, 402x402px
What does "Frictionless development" mean?
>>
>>58824102
lube
>>
>>58824102
BINGO!
>>
why are women the best programmers?
>>
>>58824102
I don't know, but it sounds xenophobic, racist, and sexist.

Please do not discuss it further, or you will be in violation of 4chan's Code of Conduct™.
>>
>>58824166
/dpt/ is a safe space board

all genders are welcome here
>>
>>58823443
>I only target a deprecated platform
>>
File: Screenshot - 060217 - 18:24:17.png (48KB, 796x509px) Image search: [Google]
Screenshot - 060217 - 18:24:17.png
48KB, 796x509px
>>58824125
>>58824137
>>58824166
i created a github account and this thing was on the right side bar
>>
>>58824039
The sarcastic 'right', but do carry on!
>>
>>58824189
Epic meme!
>>
I don't know what the hell I'm doing
name = input("What is your name?")
helloWorld = print("Hello world!")
helloName = print("Hello, %s!" % name)
print(helloWorld if " " else print(helloName))


Where can I get some documentation for this without being told the answer? I was told to make a helloworld script that would say "hello (name)" and if no name was given "hello world"
>>
>>58824299
> an if else statement inside a print command

holy shit that code
>>
File: cs degrees in 2016.png (59KB, 863x1047px) Image search: [Google]
cs degrees in 2016.png
59KB, 863x1047px
How does this make you feel, /g/?
>>
>>58824299
you cannot assign a print function to anything, it just returns None
>>
>>58824299
name = input("What is your name? ")
if len(name) == 0:
print ("Hello world!")
else:
print ("Hello",name)
>>
>>58824360
in non-shit languages, print functions return the number of bytes sent through stdout
>>
>>58824346
this looks like typical Java code I see nothing wrong with it
>>
>>58824345
This is what it outputs. It runs at least

What is your name?faggot
Hello world!
Hello, faggot!
None
None

I'm trying to figure this out from reading syntax
>>
>>58824373
>print functions return the number of bytes
disgusting

It's a verb, not a noun.

It should do something, not be something.
>>
>>58824377
Take a closer look, Pajeet
>>
>>58824389
I just glanced over it not looking through all that
>>
>>58824387
is that what they're teaching you?
predicate function naming is a design choice, an optional one at that
>>
>>58824389
what about it, Rajesh Kumar?
>>
>>58824346
why the fuck did you white out pieces of the code
>>
>>58824346
Is the issue the inputs after the main method declaration? Maybe they want comments or something?
>>
>>58824413
those are text fields

students are supposed to fill in the blanks
>>
>>58824413
you're suppose to complete it, retarded faggot
>>
>>58824299
>documentation
Start with this: https://docs.python.org/3/tutorial/index.html

There are a lot of syntactic and semantic errors in your code. What you were trying to do is:
name = input('What is your name?')
helloWorld = 'Hello world!'
helloName = 'Hello, {}!'.format(name)
print(helloWorld if name == '' else helloName)
>>
>>58824451
that code is still horribly wrong
>>
>>58824346
Going off pure memory
>PrintWriter
>throws IOException
>myFile
>outFileName
>hasNextLine()
>nextLine()
>outputFile
>close()
>close()
>>
>>58824466
how so?
>>
File: vomitchan.jpg (51KB, 600x600px) Image search: [Google]
vomitchan.jpg
51KB, 600x600px
>>58824346
>//Always do this to your files.
>ordering students to do shit without explaining what they're doing or why, like they're mindless sheep
>>
>>58824497
Welcome to computer science in university
>>
>>58824497
Pretty sure releasing I/O resources was explained at some point, and you're looking at a quiz/worksheet meant to reinforce this.
>>
>>58824539
Yeah, I'm sure memorizing a phrasebook is an excellent way to learn a language.
>>
>>58824557
programming is all about memorizing your libraries all you have to do is know all the libraries in whatever language you are working with
>>
File: 4d6.gif (3KB, 452x523px) Image search: [Google]
4d6.gif
3KB, 452x523px
I'm working on a game about Trump building a wall to keep zombies out. Very simple turn based strategy, mspaint 2D, just a bunch of buttons. I wanted experience with C# and sqllite. I was using VS community but last night it locked up and says I need to register. Is it safe to put in a fake name? Or is this some sneaky Jewish trick to get real id on my copy of windows and a fake name will fuck me up when I replace my cpu and need to call support to let me use my cd key because it thinks I'm trying to install on multiple machines? Can anyone recommend an alienating to VS that will let me use sqllite in my project easily?
>>
>>58824557
The point is that they were probably shown "why" in lecture and materials, whereas this is meant to be a judgement on whether they know what they should be doing.

You're making the false assumption that this worksheet is the only material presented to the student on the subject.
>>
>>58824592
*recommend an alternative
>>
>>58824592
/pol/ please go
>>
>>58824596
Well anon, without making false assumptions, that poster wouldn't have had an excuse to post his red_girl_vomitting.jpg anime image. You have to understand that to the physically and mentally obese autistic fuckwads that browse /dpt/, anime is very important.
>>
>>58824592
Make a Microsoft account and register the product.

There are also other development tools you can use, but there isn't an equivalent to Visual Studio for C# development. You could use VS Code, which is open-source, if you want.
>>
>>58824625
Being a retard and posting anime are separate things, anon.

That anon just so happens to post an anime macro and be retarded at the same time.
>>
>>58824586
That's fine, but if you ever came across a problem that couldn't be solved with someone else's library, you'd have to implement your own functionality and that's where "library programmers" really suffer.

Their teachers and material regularly discourage them from ever reimplementing anything that exists in the standard library so they never actually have to think.
>>
>>58824651
that never happens though there is a library for that
>>
File: 1467219408455.jpg (66KB, 595x806px) Image search: [Google]
1467219408455.jpg
66KB, 595x806px
>>58824592
>I have no actual intent to program anything
>>
>>58824629
When I register will that implicitly register my copy of windows as well?
>>
>>58824665
No.
>>
>>58824640
While you can be retarded and not like anime, the reverse isn't possible (if you like anime, you are automatically a retard). The poster posted anime, so we can safely conclude he's a retard!

I see you're not very used to /dpt/ anon, but that's ok, you seem like a nice guy. Don't let the animetards corrupt you.
>>
>>58824692
Nigger, I guarantee I've been here much longer than you.
>>
>>58824696
That may very well be, but that doesn't excuse you from the fact that your contributions are next to worthless and always have been.
>>
>>58824692
>have you ever gotten so butthurt over cartoons...
>>
CL fags, help
i have a loop macro, and i'm wondering if when I insert a macro in the body, it will expand
for example
i'd want
(loop as x to 10 
(cuck x)

to turn into something like
(loop as x to 10
when (= (expt x 3) 125)
do (format t "ayy lmao"))

and then it be run

you get the geist?
>>
>>58824692
>>58824704
You need to go back to /r/eddit.
>>
Please don't reply to people posting for or against anime.

Best case, they genuinely believe and care about what they're saying.

Worst case, they're false-flagging and fishing for (You)s.

In either case, it's not programming, and you should continue to post about programming with or without anime and not post about whether something has anime or not.

Thanks, /dpt/. We'll get there together.

>>58820533
>What are you working on, /g/?
I am learning about automated manipulation and management of cloud services in my favorite language.
>>
>>58824692
brainlet plz
>>
>>58824670
Thanks
>>
>>58824760
Please don't encourage anime-kin by validating their posts, lest you want to see more of "hay guys is anime programming?" and other bottom of the barrel anime validation.
>>
>>58824797
There is literally nothing wrong with Anime
>>
>>58824760
Please don't reply to people posting for or against hardcore scat porn.

Best case, they genuinely believe and care about what they're saying.

Worst case, they're false-flagging and fishing for (You)s.

In either case, it's not programming, and you should continue to post about programming with or withotu hardcore scat porn and not post about whether something has hardcore scat porn or not.

Thanks, /dpt/. We'll get there together.

___________

This is how stupid you sound. There's literally no reason to defend anime, it's off-topic bullshit and doesn't belong in /dpt/ (never has, never will).
>>
>>58824821
You know we wouldn't be having this conversation if you didn't start crying about an anime pic
>>
>>58823398
Bump.
>>
Holy fuck, C# is cute.

Why does /dpt/ hate it?
>>
>>58824821
>he substituted an entire post because animoooooooooooooooooooooooo
You're not in a position to criticize
>>
>>58824841
And I wouldn't be criyng about an anime pic if someone hadn't posted it in the first place. I'm not the one in the wrong here. Would you also tell me off if I were complaining about someone posting some hardcore scat porn instead?
>>
>>58824859
Vendor lock-in.

Until quite recently, you were SOL if you wanted to write C# code to run outside of microsoft platforms.
The language was always open, but it's standard library .NET wasn't open sourced until last year.

Now it's just a matter of "too little too late", as java has been fully open source for literal decades and never had this problem.
>>
File: download (1).jpg (5KB, 290x174px) Image search: [Google]
download (1).jpg
5KB, 290x174px
>>58824863
>And I wouldn't be criyng about an anime pic if someone hadn't posted it in the first place. I'm not the one in the wrong here.
Yes you are. It was a reaction image like any other, but since it was anime you got triggered like a bitch.
>Would you also tell me off if I were complaining about someone posting some hardcore scat porn instead?
No, because that's not allowed on an SFW board
>>
>>58824863
yes, this is not your safe space faggot
>>
>>58824915
superior Java master race can one language be so based?
>>
>>58824346
Why do they expect you to memorize these things, if I didn't know what to put or what I could do with an object I could easily just look at the java docs
>>
I want to build a compiler. I'm currently working through SICP and want to pick up the dragon book afterwards, is that enough?
>>
File: 1446507760697.png (184KB, 659x609px) Image search: [Google]
1446507760697.png
184KB, 659x609px
>tfw programming java, eating curry
can you get any more comfy?
>>
>>58824915
Frankly, I don't care what a language and its tools were; I care what they are now, and what I can do with them.

I can see why you'd feel that way, though.
>>
>>58825132
make factories
>>
What's the next step of learning programming, after basic shit like loops and classes? Becoming comfortable with the most used libraries?
>>
>>58825222
Make a project
>>
>>58825222
classes have nothing to do with programming
>>
>>58825222
algorithms, data structures, design patterns, CS level probability theory, discreet math, etc
>>
>>58825222
Understand OOP and FP.
>>
>>58825238
fizzbuzz, arraylists,top down pattern, flip a coin, binary math
>>
>>58825238
>>58825259
These
>>
>>58825222
list eaters
>>
>>58825249
https://www.youtube.com/watch?v=Qe026vn1tbc
>>
>>58825277
>hindi
garbageman.mp3.exe
>>
>>58825238
>algorithms, data structures, design patterns
recommended resources for these? Are the MIT ones i see sometimes on images here on /g/ actually worth it or are they just memes? What about o'reilly books?
>>
>>58820533
Thank you for not using an anime image
>>
File: 1485900658587.jpg (211KB, 1280x720px) Image search: [Google]
1485900658587.jpg
211KB, 1280x720px
>>58825442
Rude
>>
>>58825315


I'd find some lecture notes or something that covers similar topics but is more digestible

but pirate the 1312 page book too, why not
>>
>>58822519
That sounds like a hack solution. I will not do that.
>>
File: cat.jpg (388KB, 2048x1366px) Image search: [Google]
cat.jpg
388KB, 2048x1366px
>>58825442
>>58820533
>not catposting
>>
File: lupin_money.gif (1023KB, 500x361px) Image search: [Google]
lupin_money.gif
1023KB, 500x361px
>mfw GNU-males leave their code for all to see, losing all possible profit from their applications
>mfw closed source master race raking in the dosh
>>
File: 14853247509362.jpg (194KB, 1024x768px) Image search: [Google]
14853247509362.jpg
194KB, 1024x768px
>>58825521
>>
>>58825487
best doragon
>>
File: 1482598020770.png (3MB, 1840x2052px) Image search: [Google]
1482598020770.png
3MB, 1840x2052px
Does this mean C++ is a dead end and a waste of time? Yes, yes it does.

https://www.youtube.com/watch?v=NvWTnIoQZj4

>>58825222
>>
Just learned what lambdas are in cpp. Why would one use them over regular function pointers though?
>>
>>58825679
Lambas reduce code bloat.
>>
>>58825679
They're more badass.
>>
>>58825679
Function pointers can't capture data.
>>
C is love, C is lief
>>
>>58825487
God damn that looks aesthetic.

>>58825521
Careful, you'll summon "a ruff victory" fag.
>>
Is SICP+20 year old MIT videos a meme or an actually good idea for a beginner?
>>
File: 15589754.jpg (24KB, 640x360px) Image search: [Google]
15589754.jpg
24KB, 640x360px
I was learning C but then became exhausted, too much labor.

Now I am taking a short course on Golang as a breath of fresh air. It's so comfy.
>>
>>58825930
http://www.ccs.neu.edu/home/matthias/HtDP2e/
>>
>>58825930
just go through cs50 on youtube or edx
>>
>>58825487
She is just a Renge rip-off
>>
i have n quarters, how do I convert into this format "$dollars.cents"
>>
File: no.jpg (86KB, 824x720px) Image search: [Google]
no.jpg
86KB, 824x720px
>>58825981
>posting worst girls

Renge can't even plant rice correctly how is she going to write code?
>>
>>58825770
Lambas? One small byte is enough to fill the memory of a grown RAM.
>>
>>58826013
nigger
>>
is book
>Compilers: Principles, Techniques and tools
a crucial for a Java Pajeet?
>>
>.exe

Welp.
>>
>>58826089

The only thing a pajeet needs to be successful is google.
>>
>>58825651
That list is suspect. What did you guys like about The Mythical Man-Month?
>>
>>58826125
successful at*
>>
>>58826135
That list in general is a bit of a joke. Half of it is pop culture for casuals.
>>
>>58826013
Divide by four?
>>
>>58826135
Most of them are memes or old enough that you've probably already indirectly absorbed their advice because everyone else repeats it as fact.

I can guarantee nobody in this thread has ever read knuth's TAOCP and understood it on any meaningful level.
>>
File: help.jpg (21KB, 521x142px) Image search: [Google]
help.jpg
21KB, 521x142px
i managed to import boost into qt in a record time of 10 seconds, it just works

yesterday i tried to import libraries i wrote following a Microsoft tutorial about creating libraries and failed for 2 hrs

is this tutorial just not applicable or something? i have very little experience in c++. https://msdn.microsoft.com/en-us/library/ms235636.aspx
i now tried to emulate the folder structure of boost. it works totally fine for boost. when i try to use functions from this library i wrote following the tutorial, i get "illegal use of this type of expression" and ".Add must have class/struct/union". i'm using the functions exactly as instructed by the tutorial tho. i'm guessing it doesn't find the .cpp file where the functions are defined?

can somebody help? what am i missing?
>>
I care fuck you
>>
>>58820533
What your experiences in relation to those "95% off "x" language bootcamp; from 0 to master in 3 months" bundles online. Did a year of CodeHS back two years ago, learning basics of C, Javascrips and a tiny bit of markup. In short; enough to build a breakout bricks game and an infinite flying 2d heli between obstacles in Java.

Just finished conscription (Eurothingy) and looking to fill up the void til uni stars with something productive.
>>
>>58826307
make something small, like a phone game
>>
>>58826307
the problem with those bootcamps compared to a regular computer science or applied computing degree or diploma etc is you don't learn the most important thing about programming how to solve problems by logic courses, algorithms course, data structures, discreet math, and so on which are huge caps for you to become a good programmer
>>
How do any of you stand to just sit down and write programs for hours on end? I can barely make it through a into to syntax before I get so bored I almost fall asleep. Not trolling at all, just trying to see what you guys did to get started.
>>
>>58826404
take many walking and gaming breaks inbetween tons of breaks filled with whatever you like to do
>>
>>58825238
>>58826365
I didn't want to point it out the first time, but it's 'discrete'.
>>
>>58826345
It's been 2 years, forgotten most of what I've learned. But eventually I'll be looking into making some sort of simple game or tool.

>>58826365
My nations university system is free, so going to open classes/watching online classes wouldn't be a big issue.
I'm guessing what I need to know if it's worth the $40, as getting to know tools and basics would be necessary before moving to problem solving.
>>
>>58826404
If you can't stay awake, then it sounds like you aren't interested in it. My advice is do something else with your life that you find fun and engaging.
>>
>>58826404
Sometimes, I'll get a good idea that I want to see to completion and I'll pour all my spare time into working on a software project for weeks at a time.
It's so satisfying to have all the different components come together in the first working build and then building on top of it until it's reasonably feature complete and robust.

If this doesn't sound fun to you, maybe you should go do something else.
>>
File: 2017-02-06-162849_557x751_scrot.png (31KB, 557x751px) Image search: [Google]
2017-02-06-162849_557x751_scrot.png
31KB, 557x751px
there has to be a another way
it feels so spaghetti
>>
>>58826507
Are you dividing a dollar amount into coins?
I'm not sure what this does.
>>
>>58826507
the absolute state of LOOP
>>
Third React Native application.

I have a Node server that does OCR for it. Fun little pet proj so far.
>>
>>58826507
>all that loop
No wonder it's so spaghetti.
>>
>>58826542
here is code, run it pls
http://0x0.st/W2_.lisp
>>
>>58826194
nobody?
>>
>>58821596
teach me i'll be your loyal pupil
>>
is it hard to become proficient in Excel?

why do normies boast about MS Office knowledge?
>>
File: 147991065891.jpg (78KB, 600x850px) Image search: [Google]
147991065891.jpg
78KB, 600x850px
>>58826732
>pupil
I have forgotten this word existed.
>>
>>58826760
why post 2d women with cats when you have a 3d woman with a 3d cat in real life?
>>
>>58826622
It appears to work in SBCL.
>>
>>58826784
because 3d women aren't cute and don't have cat ears
>>
File: 1483684213593.png (228KB, 600x600px) Image search: [Google]
1483684213593.png
228KB, 600x600px
>>58826784
It's a catgirl with cat, anon.
Catgirls don't exist (yet).
>>
File: 1486061936910.jpg (41KB, 640x441px) Image search: [Google]
1486061936910.jpg
41KB, 640x441px
>>58826784
>tfw you don't have a 3d woman with a 3d cat in real life
>>
why can't you extend multiple classes in java?
>>
File: hrwah.jpg (60KB, 500x491px) Image search: [Google]
hrwah.jpg
60KB, 500x491px
>>58826784
This
>>
>>58826822
because it's shit
>>
>>58826788
yes, but its too spaghetti
how to refactor?
>>
>>58826854
can we agree 3d cats are cuter than 2d cats atleast?
>>
>>58826875
Yes, of course
>>
New thread:

>>58826877
>>58826877
>>58826877
>>
>>58826870
Write it in a functional style.
>>
>>58820911
It seems to me like the only way to do this is to put the key under the predefined shell object for all files, and then when a user right clicks on a file, have my shell extension check if that file is a .txt before initializing, but that's such a hack solution. Oh well.
>>
Recommendations on a textbook for learning C++?
>>
>>58827332
http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list
>>
>>58827362
Thanks pham
Thread posts: 317
Thread images: 40


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