[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: 318
Thread images: 33

File: timetocode.webm (2MB, 1152x648px) Image search: [Google]
timetocode.webm
2MB, 1152x648px
This is /dpt/, the best subreddit of /g/

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

/!\ ** Read this before asking questions ** /!\

http://mattgemmell.com/what-have-you-tried/
http://www.catb.org/~esr/faqs/smart-questions.html


What are you working on ?
>>
first for rebirth of gopher
>>
>>56966720

Best of luck.
>>
I know the plebbit form links are supposed to be funny but having the article and the smart questions guide as hyperlinks in the OP doesn't sound like a bad idea.
>>
File: indians.png (5KB, 235x117px) Image search: [Google]
indians.png
5KB, 235x117px
>>56966703
That doesn't make sense.

C# is pronounced "See Pound"
>>
array1.concat(array2.filter(function(num){
return array1.every(function(n){return Math.abs(num - n) > 4})
}))
.sort(function(a,b){return a - b})


>>56966654
I was under the impression that higher level languages were meant to be easier to use / look more terse.


>>56966399
>>56966536
Anyway, again I'm curious why you'd need that algo. If you have anymore Js problems like that, beam them up.
>>
>>56966436
>>56966536
Thanks, That's working well for removing near duplicates. But now i need it to always add the extra elements in array2 that are least likely to be duplicates.

>I'm curious why you'd need to do this
I'm trying to merge two event timelines that two different people recorded. Person 2 might have noted an extra event that person 1 missed. But person 1 might have messed up his timing a bit.
>>
>>56966808
>always add the extra elements in array2 that are least likely to be duplicates
I'm confused as to what you mean by this.
>>
File: memefacepillow.jpg (78KB, 900x900px) Image search: [Google]
memefacepillow.jpg
78KB, 900x900px
>>56966795
>2016
>American teams still doing needless
And you guys wonder why they're taking your jobs
>>
>>56966795
>C# is pronounced "See Pound"
em.. no anon, it's not.
>>
>>56966804
>I was under the impression that higher level languages were meant to be easier to use / look more terse
They do
>>
fyi I didn't translate anything that guy wrote to make my code, but what do you mean add? Like sum them?
>>
>>56966824
var array1 = [4, 11, 60],
array2 = [6, 9, 14, 47, 58];


array2 has two extra numbers so the function must add two numbers to array1. Those two numbers can be near duplicates but they must be the least likely to be duplicates. The function should figure out that 14 and 47 are those two numbers.
>>
>>56966906
No, you're code was smaller and looked better.

>>56966941
I don't think it's going to look pretty, but okay
>>
>>56966976
>No, you're code was smaller and looked better.
C# is high level
>>
>mfw learning QML and C++ interop

At first I was euphoric but the more I get into the details the more cancer I get from the atracious design of binding C++ objects and types to QML but I'll get there eventually.
>>
Studying CryENGINE's source code. Who knows, maybe I'll learn something.
>>
Why is std::move defined as follows:

template<class T>
std::remove_reference_t<T>&& move(T&& t);


instead of

template<class T>
T&& move(T&& t);


Given an example where the second one would be incorrect.
>>
A stupid question.
How do filestreams work?
What happens if I have a filestream open and read the contents line by line, then at the same time some other instance opens the file, adds a new line and saves the file. Will this change be visible in the first instance?
>>
>>56966941
function eraseDuplicate(arr1,arr2){
for (var i = 0, result = []; i < arr1.length; i++){
if (Math.abs(arr1[i] - arr2[i]) > 3){
result.push(arr2.splice(i,1)[0]);
i--;
continue;
}
}
return arr1.concat(result).sort(function(a,b){return a - b});
}
>>
>>56967081
I'm working on an integration script between magento and some ancient desktop business software application, which obviously does not have any sort of web api, it can only export data to xml files.
>>
>>56967065
http://stackoverflow.com/a/7518365
>>
>>56967156
Let me know if this doesn't work. I did it in a shitty looking way and I didn't sleep last night
>>
File: 1475052322965.jpg (155KB, 1280x720px) Image search: [Google]
1475052322965.jpg
155KB, 1280x720px
I want to make a CLI program that uploads your file to pomf.cat and returns his link.

What should I use /dpt/? I know C and Python.
>>
Anyone has any ideas for a long term software project? Preferably something useful that could help anons with waifu-related stuff.
>>
>>56967253
i always use python for this sort of stuff
urllib and beautifulsoup make things easy
>>
Messing around with Tkinter for memesnek; if I want to get a filename from a file in an "open file..." box and use it within the script, would I make a variable where I store the file name as a global? See:

def getInputFile():
getFile = askopenfilename()
# fileName = getFile.name

displayInputfile = ttk.Entry(content, textvariable = fileName, width = 80)
findFile = ttk.Button(content, text = "Browse", command = getInputFile)
>>
How would a system like the LoL champions' passive powers be implemented? I mean, you've got like 150 or whatever different champions, each with its own superpower that can affect different aspects of them game, from how much gold per second you get to how much damage you can do if you do a certain action from inside a brush. And all these powers could potentially interact with each other, e.g. some dude shooting while in a bush but the target is close to 3 allies so he gets more defense or whatever.

Anyway, these are just shitty examples, I don't even play LoL. The point is, I'm working on something similar that has loads of "champions" each with their own trait that affects different parts of the game. How would this be implemented? How could the game check if an action is being performed by a champion who has a power that modifies that particular action?
>>
File: waifu.jpg (148KB, 800x1200px) Image search: [Google]
waifu.jpg
148KB, 800x1200px
>>56967266
tistory downloader
you'll be rich
>>
>>56967156
>>56967184
Thanks, nearly working but its having trouble with higher numbers. array2 = [6, 9, 47, 58, 90,100] should add 47, 90, 100 but only adds 47.
>>
>>56967318
https://en.wikipedia.org/wiki/Entity_component_system

Honestly though it's just a lot of code. A LOT of code.
>>
>>56967377
thanks, I'll look into this. My project is nowhere near as complex as LoL so hopefully it won't become a black hole that drains away my time and soul.

yea right.
>>
I get compiler error when I'm trying to pass a self made datatype to a function.
"expected 'struct cell (*)[(sizetype)cols]' but argument is of type 'cell'"
This is the function declaration.
void initField(const int rows, const int cols, cell field[rows][cols]);
Datatype.
typedef struct{
char current;
char next;
} cell;
And the function call.
initField(rows, cols, field[rows][cols]);
Rows and cols are constants.
>>
>>56967448
>initField(rows, cols, field[rows][cols]);
You're passing the value in
field[rows][cols]
to a function which expects an array. Remove the indices.
>>
>>56967448
Forgot to mention.
Ofc I initialize the cell datatype before the call.
cell field[rows][cols];
>>
>>56967318
Fucktons of conditionals.

void GoldCounterAction()
{
if (playername = "Shecklestein")
{
player.Gold += 2;
}
else
{
player.Gold += 1;
}
}
>>
>>56967480
Oh ye, thanks ^^
>>
File: doc.png (4KB, 75x100px) Image search: [Google]
doc.png
4KB, 75x100px
ww@
>>
>>56967497
I considered doing that but it doesn't seem like the most elegant solution. For example if I wanted to add another bunch of heroes later on I'd have to go back and edit a lot of stuff buried deep in the code.
I'll keep it as my final solution if all else fails.
>>
>>56967372
result = result.concat(arr2.slice(arr1.length,arr2.length));

Add this just above the return statement
>>
>>56967528
>>56966720
we need a Gopher server written in Go, it just makes sense
>>
File: Untitled.png (2MB, 1464x908px) Image search: [Google]
Untitled.png
2MB, 1464x908px
rate my programming
>>
>>56967540
Here's the thing; some of the abilites are unique in such a way that it makes no sense to store that information on every single character.

In the contrived example I've given, a particular Jewish character gets more passive gold.

Now, are you going to add an attribute to every single character defining their gold generation rate? Maybe. But when does that stop?

Do you set booleans on every character like Skarner specifying whether the character can interact with his little "zones"? No, the zone knows that only Skarner can interact.

In my example, the Gold Counter knows who gets more gold, because it's something that only "Shecklestein" cares about.
>>
>>56967497
No. Don't do this. DO NOT DO THIS. KEEP YOUR FUCKING SYSTEMS SEPARATED
>>
File: 1466212175564.png (48KB, 336x280px) Image search: [Google]
1466212175564.png
48KB, 336x280px
So now that we have C--, C, C+=, C++ and C#, when's the time for C##?
>>
>>56967585
how about ++C
>>
>>56967585
>C+=
Good times
>>
>>56967585
C## is what happened to C# over the past two years.
>>
>>56967497
That kind of code should be inside the Player class at the very least.
void GoldCounterAction()
{
if (playername = "Shecklestein")
{
this.Gold += 2;
}
else
{
this.Gold += 1;
}
}
>>
>>56967600

Which is a good thing.
>>
>>56967569
Hmm that's a good point, I hadn't considered that.
>>
>>56967608
Absolutely true, that's what I was going for but wasn't paying attention.

However "this" is superficial and unnecessary.
>>
>>56967081
anyone?
will probably have to test this out myself, and also concurrent writes to the file
>>
>>56966720

>>56966121
this could also be implemented on top of gopher if you like the idea of formatting a document in JSON, just with the concept of a 'mole' (gopher's CGI scripts)
>>
>>56967642
What are your requirements?

Are you trying to lock the file? Do you want to see additional data that's added if it's added before you reach the end?
>>
File: 1458323447166.png (97KB, 200x337px) Image search: [Google]
1458323447166.png
97KB, 200x337px
>>56967585
>mfw C++ is D
>>
Project update:
A nice fellow got me a URL.
http://boomer.archdev.org/

Also did a bunch of updates, like linking to the post a webm is from and flattening out the random function. Previously it just picked a random thread then a random webm, obviously favoring webms from small threads. Now it's a lot more random in what you get.

Source still at:
https://github.com/Booom3/Random-Wsg-Webm
>>
>>56966902
its a joke
>>
>>56967608
>playername = "Shecklestein"
not ==?
>>
File: seinfeld.jpg (23KB, 587x616px) Image search: [Google]
seinfeld.jpg
23KB, 587x616px
>mfw a filthy ASPajeet breathes near me
>>
>>56967664
i just want to know if some funky shit will happen while reading from one instance and writing from the other at the same time whether the file is locked or not

my requirements will be based on what happens
>>
>>56967736
>playing your favorite MOBA
>badass tree man
>suddenly bad code turns your character into a Jew

This is why we let our compilers prevent us from assigning in an if statement.
>>
>>56967555
i dont watch anime

is this real
>>
>>56967745
The issue would be the possibility of a dirty read.

You could potentially read in incomplete data.

Depending on your definition of "funky", yes, some "funky shit" could happen.
>>
File: index.png (115B, 32x32px) Image search: [Google]
index.png
115B, 32x32px
how to compress this image even more?
>>
>>56967783
groovy
>>
>>56967799
Look into vector graphics.
>>
>>56967812
it has to be png
>>
>>56966795

Anon, I know there are plenty of jokes about the pronunciation of C#, but keep in mind that the file extension is .cs.
>>
>>56967799

You already have a compression of 8.9 pixels per byte for an image with 3 colors. Is this not enough? Are you not entertained?
>>
File: index.png (113B, 32x32px) Image search: [Google]
index.png
113B, 32x32px
>>56967799
>>
++i++;

where is your god now?
>>
Anyone know of some good tutorials for using selenium with python 3?
>>
>>56968124
(++i)++;
?
>>
File: AMERICA.jpg (111KB, 1920x1200px) Image search: [Google]
AMERICA.jpg
111KB, 1920x1200px
TV guy here again. I came up with the idea of a Bitcoin sponsorship. You will pay X BTC for every minute watched up to Y hours (Y is to prevent runaway donations and X is set on a channel basis). Donations will be chunked together into large transactions and sent out to minimize transaction fees. The Bitcoin address is stored on the RPi (or whatever computer) and can be pulled up onto the screen on demand. Thoughts?
>>
>>56968124
The joke's on you, my language is immutable
>>
File: 751px-Rorschach_blot_10.jpg (68KB, 751x600px) Image search: [Google]
751px-Rorschach_blot_10.jpg
68KB, 751x600px
>>56966686
Want to fool around with creating a simple shell in C as a learning experience, problem is have no idea how to extract the entry from stdin into useable arguments. I have the correct implementation of fork and exec to run programs but I cant get meaningful user input to use them. Currently using fgets and then strtok to try to parse out arguments but I only get segfault after segfault. Is there any preferred method of doing this?
>>
7th edition when?
>>
tripfags are the worst
>>
How would an assignment statement for this look in C?

A value of 1 to divisor if digit is a divisor of num ; otherwise,
assign a value of 0
>>
>>56968440
Just filter them, you lobster
>>
>>56968446
int value = (num % digit == 0);
>>
>>56968446
I'll just show you Js because you seem pretty language agnostic at your level anyway

var divisor = digit % num === 0 ? 1 : 0;
console.log(digit / divisor)


I'm sure there's better ways to do it, but that's a random and odd question when abstracted
>>
>>56968542
>? 1 : 0
>>
>>56968542
what the fuck is language agnostic? You're just plain retarded
>>
is it worth learning Python ? None of the job listings I have seen ask for it so I don't think it would really be much of value career wise. But what about for personal and hobby use any value there ? I mostly program in c style imperative languages.
>>
>>56968561
>limited vocabulary
language agnostic means it doesn't matter what language, i.e. the answer is agnostic to the language
you're just plain retarded
>>
>>56968542
Sorry here
digit / digit % num === 0 ? 1 : 0


>add the value to divisor
It's hard to get what you meant by this
>>
>>56968561
http://programmers.stackexchange.com/questions/28484/what-is-language-agnosticism-and-why-is-it-called-that-way

Don't talk to me or my programming languages ever again.
>>
>>56968604
>===
>>
>>56968615
its really, really, REALLY equal
>>
>>56968561
It means you have no clue what you're doing anyway, so the language doesn't matter.

>add the value to divisor
So you want 1 or 0 to be the value of divisor, or l'm guessing literally added to the divisor. The divisor is num correct?

Take a look at how you worded that question. And you're calling me retarded
>>
>>56968615
Do you not know JS? In JS == is value check with type conversion where it simply makes its best guess as to what types you want. === is value check with no type conversion where different types evaluates to false.
>>
>>56968649
>Do you not know JS?
top kek
>>
>>56968656
Node is a real thing and it's really nice.
>>
>>56968614
no one was ever talking to you, nerd
>>
>>56968664
get out webshit
>>
>>56968632
>>56968632
I just learned my lesson about trying to answer stupid questions in these threads

>>56968656
What is your problem?
>>
>>56968664
I don't know why anyone would use node for anything. Besides trying to avoid to learn a language besides JS.
>>
>>56968671
DON'T TALK TO ME OR MY PROGRAMMING LANGUAGES EVER AGAIN
>>
File: plshelp.png (75KB, 2080x832px) Image search: [Google]
plshelp.png
75KB, 2080x832px
I have a java library that is a wrapper for c++.
I need to extend the library by adding another method which calls a method that's written in c++.

Pic related is my progress.
Please point out any obvious errors, and any resources would be very helpful

Also, what is the middle section written in? Is it C or C++?
>>
>>56968674
I'm a real dev. :(

>>56968687
Ridiculously speedy development times. Very dynamic.
>>
>>56968681
You're stupid
>>
I just found out my conference I'm going to tomorrow has a CoC. Since when do conferences have a CoC? This cancer has to stop.
>>
>>56968696
>>>>>>>>>>dev
>>
it's more equal than the others
>>
>>56968696
>Ridiculously speedy development times.
compared to what? C?

>Very dynamic.
Actually not a good thing
>>
File: meirl.png (377KB, 594x422px) Image search: [Google]
meirl.png
377KB, 594x422px
>>56968688
>>56968671
BTW DO I LOOK LIKE IM PLAYING
>>
>>56968735
No you don't sir. Sorry, I didn't realize your greatness. Didn't mean to offend you, cheers
>>
>>56968729
Php, go.
Dynamic is a great thing when you're just trying to get something to work in the first place, and makes it very versatile on small scale.
>>
File: shogun.webm (3MB, 720x404px) Image search: [Google]
shogun.webm
3MB, 720x404px
/dpt/-chan, daisuki~

>>56968703
Since pycon 2013

>>56968674
Please, don't bully.

>>56968154
>>56968124
Should produce a compiler error since both prefix and postfix ++ require a l-value but both return a r-value.

>>56967799
Try ken silverman's pngout

>>56967585
http://c2lang.org/

>>56967318
PROCEDURE applyArmorBonus (owner, entities)
{
FOR entity IN entities
IF entity.team = owner.team
entity.armorBonus = distance(owner, entity) < 15.0
}

PROCEDURE applyDamage (attacker, target)
{
armor := target.armor

IF target.armorBonus
armor :+= 5

IF target.force > armor
target.health :-= attacker.force - armor
}

# in main loop, before handling events
FOR entity IN entities
entity.getPassive().apply(entity, entities)


>>56967266
A website that will mix both catalogs of /g/ and /λ/

>>56967253
Python.

>>56967081
Depends if it's a buffered stream or not but file I/O are atomic on most operating systems.

>>56966996
How they implemented the list/graph structures is interesting.

>>56966686
Thank you for using an anime webm.
>>
>using WinAPI for work shit
>have to iterate through USB devices to get their GUIDs
>the proper way to do this is to do two separate calls to the same function
>the first call gives you the size of how much memory you need, the second call actually gives you the info

Is there an actual good reason for this? Why not break it up into two functions?
I get that Microsoft has a hard-on for 10-parameter functions with NULL for every other argument, but they could at least try to be sensible.
>>
File: 1465333395741.png (258KB, 549x560px) Image search: [Google]
1465333395741.png
258KB, 549x560px
>>56968763
drifters.webm?
>>
>>56968754
How is it faster than go? Or C# for example?

>Dynamic is a great thing when you're just trying to get something to work in the first place, and makes it very versatile on small scale.
Besides the lower verbosity in some dynamic langugaes, it has no advantage over static at any size. And as things get bigger it becomes a huge fucking pain.

The only big advantage to dynamic programming is that it's easier for newbies to pick up.
>>
Is this C or C++?

JNIEXPORT void JNICALL Java_finnstr_libgdx_liquidfun_ParticleSystem_jniSetParticleDamping(JNIEnv* env, jobject object, jlong addr, jfloat damping) {
b2ParticleSystem* system = (b2ParticleSystem*)addr;
system->SetDamping(damping);
}
>>
>>56968754
>Dynamic is a great thing when you're just trying to get something to work in the first place, and makes it very versatile on small scale.
that's not true though
>>
>>56968835
Your other post had a comment with .cpp in it, so it's C++ in all likelihood.
>>
>>56968835
Both but
>Env* env
>b2ParticleSystem* system
is trash
>>
>>56968835
JNI is written in C, so I guess C.
>>
>>56968861
I've never made the connection between c++ and .cpp, thank you anon

>>56968870
what are you trying to say?
>>
>>56968835
>
system->SetDamping(damping);

C++
>>
>>56968735
>>56968749
thats what i thought..................

*zips katana*
>>
>>56968884
that's valid C
>>
>>56968818
My favorite language is C# and I've written some things in it but Node is blatantly a lot faster to develop in. Less boilerplate, more package managing. npm install saves so much time it's not even funny. Bigger repository for modules.

>>56968844
How is it not? Let's you change things around real fast.
>>
>>56968884
nice eye
could still be C but far less likely
>>
>"haha, i've been writing some c# this weekend, but i wear glasses so i don't actually see sharp, haha, get it?"
>>
i recommend to write jni code in c++

>>56968870
do you have a better option in the JNI? Each function must accept the JNIEnv*.
>>
>>56968934
>"haha, I've been writing some c this weekend, but i'm blind so i don't actually see, haha, get it?"
>>
>>56968914
>Less boilerplate, more package managing
Right, that's what I mean by verbosity being the only difference. But you could use F# which is less verbose than JavaScript.

How is npm better than nuget?

>Let's you change things around real fast.
How so?
>>
>>56968934
>"haha, i've been writing some PHP this weekend, but my life is a meaningless charade and I just want the paint to stop, haha, get it?"
>>
File: fc7.jpg (12KB, 452x331px) Image search: [Google]
fc7.jpg
12KB, 452x331px
>>56968993
>I just want the paint to stop
>>
>>56969003
oh fuk me
>>
>>56968914
>npm install saves so much time it's not even funny. Bigger repository for modules.

Yeah sure, it takes ages to resolve dependencies because every package depends on 500 other packages.
>>
>>56968914
>Let's you change things around real fast.
changing things around real fast is precisely what dynamic langugaes are terrible at.
>>
>>56968973
From my limited experience with nuget npm seems to have a lot more stuff so you're more likely to find what you need.

Imagine you have a class.
In JS, there is no class definition. You add and remove as you please. Passing data around is as easy as accepting a parameter or converting to JSON on the fly.
In C#, that class becomes a liability every time you need to change something. Wanted to add some more data? Gotta go to the class definition, possibly write more getters and setters depending on how you need to interact with that data. Gotta make sure any endpoint is properly synced up if you ever want to serialize it.
>>
>>56968884

Could be a function pointer.
>>
Who /verboseIRL/ here?
I can't tell a story or an anecdote without including a lot of unnecessary and unrelatable detail
>>
>>56969051
xD so quirky
>>
>>56968754
https://hackernoon.com/how-it-feels-to-learn-javascript-in-2016-d3a717dd577f#.u2htocr9o
>>
>>56969051
Single character is best
>>
>>56969035
>Wanted to add some more data? Gotta go to the class definition
This is why C# is so much faster for changing things around. In JS there is no class definitions, so instead you have to go to every single line of code that is effected by adding the new data and change things and hope to god you don't make any mistakes because it will take a long time to figure out where you went wrong, and often you won't realise there was a mistake until the code makes it to production. JS cannot statically verify you didn't start referencing a member of field that wasn't going to exist at runtime like C# can. so adding a new field to a "class" that is used 200 times in the code base is dangerous stuff.
>>
>>56969051
It's hard because people are too polite. If people IRL would tell you to shut up more often you'd learn.
>>
>>56969099
If we're talking about larger projects this is absolutely true, but when you're one guy wanting to put together something neat that's not much of a concern.
>>
>>56969085
I saw that on HN too. I couldn't even finish reading before I had to backclick. I'm still gaining a grasp of vanilla
>>
features that should be removed from all languages
i'll start

>identifiers longer than 3 characters
>>
>>56969126
excluding function names
>>
>>56969126
semi colons
>>
>>56969111
>but when you're one guy wanting to put together something neat that's not much of a concern.
Because you wouldn't have classes at all in a very small script, but you still lose the static verification and strong typing.
>>
>>56969161
lua/haskell pls go be heretical somewhere else.
>>
>>56969178
haskell has semicolons and braces
>>
>>56969085
See I get that there's a lot of retardation going around Javascript but just install Jquery, node and some node modules and you'll have a good time with it. Ignore the hipster fucks and just put together a nice and dynamic page with little effort. It'll feel good.

>>56969168
int senddata(int index, string name, string link, string linkcontext, string[] options, string information)
>>
>>56969178
lua tolerates semicolons
>>
>>56969213
>It'll feel good.
No, it will not. In fact, I've tried frontend faggotry not that long ago for a week or so and I wish I had not.
>>
>>56969213
>int senddata(int index, string name, string link, string linkcontext, string[] options, string information)
like i said, verbosity is the only difference.

Also with F# you have type inference so don't have to deal with that either.

not to mention methods with that many parameters in JS in my experience almost always eventually have problems with the parameters getting mixed up, so a little type documentation goes a long way to having time.
>>
>>56969240
I feel you, frontend is the worst. But backend node feels nice to me.
>>
>>56969265
In that scenario in JS I would just do function(relevantName) and call it with function({index: 0, name: "dicks", link: "linktodicks.com", options: { etc etc }})
Put together classes however you want, when you don't need it anymore delete it. Terrible for large code bases, terrific for just putting something together real quick.
>>
>>56969305
>In that scenario in JS I would just do function(relevantName) and call it with function({index: 0, name: "dicks", link: "linktodicks.com", options: { etc etc }})
Sounds like a real good reason to avoid JS. I do this in JS too, but it's a problem that I need to do it to make the code a little safer.

>Put together classes however you want, when you don't need it anymore delete it.
Classes don't exist in JS guy.

>terrific for just putting something together real quick.
I fail so see how
>>
C++11 is the best thing to happen to programming since C
>>
#56969392 (You)
>>
File: breaking-the-conditioning.jpg (11KB, 296x300px) Image search: [Google]
breaking-the-conditioning.jpg
11KB, 296x300px
>>56966686
>best subreddit of /g/
>reddit links
>>
>>56969427
did OP trigger you?
>>
>>56969392
I'm not familiar with C++11. Are you saying it is an unending nightmare?
>>
>>56969427
>When the male vitality pills kick in
>>
File: C++.png (54KB, 972x259px) Image search: [Google]
C++.png
54KB, 972x259px
>>
>>56969451
I'm saying it's a joy to work with.
>>
>>56969213
>See I get that there's a lot of retardation going around Javascript but just install Jquery, node and some node modules and you'll have a good time with it.

I wish this was the case, but even with jquery changing the dom in any significant way is still a fucking pain. I end up with string-blobs with god knows how many escaped quote characters every fucking time. Maybe I'm just bad at it though, since I usually try to avoid frontend stuff.

React is a little more tolerable because of jsx, but it's also overkill for my personal projects.

Why the fuck haven't we solved DOM navigation in $CURRENT_YEAR?
>>
>>56969550
What's wrong with the DOM exactly? How *should* DOM navigation work?
>>
>>56969504
C++ is needlessly inefficient because of its heritage. The very need for move constructors etc. makes me angry.
>>
File: 1472516292639.png (566KB, 1000x352px) Image search: [Google]
1472516292639.png
566KB, 1000x352px
>>56967597
>how about ++C
that would be java!
>>
>>56969584
It's not so much the dom itself, but how changing it in jquery works. For example here's a simple loop i wrote to add some data to a panel. And this isn't even the beginning of the insanity my tiny web page needed. This is inside a $.each, and there's another $.each in there too somewhere.

$("#" + i).append(" \
<div id=\"collapse" + i + "\" class=\"panel-collapse collapse in\"> \
<div class=\"panel-body\"> \
<div class=\"row\" id=\"" + i + "control\" style=\"margin-bottom:15px\"> \
<div style=\"padding:5px\"> \
<button type=\"button\" style=\"margin-right:10px;\" class=\"btn btn-default\" \
onclick=\"someFunction('" + i + "')\"> \
<span class=\"glyphicon glyphicon-ok\"></span> \
Some text here \
</a> \
<button type=\"button\" class=\"btn btn-default\" \
onclick=\"someOtherFuction('" + i + "')\"> \
<span class=\"glyphicon glyphicon-remove\"></span> \
Some text here \
</a> \
</div> \
</div> \
<div class=\"row\" id=\"" + i + "someid\"> \
");
>>
Why do people dislike Java?
What makes it so bad, and does it have any positive qualities?
>>
>>56969718
Because they can't see sharp
>>
>>56969693
What would be a better way of doing this though?
>>
exokernel for ARM64
apparently the old amiga had something similar, it just did the minimum for startup and prevented race condition accesses / unprivileged accesses, neat
>>
>>56969718
Because it's a retarded version of C# and little else.
>>
>>56969718
It doesn't have any nice features. Think Ansi C + Classes - everything that makes C efficient + safety.

There is simply nothing in Java that makes programming nice.

But I think they've recently added some 90s technology to Java 9.
>>
>>56969693
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
>>
>>56969746
>exokernel
Why not endo?
>>
File: 1454531188660.jpg (214KB, 600x620px) Image search: [Google]
1454531188660.jpg
214KB, 600x620px
>mathfag trying to feel superior about their math skills in programming and how they're a better programmer
>mathfag writes a web page with numerous security vulnerabilities

defend this
>>
>>56969808
theres already kernels that came out of someone's endo, linux for one
>>
>>56966686
Repaired some minor bugs in my 4chan image donwloader in Prolog. Thinking about new features.
https://github.com/Floctioncers/Fi
>>
>>56969815
What's there to defend?
>>
>>56969584
I can't tell you how it *should* work unless you're willing to pay me a bajillion neetbucks to rewrite the Internet, but the way it currently works is why things like styling (CSS) are so fucked up. A styling language should be all classes, it should have absolutely nothing to do with the literal inheritance model of the styled document.
>>
>>56969627
too many keks
>>
>>56969833
Oh wow, someone seriously uses Prolog language.
>>
>>56969833
Make a gooey
>>
>>56969731
Some sort of DSL. React uses JSX as I mentioned which is ok, but not perfect. I've considered writing my own, with C-style syntax. For example my code above would be something like

div("collapse" + i, "panel-collapse collapse in") {
div("", "panel-body") {
div("", "row" + i + "control", style: "margin-bottom:15px") {
... and so on
}
}
}


Which would at least save having to escape every fucking ", and adding </div> etc. But all in all it doesn't save that much typing, so I don't know...

A lisp-like syntax might be nice as well.
Pug/Jade is okay but you can't inline it in javascript, and I'm not a fan of semantic whitespace... but it honestly might be the best way to do things.

>>56969789
Yes exactly.
>>
>>56969877
Yeah, there's not many of us. But for hobby projects it's actually fun and refreshing experience.
>>
>>56969889
literally pointless
doesn't need to be a dsl
>>
>>56969881
Gooey? The web chat application? Sounds interesting...
>>
>>56969889
>Which would at least save having to escape every fucking "
...
you know you can just do
var muhDiv = '<div width="50" height="50"/>';

right?
>>
>>56969923
That's a great point, but you still run in to problems with things like buttons that need both types of quotes. Like onclick='hello("some argument")'... That's much less frequent though. So I guess it's partially just me being dumb.
>>
>>56969889
why not just do
div("collapse" + i, "panel-collapse collapse in",
div("", "panel-body",
div("", "row" + i + "control", style: "margin-bottom:15px",
//... and so on
)
)
)
>>
>>56969951
Another trick i do sometimes to avoid strings looking messy is:
var muhDiv = 
'<div width="%%width" height="%%height"/>'
.replace("%%width", width)
.replace("%%height", height);

Real simple templating. Dunno, maybe it's shit though.
>>
File: 1475046926131-fs8.png (2KB, 404x404px) Image search: [Google]
1475046926131-fs8.png
2KB, 404x404px
How to develop new algorithms in Artificial Intelligence, when there are already good ones?

how do you come up with a new one?

this is hard, guise
>>
>>56969693
You know if you use ' to start a string it will auto escape " inside the string right? And vice versa.
And this is just about the worst way to go about this. Write just a tiny bit of boiler plate. Here's a tiny example:
function collapseDiv(i) { return '<div id="collapse' + i + '"class="panel-collapse collapse in">'; }
>>
>>56969998
You don't. It's really hard.
>>
>>56969998
Use your brain
>>
>>56969998
try to do something stupid and tedious.
>>
>>56970024
>>56970008
>>56970006
basically, i have to develop a new algorithm based on a paper
>>
>>56970074
I feel you, mate.
I guess, there's no cookbook for that.
>>
>>56970074
Some guy did his masters on a grass shader, so anythings possible.
Think of something that's really lacking or you want though.
>>
>4chan tab just crashed because of a memory leak
take heed those who wanna use Javascript
>>
>>56969998
>How to develop new algorithms
How do I find a cure for cancer?
this is hard, guise
>>
>>56969998
why do you have to do this
i can't imagine a scenario in which you are not in a phd program and don't have someone at least superficially responsible for your completing this
>>
>>56970137
It's for the artificial intelligence course, master's degree.

that's the course project
>>
>>56970110
sounds like a firefox problem
>>
>>56970137
forgot to say here >>56970150
my professor has written dozens of papers for conferences
>>
>>56970003
Sure after a certain point that becomes better. But checking the whole page, the only place where I reused an element (i.e. same element type and same classes), were the buttons.

>>56969997
My code already has enough regex nastiness in it.

>>56969962
That could work, and might actually be pretty easy to implement in javascript because you don't have to parse anything, just implement a div function that parses an arbitrary amount of arguments, first being id, second being class, third and onwards being optional things like style, or additional dom elements. You'd just have to make one function for each html element type.
>>
Consider this simple example C program to translate an infix expression into postfix form, taken from Compilers: Principles, Techniques, and Tools by Aho, Sethi and Ullman.

#include <ctype.h>
int lookahead;

main()
{
lookahead = getchar();
expr();
putchar('\n');
}

expr()
{
term();
while(1)
if (lookahead=='+') {
match('+'); term(); putchar('+');
}
else if (lookahead == '-') {
match('-'); term(); putchar('-');
}
else break;
}

term()
{
if (isdigit(lookahead)) {
putchar(lookahead);
match(lookahead);
}
else error();
}

match(t)
int t;
{
if (lookahead == t)
lookahead = getchar();
else error();
}

error()
{
printf("syntax error\n");
exit(1);
}


I don't understand the point of the match() function. Why do they constantly want compare lookahead == lookahead everywhere, and why is it named 'match'?
>>
>>56970199
Ask him then you dummy. Alternatively figure out a problem you want to solve with AI first, then figure out how to solve it.
>>
is every coding job pain and agony and torment and boredom or am i just doing it wrong?
>>
Learning to use gdb something I really should be doing?
>>
>>56970192
it's chrome tho
>>
>>56970254
>That could work, and might actually be pretty easy to implement in javascript because you don't have to parse anything
there must be a shitzillion JS frameworks that do this already. SInce JS is dynamic, it's not a lot safer than just using the html string. Probably helps if you use TypeScript though.
>>
>>56970281
If you want to write C then yes.
>>
>>56970266
>doesn't declare the type of main
>declares the type of lookahead
stopped reading there
>>
File: gets.png (439KB, 659x673px) Image search: [Google]
gets.png
439KB, 659x673px
>>56970280
If you're not coasting at your job doing the bare minimum while at the same time saving up all your bowel movements so you can get paid to shit and write personal open source projects on company time, you're doing it very wrong.
>>
Why doesn't your code read its own source to see what function it should call next?
>>
>>56970349
It does, that's how just-in-time compilation works.
>>
File: 1394654549165.jpg (11KB, 200x245px) Image search: [Google]
1394654549165.jpg
11KB, 200x245px
>>56970340
>coasting at your job doing the bare minimum while at the same time saving up all your bowel movements so you can get paid to shit
Relatable/10
>>
Why does liking Python make me a faggot
>>
>>56970366
Make it read itself again!
>>
>>56970292
ditto for c++?
>>
>>56970376
because shitters use it
>>
>>56970376
because stop using what i don't like
>>
Anyone have experience with MiGLayout (Java swing layout)? How do you feel about it?
>>
If only C++ had designated initializers. It would be quite the nice language.
>>
>>56970440
Are you a university student?
>>
>>56970471
If C had namespaces, it would be perfect.
>>
>>56970471
What's that?
>>
>>56970502
Add statement expressions, generics, defer, and closures. Closures are less important but defer doesn't work without them.
>>56970503
{ .a = 1 }
>>
File: doytoy.jpg (134KB, 720x960px) Image search: [Google]
doytoy.jpg
134KB, 720x960px
>>56970502
word
>>
>>56970477
yeap
>>
>>56970502
You can do namespaces easily with a C macro.
>>
>>56970502
#include <SomeLibrary.h>
// all identifiers begin with SomeLibrary_

#define sl(X) SomeLibrary_##X

:^)
>>
>>56970526
generics are pretty easy with macros dood
>>
>>56970526
It does have something like that?
>>
>>56970573
But then you don't get proper syntax highlighting.
>>56970582
"no"
>>
>c would be perfect with < other languages standard feature>
>JUST MACRO IT
C luddites are awful
>>
>>56969998
Think simple
>>
>>56970604
The point of C is to be minimal, that's why it's still used today.
Wanting to add huge features to it is nonsensical, just use a language with those features that isn't intended to be so small.
>>
>>56970502
The only thing I really want from SEPPLES is constexprs tbqhwy
>>
>>56970502
And member functions. Literally just syntactic sugar, but so nice at the same time.
>>
>>56970381
I think so but I can't speak from experience. But afaik there isn't a better C++ debugger.
>>
>>56970675
>
Just make a struct with a bunch of member function pointers

Don't go full retard.
>>
>>56970604
>>56970655
A common complaint is that C doesn't have namespaces or classes.

You can easily implement these in C without macros.
Just make a struct with a bunch of member function pointers and populate them when initializing your "object".

obj.do_something(&obj);

Since C has no support for "this" pointer, you also have to pass the pointer of the object you're working on, making you quickly realize that there's no fucking point to implementing "classes" in C.
>>
>>56970636
>wanting to add logical features and qol stuff is bloat
>anything that wasn't ordained in Ritchie-C is bloat
alright.
>>56970675
>c is minimal
>but all you have to do is needless tedium for a basic data structure
>>
>>56970704
You're misunderstanding.
It's meant to be minimal for the computer, not for you.
>>
>>56970637
good news!
>>
>>56970582
Get with the times gramps
type X is record
A : Integer;
B : Integer;
C : Integer;
end record;

Z : X := (B=>4, A=>2, others=>0);
>>
>>56970675
Literally 0 point to do that here.
Just prefix the name of the function with.
>>
>>56970702

Having to explicitly pass the self pointer is part of the issue. It's just not the same.
>>
>>56970768
C++ does the same thing, it just hides it from the user.
>>
>>56970731
language?
>>
>>56970731
Oh, ok, i see.

I have never missed such a feature in c++.
>>
>>56970796
You can't miss what you've never known anon
>>
>>56970781
Which is nice.
>>
>>56970768
#define call(obj, method, ...) (obj)->(method)(obj, __VA_ARGS__)
>>
The main thing I want in C is exception handling.

I want to be able to iterate over an array and catch the out of bounds exception when I'm done, instead of having to worry about null terminators and buffer size and gay shit like that.
>>
>>56970810
>The main thing I want in C is exception handling.
You're so wrong it hurts.
>>
>>56970804
I miss fucking women.
>>
>>56970810
>exceptions
BLEH

the array issue you're talking about has nothing to do with exceptions
>>
>>56970810
>C will never have D unit tests and all its wonderful features
>>
>>56970807
I'm sure you could write a macro to deal with this.
C++ used to be a bunch of shitty hacks on top of C back when the compiler was called cfront.
>>
>>56970810
Just implement bounds checking so your loops never go out of bounds, you dumbass.
And if they do go out of bounds, break out of the loop.

Why the fuck does try catch exist?
>>
>>56970781

If something is hidden from the user that makes it implicit, rather than explicit.

>>56970809

Still shit.
>>
>>56970810
Who not use sepples? It's close enough to C that your code can look exactly like your used to, and and you can use exception handling if you wish to.
>>
I just want better macro system and lambdas for.
You can't even do something like
#define inc(x) #include <x##.h>
#inc(stdio)


gcc extensions gives lambdas with {( }) but it would be nice if it was in THE STANDARD.
>>
>C would be perfect if it had <some feature C++ has>
Just use C++ like it's C with that feature. Easy.
>>
>>56970826
>I'm sure you could write a macro to deal with this.
Bjarne already did this.
>>
>>56970866
Write your own C preprocessor that rewrites your custom macros to whatever you want.
>>
>>56970866

LISP macros a best.
>>
>>56970871
>>56970471
C++ is also a bad language. Might as well use Rust at that point.
>>
>>56970795
"Meme" language nobody here cares about
>>
>>56970889
You're not using the bad parts of C++ if just do what I suggested, unless that feature you want IS bad

Rust just takes the trash syntax of C++ and makes an uglier, slightly better language.
>>
>>56970890
well i know that much
>>
struct foo {
int a;
int doStuff(int b) { return a + b; }
// real signature generated: int doStuff(struct foo* this, int b)
}

struct foo f = {.a = 2};
f.doStuff(3);
// real code generated: doStuff(&f, 3);


Basically copy Lua, let's hope for C21


>>56970810
That's a very complex area. Just allow multiple returns and establish the following notation:

int, _Bool someCalculation(int a, int b) {
// ...
if (/* success */)
return true, value;
else
return false, 0;
}

_Bool err; int v;
v, err = someCalculation();
if (!err)
foo(v);
}
>>
>>56970795
Looks like some kind of language agnostic formal notation.
>>
>>56970900
Ada
>>
>>56970912

If any of this ever comes to C I will eat a fucking hat.
>>
>>56970899
C++ doesn't have proper move semantics. Neither does it have sum types. And let's not even start with the compile times.
>>
File: C switch hackery.png (5KB, 376x214px) Image search: [Google]
C switch hackery.png
5KB, 376x214px
>GCC documentation actually encourages you to use do { ... } while (0) to make your macros swallow the semicolon because the macro system is so fucking shit

Why is C such a steaming load?
>>
>>56970899
Not him, but what ends up happening is down the road someone uses features of C++ that aren't supposed to get used on the project.
Then after awhile you start having these features not integrating where they're supposed to, and everything goes to shit.

It's why at my job we just use C and deal with the inconveniences, instead of using a small subset of C++.
>>
>>56970912
>Basically copy Lua, let's hope for C21
That's not gonna happen. No compiler implements this extension.
>Just allow multiple returns
Neither is this.
>>
if I have a situation where for, while and do while they all work, which one do I use?
>>
>>56970945
I believe compiler should bitch about this code.
You have case switches placed at nowhere.
>>
You can implement exceptions for C using setjmp and longjmp.
I saw one great implementation that had everything perfect except there is no exception struct, e.g. it was like so
int main(void) {
try {
something();
} catch (Error1Exception) {
handle1();
} catch (Error2Exception) {
handle2();
} finally {
fin();
}

return 0;
}
>>
>>56971000
Always use for if possible, while and do-while are for very specific purposes and aren't meant to be used often.
>>
>>56971000
Whichever would be more explicit and straightforward about what's going on. Probably a for loop.
>>
File: what?.jpg (32KB, 310x280px) Image search: [Google]
what?.jpg
32KB, 310x280px
>in 50 years, people will still be writing C
>people will still be using C89 because nobody wants to fully implement C21, C34, C47, or C5X's new quantum math library
>>
is there a good way to work on my own, earn a livable income with knowledge that is feasible self-taught in programming? reliably
>>
>>56971029
Let them toil in the pit.
>>
>>56971045
Sure, become a freelancer. Get good.

probably easier to find some shitty job that lets you work remote though
>>
Alright guys, I need some serious c# help.. I'm half retarded obviously. The code is below. The real code hits a stored proc and returns a datatable with the results...

http://rextester.com/FPK90510

I need to now use that returned object in the calling function to use values later on.

I see that it is
System.Data.EnumerableRowCollection`1[<>f__AnonymousType0`2[System.Int32,System.String]]
but I fail on trying to cast it, enumerate over it, ect. How can I enumerate over this returned object so I may store the values in a list<dic<>>?
>>
>>56971000

Don't listen to >>56971014
You'll end up with shit like
for(;;)
instead of
while(true)
.
Use whatever makes the most semantic sense.
>>
File: 1432763451412.jpg (72KB, 335x508px) Image search: [Google]
1432763451412.jpg
72KB, 335x508px
Computer sciences are very feminine. Honestly, it gives me a boner when I see a guy programming in public because it's like wearing lipstick and a skirt. I only come to this board for all the cute boys who worship gnu/linux and writes code.
>>
>>56968993
googling something I could post to underline my sense of humour actually solved a problem I had with a diy project.

thanks anon.
>>
>>56971082
#define ever (;;)
>>
>>56971067
>become a freelancer
that's very vague. what'd I do? Freelancing is just rephrasing my question, I'm asking what's the best approach to making a reliable living with freelance. what should I learn, how should I apply it, etc.
>>
>>56971109
Web dev i guess.
>>
>>56971109
Learn Java or C# and become a monkey
>>
>>56971090
This trap programmer meme is getting out of hand.

>>56971108
just use while (1)
>>
>>56971135
"become a monkey" sounds like a cooperative effort, I'd really like to make my own sources of revenue, it's literally impossible to get jobs without diplomas where I live and it's pretty much beyond me to get that in my situation
>>
>>56969998
why reinvent the wheel when there are so many learners out there?
>>
File: Ada_Lovelace_portrait.jpg (2MB, 2439x3504px) Image search: [Google]
Ada_Lovelace_portrait.jpg
2MB, 2439x3504px
>>56971090
Eh, sounds about right.

I'm gonna start wearing a Victorian style dress to work.
>>
>>56971153
I don't know. What about killing yourself then?
>>
>>56971151
>it's literally impossible to get jobs without diplomas where I live and it's pretty much beyond me to get that in my situation
move, or find a start up. Most startups are willing to hire anyone with a good GitHub portfolio.

Once you have work experience people don't care much about diplomas.
>>
>find a qt streaming programming
>it's a trap
>>
>>56971178
nice! I bet they're god-tier to write code in.
>>
>>56971190
w-where?
>>
>>56971108
Macros are evil, because of macro pollution, and should be avoided to the greatest length possible. Otherwise, i like it!
>>
>>56971188
really, I need to know what kinda approach I need to take, I don't know anything about code. What's the essentials to learn?
Also another issue is that with my mental deficiencies following a strict routine like a company wants is pretty unlikely.
I know it sounds naive to approach coding like this but I kinda need it.
>>
>>56971227
>Also another issue is that with my mental deficiencies following a strict routine like a company wants is pretty unlikely.
Describe this in more detail. If someone pays you to get a job done in a certain amount of time can you do it?

If you don't know anything about coding, you have a lot to learn before you can get a job doing it.

Any particular area that you're interested in?
>>
>>56971227
i worry about hitching your hopes to something you've never really tried
>>
>>56971257
>If someone pays you to get a job done in a certain amount of time can you do it?
probably. depends on the timeframe right? I have bipolar.
I don't have clear preferences, I like vidya but that's not necessarily what I wanna work with. I think my visual design senses are pretty poor by nature, but I'm not sure if that's just because I've always been scared to work on it, but that's my only concern.
>>56971289
Sure, but I mean, trying it is the easiest way to find out if that's a mistake, I just kinda need to know what's a good place to start.
>>
New thread:
>>56971303
>>56971303
>>56971303

No stupid reddit shit edition.
>>
>>56971311
>probably. depends on the timeframe right? I have bipolar.
You could probably work an office job then I'd say.

If you're new to coding I think a Java or C# job might be easiest to get into.
Thread posts: 318
Thread images: 33


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