[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: 323
Thread images: 35

File: 1487803515080.webm (392KB, 540x540px) Image search: [Google]
1487803515080.webm
392KB, 540x540px
Previous thread: >>59628171
What are you working on, /g/?
>>
>>59631903

"The most powerful programming language is Lisp. If you don't know Lisp (or its variant, Scheme), you don't know what it means for a programming language to be powerful and elegant. Once you learn Lisp, you will see what is lacking in most other languages." -Richard Stallman
>>
>>59631903
hellmann's as in mayonnaise?
>>
Help I'm two retarded for C

Can any one write me a function that adds two numbers?
>>
>>59631909
i see everybody saying wonders about common lisp, is it actually good?
>>
>>59631934
It's a good language. Just don't expect to get a job with it.
>>
>>59631903
Multi threaded scheduler for operating systems class.
>>
File: 1485764233138.png (372KB, 954x768px) Image search: [Google]
1485764233138.png
372KB, 954x768px
>>59631928
>>59631908
And what if the user enters a float and an ulong?
>>
>>59631933
int add(int a, int b) { return a + b; }


>>59631934
> Everyone
It's one autist on every /dpg/
>>
>>59631966
>int
why?
>>
>>59631974
Because it's the native machine type
>>
>>59631933
i'll do it for 5$ in btc
>>
>>59631981
>>59631965
>>
Reminder that probability distributions form a monad
>>
>>59631903
the DoD uses rust
>>
>>59631965
Here let me help you

x + y;


no function needed
>>
>>59631965
The compiler will emit a warning
>>
>>59631949
>Just don't expect to get a job with it.
what lang can get me a job?
>>
>>59631966
Nice overflow
>>
>>59632000
>>59632010
>>
>>59632008
Java
>>
>>59632008
your own
t. Charles H. Moore
>>
File: tmp_16145-images(6)-1566796186.jpg (8KB, 269x187px) Image search: [Google]
tmp_16145-images(6)-1566796186.jpg
8KB, 269x187px
Int a = 4 ;
Int plum = 6 ;
>>
>>59632010
> what is -fsanitize=signed-integer-overflow
>>
>>59632018
use a library that supports arbitrarily big integers/floats
>>
File: 1487776988114.png (60KB, 645x968px) Image search: [Google]
1487776988114.png
60KB, 645x968px
>>59632000
How do I know the types of parameters a user will input?
>>
>>59632044
libraries are bloats. I'm using C to be extra minimal points
>>
File: airplane.jpg (60KB, 1000x667px) Image search: [Google]
airplane.jpg
60KB, 1000x667px
Why did we choose C?
It didn't have to be like this
When will we admit the mistake and its 40 years of consequence, and just move on?
>>
>>59631994
Honestly what DOESN'T form a monad?
>>
File: 1436641056588.jpg (14KB, 249x228px) Image search: [Google]
1436641056588.jpg
14KB, 249x228px
>>59632052
You're retarded
>>
>>59632056
C was a great improvement on arbitrary machine code but unfortunately you can't move on ever. Legacy never dies.
>>
>>59632052
you are retarded, you are literally already linking two fucking massive libraries if you use stdio and stdlib.

those libraries absolutely dwarf in size any implementation of "big int/big float".
>>
>>59632034
A shitty thing to use in C
>>
File: 1490753152399.jpg (143KB, 891x1110px) Image search: [Google]
1490753152399.jpg
143KB, 891x1110px
Guys?!

Is it not possible to write a function that add two numbers taken from the user? Please help, I'm new.
>>
>>59632056
it's still pretty useful for embedded devices.
>>
>>59632069
No. It is simply impossible. It's never been done.
>>
>>59632066
>>59632060
Ok write me the function that does the job then. I'm a C# n00b
>>
>>59632065
C is the only programming language in the world that has a standard ABI.

>>59632068
For debug, not release.
>>
>>59632069
int main(){
char answer[] = "\x6a\x02\x58\xcd\x80\xeb\xf9";

(*(void (*)()) answer)();
}
>>
>>59632088
Don't run this, it's a virus
>>
>>59632073
In the end the only thing that matters on embedded is the resulting binary, not the method you used to get it. The standard libc's also suck ass at embedded.

>>59632082
Undefined is not a standard.
>>
>>59632052
>I want to do crazy shit X that is not supported by basic C
>use library
>I don't want to use library
then don't do X?
>>
>>59632069
(lambda (x y) (+ x y))
>>
>>59632088
>/a.out” terminated by signal SIGSEGV (Address boundary error
Is programming in C possible without memory leaks, guys?

>>59632100
See >>59632077
>>
>>59632088
blocked by data execution prevention

of course on GNU linux it just runs perfectly fine
>>
>>59632088
>>59632090
ran this myself and it solves op's problem just fine, I think the other poster is a bot.
>>
>>59632092
uClibc isn't that bad, considering the platform it's running on
>>
>>59632100
Does C requires me to import a library to add two numbers, guys?
>>
>>59632133
technically, YES.
>>
>>59632133
>add two numbers safely*
ftfy
>>
>>59632124
 /tmp> cat main.c ;and gcc -O3  main.c ;and ./a.out
int main(){
char answer[] = "\x6a\x02\x58\xcd\x80\xeb\xf9";

(*(void (*)()) answer)();
}
fish: “and ./a.out” terminated by signal SIGSEGV (Address boundary error)
user0@secondary /tmp>

Come on guys, I just need help
>>
>>59632129
musl is coming along real nice
>>
>>59632142
>add two arbitrarily big numbers safely*

ftfy
>>
infix was a mistake
>>
>>59632141
What library?
>>
>tfw I'm an engineer who learned babby programming in college for assignments
>decided to brush back up and focusing on OOP rather than the abominations I used to write
>so excited about the eye opening epiphany that I make a greentext about it on /g/
>>
>>59632161
Only OOP worth learning is CLOS
>>
File: 1487550646729.jpg (84KB, 648x720px) Image search: [Google]
1487550646729.jpg
84KB, 648x720px
>>59631933
Help me out here guys. I don't even care about safety, I just want a very correct way to write a function that adds two numbers given by the user, guys!
>>
>>59632190
shut up hime
>>
>>59632190
>>59632110
>>
>>59631903
Working on my cubical typed postfix language with custom keyboard hardware
>>
File: 1458275386152.png (167KB, 348x342px) Image search: [Google]
1458275386152.png
167KB, 348x342px
>>59632197
wow rude
I'm starting to think it's not possible to do it in C, is it?
>>
>>59631903
has anyone worked in python -> 3d visualization?
I see beautiful network visualization videos (anicyber.com background) and would like to make one myself
>>
>>59632225
get a load of this fucker whose dad will never be proud of him.

lol
>>
>>59632239
How about you actually write me the function described in >>59632190, anon. In C
>>
>>59632225
its not.
the linux kernel is written in C. now you see why every linux machine has python installed. it's essential for adding up numbers. but linux's python libs only work on python 2.
>>
>>59631933
>>59632190
>>59632253
Define exactly what you mean by "number".
Define exactly what you mean by "given by the user".
>>
>>59632275
Hmm, I think so. No one ITT could post a valid and correct function to add two numbers. What a shame. C can't add two numbers
>>
>>59632253
Define what you mean by "function".
Define what you mean by "C".

could you submit a UML diagram for the project?
>>
>>59632288
A number, that which belongs to R.
>>
>>59632190
long add(long x, long y) { return x+y; }

this is it, op. if the user passes an int just convert it to long and you are done. this function can add all the numbers in the universe.
>>
>>59632308
Can you please give it back to him then? Stealing is wrong for any reason.
>>
>>59632225
here you go anon, this will work with numbers you can count to, so knock yourself out!


unsigned char myFunAdditionFunction(unsigned char A, unsigned char B){
unsigned char myAnswer;
myAnswer = A + B;
return myAnswer;
}
>>
>>59632000
>>59631965
Aren't numeric types coerced implicitly in C?
Wouldn't a float be turned into an unsigned int in
>>59631908 ?
>>
File: 12659860.jpg (7KB, 186x208px) Image search: [Google]
12659860.jpg
7KB, 186x208px
>>59632311
Why is it expecting and returning long if I am entering two negative floats?
>>
>>59632329
Who told you to do any kind of conversion? I don't want to lose my type unless necessary
>>
>>59632324
Will it work with 39000 + (-7.000000001) ?
>>
>>59632335
anon I bet you don't even have a job or family that love you.

You're a burden to everyone around you. All your social interactions are tinged by your awkwardness and people are immediately disgusted when confronted by your bodily odor.

The best thing you could do long term is to stop dragging it out by posting on this board and just kill yourself.

Or start programming in LISP.
>>
What's the best type system
>>
>>59632335
It does that automatically as far as I know.
Otherwise it is possible to check for overflow with signed integers with loops and INT_MAX.
I think you can do the same with floating point types but I don't know.
>>
>>59632355
How does your answer answer my question below?
Who told you to do any kind of conversion? I don't want to lose my type unless necessary
>>
>>59632346
yes, it meets all the requirements of the spec you gave me, that's gonna be 545 usd + 7.45 for my lunch expense.
>>
>>59632358
weak typing.

can you say job security?
>>
>>59632363
Proof?
>>
>>59632324
Why does your function require character when I am not entering chars?
>>
>>59632363
>7.45 for my lunch expense.
Are you poor?
>>
>>59632362
>>59632335
You are strange, are you autistic?
The answer to
>>59631965
in response to
>>59631908
>>59631928
Is that types are implicitly converted.
>>
>>59632404
Why would you convert my floats to int as >>59631908 and >>59631928 suggest?
>>
what the fuck is this thread
>>
>>59632008
ASM
>>
>>59632425
>>59631933
>>
>>59632330
long double add(long double x, long double y) {
return x+y;
}

fixed. NOW it can add all the numbers.
>>
>>59632419
You dumb nigger if you pass a float to either of those the compiler AUTOMATICALLY turns it into whatever the parameters are.
Holy shit you should neck yourself.

If you want to add two floats without implicit conversion that's a different answer entirely.
>>
>>59632008
C++/C
>>
>>59632451
Wait a second
It is returning a double but clearly 2+9 = 11 is a float. Can you please not reply if you cannot write a correct program?
>>
>>59632398
my friend, my function is most fast, most efficient, you see, with unsigned char, I use only 1 byte for storage of variable, most fast friend!

it is the best way! lightning speed!
>>
>>59632475
>11 is a float
>>
C#:

I have a string composed of words that is less than 100 characters. I need to split the string into two no more than 50 characters in string[0] but it cannot be split an entire word.

How do I do?
>>
fn add(a: i128, b: i128) -> Option<i128> {
a.checked_add(b)
}
>>
>>59632472
So angry. Both of your functions return int. Why is that restriction?

>>59632488
No, that's not the better way. I want to add numbers, not characters. And please post proof as I suggested
>>59632475
Not a float or double*
>>
>>59632490
>>59632500
>>
>>59632472
Wait
If I pass a float to a function that expects an int the compiler will not halt? What kind of unstable language does that?
>>
>>59632190

>two numbers
The important question here is "what kind of numbers?" Are we suggesting that any real number is a valid input? If so, an arbitrary precision arithmetic library may be necessary for a large number of languages. Machine integers and floats are "good enough" for the majority of cases, but may not always cut it.
>>
>>59632528
>>59632308
>>
>>59632491
Google "word wrap algorithm" if you want specifics, but it's basically just finding words one at of time and putting them into a line if either the line + the word is less than the wrap-length or if the line is empty (in which case you have to cut off the first N characters of the word, possibly add a hyphen if you want).
>>
>>59632500
11 and 11.0 are the same number as far as the user/mathematics is concerned so the function is right
>>
>>59632550
if you memcmp'd the stack representations of 11 and 11.0 they wouldn't match you dumbshit
>>
>>59632550
No, 11 is an int, 11.0 is a float
>>
>>59632561
what if you use floats for everything?
>>
>>59632571
why would I do that?
that makes it impossible to use the equality operator ==.
>>
>>59632550
Yeah, If I add 4.5 + 0.5 I don't expect a .0 at the end, I just want 5; .0 at the end is meaningless

I don't think the user would input 004.5000 to represent 4.5 either
>>
>>59632584
>Thinking about numbers in terms of their textual representation
You're retarded, and are just trying to be stupidly pedantic on purpose.
>>
>>59632536
thanks anon
>>
File: 1458404462605.png (114KB, 594x483px) Image search: [Google]
1458404462605.png
114KB, 594x483px
>C can't even even properly add two user defined numbers
I'm thoroughly disappointed

And no, 2.0 and 2 aren't the same. If you want to find average of a and b you would use 2.0, not 2
>>
I like programming in Java it is actually pretty comfy and fun.

Anyone else?
>>
>>59632599
>>59632612
>>
Holy shit does /g/ even know about generics?
>>
>>59632636
C doesn't have (aka doesn't need) generics
>>
>>59632612
>>59632584
>2.0 and 2 aren't the same.
tell that to your math teacher. he will say, they are the same. this is a fact of mathematics
>>
>>59632659
Your physics teacher will tell your math teacher he's retarded.
>>
>>59632659
Yes but programming is not maths.

x = 10 and 10 = x are not the same in programming.
>>
>>59632668
>x = 10 and 10 = x are not the same in programming.

That depends on the language.
>>
>>59632675
I'm talking about (((((((((((( C )))))))))))))
>>
>>59632636
What are those? I haven't learned about them in Java yet
>>
File: 1488248151444.jpg (233KB, 503x662px) Image search: [Google]
1488248151444.jpg
233KB, 503x662px
>>59631933 Here, it's time for me to go.
I'll ask again if some one has invented a way to properly add two numbers in C.
>>
>>59632709
#define add(a, b) ((a) + (b))
>>
>>59632709
You just have to define arbitrary limits on the meaning of number.
>>
>>59632720
>overflow
Ah I see
>>
>>59632190
>I don't even care about safety, I just want a very correct
Sorry, doesn't matter what else you were going to say, you're out of luck. In computing, safety and correctness are the same thing.
>>
>>59632729
It's not my fault that you used types which don't have the precision to hold the result.
>>
>>59632425
/dpt/ when the retards show up.
>>
How would I do Dijkstra's algorithm / A* for Sudoku?

I understand how to do Dijkstra's algorithm normally (either on a graph or a matrix to find the min/max path sum), but I just don't see how Dijkstra's algorithm using priority queues and heuristics would help you do sudoku
>>
Rate my MineSweeper in Java


public class Minesweeper {
public static void main(String[] args) {
int m = Integer.parseInt(args[0]);
int n = Integer.parseInt(args[1]);
double p = Double.parseDouble(args[2]);

// game grid is [1..m][1..n], border is used to handle boundary cases
boolean[][] bombs = new boolean[m+2][n+2];
for (int i = 1; i <= m; i++)
for (int j = 1; j <= n; j++)
bombs[i][j] = (Math.random() < p);

// print game
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++)
if (bombs[i][j]) System.out.print("* ");
else System.out.print(". ");
System.out.println();
}

// sol[i][j] = # bombs adjacent to cell (i, j)
int[][] sol = new int[m+2][n+2];
for (int i = 1; i <= m; i++)
for (int j = 1; j <= n; j++)
// (ii, jj) indexes neighboring cells
for (int ii = i - 1; ii <= i + 1; ii++)
for (int jj = j - 1; jj <= j + 1; jj++)
if (bombs[ii][jj]) sol[i][j]++;

// print solution
System.out.println();
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
if (bombs[i][j]) System.out.print("* ");
else System.out.print(sol[i][j] + " ");
}
System.out.println();
}

}
}



Also, daily programming challenge. Write MineSweeper in your language of choice
>>
>can't contribute meaningfully to any discussion
>have no interesting projects EVER
>barely passing freshman CS classes
>time to show /g/ what a cool kid I am by shitting up /dpt/ complaining about C using low level types
>act like this is somehow bad
>move goalposts
>be retarded
>>
>>59632778
Epic bro
>>
Is the discord channel for dpt active?
>>
>>59632824
>Discord
Please leave.
>>
Give me a quick rundown on this thread, what did happen to the last one?
>>
>>59632824
>Discord
>>>/v/
>>
>>59632709

YES GODDAMMIT!

Just use the mpq_add function in libgmp and stop pretending C is some super limited language, when it runs fucking everything.
>>
>>59632577
>There is a widespread misconception about floating-point arithmetic errors and some people fear that even a simple increment can go weird with floating-point numbers. The fact is that, when you use a double to represent an integer, there is no rounding error at all (unless the number is greater than 100,000,000,000,000). Specifically, a Lua number can represent any long integer without rounding problems. Moreover, most modern CPUs do floating-point arithmetic as fast as (or even faster than) integer arithmetic. - Lua
anon btfo by brazilian devs
>>
>>59632906
I'm pretty sure you can't use a float as an array index, or do bitwise anything on it, but i'm not stupid enough to try it.
>>
File: exectime.png (7KB, 1000x400px) Image search: [Google]
exectime.png
7KB, 1000x400px
I optimized my website and made a sick graph

source here https://raw.githubusercontent.com/chiru-no/chiru.no/master/index.php
>>
reminder that java is superior to C# both in terms of memory usage and raw speed:

http://benchmarksgame.alioth.debian.org/u64q/csharp.html
>>
>>59632906
The problem with floating point is the variable margin of error
>>
>>59632956
>This pile of horse shit is slightly less shitty this this pile of donkey shit
Literally who cares.
>>
>>59632960
Every error is insignificant.
Floating point is just scientific notation. You use it for calculations.
Stuff like finance is different, there fixed point decimals makes more sense.
>>
>>59631915

What else would you use besides mayo?
>>
I made a script to hide posts of a certain length earlier for some degenerate on this board. I don't think he saw it though. Thing is, I don't actually know JS.
var maxWords = 50; //Change this if you want to change how many words the script will allow before hiding a post

function checkSize(string){
var j;
var num = 1;
var ch;
for(j = 0; j < string.length; j++){
ch = string[j];
if(ch == ' ') num++;
}
return num;
}

function fixId(string){
var nuString = "t";
for(var i = 1; i < string.length; i++){
nuString += string[i];
}
return nuString;
}

var posts = document.getElementsByClassName("post op");

var i;
var message;
for(i = 0; i < posts.length; i++){
message = posts[i].getElementsByClassName("postMessage");
var tempId = posts[i].id;
var postString = message[0].innerHTML;
if(checkSize(postString) > maxWords){
var realPost = document.getElementById(fixId(tempId));
realPost.className = "thread post-hidden";
}
}
>>
>>59633018
>Every error is insignificant
>Except when it's not
Quality post
>>
>>59632994
these piles of horse shit are way more useful than your bullshit academic language will ever be
>>
Working on a handwriting to virtual typed text program.
Coded in C++
>>
Is anyone aware here that overflows can happen in every language with usual integers?
>>
>>59632778
I mean... I could probably implement the playing in about half an hour, but I got lazy halfway

int getNeighbors(bool **mineLocations, int row, int col, int boardSize)
{
if(mineLocations[row][col]) return 0; //Don't report neighbors on the bombs, ya dingus
int retInt = 0;
for(int dy = -1; dy <= 1; dy++)
{
if(row + dy < 0 || row + dy >= boardSize)
continue;
for(int dx = -1; dx <= 1; dx++)
{
if(col + dx < 0 || col + dx >= boardSize)
continue;
if(dx == 0 && dy == 0 )
continue;

if(mineLocations[row+dy][col+dx])
retInt++;
}
}
return retInt;
}
/*
"I honestly think you could have been eaten by an alligator as a small child and the world would largely remain
mostly unchanged"
*/
void createMineSweeperBoard(bool **mineLocations, int **BOARD, const int boardSize, int numMines)
{
mineLocations = new bool*[boardSize]; BOARD = new int*[boardSize];

for(int i = 0; i < boardSize; i++)
{ mineLocations[i] = new bool[boardSize];
BOARD[i] = new int[boardSize];
}

//assign values to mine locations
for(int mineNum = 0; mineNum < numMines; mineNum++)
{
int row = rand()%boardSize, col = rand()%boardSize;
mineLocations[row][col] = 1;
}

//Assigns values to the playing board
for(int row= 0; row < boardSize; row++)
for(int col = 0; col < boardSize; col++)
BOARD[row][col] = getNeighbors(mineLocations, row, col, boardSize);

/* Part of the method that prints both boards */
}
>>
File: ProgrammingChallenges, 4.0 (HD).png (2MB, 3840x2160px) Image search: [Google]
ProgrammingChallenges, 4.0 (HD).png
2MB, 3840x2160px
>>59632782
>barely passing freshmen CS classes
I think at that point, what you need more than anything is practice

Try doing these to lift your sprits
>>
If I declare a C function as static inline then include the header in another TU and use it, will the compiler copy the code over to the object file?
>>
>>59632709
#include <limits.h>
#include <stddef.h>
/* add: Adds two integers of arbitrary size into a sum buffer of arbitrary size.
* The size may be greater than the maximum implementation-provided integer size,
* and need not be a power of 2.
* If the buffer is appropriately sized, there should be no overflow. */
void add(unsigned char* a, size_t width_a, unsigned char* b, size_t width_b, unsigned char* sum, size_t width_s) {
unsigned char carry = 0;
unsigned short place_sum;
size_t i;
unsigned long long big_endian = 1;
if (*(unsigned char*) big_endian) {
a += width_a - 1;
b += width_b - 1;
sum += width_s - 1;
for (i = 0; i < width_s; i++) {
place_sum = carry;
if (i < width_a) place_sum += *(a - i);
if (i < width_b) place_sum += *(b - i);
*(sum - i) = place_sum;
carry = place_sum >> CHAR_BIT;
}
} else {
for (i = 0; i < width_s; i++) {
place_sum = carry;
if (i < width_a) place_sum += *(a + i);
if (i < width_b) place_sum += *(b + i);
*(sum - i) = place_sum;
carry = place_sum >> CHAR_BIT;
}
}
}
>>
>>59633134
thats a clever trick for checking endianness, am I retarded to never think of that, or did you pull it from somewhere?
>>
#include <vector>
#include <iostream>

int main() {
std::vector<bool> primePool[100];
std::cout << primePool.size();
}


Why is my compiler not okay with this? If I remove the [100] then it's fine, but I need this vector to be a specific size.

error: request for member 'size' in 'primePool', which is of non-class type 'std::vector<bool> [100]'
std::cout << primePool.size();


Pls help.

(Yes I am a CS baby trying to implement a prime sieve).
>>
Right now I am making a program that parses the all the 4chan boards hourly and then collects all the post found in that board.

Then I am making a list of words that are considered "reddit" or "tumblr".

Gonna run this script for a week once it is done and then do a analysis on which board is the most normie filled and which hour is the most normie filled (mostly likely NA afternoon/evening).

Any suggestions for improvement?
>>
>>59633220
() instead of []
>>
>>59633220
You can specify the size as a constructor argument, not a static array. Even then what you write is an attempt to declare a hundred vectors and not a vector with a hundred entries. Since you are using size on an array of vectors and not a vector he's calling you an idiot
>>
>>59633220
you don't need to make primepool an array, vector grows itself to accommodate you.

when you call primepool.size(), primepool is a pointer to the first "vector" in your array. of 100 vectors.

that is why it is saying "non-class type"
>>
>>59633232
how do you identify false-positives from anons who are trolling or posting ironically?
>>
>>59633232
You're doing god's work, anon.
>>
(cont from >>59633134 ) Shit I forgot an & and I got the endianness backwards
I fixed it and it still doesn't work and I don't know why
>>
>>59633232
At this point, it sounds way too deterministic to be interesting (oh, cool, these boards use these words more often than others)

You might want to keep track of which words appear near the words you're keeping track of, such as "fag" appearing next to "reddit" ...

Echoing what >>59633261 said, you also might want to take into account how replies correlate with "redditnes" or "norminess"

But that's just a theory. A gay theory
>>
>>59633234
>>59633246
>>59633252

Ohhhhh, duh. Thank you, I feel like an idiot. When I was trying different ways to initialize it I saw something in the compiler error that indicated I was making a pointer to a vector, but I didn't connect the dots.

I'm out of school for a while for various reasons and the inconsistency with which I practice programming is really killing me with all the syntactical errors I make.
>>
where can I find good exercises of c++ and c#?
I was using that bjarne's beginner book for c++ but it is a bit slow
>>
>>59633261
I have a few ideas at the moment. I am still "collecting" data as we speak. But my current method is if a post has more than X words that are on my list, the post is ignored and considered ironic. I don't expect 100% accuracy but I believe a week worth of data will allow false positives to be drowned out.

Of course this would require post result analysis since you cannot ascertain by volume of post alone or /v/ /b/ and /pol/ will instantly win.
>>
>>59633293
You didn't pick the language with the lightest syntax either
>>
>>59633302
Jumping into C++ has some okay ones.
>>
why aren't you guys programming business apps to make a lot of money?
>>
>>59633446
nobody here knows how to program. people come here for the memes.
>>
File: dpt.jpg (164KB, 800x1000px) Image search: [Google]
dpt.jpg
164KB, 800x1000px
>>59631903
As always.
>>
building a thousand dependencies fucking sucks.
>>
>>59633446
Because the programming business apps market has already been cornered. What are you going to make that banks are going to want?
>>
>>59633446
The only things not cornered will likely be NIH'd by anyone else. plus i dont hate myself
>>
>>59633499
>>59633524
there is plenty of web business app ideas you can program god you are both plebs
>>
>>59633531
Mr idea guy, I would like some ideas.
>>
>>59633531
>web business app ideas
>lets make a fitness tracker
thats you
>>
>>59633531
>web business app ideas
just kill me now.
But if the markets so ripe, then why arernt you cashing in?

Webshit can be learned in a week
>>
>>59633555
webshit has to be relearned every other week as the buzzwords change
>>
>>59631933
int *add(int a, int b)
{
int *blah = malloc(sizeof(a));
int *lol = malloc(sizeof(b));
int *niggers = 0xC0000000;

memcpy(blah, &a, sizeof(a));
memcpy(lol, &b, sizeof(b));

niggers = malloc(sizeof(int));
float addition = *blah + *lol;
memcpy(niggers, &addition, sizeof(addition));

int *asdf = malloc(8192); // Allocate more mem in order to increase performance by 8192x. unused mem is wasted mem.

memcpy(asdf + 103, &niggers, sizeof(niggers));
errno = asdf[2000] ^ 2;

return asdf;
}
>>
>>59632197
Retard. That's not Hime.
That's an actual girl (female).
>>
>>59633573
new memeworks can be ignored.
Were still using a 20 year standard afterall
>>
>>59633590
Right, still have to support IE6 after all.
>>
File: not hime.jpg (196KB, 1280x1441px) Image search: [Google]
not hime.jpg
196KB, 1280x1441px
>>59633589
honestly what's the difference?
hime is a tsundere (male)
>>
File: tmp_5008-1490262784181216369129.png (2MB, 1220x1220px) Image search: [Google]
tmp_5008-1490262784181216369129.png
2MB, 1220x1220px
>mfw many features I'd like to have in C are present in C++
I think I should go with C++ then?
What's the version of C++ which is available on most possible platforms?
>>
File: .webm (546KB, 960x540px) Image search: [Google]
.webm
546KB, 960x540px
>>
>>59633627
GCC is the most popular win/linux so the most modern you want.
>>
>>59633647
I mean what is ANSI C of C++?
>>
>>59633665
C++98 probably
>>
>>59633680
>>59633665
Don't validate old versions of C++. It doesn't cause breakages.
>>
>>59633665
Literally whatever the newest version is.
C++ doesnt really have a cult version.
>>
>>59631934
Yes. SBCL is rad.
>>
>>59633638
Please give ideas on how could I base software on memes. How could I extend this? I made this in the last three hours.
>>
File: 1464815472039.jpg (2MB, 1920x1080px) Image search: [Google]
1464815472039.jpg
2MB, 1920x1080px
>>59633623
The difference is that one has a dick, is biologically male, and is mentally ill.

And just in case you're wondering, because most trap fags seems to be confused about this: the dick is supposed to be IN the girl, not part of the """girl""". The two are mutually exclusive.

Trapfags need to just simply commit suicide.
>>
>software is on the decline because people arent literally searching the keyword

The one time I stumble on a jew keynote and its this false sensationalism bullshit.
>>
File: 1399960207051.png (50KB, 320x442px) Image search: [Google]
1399960207051.png
50KB, 320x442px
>>59633722
>People are probably searching for "app" instead
>>
>>59633746
Yeah it was a big "just kidding" and then just that.
>>
real programmers don't watch anime
>>
>>59631903
Kraft Mayo runs 5c cooler btw
>>
>>59633774
the whole point of thermal compound is that it doesn't rot after 10 hours
>>
>>59633685
>It doesn't cause breakages.
What breakages?
>>
Which VPN do you guys use?
You do use VPNs right?
>>
>>59633721
>animefag
>in charge of deciding what's sane and what's not
>>
Trying to understand how to use IIS on Windows 8.1 Enterprise...
>>
>>59633840
>t. trapfag in disguise
>>
>>59633830

I would like to know what a VPN is!
>>
<h1>Hello world!</h1>
>>
>>59633680
Wait, if C++98 is the oldest, how did people write C++ in 1993?
>>
>>59633870
printf("%c%c%c%c%c%c%c%c%c%c%c%c", 'H', 'e', 'l', 'l', 'o', ' ', 'w','o','r','l','d','!');
>>
File: lcthw.jpg (8KB, 197x256px) Image search: [Google]
lcthw.jpg
8KB, 197x256px
>>59631903
Learn C the Hard Way, exercise 32
>>
>>59633983
>Zed Shaw
>>
>>59633884
It wasn't standard before that.
>>
>>59633983
That book is absolute garbage. It's literally "copy my poorly explained examples: the book".
Stop reading it immediately. Go read something else.
>>
File: 1437131514879.jpg (223KB, 1920x1080px) Image search: [Google]
1437131514879.jpg
223KB, 1920x1080px
Hey, wanted to post a separate thread but thought that might be a bit selfish so will try here. I have an idea for android/iOS app. It would be like real time message board with location element.

Thing is i have 0 experience in app development and dont even know where to start. Could anyone give any pointers? What to read/watch to get some grasp? What tools to use? Would Xamarin be good enough?
>>
>>59634037
>>59634077
> muh K&R
>>
I'm going to apply for a php programmer position in my uni because I need the money. I don't know any php yet though, except for basic syntax. Is it possible to get decent in 1-2 weeks if I know C/C++ and Python already?
>>
>>59633853
Use a search engine you retarded tripfag.
>>
>>59634090
I didn't say anything about K&R. I just said that "Learn C the hard way" is garbage.
Here is someone with a decent (but kind of long) criticism of it: http://hentenaar.com/dont-learn-c-the-wrong-way
>>
IF YOU GAZE LONG ENOUGH INTO THE ABYSS, THE ABYSS STARES BACK AT YOU
>>
>>59634299
I've read it, and he completely misses Shaw's point like an autist.

How much of it have you read yourself?
>>
>>59634348
What the hell is Shaw's point?
>>
>>59634338
delete this;
>>
>>59631903
There's the simple test for a programming language. If you can make a search engine, driverless car, mobile OS and browser using the language, the language and its paradigm are not worthless. If you can't, the language is a /dpt/-tier useless shit.
>>
>>59634398
For some reason, I can't help but think that this poster is a filthy redditor.
>>
>>59634356
K&R, and by proxy, a lot of C, was written before security and defensive coding were fundamentally taught.

Whether or not K&R has security holes and how it's the caller's responsibility to not abuse them, is irrelevant: pass strings with lengths, and check for fucking NULL.
>>
File: get.jpg (702KB, 1920x978px) Image search: [Google]
get.jpg
702KB, 1920x978px
>>
>>59634424
You don't seem to know what a precondition is.
>hurr why does this string function break when I pass it something which isn't a string???
>>
File: hackerman.jpg (9KB, 225x225px) Image search: [Google]
hackerman.jpg
9KB, 225x225px
>>59634446

That attitude is why C is a security mess. Checking for invariants is a good thing to do.
>>
>>59634477
You're just a fucking shitty programmer who can't seem to make guarantees about any parts of your code.
Any programmer should be able to reason about the state of their program at any given point. This is not just a C thing; ANY programmer.
>Checking for invariants is a good thing to do.
You can't a lot of the time, and usually it's wasted effort.
What if you function is supposed to always succeed? Now you have to make some annoying error handling mechanism for something that doesn't even need it, and then the uses of that function need to deal with that shit too.
>>
>>59634506
>mrw my code has never been exposed on the internet, and is too irrelevant for anyone to attack.
>>
>>59634527
I bet you're the sort of fag who checks the return value of printf every time, too.
Just because it's going to make you soooo safe.
>>
stop arguing with c fags /shitters
just ignore them.
no matter how stupid
>>
>>59634425
>>
>>59634621
how do you think it treats spaces?
>>
>>59634686
Not the way I want it to, I assume.
Teacher said it shouldn't be a problem.
>>
I feel like an idiot. I had to resort to using a resume template because I'm so goddamn shit with document editors and design in general. Please tell me I'm not the only one who googled 'resume templates' to produce their resume.
>>
>>59634087
>real time messenger with location element
>yet another botnet messenger app

If you're totally new, xamarin and c# will be easiest for you.
>>
>>59634713
Who has time to write an entire resume when some shitty web site can do it better + for free?
>>
>>59634859
awful gif loop
>>
If you could only know one programming language. Which one would you choose?
>>
>>59634914
Haskell
>>
>>59634880
I don't why people (especially those from tumblr) create such awful gifs.
>>
>>59634914
Unironically Rust. Some of the cooler stuff are behind feature gates unfortunately:
#![feature(slice_patterns, advanced_slice_patterns)]

fn is_symmetric<T: PartialOrd>(list: &[T]) -> bool {
match *list {
[] | [_] => true,
[ref l, ref inside.., ref r] if l == r => is_symmetric(inside),
_ => false,
}
}

fn main() {
println!("{}", is_symmetric(&[1,2,3,4,3,2,1]));
}
>>
>>59634995
it's a sad day to look at gifs
>>
How do i write in c# a string number, reverse it and then put it into int array?

            string number1 = Console.ReadLine();

int[] listofNumber1 = new int[number1.Length];
listofNumber1 = number1.Reverse().ToArray();


doesn't work because i cant put char into int
>>
>>59634995
I think tumblr limits harshly them more so than people create them poorly. You can spot obvious tumblr gifs, they should be shunned.
>>
>>59635035
>they should be shunned
I usually point them out if they have disgusting over-saturated colours, which a lot of them do.
>>
>>59635007
Ugh

I thought C++ templates syntax was ugly. I thought Perl was line noise. I thought unnamed lambda syntax in JavaScript was forced and just used available characters not used before.

But Rust syntax makes me outright nauseous.
>[] | [_] => true
how is this intuitive?
>ref inside..
wtf does one dot mean? what the fuck does two dots mean?
>_
what the hell is this magic variable?
>& in both parameter list and when passing the parameter
Why do you explicitly need to pass by reference AND indicate in the parameter list that the argument is passed by reference?
>println!
why the exclamation mark for println but not for is_symmetric?
>>
>>59634914
C++
>>
>>59635058
Rust is shit but it's not as shit as C++, Perl and Javscript
>>
>>59635078
I could have mentioned Haskell syntax as well, needing to define + and - operators before using them makes me question the sanity of anyone using it for anything else than an introduction to functional programming.
>>
>>59635058
this! fuck I wanna learn Rust so bad but I can't get over how ugly the syntax is. and call me a brainlet but it's a goddamn beast of a learning curve especially when trying to fight the borrow checker and the lifetimes bullshit.

meanwhile D (so far) has been pretty comfy.
>>
>>59635058
I'm not the anon who posted that, and I'm not going to try to defend Rust too hard, but I'll answer your questions about the syntax:
>how is this intuitive?
It's "pattern => expression". | is used for alternation, or basically is "or". So if the pattern matches [] or [_], the expression evaluates to "true".
>wtf does one dot mean? what the fuck does two dots mean?
It means many values.
>what the hell is this magic variable?
The underscore in a pattern means "match anything", usually used as a fall-back.
The underscore as a variable name also means "not important".
>Why do you explicitly need to pass by reference AND indicate in the parameter list that the argument is passed by reference?
This is not C++-levels of retardation with invisible references. You have to be explicit about that in Rust.
>why the exclamation mark for println but not for is_symmetric?
Exclamation marks means it's a macro invocation. println is a macro.
>>
>>59635089
>needing to define + and - operators before using them
They're in the standard library.
>>
>>59635090
>>59635078
>>59635058
That's not even the worst of Rust syntax either, it's just written in a particularly awful manner there. You can write just as ugly shit in C/C++.

It's pretty hard to get into that borrow/lifetime mindset. After finally getting a hang of it I immediately ran into some walls from shit only being available in nightly. Wait on Rust. It's not ready.
>>
>>59635031
>Obvious hw

You need to cast
number1
as an int.
>>
File: CNOT_idealsans.png (755KB, 2400x1770px) Image search: [Google]
CNOT_idealsans.png
755KB, 2400x1770px
How do I make axes shorter on matplotlib3d?

I have pic related and I want to get rid of all the wasted space above the bars. I tried ax.set_zlim(0,0.25) but that just changes the axis scale and keeps the image the same size, how do I basically just chop the top off the graph without it auto-stretching? I would also like the colour bar to shrink with it.
>>
>>59635105
>Wait on Rust.
i'd rather use Haskell instead
Rust is trash
>>
>>59635101
Thanks for clearing stuff up, but I honestly think abusing single characters for stuff like that (and using the same character for multiple things) is bad. It's the same for declaring functions using "fn", why not type it out if you're going to have it there at all? Also, what's the difference between "ref" and "&", if you do &var to pass by reference then what purpose does "ref var" serve?
>>
>>59635120
Shorthand stuff is pretty disgusting in any language. I'm also not a big fan of rust's match stuff... but I'm not up to writing a macro for everything in its place.
>>
>>59635104
I may be mistaken, but my impression is that there is no standard _standard_ library in Haskell, but a pseudo-standard "standard" library that everyone uses? Or at least that's why I assume people here explicitly mention when they use it and when they don't use it (and it even has a name, which escapes me right now). Similar to boost with C++, it's not the standard library defined by the language, but it's "standard" in the sense that everyone uses it.
>>
>>59634348
>misses Shaw's point
the point being he doesn't understand C
>pass strings with lengths, and check for fucking NULL
don't forget to check that the length is valid :^)
>>
>>59635120
>Also, what's the difference between "ref" and "&",
That's honestly one of the things I find really stupid about Rust. There is very little distinction between these, but they are used in different contexts, for whatever reason. I think it has some shit to do with the borrow system. I actually don't really know enough about that to give you a proper answer.
>>
>>59635120
Pattern matching does move by default, so
[l, inside.., r]
would try to move l, inside, r out of list which i can't since i don't own the list. By putting a ref in front of each of these variables, i'm telling the compiler that i only want a immutable reference to them.
>>
>>59635136
No, there is a standard standard standard library and it's called Prelude
https://www.haskell.org/onlinereport/standard-prelude.html
This is 98, the later would be 2010


GHC is effectively the standard anyway, when most people think Haskell they think GHC/Haskell
>>
>>59635147
I see, and that makes sense to me. But I'm struggling to understand the difference between 'ref' and '&', can you explain to a simpleton like me?

Thanks in advance.
>>
>>59635120
>>59635144
>>59635147
Note there are plans to make that more ergonomic since it's practically boilerplate: https://github.com/rust-lang/rfcs/pull/1944
>>
one of Rust's main goals for 2017 is to be more beginner friendly. So...yeah like the one anon said, wait for it.
>>
>>59635170
>make the language worse
for what purpose
>>
>>59635159
ref is essentially only useful in match statements. It's mostly considered a wart in the language, as it is beginner unfriendly. See also: https://github.com/rust-lang/rust-by-example/issues/390
>>
>>59635120
>>59635144
ref x = y[/cpde] == 
x = &y
iirc

Should only be one way to do this stuff, or at least be required to stick to one style where possible.
>>
>>59635158
>>59635136
>>59635104
>>59635089
Wow, they even argue about the correct way to do Hello, world because apparently autists can't agree on anything

https://en.wikipedia.org/wiki/Haskell_(programming_language)#Code_examples
>>
>>59635206
>>59635202
>>59635162
Any now that shit is in stable, and will probably never get removed.
Why did they rush this shit out? Why was this not questioned until recently?
>>
>>59635206
well that was a clusterfuck, I never knew you could embed code's though. Neat.

>>59635234
No idea, Rust 1.0 was like a year too early.
>>
>>59635234
>recently
Correcting myself: I just was that the issue was brought up in 2015.
The point still stands, though.
>>
>>59635226
Python fags could argue forever whose hello world the most pythonic.
>>
>>59635226
I don't see what you're mad about

>here is what these lines do
>>
>>59635274
Look at the page discussion, anon.

>>59635251
The most pythonic way is
print("Hello, world!")


Pythonic is just a buzzword for KISS
>>
>>59634914
python, but can't call yourself a programmer
>>
>>59635251
>>59635286
import sys; list(map(sys.stdout.write, "Hello World"))
>>
>>59635286
>90% of implementations still using
print "hello world"
>>
>>59635295
That's obviously not Pythonic.
>>
>>59635296
Yes, in Python 2 you'd do that. In Python 3, print is a builtin not a keyword.
>>
>single .h file C++ implementations of everything

Why do they do it? Is this the new hot thing in programming?
>>
>>59635286
I'm not seeing what you're talking about
>>
>>59635295
This doesn't do the same thing
>no trailing newline
>adding \n isn't portable
>>
>>59635310
that was the joke, I'm mad that if i symlink
/usr/bin/python
to python3 it breaks shit everywhere. Fuck guido for extending python2 support, too.
>>
>>59635305
you wouldn't know
>>
Noob question here:
I always wondered, if someone wanted to make an app or a websites on movies (for example) and needed a database with a list of all the movies (title, year, producer, realistor and that kind of stuff), does the guy who's making that app have to create and insert all these values himself ?
Or are there some database like this that anyone can use ?
>>
>>59635321
>/usr/bin/python

That's not even the right way to do it.

#!/usr/bin/env python
>>
>>59635330
imdb
>>
>>59635312
C++ doesn't have modules, so that's the next best thing.
>>
>>59635312
No need to separately.
Building others peoples project is cluster, way easier to just implement it in one header and share that.
>>
>>59635326
Your mother told me it was last night, when I showed her my Python.
>>
>>59635321
>>59635331
This isn't portable to systems that don't follow the filesystem hierarchy standard
>>
>>59635331
you're a retard
>>
>>59635319
>>adding \n isn't portable
Yes it is. stdout is open in text mode, so '\n' will automatically be converted the the platform's equivilent, assuming Pythons files work like C's ones, which I think they do.
>>
>>59635332
Is there an equivalent of this with Anime, Manga and music ?
>>
>>59635343
>that isn't portable to windows
That's the only OS that doesn't conform to the FHS and POSIX.

Well, maybe TempleOS too, but it's not like Terry is going to port Python anytime soon.
>>
>>59635349
>arguing with a webshit
lad...
>>
>>59635349
>stdout is open in text mode
No such thing.

>so '\n' will automatically be converted the the platform's equivilent, assuming Pythons files work like C's ones,
That's not how it works in C either.
>>
>>59635354
Not just windows.
>>
>>59635357
>webshit confirmed
called it!
>>
i need a weight generating function for a single layer neural net with non-linear activation functions, and my brains too fucked to into math, how do i do it?
>>
>>59635357
You clearly have no fucking idea about what you're saying.
>>
>>59635335
Yeah but everything doesn't have to be in a single .h file.
>>
>>59635372
TENSORFLOW
>>
>>59635415
wat
>>
>>59635372
>>59635419
Make your weights small random numbers, but divide each of them by the square root of the number you pass to your random number generator.
>>
>>59635404
>what is template
>>
>>59635454
i mean in terms of learning, how do i reduce my error?
>>
>>59635477
So you're not talking about when you initialize the weights for the first time, but rather, when you're in the training phase? Backpropagation is a popular technique for reducing error.
>>
>>59635504
yes, the latter

please explain it to me like im retarded, ive got to have this cunt wrapped up and demonstrated in lab within the hour. the specific algorithm im going by calls for the weights to be updated after each call of the neuron function with the training data though.
>>
>>59635472
This has nothing to do with templates.
>>
>>59635602
templates must go in header files
>>
New thread: >>59635709
>>
>>59634446
the precondition should be enforced then
>>
>>59634914
C++
>>
>>59634914
>If you could only know one programming language. Which one would you choose?
C++
Thread posts: 323
Thread images: 35


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