[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: 36

Old thread: >>58542482

What are you working on /g/?
>>
what's the type of undershirt called that has thin straps
it's like a training bra but the straps are thin and it's longer
>>
>>58549458
Tank top?
>>
File: Rust wins! - Imgur.png (529KB, 1006x968px) Image search: [Google]
Rust wins! - Imgur.png
529KB, 1006x968px
>>58549458
Camisole?
>>
Learning C#.

Should i use ReSharper or will it just automate shit for me that i'd be better off doing myself?
>>
>>58549495
>Rust
>17
2017 Year of the Rust Programming Language
>>
>>58549495
>>58549508
fuck of shills
>>
File: c99.jpg (5KB, 248x243px) Image search: [Google]
c99.jpg
5KB, 248x243px
>>58549352
>"c++ is easier, anon"
>virtual function calls
>vtable
>shitty implementaton of mutexes
>procedures/methods are recognized by arguments and may have same names
>"lol, you don't need copy and paste, just slap these definitions 50 times in front of procedures/methods"
>template bloat
>c++11
>new versions being released like new OS
>streams
>STL / Boost

CPP should've been just C with classes and namespaces.

such retarded thing couled've been only designed in university
>>
File: logocaml.gif (5KB, 375x352px) Image search: [Google]
logocaml.gif
5KB, 375x352px
OCaml master race!
>>
>>58549536
>CPP should've been just C with classes and namespaces.
No. Good generics (ie. templates) and namespaces would have been enough.
>>
>>58549527
Fuck off nigger
>>
>C++ is too complicated for me :'(((
Then fuck off back to some baby language like Go or PHP
>>
>>58549557
I hope you mean properly parametric rather than with template specialization (which completely destroys any semblance of reasoning).
>>
How do you write DRM for software?
>>
>>58549600
Enjoy your buffer overflows.
>>
>>58549600
>if you don't like the insane complexity of C++ it's because you're a bad programmer lolol
Delusional C++ fags.
>>
>>58549616
you dont
good quality products is your DRM
>>
>>58549557
>generics
surprise, they're part of C11
>>
>>58549624
I would, but that usually only happens in C

>>58549629
The bad programmer blames the tools.
>>
>>58549624
>buffer overflows
>C++
>>
>>58549635
>The bad programmer blames the tools.
Doesn't apply. That would be me using C++, making bad software, and blaming C++ for it. I don't use C++.
>>
>>58549661
Oh it does still apply, yes. And not using a tool before criticizing it isn't exactly something to be proud of.
>>
>>58549685
I've used C++ in the past so I can speak from experience.
>>
>>58549536

you're misinformed anon
>>
>>58549630
How does a product being quality stop people from uploading it to the internet?
>>
>>58549694
Ok, so the crux of your argument is you've tried X and you don't like X so anyone who uses X is delusional.

I don't know what the world would be doing without your opinion — except, you know, using one of the most popular and powerful languages in the world.
>>
>>58549616
You don't. The only safe thing is to not put it, or at least a crucial component, on the user's machine at all. You can sell services, but not bytes.

Some people might want to still give you money in exchange to support you. DRM may turn these people away.
>>
>>58549735
No, the argument is that I've used C++ and agree with most of >>58549536 from experience, but it's not like I'm a bad programmer and blaming it on C++.
>>
>>58549614
Of course. Otherwise I would have just say template.
>>
>>58549775
Well, you did say template, so I'm just making sure.
>>
>>58549758
Most of >>58549536 is complete bullshit, though. Half of it is a list of feature, the other half is plain wrong, and the premise that C++ is easier is a strawman.
If you agree with that then clearly you haven't seriously used C++ before.
>>
https://gist.github.com/anonymous/bc588e55f3b9e69c9e11731c91a65ae5

template engine i wrote last week. can any anons give feedback on this so i can add/fix things?
>>
>>58549787
>Half of it is a list of feature
Bad (-ly implemented) ones. Though it doesn't touch on the particularly bad things at all, like how badly C++ implements copying and moving for RAII, the proliferation of different kinds of references, how it uses exceptions in general, etc.

>the premise that C++ is easier is a strawman
I don't agree with that part or the "C++ should have been C with classes" BS.
>>
>>58549536
What would you recommend me lord
D?
>>
>graduate
>unemployed for two months
>get a job
>lose it two and a half months later for bullshit reasons
>job hunt for a month and a half
>get to the last stage with a company then they decide they're not going to hire anyone
>job hunt for three more months
>get to the last stage with a company then they just ghost me for a month
>tfw I've now spent ~8/10 months sinceI graduated unemployed

programming was a mistake
>>
>>58549814
>mytpl.php
enjoy your shitposts anon
>>
>>58549928
Hell yeah (different anon tho)
>>
>>58549928
>>58549969
Enjoy your GC, tbqh
Might as well use Java or Python at this point
>>
>>58549944
It seems like you stopped hunting for jobs once you got to a good standing with a company.
Dont. I also needed 7 months until my employment started after graduation, and only got the job after being unemployed for 5 months.
>>
>>58549981
@nogc
>>
>>58549968
it's just a placeholder name. why would anyone shitpost because of the name?
>>
>>58549928
Rust
>>
>>58550028
Not used by any library, not even the standard library, so you can't really ever escape it.
If it exists at all, GC should be opt-in, not opt-out.
>>
>>58550036
>php
>>
>>58550054
>If it exists at all, GC should be opt-in, not opt-out.
And it shouldn't be global. It should be done regionally. And it shouldn't be tracing, it should work with RAII and simply make it more efficient to allocate and free memory.
>>
In C, how do I send two functions for different types (one for int and one for char) to a generic function depending on the type entered?
For example two print functions to a generic print function?
>>
>>58550078
So, essentially Sutter's GC library.
https://github.com/hsutter/gcpp
>>
>>58549928
Jai
>>
>>58549981
>Might as well use Java or Python at this point
lmao no, those languages are garbage
>>
>>58550143
My point exactly
>>
>>58550085
>generic
>c

Use macro.
>>
>>58550063
so? it's still being used and i don't see why i shouldn't use it unless i wanna be a hipster.
>>
>>58550185
I'm just practising.
I have two inputs, one char and one int,
Then I want to print all my chars in a way and all my numbers in a different way, but I want to have a generic print functions that sets up a printing loop instead of doing it separately in each function.
>>
D isn't even dissimilar enough from C++ for C++ to not incorporate its features and make it pointless. Sad!
>>
>>58549991
I keep hunting, it's just going nowhere
>>
>>58550313
Was that a sentence?
>>
File: slug.jpg (37KB, 500x461px) Image search: [Google]
slug.jpg
37KB, 500x461px
>>58550313
>Sad!
kys for real
>>
File: halp.jpg (20KB, 359x264px) Image search: [Google]
halp.jpg
20KB, 359x264px
I'm learning C# today and I was nailing this series of video tutorials and questions until I got to this one.

Go for it /g/, I already fucked up, I'm curious to see if anyone makes the same mistake.
>>
>>58550263
If you have 2 different vars, of 2 different types.
why do you want a to plug them both into the same function?
Make 1 function for each type...

If you have 1 abstract var which can be 2 types, then i understand where your coming from.
In which you need an id along with that abstract var to remember what the type is.
Then use that id to decide which of the 2 previous functions to call.
>>
>java
>no struct, union, enum, unsigned, typedef

kek

why even bother with C++?
>>
>>58549352
>/dpt/
>What are you working on /g/?
>NEETs proceed to argue about which language is best
>No mention of what anyone is actually working on

why am I not surprised?
>>
>>58550591
Hey
Why don't you post something
>>58550572
Because Java is hot garbage
>>
>>58550563
Answer is D. car - 2

(userValue == 1) is false so message is set to "car"
>>
File: elephant2.jpg (276KB, 1024x768px) Image search: [Google]
elephant2.jpg
276KB, 1024x768px
>>58550605
I'm actually here looking for ideas. I've recent set up some infrastructure for kicks on AWS and I am looking to put something on there.
>>
>>58550630
I thought it was C, 2 - Car

But now I see where I fucked up. Those {} kind of confuse the shit out of me.
>>
File: Viewer2017-1-18.png (73KB, 800x700px) Image search: [Google]
Viewer2017-1-18.png
73KB, 800x700px
>>58549352
Hey /dpt/ heres what im working on, a C SDL GL, txt editor/IDE.
The purpose is to minimize visual clutter (maximize code space) and allow easy and remap able click-buttons to my scripts.
>>58550591
Since your so interested please tell me what you think.
>>
I'm reading through "The D programming language" and testing every feature I come across to build a solid understanding of the language, before I write any actual code.
>>
>tfw can't fizzbuzz in c
>>
>>58549352

don't bother reading that book

it's irrelevant management masturbation material
>>
>>58550679

what do you get out of making something that's not interesting and has already been made
>>
>>58550717
>The purpose is to minimize visual clutter (maximize code space) and allow easy and remap able click-buttons to my scripts.
>>
>>58550691
#include <fizzbuzz.h>

int main()
{
fizzbuzz();

return 0;
}
>>
>>58550678
it was sort of a trick question

for things like Console.WriteLine() and String.Format()

the first argument goes to {0}, second to {1}, and so on
>>
>>58550683
Oh and so far it doesn't seem like a language that actually lets me do MMM conveniently. Which is extremely disappointing considering its advertising itself as a systems language. I'm sure there's some flag that disables all GC but to me that looks like you're basically disabling associative arrays and plenty of other nice features. There's no place where I can define an allocator for these features it seems.

I hope I'm wrong. Because down the road being locked to GC will be awful. My programs normally don't actually allocate memory with unpredictable sizes. And that's the only place where completely dynamic allocation shines.
>>
File: Haha-Faggot.jpg (21KB, 367x451px) Image search: [Google]
Haha-Faggot.jpg
21KB, 367x451px
>>58550605
>hot garbage
just be productive, write java code and don't spend half your life learning C++ you dummy
>>
>>58550772
'no'
>>
>>58550821
class yes {
public static void main( String [] args )
{
System.out.println("yes!");
}
}
>>
>>58550772
>just be productive, write java code and don't spend half your life learning C++ you dummy
I always wonder if these people realise what they're saying. This person is actually encouraging not knowing what the fuck is going on and leaving his fate in the hands of others completely.

And when you've chosen java, tried to avoid knowing intricate detail. You've also removed any attempt at relatively OK performance.

So why pick java then? It's not particularly expressive. The only advantage which isn't nullified now is its expressiveness and perceived portability among management. And even python manages to do both of those better.
>>
>>58550848
>Welcome to Java, where even the fucking main function has to be in a class
No thanks
>>
>>58550853
Not him, but performance is a feature.

If out of the box performance is "good enough" for your app why not focus on the app itself instead of wrestling with the language? productivity and being able to ship in a timely manner is also very important.
>>
>>58550853
>C++ outperforms Java meme

nice try but smart compilers do all the work anyway and Java is just as fast nowadays

but what's true C++ is nowhere near as fast as pure C, so that gotta make you realize that you've been wasting your life you colossal faggot

value YOUR time and use Java!
>>
>>58550887
>I will remain a C++ cuck because of a made up problem

whatever, anon.
>>
File: 1482471004598.jpg (29KB, 720x720px) Image search: [Google]
1482471004598.jpg
29KB, 720x720px
>>58549944
I've got you beat my friend:
>Graduate with ChemEng PhD
>Thesis primarily experimental but significant element of theory/modeling using both commercial and Fortran/Matlab simulations
>On-site interviews at oil and biotech companies but no job offer
>Desperately accept academic postdoc for shit pay thinking it will be similar work
>Find out it's 100% simulations
>Numerical method is fucking obscure shit nobody in industry will ever fucking use
>Prof keeps asking for more simulations so I can never try to work out my own ideas/experiments
>Finish postdoc
>Fucking NEET for 10 months now
still waiting to hear back from another interview but yeah, programming is a fucking mistake
>>
>>58550929
Where is this meme that C++ is somehow less productive than Java coming from
>>58550941
And why do I use C++ all of a sudden
>>
>>58550920
this

these faggots act like Java is Python or something when in reality it's on the same level as C++ without the headache
>>
>>58550941
It's actually part of a bigger problem, OOP-only
I'd rather use a language that gives me a choice
>>
>>58550955
Damn my dude take the PE exam and go make concrete, beer, or some comfy shit like soap.

You will make good money and can work on your own stuff in your spare time.
>>
>>58551007
you don't need to actually implement with OOP in your apps
>>
>>58550929
>Java is just as fast
Toppest of keks.
Java only comes close in some cherry-picked benchmarks, and even then only after fighting the garbage collector like mad.
>>
>>58551022
With Java, yes
Everything is an object
>>
>>58551048
>having objects = OOP

fuckin newfags
>>
>>58550929
I'm not a c++ programmer but C++ can certainly be as fast as C. You can be limited in certain choices you make, and sometimes (fairly rare if you avoid msvc) the compilers aren't up to snuff. But most abstractions are actually zero cost in C. Which would be impressive if it wasn't so extremely specific and limited.

If you don't understand what the limitations of compilers are and how java's JIT doesn't compared to people who care then you really shouldn't comment on this topic.

>>58550920
Yes. Exactly. If your out of the box performance is fine (aka, 'performance doesn't matter') why pick a language that's not more expressive than Java.

People don't pick C++ because it's the easiest language they know or because it's the easiest language to write their shit in. It's because it has characteristics that allow them the control they need.

Java just doesn't make sense for this hypothetical application we have. I'm not a high level programmer when we're talking java and C++ but I know they're quite far down the ladder if high level of expression is the goal.
>>58551022
But you're using a language that's built around oop entirely. The libraries you use provide an OOP centric interface more often than not etc.

You could do OOP in C but the lack of language supported inheritance would make it a mess relatively speaking. And I doubt the compiler could keep up. You run into the same (but opposite) issues in java/c++. Though the C heritage and multiparadigm of c++ leaves you more options.
>>
>>58550988
It can reach near C++ performance on optimised code after the JVM has had time wasting gigabytes of RAM on building caches and optimising it further. And then GC pause happens.
>>
>>58551059
>Java isn't OOP only
What am I reading
>>
>>58551074
>then GC happens
Hey. Anon. That's not what we're benchmarking here. We only time our inner loop. Don't be 'unfair'.
>>
>>58551078
It isn't. Programming with object doesn't mean you program in an object oriented manner.
But as I said here >>58551071
It doesn't make sense to use java if you're not doing oop because it's among the only convenience it provides.
>>
>>58551059
>nearly everything is an object
>not object-oriented
>>
>>58551078
being forced to do shit inside an object is not OOP

just write a fucking object you lazy fuck
>>
>>58551119
*object=class
>>
>>58551117
>nearly everything
I thought even 'primitives' inherit from object.
What doesn't inherit from object in java?
>>
>>58551179
Primitives. But they all have "boxed" versions (except void) that are necessary for using with generics because Java doesn't do monomorphization.
>>
File: code2.jpg (79KB, 731x960px) Image search: [Google]
code2.jpg
79KB, 731x960px
is this just a stupid meme?
>>
>>58551119
>just write a fucking object you lazy fuck
Maybe that'll work if you're just doing a FizzBuzz, but anything nontrivial will require OOP
Don't pretend you can avoid it in Java
>>
>>58551117
this is not even programming with objects but it's java so fuck off

class program{
function
...
function
function
main
}
>>
File: code1.jpg (60KB, 600x787px) Image search: [Google]
code1.jpg
60KB, 600x787px
and what about this?
>>
>>58551209
And you can't do anything without objects unless all you're doing is calling static methods and passing primitives around.
>>
>>58551207
you can easily avoid OOP

use functions, call outside libraries, you can write very nontrivial applications
>>
>>58551200
Yes unless you're a programmer that's working his first job and didn't even know the language before you started.

Or you're crap even after 20 years.
It's really just a meme.

Reading about algorithms is different though. You could search your issue, find someone suggests an algorithm (and wrote it in your language) on SO and then it'd be just foolish to not copy it assuming they've licensed it appropriately for your use.

In general if you're dealing with issues that you can Google effectively you're not at the core of your domain. Or you're just all a bunch of hacks at your company who literally do nothing because you're just repackaging wheels.
You should just be replaced by Indians in that case.
>>
>>58551200
> is this just a stupid meme?
no, it's just what working is
>>
>>58549944
>lose it two and a half months later for bullshit reasons
what's the "bullshit reason"
>>
I added a ScriptSystem with support for lua-scripting to my homebrew C++ Engine.

Fucked around with it and played a bit in WWise and shat out this
https://vid.me/rIUl

Pretty happy all in all
>>
>>58551221
>static methods
what difference does that make in my example?
>and passing primitives around
you wanted non-OOP programming in java
>>
>>58549928
>>58549969
This. D fuck yeah.
>>
>>58549557
>good generics (templates)
Wow. He used those words in a coherent sentence?
Radical.

Templates are a terrible generic programming feature and only people who have been introduced to it as their first would consider them OK.
>>
>>58551074
>And then GC pause happens.
then you're doing something very stupid
>>
>>58551346
Please enlighten me on how to never have GC pauses in Java.
>>
>>58551357
Don't use it.
>>
>>58551357
don't use java
>>
I'm working on my decentralized TV system (BasicTV). Currently i'm logging tons of networking queries so I can get a statistical likelihood that a certain node has wanted data. After this, I need to polish up some initiation and bootstrapping code, but I should be set after that (networking wise). I still need to implement Opus, but that shouldn't be hard, and a UI, which i'm not worried about (for now).

I also set up an IRC channel for the project (#basictv on Freenode, you can use webchat.freenode.net).
>>
What does dpt think about unit testing?
>>
>>58551357
if it's disruptive for your app then you're doing something wrong
>>
>>58551357
>Java
>>
>>58551398
Pretty important. I stress tested SDL2_net and found that it segfaults after around 500 TCP connections (i'm working on >>58551393
, so having an insane amount of TCP connections would be pretty helpful. However, 500 is probably too much for most routers).

Also, you can stress test and profile this way as well (although KCachegrind can work fine too).
>>
Hey /dpt/ what book is great to learn modern C++ ?
>>
>>58551499
learn Java
>>
>>58550572
why use structs when you can use classes? and java does have enums
>>
File: tmp_10937-th-1831805156.jpg (13KB, 228x300px) Image search: [Google]
tmp_10937-th-1831805156.jpg
13KB, 228x300px
>>58551499
pic related
>>
>>58551277
I got my work done too quickly and they didnt have any more work for me to do so my coworkers complained that I wasn't doing anything and they fired me
>>
>>58551357
If you don't want the GC to be a problem in a managed language then you have to manage memory yourself anyways through things like object pooling :^)
>>
>>58551421
That didn't answer the question
>>
>>58551628
it did actually

your code must be garbage
>>
File: argb.png (14KB, 1268x205px) Image search: [Google]
argb.png
14KB, 1268x205px
I'm writing a little program to take snapshots of the active window and save it to .png, with each program having its own folder, but I don't know shit about imaging.Which one of these should I pick for the best quality possible and transparency enabled?
>>
>>58551671
>how do you prevent GC
>you just do
Real informative, I expect nothing less from Javafags
>>
Why does updateList() only work if a two keys are pressed rather than on the first key? The other function works on the first key press
document.getElementById("searchBox").onkeyup = function(key) {
if(key.keyCode == 13) {
updateCard();
} else {
updateList();
}
}

function updateList() {
$("#entry1").val(document.getElementById("searchBox").value.toLowerCase());
}
>>
>>58551684
I would go with 24bppRgb, just because transparency information doesn't need to be stored in the image (and that's a pretty standard format). Just make sure that the PNG library can handle that format, which it should for 24 bit RGB
>>
>>58551721
All right, I see.
Thanks, anon.
>>
>>58551689
>prevent GC
but why would you want to?

if your code is disposing of objects all the time for no good reason then it's your problem, not java's
>>
>>58551769
Then what good is GC?
>>
>>58551769
You're free to elaborate whenever
>>
>>58551786
it's there when you need it

shouldn't be a big or constant problem unless your code is shit
>>
>>58551808
you too, why GC causing you such tremendous performance problems
>>
>>58551809
>it's there when you need it
If it's only meant to be used in certain circumstances then why is it the default? Why not have RAII, which is much more useful, and have opt-in garbage collection that isn't tracing everything and doesn't need to operate across threads (which involves pausing all those threads to collect).
>>
>>58551822
I can only conclude you're bullshitting at this point
If the GC is there to manage memory for me, why do I have to worry about managing the GC?
>>
>>58551569
i've got a copy and this is a pretty good summary of all of the new things in C++11/14.

i also read in this book that apparently it was a common misconception that the "volatile" keyword has something to do with parallelism (it doesn't). i wonder where that myth started.
>>
>>58551844
>>58551838
http://javarevisited.blogspot.com/2011/04/garbage-collection-in-java.html
>>
>>58551914
gc is the only thing I really fucking hate about java. give me fucking control.
>>
I have a class that's going to contain around 100+ variables. how do I organize it all? should I make a separate class just for variables, then reference it?
>>
>>58551914
>I don't have anything to say so I'll just pretend they're stupid
>>
>>58551927
yeah, read that blog post and you'll get it
>>
>>58551940
cut the whole shit. instead with java 9 even the unsafe class will be axed. just awesome.
>>
File: hqdefault.jpg (10KB, 480x360px) Image search: [Google]
hqdefault.jpg
10KB, 480x360px
Hey bros quick question, how does one go about picking an appropriate data persistence mechanism? Obviously a lot of data calls for a DBMS, but can I get away with storing hotel reservations in XML ?
>>
How hard is it to write a compiler?
Asking for a friend
>>
>>58551346
Frankly. If you have to tip toe around the GC to not have it do stupid things then you probably shouldn't be using GC.
GC is marketed in a way that implies you shouldn't have to care.
If it doesn't deliver on that MMM is easier. Because MMM really isn't hard.
>>
>>58551900
In what way doesn't it? Volatile tells the compiler that the complete variable use isn't visible to it.
I don't see a use for it if you're not dodging some compiler bug (compiler doesn't understand that there's pointer aliasing or something).

What does the book say?
>>
>>58551438
>SDL2_net fails at 500 tcp connections
That's impressively little. Wonder how they manage that.
>>
>>58551988
Depends on scope.
Not particularly if it's just supposed to produce a 32bit Executable for your platform and you have a syntax tree ready.

But if you're gonna make your own language I suggest llvm rather than writing a compiler.
>>
File: soulja.jpg (69KB, 750x916px) Image search: [Google]
soulja.jpg
69KB, 750x916px
>>58551981

Yes but to quote Chris Rock

> Just because you can drive a car with your feet doesnt make it a good idea

If you want an RDBMS that you can use right now, use SQLITE
>>
>>58552068
I was maybe gonna try to make my own language. I have to do a research/development project for school and was interested in it.
>>
>>58552111
>I was
HA caught you. 'asking for a friend' my ass.

No way I'm helping some loser who asks /dpt/ for help.
>>
File: java.png (16KB, 502x438px) Image search: [Google]
java.png
16KB, 502x438px
>>58550772
Just be productive and don't spend your life working a soul-crushing industry job that ends up getting outsourced to some pajeet for half the cost of paying you.
>>
>>58552121
I'm not necessarily asking for help I'm just asking how to get started
>>
>>58552077
thank you
>>
File: 2hr1v83.jpg.gif (3MB, 350x197px) Image search: [Google]
2hr1v83.jpg.gif
3MB, 350x197px
>>58551714

Try listening on keydown instead of keyup
>>
>use a managed language
>have to free resources yourself because finalizers aren't deterministic
>have to manage memory yourself if you don't want GC pauses
RAII is easier, safer, and faster in most cases. In the niches where GC is required you opt in to GC. Fixed.
>>
>>58551930
in c#, is using structs specifically to hold only variables ok.
>>
>>58552218
>RAII
DISGUSTING.
it implies all the wrong things.
>>
>>58552237
What's wrong with RAII?
>>
>>58552157
what's randomsort?

and why would your precious C++ job be safer from Moldavian technical college graduate competition?
>>
>>58552238
Too much to explain in a short post on reddit.

But basically 'resources' are almost never what you cared about managing. Unless you're doing exceptions.
>>
>>58552077
>SQLITE
Very interesting, I'm in the same situation as the other anon, I think this might be useful.
>>
>>58552258
That's not even coherent English.
>>
>>58552268
It is.
>>
>>58552157
>he thinks people who learn Chinese writing can't learn C++

enjoy being out-competed by 1.6 billion qualified professionals
>>
>>58552238
Can't return an && in C++ because it'll call the destructor
>>
>>58552280
I'll try harder to interpret it.
>You almost never care about managing resources unless you're doing exceptions.
Of course you care about managing resources. You don't want them to leak or be used improperly. RAII prevents this from happening and doesn't require you to call destructors on all code paths yourself (and branching happens with more than just exceptions).

>>58552310
>What's wrong with RAII?
>C++
I agree, but I don't know what you mean by "returning &&".
>>
>>58552352
>>What's wrong with RAII?
>>C++
>I agree, but I don't know what you mean by "returning &&".


std::move a local variable
>>
>>58552359
Oh, returning an rvalue. Again, that's a C++ thing.
>>
>>58552157
Where is the sort function?
I would like to see it
>>
just realized apple doesn't use gc

https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)
>>
>>58552497
They use reference counting, which trades off the intermittent pauses for constant overhead.
>>
Making GL shader for rendering my strings, using a texture atlas.
Do i want to pass a string to the shader and compute the UVs on gCard.
Or computer the UVs on the processor and send them to gCard.

Is it advised to save UV math for the gCard?
>>
>>58552524
>gCard
*gpu
>>
>>58552524
It's such a small task that I can't see the GPU providing a noticeable speedup, and it's much easier to just do it on the CPU. It could actually hurt performance if you do it on the GPU because the shader will be more specific and harder to reuse from drawing something else. Switching shaders means switching pipeline states which is not fast.
>>
>C++ is taught as a beginner language

How would a beginner react to the error message produced by this simple mistake?
#include <iostream>

int foo (int& x) {
x = x * 2;
return x;
}

int main (void) {
std::cout << foo(3) << std::endl;
}

$ g++ -std=c++11 scratch.cpp
scratch.cpp: In function ‘int main()’:
scratch.cpp:9:21: error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’
std::cout << foo(3) << std::endl;
^
scratch.cpp:3:5: note: initializing argument 1 of ‘int foo(int&)’
int foo (int& x) {
^~~

$ clang++ -std=c++11 scratch.cpp
scratch.cpp:9:16: error: no matching function for call to 'foo'
std::cout << foo(3) << std::endl;
^~~
scratch.cpp:3:5: note: candidate function not viable: expects an l-value for 1st argument
int foo (int& x) {
^
1 error generated.
>>
>>58552617
You can't pass 3 as a reference, since it isn't stored in memory, but instead as a constant.
>>
reminder that python is THE only language you need.

def is_palindrome(word):
return word == word[::-1]

QED
>>
>>58552617
If they're at the point where they know how pass-by-reference works, I'm sure they'll manage
>>
>>58552617
>error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’
I think it's pretty clear that you can't mutate a literal so that shouldn't be allowed.
>>
>>58552642
>>58552657
Can you explain to me what the difference between an l-value and an rvalue is?

>>58552651
>manage
So, they'll ignore the compiler output entirely and get by eventually
>>
>>58552675
An lvalue is something that can go on the left (or right) of an assignment. rvalues are only allowed on the right side.
>>
>>58551398
I would rather gouge my eyes out then produce high quality software.
>>
>>58552675
>they'll ignore the compiler output entirely and get by eventually
This.
And worse they will learn to not use the compiler output because it was unhelpful to them in the past.
>>
>>58552675
An r value, or right value, is either a variable or a constant
int a = 3;
int b = a;

An l value has to be a variable
int a = 3;
3 = a; // doesn't work, can't assign to a literal
>>
>>58552650
In haskell this is just
is_palindrome x = (==) <*> reverse
>>
>>58552695
remove that x immediately
>>
>>58552695
Shit it's point free so
is_palindrome = (==) <*> reverse
>>
File: images.jpg (9KB, 575x87px) Image search: [Google]
images.jpg
9KB, 575x87px
Anyone want the source to a driving sim engine by RAYDON?
>>
>>58552675
>So, they'll ignore the compiler output entirely and get by eventually
Assumptions
>>
>>58552686
this. I try and get all of my projects down to zero warnings (Wall Wextra Wpediantic), except for ones that make sense like not using a static function, unused variable for a not yet implemented feature, etc.
>>
>>58552714
Sure, I'll take it.
>>
>>58552695
>>58552709
in my language this is just
is_palindrome str
>>
>>58552718
Have you ever tutored/taught anyone?

>>58552720
Lots of new programmers get frustrated with the errors and just try random things until the errors go away. It's p bad
>>
>>58552726
is_palindrome, surely
>>
>>58552695
>>58552709

beginsWith = zipWith const >=> (==)


(>=>) is in Control.Monad

"asdf" `beginsWith` "as"
>>
>>58552726
in mine it's
is_palindrome = x = STRREVERSE$(x)
>>
>>58552728
>Have you ever tutored/taught anyone?
Yes
And I'm saying if they know what pass-by-reference is, they should be able to figure out what the issue is, especially with the error pointing straight at the offending function
>>
File: 1477859803400.jpg (201KB, 600x600px) Image search: [Google]
1477859803400.jpg
201KB, 600x600px
>nested for loops
>>
>>58552944
what do you propose instead?
>>
>>58552617
>int main (void)
kys
>>
>>58552944
Are you a beginner?
>>
>>58552944
>exiting 3 loops
exit, exit, exit
>>
>>58552944

That is not an argument.
>>
>>58552970

>he doesn't unroll his loops for max performance
>>
>>58552617
clang message is so much better

gcc is finish'd
>>
>>58552944
Give me a non-meme answer as to why this might be bad.
>>
>>58552996

Γ ⊢ ¬(unravels his for loops (he))
---------------------------------------
he : faggot
>>
>>58552514
if you do gc you still have to keep track of every object ever made which will always be a constant overhead
>>
So my normal hobby programming interests are things that you'd have to do in C/C++: games, graphics, realtime audio, things like that.

But I want to learn a managed gc language. What's some good projects that you can make with a language w/ gc? Just web stuff?

Would love to hear some opinions, since I'm looking to get out of my wheelhouse here.
>>
>>58553085
>What's some good projects that you can make with a language w/ gc?
CRUD applications for enterprise.
>>
>>58549536
Oh god. Back in college final year we had someone on our team who couldn't possibly have still been around except for his ethnicity in charge of doing a message system for the stuff we were working on. None of it worked, long story short the part I most remember is him proclaiming that something was a boost pointer.
>>
>>58553104
Not just java.

I'm talking python, ruby, ocaml, lisp, anything where you don't manually manage memory.
>>
>>58553145
Functional languages are good for language implementation and GC (and laziness) lets you do all sorts of AST transformations without much worry.
>>
>>58553085
>But I want to learn a managed gc language.
Practically nobody learns to do managed gc. I don't think you should expect to get many good answers.
>>
What makes browser engines so difficult to create?

Getting interested in programming. Heard browser engines are so difficult that most companies just reused the old ones we had, but I never really got a satisfying answer. I know about video game engines and how they're difficult, especially 3D, due to vectors and algorithms.

However, I don't understand what's so difficult about a browser engine. There doesn't seem to be that much going on in general. You get the HTML and the CSS on top of it. Then, whatever JavaScript wants you to do. What is there to "engine" about?

Yeah yeah I know... I'm just really fascinated by this and while people say that it's extremely difficult they never say HOW. As in is it difficult for compatibility... Is it difficult for performance... etc.
>>
>>58553023
dont spread your stupid placebo
>>
>>58553168
Large standards.
>>
>>58553168
that picture and filename just made my fucking night. thanks, man.
>>
>>58553164
Didn't think of languages, that's a good point. Thanks.

>>58553166
Bait? Lots of people learn languages other than C/C++ and use them for something.
>>
>>58550263
You usually need to go deeper.

Something like an identifier so you could later correctly print signed and unsigned for example.

Or make a struct that holds both the data and the printing function pointer. You could be essentially using the function pointer as the identifier itself if you want to go further
>>
>>58553238
Managed GC is different from normal GC.
>>
>>58550563
D? I don't do C# but the only real difference is the syntax
>>
>>58549944
I didn't have work after graduating for awhile too. After being laid off from my first job I have not been out of work for longer than a month. The real experience helps make you more valuable to other people.
>>
>>58551087
random GC is the reason Java will never be performant. You need to be able to control everything.
>>
File: 324324.png (11KB, 231x180px) Image search: [Google]
324324.png
11KB, 231x180px
either of these worth joining?
>>
working on decompiling a encrypted file format in python, the only "encrypted" part of it is the string tables and all it really is just a table with each entry xor'd with a pretty simple key
not that secure 0/10
>>
File: threading.png (51KB, 1745x920px) Image search: [Google]
threading.png
51KB, 1745x920px
>>58549352

Implemented basic multithreading and synchronization in my kernel.
>>
>>58553495
ACM
>>
>>58553545
I did hear ACM is better for the CS folk. What are the benefits tho?
>>
>>58553543
what editor is that?
>>
>>58553555
looks like gvim with addons and meme lines enabled
>>
>>58553555
Vim
>>
>>58553543
Congrats.
No Ring3 yet tho?
>>
>>58553495
No.
>>
>>58553603
Nope. Still got a lot to add before I get there.
>>
>>58553668
Alrighty, best of luck then.
>>
If I don't do low level J2EE stuff and mostly use frameworks such as Spring, Struts, etc to create webapps, can I consider myself as a J2EE developer or has at least J2EE experience?
>>
>>58553890
>I drive a car, can I consider myself a mechanic?
>>
File: scrot.png (4KB, 478x341px) Image search: [Google]
scrot.png
4KB, 478x341px
What's a good way to learn AMD64/x64 assembly as someone who knows C?
>>
>>58554009
Computer Systems: A Programmer's Perspective
>>
>>58549536

>c++ is easier
Who the fuck told you this? C++ is not an easy language. Easy to use was never a design principle taken into account when the language was first designed, and subsequently redesigned several times later.

C++ is powerful, but fuck it ain't easy. In any case, most of the things you mentioned are there for good reasons. Boost isn't a relevant argument about C++ because Boost isn't a part of C++. Some parts of Boost were brought into the standard library, but really, only the less shitty parts.
>>
>>58554009
Start cracking software. Or pick up some tutorial, literally anything, and start writing simple ASM stuff
>>
>>58554052
>powerful
meme
>>
>>58554052
>C++ is powerful
It offers abstractions that are (often in production code) so difficult to use that you might aswell not use it.

It's as 'powerful' as C.
>>
>>58554163

If you put the time into understanding how the language works, the abstractions can make your job a lot easier. But you have to have an autistic level of understanding of it.
>>
>>58552944
only bad if it breaks 80 col
after that, use different functions
>>
>>58554052
>c++ is so hard waaa
it is if you start out with it, if you already are familiar with other languages, learning this is easier, anon.
>c++ is so nit picky
well that is the price of it being powerful
>>
>>58554295

I'm not saying C++ is hard, only that it isn't easy. Incidentally, I started out with C++. It took a few years for the language to truly "click" with me. I don't recommend it to beginners.
>>
Learn C# first before C++

>tfw c++ is your favorite language but everyone thinks your crazy
>>
>>58554350
>c#
>being this much of a suck-up to microsoft
anon...
>>
>>58554350
That's terrible advice, you'd be so used to .NET doing things behind your back you wouldn't understand the hardware at all
>>
>>58554319
Have you learned Haskell yet Ruby?
>>
>>58554368
>>58554376
If they end up loving C# so much they're a lost cause anyway. I used it because I had to and hated being hand held and not having control so I decided to git gud and never looked back.
>>
Oh, now I'm remembering something I wanted to post about today. The C standard has a problem that I feel needs addressing. This problem, primarily, is related to the %n specifier on the printf family of functions. Namely, it is correlated to an int pointer, but is used to track the number of bytes read. The int data type is not necessarily as large as the maximum amount of bytes written by these types, and therefore is in error. The C2X standard should replace the specification to use a ptrdiff_t pointer instead.
>>
>>58554405

ur an idiot
>>
>>58554500
ur 2 idiots
>>
>>58554475
It's also just stupidly dangerous as it has very little real world uses and can be used to trivially exploit format-string vulnerabilities
>>
>>58549506
Figure out what the fuck you're doing with the language first, then reread what all it does and see if it sounds nice, and use the free trial.

I don't use it at work, a lot of the functionality isn't a big deal or seems to be already covered by VS. Coworker tried it and liked it but did not pay for it once the trial was up
>>
how hard would it be to implement hypercomplex numbers in python like k where

k*k = 1
|a+bk| = √(a^2 - b^2)
exp(a+kb) = cosh(a) + sinh(b)k
>>
>>58554527
Babby level task.
>>
>>58554527
k*k = 1, what kind of crazy structure is that, even.
>>
>>58554511

suck my butt
>>
>>58554568
no
>>
>>58554561
https://en.wikipedia.org/wiki/Split-complex_number
>>
File: 1482870681809.png (2MB, 1254x1771px) Image search: [Google]
1482870681809.png
2MB, 1254x1771px
ded
>>
File: OUT-5000000.png (510KB, 1708x1708px) Image search: [Google]
OUT-5000000.png
510KB, 1708x1708px
This took a while...
>>
>>58555099
is that a sandpile?
>>
>>58555246
It is
>>
File: x.png (171KB, 897x2228px) Image search: [Google]
x.png
171KB, 897x2228px
Ah yes, lobste.rs discussions
>>
>>58554527

>hypercomplex numbers
Today I learned about a math thing I did not know about. These seem pretty cool. And it probably shouldn't be too difficult to design a data type representing these. You make a class, you overload some arithmetic operators and define how operations act on said class... should not be much more complicated than defining a regular Complex number type.
>>
>>58555331
I tried it. What surprised me is that each operator is defined independently of the others, so if you change one it won't change the others, meaning you have to change each individual operator, plus some of the other class functions like abs or exp.

and don't even get me started on what happens when you try adding a complex to a hypercomplex. it gets hairy
>>
>>58555099
if anyone wants to try or critique
https://gist.github.com/anonymous/6c1d924a21c97464db0cf46471417215
>>
File: DilbertWhatWouldWallyDoCover.jpg (40KB, 381x487px) Image search: [Google]
DilbertWhatWouldWallyDoCover.jpg
40KB, 381x487px
>>58551570
If this is real, welcome to the real world fucktard. Corporate jobs are all looking like you're doing something useful / contributing to the discussion. It's irrelevant whether you actually do your job or not.
>>
File: killer-whale-talk (1).jpg (126KB, 800x581px) Image search: [Google]
killer-whale-talk (1).jpg
126KB, 800x581px
guys rate my very first project

it helps you counter picking the enemy team in dota.

it parses the recent ranked matches the enemies won and displays which hero they played


it took me over 20 hours to write this
>>
File: dotacoding.jpg (275KB, 1164x492px) Image search: [Google]
dotacoding.jpg
275KB, 1164x492px
>>58555677

wrong pic
>>
tell me about this site
hackerrank.com
>>
>>58555371

>each operator is defined independently of the others
Things like +, -, *, and / mean different things in different concepts, and you cannot always assume that - undoes + and / undoes *, or that the operations are trivial enough to make one easy to implement in terms of the other. Not everything is a scalar. For instance, consider a set data type. It might be reasonable for + to indicate a set union and - to indicate a set difference. A complex number data type might have + and - as well, defined respectively as adding and subtracting both real and imaginary terms. If you had a + operation, could you define a generic operation for - that works for both of these types? Not really. They're completely different classes of data. So + and - must be defined independently of each other because it is quite clear that there are enough cases where one would want a + and/or - operator where the definition of one or both are non-trivial.
>>
>>58555484
That topple algorithm is pretty clever, or maybe I'm just dumb.
>>
which square is best?
pic related
>>
When I read comments in /dpt/ I get the feeling no one actually reads technical books anymore. Also very few of you are at all competent.

When the most repeated complaint about c is "having to reinvent the wheel" you know everyone talking has fucking downs.

Protip: They are called libraries, and you can use them.
>>
If I have only been coding since sept for my course but I wont to learn more in free time what kind of stuff could I be doing? I know people will say "write programs" but I don't really know where to start.
>>
What's the advantage of dynamic types? Is there a situation where dynamic typing would be beneficial over static types?
>>
>>58556075
we'll im guessing you have some sort of a '4chan folder', so you can start by writing a program that lists the duplicate files there
long story short, in your spare time, write programs that you can use.
webpage scraper, duplicate finder, GUI for your favorite tool (ffmpeg for example), etc..
>>
File: chart (1).png (86KB, 1200x800px) Image search: [Google]
chart (1).png
86KB, 1200x800px
>>58549352
I'm writing a bitcoin bot from scratch that is market neutral to trade off of stagnation in the market, with the ability to lean bullish or bearish. Already have my first investor, but I'm not taking real shekels just yet.

Pic related, testing 5 different strategies out at once, just launched the first scaled test where I launch multiple nodes/bots that report back to my main charting instance that displays all the data.

Built over the last week, still got a ways to go.
>>
>>58553543
Can you post your mutex implementation? I'm literally doing the same thing in my kernel right now and I'm having trouble with synchronization.
>>
>>58554527
>>58554692
>>58555331
>>58555371
Jesus Christ, it baffles me how bad at math most programmers are.

A split-complex number is simply an ordered pair:
typedef struct pair {
double x;
double y;
} Hypercomplex;


Addition is defined by:
Hypercomplex hc_add(Hypercomplex a, Hypercomplex b)
{
a.x += b.x;
a.y += b.y;
return a;
}


Multiplication is defined by:
Hypercomplex hc_mult(Hypercomplex a, Hypercomplex b)
{
Hypercomplex c;
c.x = a.x * b.x + a.y * b.y;
c.y = a.x * b.y + a.y * b.x;
return c;
}


Similarly for absolute value, exp, etc. Your "k" would be nothing more than:
Hypercomplex k = {0, 1};
.

It's even easier to define that in Python, I don't get what you're struggling with.
>>
File: IndianProgrammerFuel.jpg (76KB, 550x450px) Image search: [Google]
IndianProgrammerFuel.jpg
76KB, 550x450px
I'm reading the Java tutorial. Got myself a pack of papadum and told my gf to call me Pajeet when we have sex.
Am I doing it rght guys?
>>
>>58556181
It looks like blini
>>
How do we make operator overloading not suck?
>just throw it out, altogether
No thank you

How about for each operator, define a set of rules it must obey
e.g.
operator + has a rule that operator - must also exist and that (a + b) - b = a = a + (b - b)
>>
Should I learn Javascript?
>>
>>58556177

>bad at math
Knowledge and capability are not the same thing, Anon. I can comprehend the operations behind an hypercomplex number just fine. I had just never heard of one until today. They do not pop up in the types of math most programmers tend to be exposed to.
>>
>>58555967
makes sense, though it's a bit annoying that they have to define both __add__ and __radd__

If you're adding two different types how does it even decided which to use?

>>58556177
addition and multiplication are the easy part, I'm more concerned about defining things like powers, roots and exponentiation.

Granted, I'm fully aware that for some spilt-complex number a+bj, e^(a+bj) = cosh(a) + j*sinh(b), but I don't know the power and root algorithms for non-integer values
>>
>>58556258
can you write c?

You can write javascript in about 5 minutes.

You should probably learn html/css, how to administer a server, and a server-side language like php, perl, or something super gay like java EE or cgi.
>>
>>58556252
>How about for each operator, define a set of rules it must obey
>e.g.
>operator + has a rule that operator - must also exist and that (a + b) - b = a = a + (b - b)
How would you define that for string variables?
>>
>>58556271
>but I don't know the power and root algorithms for non-integer values
I'm assuming you mean non-integer powers. Split-complex numbers are isomorphic to square matrices. Indeed, the hypercomplex z = (x, y) is equivalent to the matrix ((x, y), (y, x)). Your problem is therefore on calculating non-integer powers of square matrices, and to do that you must know a bit of Linear Algebra. Here's how you do it: http://www.blackmesapress.com/Eigenvalues.htm

At the end of the day this is more of a mathematical problem than a CS/programming one, though.
>>
>>58556258
for what? if your main in C, i don't see why you should learn JS.
if you're into web technologies, though, it's essential.
>>
>>58556181
>gf
stopped reading there
>>
>>58556177
>underscores in function names
>a, b
>opening brace in separate line
>>
>>58556453
How would you know if his main in C
>>
>>58556493
>if your main is C
>if
>>
>>58556485
So how would you name them?
>retarded bracing
>>
>web devs
>javascript, css, html
not real languages
>>
>>58556485
If you wanted to go down on me so bad you just had to ask, sissy boy.
>>
New thread: >>58556533
>New thread: >>58556533
New thread: >>58556533
>New thread: >>58556533
New thread: >>58556533
>New thread: >>58556533
New thread: >>58556533
>New thread: >>58556533
>>
>>58556543
web devs deserve a lot of respect for their pain tolerance
>>
>>58556547
Got to migrate this thrilling talk, ASAP [spoiler] faggot [/spoiler]
>>
>>58549352
>"That'sracist".gif
>>
>>58556252
How are you going to enforce those rules?
Thread posts: 317
Thread images: 36


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