[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: 322
Thread images: 17

File: 1503423052994.jpg (44KB, 640x496px) Image search: [Google]
1503423052994.jpg
44KB, 640x496px
What are you working on, /g/?

Old thread: >>62094155
>>
i've got to get child processes to compute a value in a 2 dimensional matrix and then have the parent plug it in to the correct place. i can't pass any extra information about the index it goes in to the child, and then have the child report it back to the parent. is the only way to do this a hash table to store and look back up the right index for its pid? i can't run the child processes one at a time
>>
I wish I could become a program
>>
Java has no place in academia
>>
>>62101164
Just fork() them all in turn, storing their pids somewhere and then join() them in the same order? I don't see the problem.
>>
Java has no place
>>
Java has
>>
Java
>>
For some reason I always misspell Java as Jave
>>
>>62101241
Ya blew it
>>
File: James_Gosling_2008.jpg (885KB, 1460x1469px) Image search: [Google]
James_Gosling_2008.jpg
885KB, 1460x1469px
heard you were talking shit
>>
>>62101241
I don't know what but there's something about this post I don't like
>>
>>62101209
the point is to allow the multiple processes to compute them in parallel, so doing them one at a time wouldn't give any benefit
>>
>>62101290
listen here punk if you want someone to solve your homework you better learn to read posts, now fuck off
>>
How do I call SIMD intructions from scala(java)?
>>
>>62101336
why are you mad?
>>
>>62101343
Use JNI to enter the realm of C.
>>
Question about C

My programming experience is java, c#, and a few web languages. I'm looking at some lessons and I see people using malloc when building arrays. Why is this necessary? Working through the ansi c book, I've been making arrays without doing this just fine. Is it dangerous to define arrays without malloc/calloc, or is it redundant?
>>
>>62101194
Fucking this.
In my uni one of the IT programs have fucking JavaScript course
>>
>>62101444
in the past you weren't able to write something like int a[n]; this is mandatory in c99 but optional in c11
>>
File: 1503748992863.jpg (157KB, 1024x768px) Image search: [Google]
1503748992863.jpg
157KB, 1024x768px
PROGRAMMING CHALLENGE

Make a £sd calculator. It must be able to add, subtract in £sd, multiply and divide by decimal fractions. Lowest coin is farting.
>>
Making a tool to design serializing/deserializing programs to export to different languages.
>>
>>62101444
malloc puts the array in the heap. normally it'd just be allocated in the stack frame, and destroyed when the function exits. as i understand it, may be mistaken
>>
>>62096863
has the patent actually expired?? fuck i wish i had a lawyer

>https://en.wikipedia.org/wiki/Term_of_patent_in_the_United_States
>>
>>62101444
Two reasons.
>size
Prior to C99, it was invalid to make an array of a size which isn't a compiletime constant. malloc allows that without problems.
>lifetime
An array allocated on the stack (i.e. the regular way) is only valid until you leave its scope. You cannot legally, for example, return a pointer to an array declared locally within a function. Anything you malloc is valid until you explicitly free it.
>>
File: 1501806894206.jpg (519KB, 1280x1079px) Image search: [Google]
1501806894206.jpg
519KB, 1280x1079px
>>62101467
more like
>do my homework for me
>>
>>62101467
>£sd
what
>>
Name ONE (1) cross platform C/C++ GUI kit that doesn't suck balls.
>>
>>62101520
>maki poster
As usually, he's dumb.
>>
>>62101562
https://en.wikipedia.org/wiki/%C2%A3sd
>>
>>62101562
Pre-decimal UK coinage
>>
File: 1502409681999.jpg (24KB, 480x360px) Image search: [Google]
1502409681999.jpg
24KB, 480x360px
>>62101575
>>
Don't know if this belongs here or on /sqt/.
How am I supposed to debug (using gdb/lldb) if I don't know where my program is fucking up?
I get a segfault but I don't know exactly what the problem is. So how do I set breakpoints?
>>
>>62101571

IUP
>>
>>62101650
too much to explain in a post
>>
>>62101571
Qt.
>>
>>62101650
if you're segfaulting then just run it through valgrind after compiling with -g
>>
>>62101571
dear imgui. but it's immediate mode, so it's only really suitable for realtime applications. and immediate mode kits are the only ones which ever don't suck balls, regardless of language. event-based approaches are forced to design themselves around requiring you to fragment the fuck out of your code
>>
>>62101742
Where would you start?
>>62101771
Well yeah but I need to be able to debug a program in general.
>>
>>62101809
https://www.cs.rochester.edu/~nelson/courses/csc_173/review/gdb.html
>>
>>62101824
Thanks. I'm guessing lldb is more or less the same shit with different commands
>>
>>62101840
Yes
>>
Simple reminder that Java is the best language to start with if you're a beginner.
>>
I hate occultists
>>
File: 1490484251912.jpg (36KB, 233x215px) Image search: [Google]
1490484251912.jpg
36KB, 233x215px
>>62102105
rude
>>
>>62102105
Occultists are pagans in denial.
>>
Common Lisp.
>>
>>62102159
Scala.
>>
>>62102087
Nah. Python is better. Teaches you good style and doesn't get you bogged down in immediately understanding types or the differences between compile- and run-time. Then introduce the student to functional programming with Haskell and assembly with MIPS. Introducing students to multiple programming paradigms early on helps them from becoming inflexible later on. Migrate to C and teach algorithm design and data structures, then finally to OO/interfaces with Java or C#. Then teach large-scale software architecture principles.
>>
Noob question: I know int, string etc. are types, but is Base type the same as Base class? For example in Visual Studio:

public class Card: Deck

and in the class view it says Card > Base Types > Deck
>>
>>62101444
Option 1 -> declaring a constant int variable at compile time and sizing your array with that variable. No problem, the size of the array is defined assigned in the stack at compile time.
Option 2 -> Defining an array at run time with a variable is dangerous and incorrect.
Option 3 -> dinamically allocating memory to satisfy the need of variable space ar run time. OK.
>>
>>62102230
Yes
>>
>>62101781
you mean nuklear
>>
>>62102238
thx
>>
>>62101166
Then go segfault yourself
>>
I do not at all understand C++ iterators, nor can I find decent documentation on implementing them yourself. Unfortunately I do not care enough to put in a real attempt to figure it out, and might just make an equivalent class. Which is an ugly, disgusting, hack. Probably just like iterators themselves, ultimately.

More or less I've created a simple ring buffer and want a relatively clean way to traverse it. Pretty much everything looks ugly, decadent, and degenerate to me at the moment. I do not know why I won't just die.
>>
>>62101129
If I told you I'd have to kill you
>>
>>62102087
You need a lot of setup to get started with Java.
>>
>>62102258
They look and feel like pointers.
>>
>>62102263
Ok. I'll suicide by information.
>>
>>62102285
Like?
>>
>>62102243
i prefer dear imgui myself, but nuklear is also immediate mode, so it reaps the same benefits in terms of API design
>>
>>62101650
$ gdb ./my-program
(gdb) r
bla bla bla
segfault ....
(gdb) bt


"bt" is short for "backtrace", and will show you the exact line where the segfault happened
>>
>>62102315
why would you use c++
>>
>>62102258
Pointers are iterators. Just use them.
>>
>>62102203
Kill yourself Pythonfag.
>>
>>62102311
Install jdk, install ide, setup PATHs.
>>
redpill me on
git merge
vs
git rebase
>>
>>62102393
both are useless
just save to the cloud from time to time
>>
>>62102393
Git rebase keeps your tree pretty and avoids superfluous commits just for the merge
>>
>>62102379
You don't need an IDE to code Java. The same applies to any other language.
pacman -S jdk8-openjdk
is all you have to type to get the JDK and set up the PATH variables.
>>
>>62102087
no, C is.
it's very minimalistic so it's easy to learn
with proper guidance most rookie errors are avoidable
you get some under the hood understanding
it gives a basis to other C family languages (+90% of the market share)
you can even slip in some basic debugging knowledge
makes you appreciate higher level languages

>>62102203
>this whole post
>>
>>62102404
thanks but no thanks

>>62102417
is that the only benefit?
>>
>>62102471
>outdated shit
>becoming less and less relevant as time goes on
>"""best to start with"""
lol
>>
>>62102471
>you get some under the hood understanding
I'm not a C hater, but what do you mean by this?
>>
>>62102258
>he didn't implement the most commonly used constructs in his c++ class
before we used something from the std namespace we implemented it first (with the exception of cin and cout)
>>
>>62102471
Writing in C++ like it's C is more comfortable than writing in C.

Daily reminder. C is no more "under the hood" than C++. The techniques that tend to stem from each are good to know, but as a whole, C really is just a more limited C++.
>>
>>62102517
I don't follow the meaning.
>>
>>62102471
Is K&R decent?
>>
>>62102579
Yes
>>
>>62102516
how memory is laid out, how pointers work, you can implement you own linked lists, trees etc

>>62102485
it's almost like you should learn basic concepts first, and then move on to the applicable stuff
you don't use long division, but you still learn it to understand what is going on in the background

>>62102579
It is , but it can be a bit dense if you are just starting out.
>>
>>62102542
>C really is just a more limited C++.
What can't I do in C++?
>>
>>62102471
>to other C family languages (+90% of the market share)
This is wrong.
>>
Ideal learning path:
C (basic computing) -> C++ (OOP) -> Java AND Scheme/Haskel (FP) -> domain specific stuff (python, R, mathlab, JS etc)
>>
>>62102669
C is irrelevant now. With Java 8 you can go straight to Java and give yourself the best opportunity of getting a job.
>>
>>62102669
>Java (FP)
>>
>>62102617
>how memory is laid out
malloc does all that magic for you, unless you write your own.
>how pointers work
That's true though.
> you can implement you own linked lists, trees etc
I can do the same in JavaScript, so I don't see why this is unique to C.
>>
>>62102659
c, c++, java, c#, go, d, rust
all of them a pretty similar in terms of syntax
>>
>>62102485
C will never be "outdated". The underlying logical constraints any given computational machinery, whether the human brain, a "computer" (which is not aptly named, and is actually a broader signal processor), a cell, or a group of humans, the underlying logic that drives the universe imposes slavery to certain constraints. You see it in every machine, and at every scale. C's symbolic grammar is close enough to these constraints that you're unlikely to ever see it truly outdated.
>>
>>62101129
Haskell.
>>
>>62102688
>C is irrelevant now
Then why all CS programs still have it?
>>
>>62102669
it would be easier to go C -> python -> C++ -> FP so you can get the idea of OOP before you dive into the sea of C++
>>
>>62102706
You work on Haskell
>>
>>62102431
Well if we are talking Linux, all you need to do to start using python is type python.
>>
>>62102669
I want to be relevant learning path:
Java/C# -> Python -> <insert meme lang>
>>
>>62102715
That's not even an argument.
>>
>>62102714
No, YOU work on Haskell
>>
>>62102571
I'm just saying that, in school we implemented our own iterators, before we used them on std objects
>>
>>62102713
>implying python is not closely as hacked together as c++
I'd rather put java instead of c++ desu
>>
>>62102480
By looking pretty I mean there won't be multiple branches forking and merging over and over. I usually create a branch, work there and rebase to master if there's other changes from someone else. Then I merge fast forward master so there's no merge commits.

If someone else has to merge your changes though, doing a rebase before the merge will ensure they don't have to deal with the conflicts themselves.
>>
>>62102669
Ideal learning path:
C++ -> nothing -> Assembly
>>
>>62102787
Ideal learning path:
nothing -> shitpost on /g/
>>
Ideal learning path:
HTML -> CSS
>wtf im a hacker now
>>
>>62102810
this desu
>>
Ok, you've convinced me /dpt/. I'm going to start wearing diapers to become a better programmer.
>>
>>62102918
Nobody told you to do that you fucking faggot
What the fuck is wrong with you?
Fuck off to whatever awful place you come from
>>
>>62102918
No socks?
>>
File: enlightenedmind.jpg (64KB, 526x523px) Image search: [Google]
enlightenedmind.jpg
64KB, 526x523px
>>62102810
>>
>>62102979
>Fuck off to whatever awful place you come from
4chan??
>>
>>62102918
Diapers are for gayming. Socks are for programming.
>>
>>62102998
Romania
>>
>>62102998
>4chan??
That place disgusts me
>>
Again, with everything Java 8 brings, along with the ease of Eclipse; it's clearly the best language to start off with.

After that, you can get started on Python if you want.
>>
>>62103046
Java 8 made Java better than C#.
>>
>>62102981
I already have the socks

Wow guys this really feels right, I actually feel like this will seriously help with my productivity
>that crinkle when I sit at my cubicle
wow!!
>>
>>62103046
SICP
I
C
P


Scheme doesn't have edge-cases
Scheme doesn't have a distinction between primitive types and reference types that crops up almost everywhere once you move beyond the basics
Scheme doesn't have NullPointerException
>>
>>62103046
Java 9 is right around the corner. They've finally replaced the shitty HttpURLConnection.
Java 10 should be even more interesting with Graal.
>>
>>62103081
>Scheme doesn't have a distinction between primitive types and reference types that crops up almost everywhere once you move beyond the basics
barely matters outside of generics
>>
Whyms'td've do I need non-free, proprietary firmware to use my intel wireless card ?
>>
>>62103104
Because fuck you - Intel.
>>
>>62103092
Let me use an ArrayList instead of an array to manage a collection of objects because it's easier to work with, that's fine

Let me use an ArrayList instead of an array to manage a collection of doubles because it's easier to work with, oops my program's performance just fell off a cliff

Sure, it's just generics, but they're used pretty much everywhere in Java.
>>
>>62103131
How did people even use Java before Java 5?
>>
>>62103138
Lots of casting to and from Object.
>>
>>62103104
because your wireless card has non-free tech. you can use a dongle to get around this. also intel wants there to always be a backdoor.
>>
The STL is so bad. Now I understand why go doesn't want generics.

I can't even make a fucking pair in this language.

>auto pair = std::make_pair(x, y);

How the fuck does this not work. And what the fuck does "cannot convert from 'initializer list' to '_Mypair'" mean?
>>
Business idea: an application that lowers a team's productivity. Then you sell it to your client's concurrents.
>>
>>62103146
So... Go?
>>
>>62103167
4chan and anime already exists, anon
>>
File: 1503597262963.png (689KB, 1280x720px) Image search: [Google]
1503597262963.png
689KB, 1280x720px
What do you guys think of starting students out with a higher level language like Java or C#? I think it's nice in that it gets beginners going quicker, but in my own experience it was a bit of a pain to go from Java to C because I actually had to think about how the computer sees data. I don't really think one way is better than the other, but I'm just curious to know your guys' thoughts.
>>
>>62103177
Yes. "Object" is shorter than "interface {}", at least.
>>
>>62103167
Congratulations you just invented microservices.
>>
>>62103167
>C++
>>
>>62103182
How do I sell 4chan to my client's concurrents?
>>
>>62103046
>Eclipse

I'd start with python or C. Relying on an IDE from the beginning doesn't sound like a good idea to me, Java forces your hand to use one.
>>
>>62103104
You should disable your wireless card, because it causes brain damage. Put the computer in an aluminum foil box if it still emits its carrier signal, as even static fields are none too grand for you.
>>
>>62103195
explain
>>
>>62103189
Java and C# are weird since they're so heavily OOP. There's a strange hump at the beginning where you just have to accept writing all these weird meaningless keywords.
>>
>>62103199
advertise it like the best place for nu-male memes obviously
>>
>>62103046
Kotlin is like Java 12 today
>>
>>62103245
I dislike Kotlin because
identifier: type
is cancer and the generics are somehow even more fucked up.
>>
>>62103262
You better get used to it
>>
>>62103245
Kotlin is shit compared to Java8.
>>
>>62103160
is that exactly what you have typed?
>>
>>62103278
I'll just continue to use dinosaur languages.
>>
>>62103285
Yep. x is std::string and y is std::unique_ptr<MyClass>.
>>
I have a question for people with high iq.
I just read a problem that had this sentence
> The barrel used in the petroleum industry equals 42 U.S. gallons.

If you didn't know that petroleum barrels are 42 gallons before do you know it now? And I mean do you save this information in your memory or you forget it when your done with the problem?
>>
>>62103189

In my opinion Python is the best langauge to start with until you get fluent, then I'd swap over to C. Python gets working code out faster than any other language, and also gives you a nice introduction to both imperitive and OOP.
>>
>>62103353
>implying an integer test score that summarizes cognition is at all significant
>further implying that intelligence has something to do with memory
not sure where to begin
>>
>>62103160
I've had a similar experience with unique / shared_ptr.
std::unique_ptr<type[]> ptr;
ptr = new type[num];
should work. But it does not. I don't remember the working syntax because I rarely use this stuff and just copy and paste the "working version" every time. I gave up on make_shared, it didn't function intuitively so I said fuck it. Never bothered.
>>
>>62103189
>>62103354
python is a shit language, and it's worse for beginners because it's full of idiosyncratic """features""" that you'll have to unlearn because it's literally just python being retarded
>>
File: dude.png (193KB, 512x512px) Image search: [Google]
dude.png
193KB, 512x512px
>>62103369
>>implying an integer test score that summarizes cognition is at all significant
Keep reassuring yourself brainlet
>>
Not really programming, but I'm trying to get mopidy working with ncmpcpp and it's making me retarded. I get no sound.
>>
>>62103399

Be specific.
>>
>>62103415
shit lambdas, shit OOP, meaningful whitespace
>>
>>62103371
Found some more debugging info in the compile output:

>error C2440: '<function-style-cast>': cannot convert from 'initializer list' to '_Mypair'
>note: No constructor could take the source type, or constructor overload resolution was ambiguous
>template instantiation 'std::pair<std::string,std::unique_ptr<Shader,std::default_delete<_Ty>>> std::make_pair<std::string&,std::unique_ptr<_Ty,std::default_delete<_Ty>>&>(_Ty1,_Ty2)' being compiled

Not sure why there's an std::default_delete in there, it's specifically made like this:

std::unique_ptr<Shader> shader = std::make_unique<Shader>(vs, fs);
>>
>>62103424
>shit OOP

little redundant there fella
>>
>>62103433
Is the unique_ptr an lvalue?
>>
>>62103369
>implying that intelligence has something to do with memory
Never implied that
>>
>>62103424

It's not LISP, all OOP is shit and the whitepace can't be meanlingless if it's the syntax dum dum.
>>
>>62103447
I... think so. Here, have the entire function:

    char* vs = (char*)vertexShader.c_str();
char* fs = (char*)fragmentShader.c_str();
std::unique_ptr<Shader> shader = std::make_unique<Shader>(vs, fs);
auto pair = std::make_pair(resName, shader);
>>
>>62103467
You can't copy construct a unique_ptr.
Try putting std::move(shader) instead.
>>
Who else /diaperdev/ here?

>crinkle crinkle
>>
>>62103495
Fuck off, degenerate.
Nopan best pan.
>>
>>62103424
van Rossum has tried several times to remove lambdas from the language entirely, along with any other functional constructs.

Python is basically the gnome 3 of languages.
>>
>>62103450
It does. Intelligence is relative. Memory storage, structuring, and recollection machinery is important for myriad tasks. The performance of which certainly factors into a given system's intelligence.

Ultimately you can have a very, very, stupid system made of very good parts. It's about the performance of individual subsystems and how they relate within the greater whole.
>>
>>62103296
unique_ptr is for unique ownership, so it can't be copied. move it into the pair with std::move(y) (note that this will invalidate y) or use a shared_ptr
>>
thoughts on cython lads?
>>
>>62103466
>all OOP
Elaborate. OOP lends itself well to creation of programs made of state machines, which is very efficient as far as controlling overall program state, and minimizing cache misses. It can afford much better locality.

OOP is not intrinsically bad. It's just often done wrong. Omnipresent masses of shit programmers are clouding your perception in a myopic and childish way.
>>
>>62101194

its widely use by lots of industries

so fuck off
>>
>>62103489
>>62103545

I see, hmm. That makes sense when you put it that way. Maybe it should be a shared_ptr. My plan was to create a container for these shaders, like std::vector<std::pair<std::string, std::unique_ptr<Shader>>> (originally I wanted a map, but then you guys taught me how shit STL maps are), put the container in a resource manager class, and pass out references to the shaders to whoever requests them. To me this sounds like the resource manager (or container inside it) should have unique ownership of the shader pointers. Is my thinking wrong? I don't know the implementation details of unique_ptr and shared_ptr so maybe this is nonsense and they should really be shared_ptrs instead.

Thanks, helpful anons.
>>
>>62103617

its /g/ dude, i wouldn't be surprised if theres a faggot somewhere hating on binary number
>>
>>62103633
All of that sounds great.
The resource manager class is a single point of ownership. i.e. only the resource manager needs to worry about deleting the pointer when it is done - the references that are passed out will not outlive the resource manager. This is the perfect situation for a unique_ptr.
>>
Where can I find inspiration for useful programs that I can put on Github to help me land a job?
>>
>>62103617
OOP definitely has its problems, but so does every programming paradigm.

Functional languages are best girl though
>>
let's say i learn c++ from bottom up.
now i want to learn c#. how to approach learning of c# to make it quick?
i assume there's no point in learning about variables again.
how to people who have at least 1 language under their belt learn more languages? surely not from scratch i presume.
>>
>>62103778
You just start using language number 2 and google "how do i do xyz in C#", but this time you already know exactly what you want to do (xyz), so it's easier to google for than when you first started out.
>>
File: blob_2017_08_26_23_07.webm (2MB, 1920x1030px) Image search: [Google]
blob_2017_08_26_23_07.webm
2MB, 1920x1030px
Please consider trying out my ambient background visual!

https://youtu.be/bSWtZhpo8IQ
>>
>>62103804
back to >>/agdg/ with you kid
>>
>>62101258
At least you don't misspell it as Jaћe
>>
i wasn't giving waitpid() all the arguments it needed, but gcc didn't say anything because it turned out i didn't include the header file it needed. but it didn't say anything about not knowing what waitpid was. which confuses me. was GCC just bugging out or what?
>>
>>62103986
Gcc recommanded command
gcc -std=c89 -Wall -Wextra -pedantic -Werror -Wfatal-errors
>>
>>62104014
>
-std=c89
>>
>>62104014
>c89
>not gnu99
>>
>>62104014
can you break this down? i'm assuming you're memeing with c89 but i'd really like to know how to avoid this stuff in the future
>>
>>62104081
c89 isn't entirely a meme, it's the only c revision that's truly portable (MSVC fucks up anything later, but that's a fucking C++ compiler so who cares)
everything else is just about raising errors on everything that smells funny
>>
>>62104081
>i'm assuming you're memeing with c89
I am not.
>>
>>62104110
retard
>>
Hello /g/ents,
I am throwing a little something in C, and am at the user input part in the console, is there anyway to do this given the following constraints (readline forces you to deal directly with dynamically allocated memory so I'd avoid it if possible):
1- Should be totally standard, i.e compiles with the c99 flag and similar.
2- Abstracts away the char stack and the need to maintain it and growing it when necessary.
3- Clean interface that will interact seamlessly with the standard library, I remember someone doing a drop in replacement for the char* data type but am not sure where I've seen it.
4- Light footprint, I am in C mainly for the compactness and the fast executables, so I avoid bloat like the plague.
5- This is something personal so I am willing to excavate a solution outta another project, licensing is no problem here.
Given C's intentional limited arsenal, compared to say common lisp, this should be a recurring problem for all console app devs, how do you deal with this, do you roll your own for each project, do you have a set of routines that do the heavy lifting, I am just curious to how others do.
>>
>>62103620
>its widely use by lots of industries
>so fuck off
Then industries can train people to use Java if they're so keen on using it. Keep your garbage to yourselves, please. We've had quite enough of industry "ideas".
>>
>>62103633
a unique_ptr has to be the *only* unique_ptr pointing to the object it owns. it can be moved (in which case the "moved from" unique_ptr will no longer point to the formerly owned object) but not copied, since that would create another unique_ptr pointing to the same object. you can still pass/return a reference to a unique_ptr, though, because it's just a reference to the one valid/owning unique_ptr, not a redundant copy

for a resource manager, unique ownership makes sense, since one would not expect the objects the manager owns to outlive the manager itself. but you will have to return requests for those objects as *references* to those unique_ptrs (or to the objects they own directly), not as unique_ptrs by value
>>
>>62104248
Coolio, thanks.


Alright C++ wizards, explain this:

I have this:
std::vector<std::pair<std::string, std::unique_ptr<Shader>>> _shaders;

This works:
    _shaders.push_back(std::make_pair(resName, std::move(shader)));


While this doesn't:
    auto pair = std::make_pair(resName, std::move(shader));
_shaders.push_back(pair);


Neither does this:
    std::pair<std::string, std::unique_ptr<Shader>> pair = std::make_pair(resName, std::move(shader));
_shaders.push_back(pair);
>>
>>62101467
Okay, done.
Lsd       ← 0 20 12 4
in_lsd ← {⍺⍺ (Lsd ∘ (⊣ ⊤ ⊥) ⍵⍵) ⍵}
plus_lsd ← in_lsd +
minus_lsd ← in_lsd −
times_lsd ← in_lsd ×
over_lsd ← in_lsd ÷
>>
>>62101467
>Do my homework
>I won't even do an effort on explaining it
>£sd calculator
>what do you want to calculate with lsd
>calculate != conversion
>I'll get an image and put a title with mayus so people feel attracted to my bullshit
>The fact that I won't learn from my homework is not important to me
>I go to school because my mom...
>Why do we even study
>Lowest coin is farting
>if homework is made to reinforce what I'm learning and I can't do my own homework, that means I can't reinforce what I don't ever understand
>I'll change my post "How do I tell my mom engineering is not for me"
>>
File: scrs.png (54KB, 363x261px) Image search: [Google]
scrs.png
54KB, 363x261px
>>62103532
>gnome 3
explain
>>
Thoughts on Go?
>>
>>62104418
It's too autistic. I'd love for it to be good, but it's just not.
>>
>>62101571
Literally Qt
>>
>>62104437
on autism spectrum from assembly to python/javascript, where does it lie
>>
>>62104341
The copy constructor for a std::pair<std::string, std::unique_ptr<Shader>> is deleted. Thus the copy operation used in _shaders.push_back is broken.
If you never need to move ownership outside of the vector, and Shader is not polymorphic, then you have no need of a unique_ptr. In that case you can use a std::vector<std::pair<std::string, Shader>>>.
_shaders.emplace_back(resName, Shader(vs, fs);

_shaders.emplace_back(resName, {vs, fs});
>>
Why does vector not release its pointer, even when I want it to release its pointer.
>>
File: 1502357646102.jpg (177KB, 709x821px) Image search: [Google]
1502357646102.jpg
177KB, 709x821px
Why is the Rust community so unintelligent?
>>
>>62104509
huh?
>>
>>62104098
i don't develop anything on windows, so i don't need the portability. is pedantic the thing which would give an error if i used waitpid() without including its header file?
>>
Does anyone know why the windows console defaults at the size it does ? I just find it strange through all the versions of windows it still does that. I feel like if it was any other program it would have smarter defaults but there is probably a good reason why it behaves the way it does.
>>
>>62104341
same issue. in the second and third cases, push_back() is trying to make a copy of pair. you could use std::move(pair), but now that i think about it...

>>62104487
>If you never need to move ownership outside of the vector, and Shader is not polymorphic, then you have no need of a unique_ptr
is right, this would probably be fine in your case
>>
>>62104487
I see. I'm not sure I understand it though. In snippets 2 and 3, the shader is created somewhere on the heap that isn't under the vector's control, while in snippet 1 it's created somewhere vector controls? Is there a general term for this? Anyway, so I could use move semantics here as well? You're right that the shader isn't polymorphic though, so I'll just do that.

>>62104609
Aha, gotch! thanks for the reply mates.
>>
>>62104536
It can't be used for the convenience of its resize machinery, then the result taken out and its husk discarded. The data is tied to the lifetime of the vector, forcing either superfluous memcpys, or superfluous passing around of references. It's infectious and soon spreads like a disease.
>>
where can I learn python 3 in 1 hour?
>>
>>62104749
Code Academy
>>
>>62104675
Stack and heap allocation have nothing to do with this.
Move semantics means it's OK to invalidate the source object if it's a temporary (an rvalue).
 _shaders.push_back(std::make_pair(resName, std::move(shader)));

The result of std::make_pair is a temporary, so it's OK to rob its unique_ptr to take ownership within the vector. But in this case:
auto pair = std::make_pair(resName, std::move(shader));
_shaders.push_back(pair);

pair has a name, it's an lvalue. It's invalid to use a move constructor on an lvalue, and the copy constructor for pair<string, unique_ptr> is deleted because the copy constructor for unique_ptr is deleted.
>>
File: 1503605450887.png (391KB, 638x480px) Image search: [Google]
1503605450887.png
391KB, 638x480px
Post yfw amd64 doesn't allow you to store an immediate value to an address in a single mnemonic
>>
Why is perl such a disgusting looking language? It truly is write only.
>>
>>62104842
It can't be worse than bash or configure scripts.
>>
>>62104779
I see. This was very instructive, thanks.
>>
hello fellow trannies and cute programmer, what data structure do i use to perform lexical analysis on an html/xml file?
im thinking of a trie but that would be insufficient to extract things like 'attributes' or script, unless we have 10000 layer of maps which is dumbo
>>
>>62104771
Is Code Academy really worth checking out?
>>
>>62104862
>lexical analysis
FDA
>>
Why is Fortran such a beautiful language?
>>
File: sageAge.png (94KB, 443x660px) Image search: [Google]
sageAge.png
94KB, 443x660px
>>62104796
That's because the instruction would have to be stupidly long.
Doing a mov eax, imm; mov [eax], imm is negligible overhead compared to paying for two 64 bit immediates.

Even with just 1 byte of opcode and no mod/rm (which would be insanely stupid, realistically it should be a 2 byte opcode w/ modrm for something so rarely used), you'd still need 8 bytes of address and 8 bytes of operand.

Whoopsie, that's already 17 bytes for a single instruction!
And newsflash, the maximum instruction length allowed is 15.
>>
>>62104882

no bully :( im not on drugs i just want to practice my codingz
>>
>>62104872

Yes.
>>
Writing a Model View Controller Framework in C with no libraries

Wish me luck boyos!
>>
anons of /dpt/, do you also visit /r9k/?
>>
>>62105005
I'm building an aircraft carrier with a toothpick and a mountain of gravel. Wish me luck!
>>
>>62105028
fuck no
>>
>>62105028
The only boards I frequent are /g/ and /pol/
>>
>>62105055
>>>/pol/
>>
>>62105035
I've got the structure all worked out, I just need to study up on the HTTP standard and MIME types. I used the company printer to print out the HTTP RFC (don't tell anyone shhh)
>>
>>62104974
Better than Youtube tutorials?
>>
>>62104900
>eax
>>
Reminder that Haskell is obsolete

https://www.youtube.com/watch?v=3U3lV5VPmOU
>>
Does /dpt/ think this guy is correct?

https://www.youtube.com/watch?v=QM1iUe6IofM
>>
>>62105055
Same but /int/ instead of /pol/, although they feel the same
>>
>>62105005
Nice it's actually rather simple to have something basic working since the idea behind MVC is just about passing messages. However I'm assuming you're aiming for something state of the art?
>>
>>62105093
Sorry I'm not used to long-form register names, I program directly in machine code ;^)

The only order I know is A, C, D, B, SP, BP, SI, DI, 9-15
>>
>>62105097
>>62105110
Why do people argue about this shit. I understand that technical stuff is our industry, but why do people argue so passionately about the tools you use to create something, and not creating cool things instead. I don't give a shit about typed vs. untyped vs functional vs oop. Just make some cool shit and get paid to do it
>>
>>62105028
I visit /sci/, /s/, /g/, /e/, /h/, and occasionally /diy/ and /mu/.

/mu/ is of course strictly for discovery and noting events that I may not have been aware of. Every 3 months or so. It's also good for messing with "Grimes is (un)attractive and (un)talented" shitposters. Which is amusingly still a thing after a year and a half plus.
>>
>>62105137
What do you mean by State of the Art?
>>
>>62105142
Go use assembly. You are now banned from using anything higher level than that because you "don't give a shit"
>>
>>62105153
State of the art usually refers to having the latest best practices/ideas implemented, usually pulled from academia. I though this would be the point of writing such a framework from scratch instead of plugging libraries together.
>>
>>62105153
In /dpt/, we believe that anything involving C is state of the art.
>>
>>62094057
what happened in 2004?
>>
>>62105173
>reading comprehension score: -50%
>>62105188
The tool you use to implement concepts is irrelevant.
>>
>>62105142
People argue about the things they understand. Everyone knows about programming languages, so that's what everyone argues about.
>>
>>62105173
you'd still be able to create higher level constructs in assembly. lots of people did that
>>
>>62105197
>The tool you use to implement concepts is irrelevant.
You must not know anything about code generation and how compilers actually work.

No, different languages are not simply different notation.
>>
fuking random numbers, messing my code's purity.
>>
>>62105147
i'd love to chat math with anons. i wish i could tolerate /sci/
>>
>>62105197
>The tool you use to implement concepts is irrelevant.
It is relevant when you try to use a tool that fundamentally cannot express the concept you are trying to express.
>>
>>62105244
You should stop assuming things. There's a reason academic paper rarely present the code they used to implement their research.
>>
>>62105249
I dont lurk sci, what is a bad about it?
>>
>>62105244
Sure they are

Java and C# and D are basically the same language
>>
What are some very different programing languages that force you to see things differently?
So far I have C, because it's how the machine works, Erlang, because of its merging of functional programming and actor model, Prolog because even though it's kinda like a functional programming language it's still feels different enough to belong to the list, Esterel because it's event-based programming but looks nothing like javascript and VHDL because it's dataflow oriented. What else could I learn in order to expand my mind?
>>
>>62105142
People like you are exactly what's killing the programming industry and community.

To quote from Clean Code:

>Yet even in the auto industry, the bulk of the work lies not in manufacturing but in maintenance—or its avoidance. In software, 80% or more of what we do is quaintly called “maintenance”: the act of repair. Rather than embracing the typical Western focus on producing good software, we should be thinking more like home repairmen in the building industry, or auto mechanics in the automotive field.

>Unfortunately, we usually don’t view such concerns as key cornerstones of the art of programming. We abandon our code early, not because it is done, but because our value system focuses more on outward appearance than on the substance of what we deliver. This inattentiveness costs us in the end: A bad penny always shows up. Research, neither in industry nor in academia, humbles itself to the lowly station of keeping code clean. Back in my days working in the Bell Labs Software Production Research organization (Production, indeed!) we had some back-of-the-envelope findings that suggested that consistent indentation style was one of the most statistically significant indicators of low bug density. We want it to be that architecture or programming language or some other high notion should be the cause of quality; as people whose supposed professionalism owes to the mastery of tools and lofty design methods, we feel insulted by the value that those factory-floor machines, the coders, add through the simple consistent application of an indentation style. To quote my own book of 17 years ago, such style distinguishes excellence from mere competence.
>>
File: mccarthy.jpg (49KB, 476x659px) Image search: [Google]
mccarthy.jpg
49KB, 476x659px
>>62105142

>I understand that technical stuff is our industry, but why do people argue so passionately about the tools you use to create something, and not creating cool things instead.

most cool things doable by one person have already been built, the tower of babel we've got with our language ecosystems is preventing people from collaborating on large projects

there are also problems in stuff, like say, operating system design, like determinism, formal verification, test automation, and security, whose solutions are trivial in functional programming, and yet C programmers still insist on writing shitty unix clones with new features barely approaching those properties and claiming progress as they crawl on their hands and knees towards areas of revelation functional programmers figured out decades ago

the problems the tech world are running into are now mostly social ones, not technical ones
>>
>>62105320
can you agree that an operating system written in a functional language is a comical notion? because i'm getting vibes from this post that you don't agree with that general consensus
>>
>>62105309
You could try SQL or state machines / automata (like grafcet or ladder) next, or an esoteric language like piet or brainfuck, where you have a direct access to an instruction pointer.
Sounds like you've tried most of the main paradigms though.
https://en.wikipedia.org/wiki/List_of_programming_languages_by_type
>>
>>62104136
You could use:
typedef *char String
>>
>>62105390
Wouldn't you just need a png decoder, then strip out the filter bytes?

You should try fitting a gAMA chunk to the data. It may work in rare cases, and compress better.
>>
>>62105405
I already know SQL and Piet. SQL doesn't bring anything new in my opinion and although Piet is fun to implement it doesn't really extend your mind.
Maybe I should go into formal verification next.
>>
>>62105409
I'm pretty sure that's not how you typedef a char*
>>
>>62105309
Try writing a binary adder using the markov algorithm, (also knows as rewriting algorithm not the statistical more known markov).
>>
>>62104379
Nice! Though, I didn't require to count in multiply and divide by Lsd.
Do you know J, by the way?
>>
>>62105309
https://en.wikipedia.org/wiki/Probabilistic_programming_language
i feel these must be a trip
>>
>>62105400

no? there is actual quite a bit of research on it?

you do know that hardware architectures are written and verified in functional languages right?
>>
>>62104407
>homework
>in summer
>>
>>62105481
you're just a functional fanboy
>>
>>62105473
I'm not very interested into statistics but it does indeed look like it could change one's way of seeing things, thank you.
>>
We all know that it doesn't matter which language you use, /dpt/. So teach me monads in Java, not Haskell.
>>
>>62105528

t. mathlet
>>
>>62105504
You mean an iTXT chunk?
>>
>>62105605

if you stick on the language you were taught in your community college class you're going to remain a shitty programmer
>>
>>62105605
what for?
>>
>>62105481
>you do know that hardware architectures are written and verified in functional languages right?
you do know that this doesn't mean functional language runtimes implemented on such architectures will be particularly efficient or practical right?
>>
>>62105621

Not sure. It's whatever chunk this function involves:
http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Desktop-generic/LSB-Desktop-generic/libpng12.png.get.text.1.html
>>
>>62105606
functional languages
+ easier to learn
+ easier to write in
+ faster development time
- slower
- less fine-control

how does any of this make them useful for writing an OS?
>>
>>62105658
because both your cons are incorrect so you just answered yourself
>>
What is the best way to do random numbers on an old C++ compiler ? I don't have C++11 compliance so i can't use MT. I also don't want to use rand() because I want true probabilities that aren't distorted by using modulo.
>>
>>62105658
https://wiki.haskell.org/Applications_and_libraries/Operating_system#Standalone_operating_systems

house paper is cool
>>
>>62105677
his cons are the only ones that are definitively right. the "pros" are highly debatable
>>
>>62105649
iTXT is plaintext, zTXT is zlib compressed text.
>>
>>62105646

most compiler research, even for imperative languages, is done using functional techniques, so you're wrong, you don't know what you're talking about

>>62105658

>slower

functional languages aren't inherently slower, C, C++ etc, compilers are just more contributed to because there are more C programs and programmers out there

the Stalin Scheme compiler has outperformed C

>less fine-control

there is nothing preventing you from doing manual memory management in a functional paradigm, FP != pure haskell all the way down
>>
>>62105701
ok if you say so lol
>>
>>62105678
there's likely an OS-specific C library that'll help you, like arc4random or maybe something a bit more portable like openssl/rand
>>
>>62105701
>>62105528

why are imperative programmers proud of being idiots?
>>
>>62105678
use pcg (either the library or implement it yourself, it's super simple):

http://www.pcg-random.org/
https://github.com/wjakob/pcg32
>>
>>62105110
Shit, why is compiling v8 such a pain?

No, I don't want to use your embedded weird version of libc++ that WON'T LINK with anything else, I don't want 50MB of your libicu fork, and I sure as hell don't wan to copy your binary snapshot files along with my executables just so the damn thing will start without crashing.

Seriously.
>>
>>62105730
i'm not an "imperative programmer" or a "functional programmer". i'm not even shit talking functional languages since i LIKE them. you're just being thick
>>
>>62105788
likely because, like with most Google products, they were designed and maintained for Google and splitting it off to a reusable open source component was a massive afterthought.
"LLVM wasn't moving they want they wanted it (speed, direction, whatever), so lets make our own libc++ for now, so Chrome can get out the door faster."

(and the conspiracy that Google makes it intentionally hard to make any derivative so you're bound to rely on them..)

why not use duktape? if you care about performance, why are you using javascript anyway?
>>
>>62105736
thanks for showing me PCG. really clears a bunch of stuff up for me.
>>
>>62105863
>why not use duktape?
Duktape sounds cool didn't know about it, but I need speed here.
Yeah, JS and performance, I know.

>if you care about performance, why are you using javascript anyway?
So I'm writing a JS static analyzer, and it has to run code to resolve imports/exports because JS is a terrible language, plus it that emulates part of the code with partial context to find out what types variables have, what arguments are actually used, etc.

It has to essentially be able to simulate all possible branches in your CFG, including most of the crap in those millions of lines of dependencies people have in their node_modules.

At least some of that code is going to get executed (minus the side effects and dangerous builtins, for obvious security reasons) so I'm going to need the interpreter to be FAST.

I probably won't need Crankshaft since I only execute things once and don't run long loops, but I think I'll make good use of v8's Ignition engine.
>>
>>62105912
no problem. there's a great talk about it (and PRNG in general) by its creator here:
https://www.youtube.com/watch?v=45Oet5qjlms
it's definitely worth the watch
>>
#include <QDebug>

int main(int argc, char** argv)
{
qDebug() << "Hello World";
return 0;
}



What's this syntax again?
What type of object is qDebug()? Please don't laugh at me.
>>
>>62106143
an ostream or iostream, or something that works similarly to one. the C++ standard library uses >> and << operator overloads for stream in/out operations. looks like Qt does something similar here
>>
>>62106143
qDebug is a class
qDebug() is a function returns an instance of this class (a default/cached/singleton)
<< is an operator defined on the class which does something with the rhs ("Hello World" here)
>>
>>62106143
also, the docs:
> http://doc.qt.io/qt-5/qtglobal.html#qDebug
>>
>>62106210
thanks.

>>62106214
thanks. You seem really smart, anon.
>>
>>62105736
>2017
>still no comparison against xorshift128+ or xoroshiro128+
admit your defeat pcg shill
>>
>>62106325
>xorshift128
My nignog
>>
>>62106325
pcg passes TestU01 BigCrush with fewer bits of state than xorshift (quite a bit less than 128 as i recall). not sure about the other one
>>
>>62106469
having fewer bits of state isn't necessarily better especially when xorshift is a bit faster anyway. you could even go for xorshift1024* if you wanted to

http://xoroshiro.di.unimi.it/#quality
>>
>>62105492
>It's still summer in the whole world
>My world is so small I think everyone is american
>the world is flat and we have the same back-to-school date
>I'm trying to defend myself from this >>62104407
with this argument >>62105492
>I have no place in 4chan
>>
>>62105492
school's in session where i live at least
>>
>>62106524
>having fewer bits of state isn't necessarily better
it tells you that the algorithm has inherently better statistical quality. having that without paying costs in speed/space/code size/predictability/etc is what i'd call better
>especially when xorshift is a bit faster anyway
are you certain of that? i've heard otherwise. and the bit depth is a also a factor since crossing certain boundaries means added/removed operations, and pcg means lower bit depths for the same quality
>you could even go for xorshift1024* if you wanted to
pcg can also be implemented to arbitrary depth, but it already fully passes every quality test at well less than 128 bits, so there's no reason to go higher
>>
>>62105492
The world is round retard. ~pfft
>>
>>62104771
that is python 2.7
>>
>Meteorological summer begins on June 1 and ends on August 31 every year.
perfectly reasonable and intuitive

starting the summer at midsummer (it's called freaking MID summer, come on folks) doesn't make sense, maybe for astronomyfags but not in common usage
>>
>>62106759
>meteorological
You sure you don't mean astronomical or something?
Because summer here is defined by meteorologists by average temperature and some sort of day count where there's not supposed to be a dip below a certain temperature. Iirc this makes sense for animal and plant life.
>>
File: tk_2017-08-26_18-52-18.png (49KB, 974x891px) Image search: [Google]
tk_2017-08-26_18-52-18.png
49KB, 974x891px
Screwing around with Tk continues.
>>
>>62103212
https://devnull-as-a-service.com/
>>
>>62101129

My father and I are close to our first release of a Linux distro for old people. Large type, simplistic mail, calendar, video call, ect. All easy for older people to understand and use.
>>
>>62107361
isn't that more of just configuring stuff ? what did you actually have to program ?
>>
>>62107430

Mainly just a lot of GUI design. There's a few things that we wrote ourselves that needed extremely limited functionality.
>>
>>62104779
Just std::move() the pair
>>
>>62107430
linux des are shit
>>
>>62107455
that's pretty cool. I always had an idea of making a fap linux distro that was designed to operated with one hand and had all the good stuff for viewing and organizing your porn collection preloaded but i never get around to it.
>>
File: 1503783625751.jpg (181KB, 576x819px) Image search: [Google]
1503783625751.jpg
181KB, 576x819px
hello umikos i have this data structure in my mind that i dont know the name of. it is basically an n-ary tree.

the quirky thing about this tree is that the flow of the tree is not exactly top-down, but more like a web with a root.
>>
https://github.com/nodejs/node/issues/12115

>Node occasionally gives multiple files/folders the same inode

>Node sometimes reports different files/folders to have identical ino values.
>I can't reproduce this consistently and copying/reproducing a folder structure that contains dupes elsewhere doesn't replicate the issue.

and people actually think this is a suitable platform for backend development? what the fuck /g/
>>
>>62107902
Does it have cycles? Then it's a graph. If it doesn't, it's a tree.
>>
>>62107929
it is actually, yeah i remember graph.
boy i havent coded data structures in FUCKING AGES
>>
New thread:

>>62107950 >>62107950
>>62107950
>>
>>62107914
everyone knows you gotta be like mongodb to be fast. don't write no files, don't have no filesystem bottlenecks.

/dev/null is webscale
Thread posts: 322
Thread images: 17


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