[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 24
File: K&R himegoto waifux2.png (1 MB, 1000x1400) Image search: [Google]
K&R himegoto waifux2.png
1 MB, 1000x1400
old thread: >>54726833

What are you working on, /g/?
>>
>1 post early
kill yourself
>>
>>54731233
First for Haskell
>>
File: enough.jpg (33 KB, 600x564) Image search: [Google]
enough.jpg
33 KB, 600x564
Reading the entire section on higher order functions in javascript made me want to vomit in my mouth a little bit.

Everything about higher order functions in JS is so fucking wasteful and yet the author goes on and on about how "beautiful" and "clean" it is.

I can't even read half the shit he wrote, passing function literals is not elegant.
>>
>>54731288
Swap to Hasklel or F2#
>>
>>54731288
>being this autistic
>>
>>54731288
also post code
>>
>>54731288
>Reading the entire section on higher order functions in javascript made me want to vomit in my mouth a little bit.

SICP is the only answer.
Learn from the masters.
>>
>>54731288
Get raped and kill yourself, you retarded fucking faggot sack of shit with down syndrome.
>>
I was working on a program to create DLC deck recipes for Tag Force Special. That project died a quick death.
>>
Last night I started a little project for a simple renderer. I called it a night when I was too tired for simple vector calculations (how to find the viewport pixel world coordinates when given the eye point, another point the camera is looking at (defining view direction), distance of viewport from camera, viewport width and height in pixels and viewport width and height in object space).

Related to uni:
Reminder that NI LabVIEW and similar graphic """programming""" """languages""" are complete and utter shit and can't produce any results an hour or two of coding won't.
>>
>>54731473
nobody uses those meme tools anyway you sperg
>>
>>54731473
"Graphic/visual" (though they really aren't) programming languages are the future
>>
>>54731488
I should add - the problem is that all instances of them are shit atm
>>
>>54731485
Actually there are two modules just in the first semester of my masters studies that require similar shit: one needs LabVIEW, one needs simulink.
> you can't even zoom in on your frontpanel or block diagram in LabVIEW
> several GB download just to run it
> Windows only, maybe Mac, and some chosen few GNU/Linux distros if you bend over and pay
> have to set up a VM, pirate Windows and wait several hours just to use this cuck abortion of a programming environment
Why is this allowed? Going back home and just coding some C in gedit was bliss compared to that.
>>
>>54731562
>require
As in absolutely? No workarounds to get your projects done?
>>
What are some good ways to practice programming other than doing projects?
I am self-taught and not looking to be a software developer, but I need to program for finance, especially trading related.
>>
>>54731579
Nope, no alternatives allowed and I wouldn't even know if there are any. The point is to learn how to use these programming environments since they're """industry standard""" (i.e. idiots who barely passed their shit can have something to click around in because coding is harrrrrd, then give up and let me rewrite their program in C or Python). At least in the previous semesters we were allowed to substitute GNU Octave for MATLAB.
>>
>>54731115
well it gives 2 different results, probably due to rounding. Which is probably what he originally wanted
let ayy n = List.takeWhile(fun i -> i * i < n) [1 .. n]
let kek n = [1 .. n |> (float >> sqrt >> round >> int)]

> ayy 135;;
val it : int list = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11]
> kek 135;;
val it : int list = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12]
>>
I recently got into programming to start prepping for an upcoming course and this is throwing me off. My Java program compiles fine, and throws no errors, however it returns a 3 on my first sysln and a 2 on my 2nd. What is happening? Surely a pajeet can help? I started learning java tonight don't judge me /g/entleman


public class NewClass {
public static void main(String[] args){
int a = 1;

System.out.println(a^2);
System.out.println(a^3);
}
}
>>
>>54731768
>started learning java
Then it's a good time to stop
>>
>>54731768
^ is bitwise XOR, not exponent
>>
>>54731768
^ isn't exponentiation it's binary XOR
>>
>>54731790
>>54731791
java doesnt have bitwise operations you dunces
>>
>>54731790
>>54731791
Shoot me a pointer guys this shits weird. Thanks ahead of time.
>>
>>54731809
pajeet...
>>
>>54731809
Really?
https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.22
>>
>>54731809
This wasn't me, just help please. I'm clueless with java
>>
Haven't tested yet, but I think this ARM assembly should do add and shift multiplication:

.section .text
.global multiply

@ Compute multiplication of two 32-bit integers
@ without the use of a multiplication instruction.
multiply:
@ If second argument is negative, negate both arguments.
@ This ensures pos * neg = neg, neg * neg = pos, pos * pos = pos.
TEQ a2, #0
BPL .L1
NEG a1, a1
NEG a2, a2
.L1:
@ If first or second argument is 0, return 0.
MOVEQ a1, #0
TEQ a1, #0
BEQ lr
@ Employ a variant of square and multiply exponentiation
@ called "add and shift" to ensure O(log(a2)) multiplication
@ of the arguments. Register a3 will be used as a scratch for this.
MOV a3, #0
.L2
@ While a1 > 1:
CMP a1, #1
BLE .L3
@ If a2 is odd, add a1 to a3
TST a2, #1
ADDEQ a3, a3, a1
@ Multiply a1 by 2, divide a2 by 2.
LSL a1, a1, #1
LSR a2, a2, #1
@ end while
B .L2
.L3:
ADD a1, a1, a2
B lr
>>
>>54731819
When you xor 2 numbers, any bits that are the same return a 0, any bits that are different return a 1

  1001
^ 1100
----
0101
>>
>>54731836
You want to use
Math.pow(double,double)

so
public class NewClass {
public static void main(String[] args){
double a = 1.0;

System.out.println(Math.pow(a,2.0));
System.out.println(Math.pow(a,3.0));
}
}
>>
>>54731858
such verbose syntax for such common functionality, surely there must be an operator not in use they can use for exponents
>>
>>54731888
Welcome to java!
>>
What tool do you guys use for Class Diagrams?
Coding a side project and it's getting pretty big
Needs to look good and be easy to update
>>
>>54731888
If you are worried about that being verbose just wait for public static HashMap<Integer,IBullshitInterface> myvar = new HashMap<Integer,IBullshitInterface>()
>>
>>54731858
Will this work for exponential growth? Is that how Java works? I'm sorry to be such a fucking noob about it dude but I'm having issues finding some actual direction in this book.
>>
>>54731902
>UML

uml is a fucking scam and nobody bothers with this shit in the real world
>>
>>54731902
PyCharm has one built-in. It makes work really easy when co-workers are using mixins and inheritance fucking everywhere
>>
File: 1374575428855.jpg (113 KB, 1280x720) Image search: [Google]
1374575428855.jpg
113 KB, 1280x720
>>54731902
>Class Diagrams
>>
>>54731908
If you mean exponentiation off of a previous power you will have to:
double a = 2.0
a=Math.pow(a,2.0)
System.out.println(a) //4
a=Math.pow(a,2.0)
System.out.println(a)//16
>>
Gonna make a baseball GM sim for my summer project
>>
>>54731923
>>54731941
I'm 4th year software dev student and they do UML in most subjects
What are you telling me anon

How would you show a fellow coder your object relationships?
>>
>>54731975
I don't use OOP. It's an inherently flawed paradigm that encourages shared, mutable state.
>>
>>54731975
Nobody uses UML shit in the real world, anon.
It's too clunky to be useful and any non-trivial program layout is unreadable.

You share source code, because your peers will know how to read code as well, dumbass.
>>
>>54731959
I almost told you that was nonsense, but upon closer look that makes alot more sense. However, why is there no operator for a straight across exponentiation?
>>
>>54731985
t. jobless loser

>>54731994
It's not used extensively, but a tool for checking or quickly drawing is useful. Most jobs I've worked in don't use UML practices to their full, but know the value of a well-laid out quick diagram
>>
>>54732018
t. code monkey
>>
>>54731994
But if I get given source code with 10+ objects I get lost
As in I'm reading ObjectA, then I see it uses ObjectB, then C and I've completely forgotten about A
Having a diagram to show relationships can speed up the process of it all?

I understand that UML is fucking annoying to do but it's useful in some scenarios surely
>>
>>54732030
t. Alberto Barbosa
>>
>>54731985
good lad
>>
>>54732016
Most of Java's operators where stolen from C, which didn't have a exponent operator because exponentiation couldn't be done on hardware in the 70s when C was made. It was implemented in software for the most part so it was just a function.
>>
>>54732041
You sound like a moron tbqh senpai.
>>
>>54732045
is there even an exponentation opcode on any modern architectures?
it seems awfully specific, considering it's just repeated multiplication and squaring.
>>
>>54732045
That makes sense, thank you anon. I'll do more research before asking my questions. Thank all of you /g/entleman.
>tits for time.
>>
>>54732077
>it seems awfully specific
So many opcodes are awfully specific even at an opcode level
>>
can you rev progider
>>
>swift will have Higher Kinded Types before F#/C# and Rust
ogre
>>
what should i do for my summer project
>>
>>54732087
>>54732077
There is no strait power opcode, but this is a thing:
http://stackoverflow.com/questions/4638473/how-to-powreal-real-in-x86
>>
File: 1463860597347.jpg (47 KB, 621x502) Image search: [Google]
1463860597347.jpg
47 KB, 621x502
>>54732116
T-that's good for swift, i guess
>>
>>54732116
Everyone already knows swift is a god-tier language, it's flaw is that it's used for apple hardware, even if you use Linux (I believe you can use it in Linux)
>>
I have this function
void enter_breakpoint(unsigned long line_num) {

char buf[60];

strcpy(buf, "Entered breakpoint @ line #");
//strcat(buf, line_num);
strcat(buf, ". Press b to continue...");

send_debug_string(buf);
}


The call to this function is: enter_breakpoint(__LINE__);

I need to use these formats because they are what is provided.

void send_debug_string(char* string);

Only accepts char array. My attempts to convert this to a single char array has failed me. The above function basically takes in a string/char array and sends it to what ever serial is connected, it works and should be irrelevant.


//snprintf(buf, sizeof buf, "%s%lu%s", str1, str2, str3); - wont print to putty

//char vOut [11];
//_ultoa_s(line_num,vOut,sizeof(vOut),10);

//ultoa(line_num)

just a few different attempts


Yes I am a retard at C, and it's homework, this just isn't my usual thing.
>>
>>54732191
Try reducing your problem and use snprintf to convert the ul to a char* and do string operations as in your current function. Then play around with cleaning it up if you so please
>>
File: Screenshot_2016-05-24-23-35-41.png (141 KB, 1080x1920) Image search: [Google]
Screenshot_2016-05-24-23-35-41.png
141 KB, 1080x1920
Ah, the dangers of programming in assembly. Do I bother debugging this? Or should I spend the night doing something less autistic?
>>
>>54732285

Ah thank you, seems I was almost there.
>>
>>54732370
code?
>>
>>54732481
Here
>>54731845

Had to make a few quick changes to get it to assemble. Namely, .L2 needs a colon after it, and the B LR and BEQ LR need to become BX and BXEQ respectively, or else the linker will look for a symbol with that name...

I made a C version of what I knew it was supposed to look like, and it produced a correct result. That is, this works:

int multiply(int a, int b)
{
if (!a || !b) return 0;
if (b < 0) { a = -a; b = -b; }
int c = 0;
while (b > 1) {
if (b % 2) c += a;
a <<= 1;
b >>= 1;
}
return a + c;
}


But I want to beat the compiler in producing optimal code, for funzies. A bit difficult though.
>>
>>54732576
>But I want to beat the compiler in producing optimal code, for funzies. A bit difficult though.

This is literally impossible.
Good luck unrolling all your loops manually, faggot.
>>
>>54732576
>I want to beat the compiler in producing optimal code [to multiply 2 integers]
Not gonna happen
>>
>>54732597

There is one loop, and it is impossible to unroll for better optimization. But strictly speaking, I could reduce the code size by an instruction or two.
>>
So, lately I finished my first actual program that was meant to be used (albeit for fun). I programmed it on OS X, for OS X. I used C and the SDL2 framework. It runs just fine on my system, but when I tried to give the binary to a friend of mine, it didn't work (he's obv. also running OS X).

So, my question is: How can I include the parts of the framework I need into the binary to be independent of it? Programming is pretty boring when your programs only work on your own system.
>>
>>54732576
I looked at the code, and for a sec I thought I forgot what I did know about Assembly, since I only used it briefly, but I realized you're using a different type of Assembly, lol.

I only knew a little bit of basic MIPS x64 for a Comp Architecture class.
I've never seen those ARM commands before at all.

I wouldn't be able to help, then, sorry. =/
>>
>>54732644

It probably has something to do with me not correctly understanding what flags certain instructions are modifying. The algorithm is right, the implementation is wrong. It's not worth expending too much time on though, as shift and add multiplication has no real world practical use... except maybe in multiplying arbitrary precision numbers - I don't know what they use for multiplying bignums.
>>
>be me
>start project in nodejs
>have no clue about javascript
>do shit just like dog
>now after over a year project gets kind of working
>realize some flaws
>now that I know some kind of javascript realize how shitty it is programmed
fuck me
>>
>>54732642
Look into static linking the binary and the library. The program you gave to your friend is probably looking for libsdl2 on the system and it can't find it.
>>
>>54732739
I'm debating whether I should make my project in NodeJS or Django

What do you think senpai
>>
>>54732760
not him, but node.js
asynchronous is good once you get used to it
npm has a huge community, which benefits you
>>
>>54732760
Golang
>>
How do people perform math on numbers of arbitrary size?
Do they store every digit separately in a string?
>>
>>54732767
yeah I was thinking node, I have experience with async

now to decide what to program. I was gonna try a reddit clone since that seems to present an opportunity to learn about a lot of different topics
>>
>>54732775

That would be one way to do it, but it would be very inefficient. An 1024 bit integer might be implemented as an array of 32 32-bit integers (or 16 64-bit integers), and when adding is necessary, an add with carry instruction (or similar assembly mnemonic). Alternatively, a C programmer could check for overflow on addition and consider that a carry if necessary.
>>
>>54732757
this >>54732767
>>
>>54732642
you need to bundle the libraries or static link it

since this is OS X, your libraries were in the library folder.

OS X also has a way to bundle apps, look at that


is this a game?
>>
>>54732757
>>54732885
Thanks, I'll look into that. I was trying to google it, but just found shit. "Static linking" was the magic word I was looking for.

And no, it's not a game.
>>
>>54731233
>posting the homosexual anime image

Kys.
>>
>>54732932
>posting cyka blyat
>>
What monospace terminal font do you use, /dpt/-chan?~
>>
If I wanted to write a function that can be called in multiple types how would I go about doing that in C.
Say I want to write a simple implementation of vectors (c++) in C, since vector can be of int, double, float etc how would I implement this in C.?
>>
Is this really the best way to update a json node in python:
def set_cog(cog, value):
with open('data/red/cogs.json', "r") as f:
data = json.load(f)
data[cog] = value
with open('data/red/cogs.json', "w") as f:
f.write(json.dumps(data))


Because this just seems inefficient
>>
>>54732972
macros
>>
>>54732972
If you dont care about size you can just use void*. If you need the size you will need to write macros to either a) generate the required functions for the type, or b) use the macro as the function, but this would result in code duplication as you are effectively inlineing everything
>>
>>54733056
>>54733065
Thanks guys
>>
File: tewi-font.png (17 KB, 492x1038) Image search: [Google]
tewi-font.png
17 KB, 492x1038
>>54732959
tewi-font
>>
>>54733104
My screen resolution is pretty bad (1280x800), but even I wouldn't use pixel fonts.
Do you have your monitor 2 inches from your face or something?
>>
>>54733162
He probably wont upgrade from his 640x480 CRT because of nonfree microcode.
>>
>>54733162
In practice it's not so bad. It doesn't look too flattering because of the coloring, I think.
>>
>>54733178
Naw, I use an LED monitor.
>>
>>54733195
how much nose grease is on your monitor?
>>
>>54733200
About the same amount as is on your mother's ass.
>>
>>54733162
I use bitmap fonts on a 1080p

sounds like you need glasses or better color/font rendering desu
>>
>>54731233
is it bad that i recognize that trap?
>>
I've been stuck on a problem with node.js for fucking hours now and I need help. I have an array set up in express and I want to pass it along to jade, but I can't figure out how routing works. I have tried passing along basic strings and shit but it just doesn't work. Can someone give me some sample code for how to get this shit set up? I just can't figure it out.
>>
>>54733305
sounds like you're having webdev problems

we have a whole general for that
>>
>>54733325
I'll post there then, thanks
>>
I just finished understanding C++
and i think i got everything important.
What should i do now?
My plan is make a music player.
Have it be Modular, and the GUI Dynamically built.
haven't studied GUI yet though. and I'm thinking of just using Qt.
i would appreciate any nod in the right direction. because i'm a little confused on where to go from here.
>>
How to do real time computing in c++

I'm thinking of setting a time limit to terminate your program. Might be cool to use on things like codechef of spoj
>>
how to cloak on freenode? they took out the faq from their website
>>
>>54733014
You don't really have much choice if you want to update a json file. If you need to make a lot of changes then you should keep it in memory and only write it back to file once you're done.
>>
File: 02.jpg (28 KB, 400x240) Image search: [Google]
02.jpg
28 KB, 400x240
>>54733257
Is it bad that I dressed my mayor up like hime in animal crossiing?
>>
>>54733436
N-no?
>>
>>54733360
Literally just make shit, and when it's too easy, step it up. Sometimes you'll feel deterred by the length of a program and then end up failing in the middle of it, which is normal and part of the process of going from understanding to being elder-god tier
>>
File: what the fuck comrade.jpg (9 KB, 228x210) Image search: [Google]
what the fuck comrade.jpg
9 KB, 228x210
>making a directx11 implementation of my shitty graphics layer
IM DROWNING IN BOILERPLATE
SEND HELP
>>
I think I know why webdev faggots insist on writing backend and desktop apps in JS.

JS teaches some very nasty habits and it makes JS developers feel inadequate when they attempt to use C++, or even C, which have none of the cushy, wasteful features of JS, like the ability to return arrays as first class objects, anonymous function literals, and native closures.

So they stick with JS forever because they're literally too stupid to write those features in other languages without functional paradigms.
>>
>>54733360
the learning process is usually something like this for me:
>want to create library/program to do some shit
>get started
>end up with a functioning but horrible code abomination
>scrap it
>write new, good one because now you know how to structure and implement certain things much better because you have the experience of the first project
its scary how often this happens
>>
>>54733577
>webdev faggots insist on writing backend and desktop apps in JS.
i dont think i've met anyone IRL who honestly thinks this is a good idea
nobody likes JS, but its a necessity because there is literally no alternative

t. webdev faggot sitting in his office right now
>>
>>54733597
>i dont think i've met anyone IRL who honestly thinks this is a good idea

>backend javascript
nodejs.org
>framework for building desktop javascript applications
http://electron.atom.io/
>javascript for embedded devices
http://www.espruino.com/
>>
>>54733626
can you read?
>>
trying to find will to live without a qt androgynous slutty bf
and working on my gnu/turd microkernel
>>
>>54733597
>>54733626
The anon said they don't like it, but there's no alternative.

I also into JS. I don't like it. The syntax is shit. But, there's no more-C/C++-like alternative that is still asynchronous.
JS can do some cool shit, m80, but I think I'd cum if there was an asynch language to come out that was more like C/C++, or even more like PHP (although, I am NOT a fan of how loosely typed it is...)
>>
>>54733688
unless gril,
lol, faggit
literally.

also:
>using GNU/[anything], girl or not
lol, faggit
>>
>>54733707
k
>>
File: yumons.webm (3 MB, 624x350) Image search: [Google]
yumons.webm
3 MB, 624x350
/dpt/-chan, dai suki~

Ask your much beloved /g/entleman anything (IAMA)

>>54733688
The kernel is actually GNU Mach. GNU Hurd is only the server.

>>54733360
>I just finished understanding C++
>and i think i got everything important.

move semantics ?
class templates ?
traits ?
iterators ?
virtual destructor/constructors?
diamond problem ?
do you know how to catch exceptions from an initializer list ?
do you know how to recursive declarations ?
have you done every gotw ?

>>54733551
>directx
>not doing software rendering
Kek.Why would you need directx ? tim sweeney wrote a 3d software renderer for unreal tournament on a 90MHz pentium.

>>54732972
You can either

1. macros that expands code for each type[1]
2. relying on void pointers
3. writing everything by yourself for each type then abstract that with _Generic
4. ditch C in favor of C++

protip: pick 4

[1] https://neetco.de/CodeArtisan/cdptlib/src/master/source/arraylist.h

>>54731582
hackatons
challenges
contributions
>>
>>54733360
Not trying to discourage you, but you need to forget about your project for a while. A big project like that needs to be organised with some foresight, but you don't have that foresight yet. There's still a lot to learn, and I believe big projects are a shit way to learn new things (other than how to organise a big project).

If I were you I would start with some stuff that sounds ridiculously simple, but is actually quite difficult when you simply are not familiar how these things work. Write a simple function that reads wave function and then plays them. Add some controls, little by little. You'll notice that you will learn a lot of stuff and by the end of even that simple little program you know that you should have done the whole thing in an entirely different way. You don't want this for larger projects. For those you need to understand the details of the implementation well enough to plan it out before even writing a single line of code.

Of course, maybe in a while you can get back to the original plans, but for now you should stick with understanding parts of it. Putting it all together is harder than it sounds.
>>
>>54733781
wrong, the kernel is entirely own making, I named it gnu turd for humor purposes
>>
>>54733360
SDL can play a number of audio files.
you could also use libVLC

SDL might be the best way to go for the graphics, as well, unless you wanna learn OpenGL, Cairo, or Allegro. OpenGL/SDL is probably the best option for that, though.
>>
What's a good read or a good storage of online information, a class of sorts, to help me with C#?
>>
>>54732959
Lemon
>>
File: yumonsa.webm (3 MB, 624x350) Image search: [Google]
yumonsa.webm
3 MB, 624x350
>>54733816
What wrong ? In the OS GNU/Hurd (sometimes GNU+Turd), GNU Mach is the microkernel while GNU Hurd is the server.

>>54733816
>the kernel is entirely own making
Never said otherwise.

>>54733816
>I named it gnu turd for humor purposes
But it's already a slang for GNU/Hurd

>>54733935
https://github.com/Michael0x2a/curated-programming-resources/blob/master/resources.md#c-sharp
https://github.com/quozd/awesome-dotnet
>>
>>54733781
C++ or C#, which has a wider range of uses.
Or is it personal preference?
>>
>>54733996
c++
>>
>>54734030
Why?
>>
>>54734057
c# is still badly supported on unix, embedded systems (mobile included), ...
there are much more libraries and tools for c++
>>
File: MTIwNjA4NjMzNzAzNzI4NjUy.jpg (14 KB, 300x300) Image search: [Google]
MTIwNjA4NjMzNzAzNzI4NjUy.jpg
14 KB, 300x300
>tfw watching someone fail at compiling boost
>>
>>54733578
thanks for sharing the experience, that kind of way to go forward with project scares me too often.
I tend to plan ahead, and sometimes use UML and the sort, but only on paper.
But even with planning it almost always ends up that way.
>>
>>54734057
This guy is full of shit.
There's little to be done in C++ that couldn't be accompolished in C#.
I wouldn't ask for opinionsome around here, unless you like giving a ton of weight to the thoughts of inexperienced juniors who will either not make it in this field, or grow and change their opinionsite considerably.

With exceptions to very low level projects such as systems programming (which is mostly done in C anyway), there's little reason to favor C++ or C#.
>>
>>54734080
What if I use C# only for my own projects; will I have trouble transitioning to C++?
>>
>>54733781
thanks for listing those, there are some i haven't gone through.
also can you tell me what gotw is short for?
>>
>>54734153
guru of the week, it's about pitfalls in c++
http://www.gotw.ca/gotw/
>>
>>54733781
>Kek.Why would you need directx ?
because i need to interface with other software that all run on directx9 or 11
>>
>>54733688
i'll be u are qt androgynous slutty bf anon-chan
>>
>>54734152
c++ syntax wise is very different from c#, but if you know one then you won't have much trouble learning another
>>
>>54733688
>>54734205
There's an entire board for you faggots, go there.
>>>/lgbt/
>>
>>54734182
>interface with other software
>all run on directx9 or 11
>I don't know what the fuck I'm talking about
ok
>>
>>54733987
>3 you's
you're gonna make me cum anon
>>54734205
are you slutty and how feminine is your cock sissy-chan
>>
>>54734236
ew no those people are gay

>>54734242
yes, and not at all unless you call 7 inches feminine
>>
>>54734239
>inject my program into some other program
>my program needs to draw shit on screen
>place hooks on directx api calls and draw shit using the already properly initialized device and resources instead of having to create my own
fucking idiot
>>
>>54734242
kill yourself
>>54734255
kill yourself

Suicide is cute as fuck and I'll date you both upon completion of this demonstration of your commitment.
>>
>>54734279
no ty thx for offering tho
>>
>>54731233
So I have been learning Python for a while now and want to move onto something that doesnt require a runtime to be installed plus I want to work on some open source projects in C++ so I have been looking at a few books. I have got it down to the following, which would you recommend g?

>Programming Principles and Practice using C++ 2nd edition
>Starting Out with C++ from Control Structures Through Objects 8th edition
>C++ Primer 5th edition
>Jumping into C++
>>
>>54734279
why? life is awesome and happy now that I have a qt androgynous bf :3
>>54734255
i guess you'll have to make up for it by looking feminine from behind and with your girly moans :3
>>54734236
but /g/ = gay general
>>
>>54734278
>making directx implementation of graphics layer
>injecting
fucking webshits, I swear
>>
>>54734336
>my program draws using the graphics layer
>layer is initialized to different implementations depending on what version of directx the target uses
stop pretending like im the retard here
>>
>>54734325
>>
>>54734365
>im the retard here
we know
>>
Hey gee, how about them 2d arrays?
>>
>>54734383
lmao, this thread is going to shit, kek. XP

go back to /b/
>>
>>54734383
>damage control
get fucked
>>
>>54734389
they... are 2D... and they're arrays...

and waifu's are 2D, and I like waifus, so I guess 2D arrays are ok with me
>>
>>54734392
>I'm a NEW retard
you don't say
>>
>>54734389
var ayy = new int[5, 5];
>>
>>54734560
lol, dawg, I'm not even that guy, XP

And I ain't new, I pop by these threads every so often. I've just never gotten to see a full-blown retard war in one.
>>
>>54733597
JS is great, a scheme gone mainstream. JS haters are C cuckolds that can't into higher order functions and the prototype chain.

Enjoy your segfaults and buffer overflows.
>>
well, I finally got the user tables set up for my website.

I think they're pretty good.

I'm gonna take a break for now, then do some of this consulting thing I'm doing.

Later or tonight, I'll finish making the signup system.
It's a real fucking load off to get some of the major SQL outta da way.
>>
>>54734782
Post schema, I need to fap.
>>
>>54734746
>I ain't new
>every so often
rajesh, come on, we all know
>>
>>54734773
Know any good sites to learn the Javascripts?

I've never worked with it, and it's actually becoming a thing for desktop dev.
>>
>>54734773
>a scheme gone mainstream.
wtf, confirmed for not knowing anything about scheme nor javascript.
>>
>>54734773
>muh frozen tabs tho
top fucking kekels
>>
>>54734773
JS syntax sucks.

I'm not a C cuck, but C++ damn sure has better... everything.
Too bad there's nothing like a "mobile C". I'd replace Java with that, too, if it was available.

Mobile C++ to replace Java
Web C++ to replace JavaScript and PHP

something to replace SQL that has more C-like syntax.

C/C++ is just too damn good. Ain't nothing cuck about it. It's just too feckin' good.
>>
>>54734826
>C++
>Not complete garbage

>Grouping C and C++ together
>>
>>54734826
>C/C++ is just too damn good. Ain't nothing cuck about it. It's just too feckin' good.

words of wisdom
>>
>>54734826
i just wish the build process wasn't so slow (and complicated when managing a lot of dependencies)
yeah sure theres autoconf and cmake but neither of them are great if you also need your shit to build on windows
>>
File: OhYou.jpg (33 KB, 576x452) Image search: [Google]
OhYou.jpg
33 KB, 576x452
>>54734807
lol kek, I don't always pop on THIS thread. I also use the other threads, dumbass. /wdg/, desktop threads, /bst/, /sqt/, sometimes one of the Windowx vs Linux vs Mac [whatever the hell they're fighting about that day].
Also, the much more rare, tech NOT related to computers threads. Sometimes, those can be really cool.

I do /dpt/ maybe a couple times a week, though, depending on what I'm doing.

>>54734799
lol, you a funny dood. This is gonna be a commercial website...
>pic related
I'll let you see the users table, though:
create table if not exists users_t(
username varchar(32) character set utf8mb4 collate
utf8mb4_unicode_520_ci not null primary key,
password varchar(40) not null,
password_tmp varchar(40),
dispname varchar(64) character set utf8mb4 collate
utf8mb4_unicode_520_ci not null,
account_type enum('ADMIN', 'MOD_HIGH', 'MOD_MEDIUM', 'MOD_LOW', 'STANDARD') not null default 'STANDARD',
account_tester enum('BETA', 'ALPHA', 'NONE') default 'NONE',
account_state enum('ACTIVE', 'LOCK', 'BAN') not null default 'ACTIVE'
)engine innodb character set utf8mb4 collate utf8mb4_unicode_520_ci

(Yeah, I know some of the encoding is a bit redundant, but I'm leaving it in atm in case I want to change anything)
>>
>>54732191
char buf[60];
snprintf(buf, 60, "Entered breakpoint @ line #%d. Press b to continue...", line_num);
send_debug_string(buf);
>>
>>54734858
I use Windows, actually.

And the fucking dll files are annoying as shit.

I should really look if C::B has an option that automatically places them in the directory, come to think of it.
>>
>>54734826
>C/C++
ask me how I know you're mentally ill, webshit
>>
>>54734899
>/wdg/, desktop threads, /bst/, /sqt/
you can't make this shit up :^)
>users_t
retarded by /wdg/ standards too
>>
>>54734936
>is clearly the same person, because the syntax of your posts is the same throughout this thread
Why you such a faggot, famalam?
>>
>>54734899
>PK on varchar
>password varchar(40)
>40

1/10 made me reply
>>
>>54734957
just ask me how I know
>>
>>54734958
>>PK on varchar
Well, it's gotta be unique anyway, so why not? Why throw in a PK on some bigint(127) and ALSO a unique key on that varchar?
>>password varchar(40)
>>40
sha1 of user-entered value and some salting strings.
duh.

>>54734956
Well, I took a class with Oracle, and I think it just helps, especially if I add views later on.

>>54734966
Not gonna give you the satisfaction, fag-alam
>>
>>54734997
>I'm embarrassed to find out what gave me out
of course you are, little shit stain
>>
>>54735020
lol, the trolling is strong with this one.
>>
What's the best way to program in C/C++ on Windows?

>inb4 linux
I'd like to, but I need windows

I'm not really looking for a big IDE, just something lightweight and small which doesn't throw a billion different project specific files at me.
>>
>>54735053
VM on top of windows using emacs
>>
>>54734899
sql scrub here, what does 'collate XXXX' do?
>>
>>54735053
MinGW, CMake and a text editor of your choice.
>>
>>54735053
Code::Blocks is pretty good.

It's not really "small", but it definitely doesn't make a billion files.
It's also relatively easy to work with.

Only problem is it takes about a minute to load. If you use RAMDisk, you should probably put it in there. If you will use it a LOT, throw it in startup folder.
>>
>>54735053
>on windows
>not using visual studio, literally the only redeeming quality of developing on windows
the fuck am i reading
if you are worried about bloat you can compile using the commandline and nmake anyways
>>
>>54735069
It's basically just how it organizes the data.

Honestly, I didn't look heavily into it, I just wanted the character set with the most characters available. It's gonna be a social network, so I need to accept every humanly-imaginable character you can type into a computer.

utf8mb4 is like an extension of utf8, and utf8mb4_unicode_520_ci is a slightly updated character standard from utf8mb4_unicode_ci, so it handles more characters correctly.
>>
>>54735053
>C/C++
what's the best way to program in java/rust?
>>
>>54735095
>Visual Studio
He said:
>lightweight and small which doesn't throw a billion different project specific files at me.
>billion different project specific files
You done goofeded, m90
>>
>>54735119
he's asking about IDEs, any decent IDE should handle both C and C++
>>
>>54735053
Just use any text editor with command line compiling if you don't want to use an IDE.
>>
>>54734997
>>54735115
I guess you are only expecting like 10 users on your "social network" a flat table should work just fine then if you do not see an issue with making a text column your PK.

>sha1
Yep I know for sure this isn't legit consulting work and you are just some freelancer in their 2nd year of undergrad building a facebook clone for a mom and pop business.
>>
>>54735095
I would also like to use Visual Studio, but it seems to be broken for me.

>try to add class
>are you sure this would like to access your computer blah blah blah
>yes
>add class wizard doesn't appear
>try to sign in
>it crashes

I can't use it.
>
>>
>>54735168
>dodging the question
you retarded m8?
>>
>>54735169
shiggy
>>
File: 1462742360823.jpg (145 KB, 700x700) Image search: [Google]
1462742360823.jpg
145 KB, 700x700
god damn i love this circlejerk thread
>>
big dick playa here, be careful what you say unless you want to have your mouth raped hard
>>
>>54735181
>using a class wizard
>getting UAC prompts in VS

What are you even doing? Did you pirate Enterprise or something?
>>
>>54735212
It's not a UAC prompt. It's some weird prompt from some webbrowser

I don't fucking know

I have VS2015 community
>>
>>54735233
>It's some weird prompt from some webbrowser
Screenshot?
>>
>>54735159
i know what he said, but i dont get why its a problem
i mean, they're basically just the equivalent of the configuration scripts, build scripts and makefiles you'd end up with if not using an IDE

>>54735212
>class wizard
>signing in
the fuck are you doing?
just add a code file/header file to your project, its literally two mouse clicks
>>
File: Capture.png (20 KB, 935x445) Image search: [Google]
Capture.png
20 KB, 935x445
>>54735239
i have no idea

i click yes and nothing happens

i click no and nothing happens
>>
>>54735176
>I guess you are only expecting like 10 users on your "social network" a flat table should work just fine then if you do not see an issue with making a text column your PK.
Ok, fine, you know, I looked it up.
If it's gonna cause that much fragmentation, what should I do?
Just change that to unique and throw an otherwise meaningless numeric value PK into that table?

The other problem with that is that all the foreign keys relate to username.

Is your suggestion that I also change each and every one of those, too?

No, it's not for 10 people. It's supposed to grow and be an alternative to Facebook.

I wanted to avoid unnecessary locks on tables to search up user ID's.
The goal was to run it all in a single transaction.
>>
File: 1463865958806.jpg (41 KB, 640x360) Image search: [Google]
1463865958806.jpg
41 KB, 640x360
>>54735267
If something that simple stops working, I don't know what other things I need might not work too.

I miss the days of using vim with guake with none of this bullshit

i want to use linux
>>
>>54735271
>i have no idea
webshits, everyone
>>
Why isn't gcc's __typeof__ extension in the C standard yet, /dpt/?
>>
>>54735332
because C is shit
>>
>>54735303
dont you ever tire of shitposting?
>>
>>54735332
Why don't you propose for it to be included in C2X?
Considering that _Generic is a thing, typeof() doesn't seem like such a stretch to add.
>>
>>54735271
Are you debugging your webshit in Internet Explorer?

That's an out-of-the-box prompt for IE when active content is one a page.
>>
>>54735338
do you?
>>
>>54735360
>_Generic is a useless thing
ftfy
>>
>>54735376
I have no fucking clue.

I'm not programming anything web related either.
>>
>>54735332
there already c++ for that. c is obsolete and dead.
>>
>>54735468
>useless
You're just no being creative enough.
#include <stdio.h>
#include <stdbool.h>
#include <assert.h>

int my_fn(int a, int b, int c)
{
printf("%d\n", a + b + c);
}

struct _def;
#define DEF ((struct _def *)NULL)
#define GET_DEF(arg, def) \
_Generic((arg), \
struct _def *: def, \
default: (arg) \
)

#define IS_DEF(arg) \
_Generic((arg), \
struct _def *: true, \
default: false \
)

#define my_fn(...) _my_fn(__VA_ARGS__, DEF, DEF, DEF)
#define _my_fn(a, b, c, end, ...) \
do { \
static_assert(IS_DEF(end), "Too many arguments to my_fn"); \
(my_fn)((a), GET_DEF((b), 0), GET_DEF((c), 0)); \
} while (0)

int main()
{
my_fn(1);
my_fn(1, 2);
my_fn(1, 2, 3);
my_fn(1, DEF, 3);
// Fails to compile
//my_fn(1, 2, 3, 4);
}
>>
Do you guys still stick to the 80 column rule?

I'm trying to become a more disciplined programmer as I'm a bit of a messy hackjob atm.

Any other good practises worth recommending?
>>
>>54735709
>Do you guys still stick to the 80 column rule?
Fuck no, it's constraining and impractical.
>>
>>54735709
Not really, we're no longer working in 80x22 terminals so there's no reason to.
>>
>>54735709
>Do you guys still stick to the 80 column rule?
I try to keep it under 80, but I only set a hard limit at 100.
>>
>>54735709
>>54735752
>>54735764
>>54735776
I stick to 120 characters. Anything over that and the lines are too wide to read comfortably.
>>
>>54735709
yes, please, you have to think for the one who want to browse multiple files at the same time on a single monitor.
>>
>>54731768
Are you trying use exponents?
^ is bitwise XOR. For exponents, use Math.pow(base, exponent)
>>
>>54735681
>proving the point
>>
>>54735709
Yes.
>>
>>54732959
terminus but I'm kind of bored of it
>>
>>54735907
Default arguments, with maximum argument argument checking in standard C and zero runtime overhead.
How is that not useful?

There are a couple of macros to implement the machinery, but you can use it for as many functions as you want.
>>
>>54735468
>abstraction technique
>useless
why have you not read your sicp ?
>>
>>54735954
>Default arguments
yeah, totally worth that macro clusterfuck
>>
>>54735997
>worthless abstraction
>>
>>54736049
>3 macros
>One is just a pointer cast
>The others are simple _Generic cases with two cases

>Two wrapper macros over each function
>One of them trivially calls the other one

>clusterfuck
You must not be very good at C.
>>
File: 32321112331.gif (30 KB, 600x260) Image search: [Google]
32321112331.gif
30 KB, 600x260
Any recommended books on parallelism? Working with c++, but general would be fine too I suppose
>>
How will one go about splitting a quantity on non equal parts but the resulting parts while random much be within a certain amount of the of the amount the part will have been if split evenly?
>>
>there are people who unironically only use C for everything
damn
>>
>>54736115
C++ Concurrency in Action is the standard reference.
>>
>>54736134
C is good for some things, but no language is good for all things.

Yes, some "purists" do that, do. All languages have them.
>>
>>54736130
>How will one go about splitting a quantity on non equal parts but the resulting parts while random much be within a certain amount of the of the amount the part will have been if split evenly?
>>
>>54736130
>>54736172
Say I have to split 100 in ten parts.
Evenly I get 10x10.
The way I want to calculate it you get
12,8,9,11,10,12,12,8,8,10 = 100

I want a formula that gives random splits within a certain range of 10.
>>
>>54736105
>Two wrapper macros over each function
that's 2 too many
>>
>>54736134
yes there are
https://balde.rgm.io/
>>
>>54736105
>muh macros
>can't average 2 ints
>can't into aliasing
>can't into arrays of arrays
>you must not be very good at c tho
anon...
>>
>>54736268
>Implying that wrapper macros are a bad thing
Dumbass. They are very useful, especially for adding shit like sentinel values at the end of variadic functions.

>>54736293
Stop projecting your incompetence onto everyone else.
>>
>>54736206
someone was talking about this a few weeks back

look at the archive
>>
>>54736206
take 5 numbers in range 1-19
then subtract the first five numbers from 20
Shuffle
>>
kys retarded webshit sperg trap cmen cshart hasklel
>>
>>54736364
I don't get it. Explain further if you please.
>>
>>54736451
There's lots of solutions to your problem. The first step would be to figure out what you want the range of numbers to be.
>>
>>54736451
arr = array of ten integers

for i = 0 to 5
take a number in range 1-19 and put it in arr[i]

for i = 6 to 10
take the result in arr[i-5] and subtract it from 20; put the result in arr[i]

shuffle arr for good measure.
>>
>>54736451
20-x=y => x+y=20
5x20=100
>>
>>54736514
ok say 100 in ten parts split randomly but within a range of 2 from 10 so [8,12].
>>
>>54736526
It works beacuse the pairs arr[i] + arr[i+5] will all sum to 20, so the total will sum to 100.
>>
>>54736536
in that case you do
>>54736364
in range of 8-12 instead of 1-19
>>
>>54736536
Same as >>54736514 but take a random number in range [8, 12] in the first loop.
>>
>>54736526
Oh and I made an abvious error with array indexes in the first loop
Thread replies: 255
Thread images: 24

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.