[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


Thread replies: 345
Thread images: 23

You faggots didn't accomplish anything in the last thread. Want to try again?
>>
Nice projects to learn Android programming ?
>>
>>53665347
Yes and thank you
to replace it I can just set a new definition and it will automatically override it, right?
>>
>>53665493
Is OCaml a meme?
>>
>>53665547
Snapchat
>>
>>53665620
Not a meme, just not taken seriously.
>>
>>53665620
Yes, but not as much as Python or Java
>>
actual thread

>>53665401
>>
>>53665563
That depends on how WordDef is implemented, but probably. Though it might be better to just use a dictionary (the data structure) instead of an array.
>>
>>53665676
>made before the bump limit
Kill yourself.
>>
>>53665676
>thread that is going to be deleted
>>
hello lads
>>
Can you guys complete this function?
boolean isOdd(int n) {
// code goes here
}

Just fill in the function.
>>
>>53665726
keep believing that, idiot

if any thread gets deleted it's going to be this one
>>
>>53665824
Past experience proves you wrong. Remember the premature mumin, premature trap and mature trap thread?
>>
>>53665820
return n == 1 || n == 3 || n == 5 || n == 7 || n == 9 /* however many you need */;

It's the fastest way to do it I swear.
>>
>>53665824
This one was posted after the bump limit. Shut the fuck up.
>>
>>53665820

if ( i == 0 ) return false;
if ( i == 1 ) return true;
if ( i == 2 ) return false;
if ( i == 3 ) return true;
...


e-z p-z
>>
>>53665820
iseven = require('is-even')
not = require('not')

module.exports = not(iseven)
>>
>>53665820
boolean isOdd(int n) {
if (abstractIsOddFactoryBean.getInstance().newIsOdd().isOdd(n) == true) {
return true;
} else if (abstractIsOddFactoryBean.getInstance().newIsOdd().isOdd(n) == false) {
return false
}
}
>>
>>53665820
Easier than isEven

boolean isOdd(int n){
return n&1;
}
>>
>>53665896
Aren't bitwise operators with signed integers undefined?
>>
>>53665885
>!(2 % 2)
>!(0)
>1
>2 is odd

>>53665896
wrong
>>
>>53665820
import Data.Bool
import Data.Maybe
import Data.Nat

mutual
data Even : Nat → Set where
evenZero : even zero
evenSuc : odd m → even (suc m)

data Odd : Nat → Set where
oddSuc : even m → odd (suc m)

mutual
isEven : (m : Nat) → Maybe (Even m)
isEven zero = Just evenZero
isEven (suc m) = map evenSuc (isOdd m)

isOdd : (m : Nat) → Maybe (Odd m)
isOdd zero = Nothing
isOdd (suc m) = map oddSuc (isEven m)
>>
>>53665875
; iseven = require('is-even')
; not = require('not')

; module.exports = not(iseven)

FTFY
>>
>>53665905
No.
>>
File: 18211.png (98KB, 400x300px) Image search: [Google] [Yandex] [Bing]
18211.png
98KB, 400x300px
>>53665919
>>
>>53665905
not sure. It works in c++. If java does it differently then Java is shit.
>>
>>53665620
it's pretty comfy :3
>>53665919
even comfier~
>>
>>53665820
return !isEven(int n);
>>
>>53665911
Actually it's right.
>>
>>53665936
>It works in c++
implementation-defined
>>
>>53665952
Actually it's not. See >>53665905
>>
>>53665933
not sure if 9gag or just reddit
>>
>>53665875
function lookup (table, key, callback, _this) {
if (key in table)
callback.call(_this, null,
{ key: key,
value: table[key]
table: table });
else
callback.call(_this,
new Error("The key could not be found");
}

module.exports = function (x, callback, _this) {
if (x === undefined || x === null ||
arguments.length === 0) {
callback.call(_this, new Error("invalid number of arguments"));
}
else if ((typeof x) !== "number") {
callback.call(_this, new Error("invalid argument"));
}
else {
var oddNumbers = {};
for (var i = 0; i < 10000; i++) {
if (i % 2 == 1) {
oddNumbers[i] = true;
}
}

lookup(oddNumbers, x, function (err, res) {
if (err)
callback(_this, null, false);
else
callback(_this, null, true);
});
}
};
>>
>>53665966
it's probably implementation-defined for C/C++ (google/stackoverflow is fucking shit) and in java it's perfectly defined you fucking retard, just that his code doesn't work because it should be (i & 1) != 0
>>
>>53665919
import Data.Bool
import Data.Maybe
import Data.Nat

mutual
data Even : Nat → Set where
even-zero : Even zero
even-suc : Odd m → Even (suc m)

data Odd : Nat → Set where
odd-suc : Even m → Odd (suc m)

mutual
isEven : (m : Nat) → Maybe (Even m)
isEven zero = Just even-zero
isEven (suc m) = map even-suc (isOdd m)

isOdd : (m : Nat) → Maybe (Odd m)
isOdd zero = Nothing
isOdd (suc m) = map odd-suc (isEven m)

Fixed and slightly improved.
>>
>>53665960
I'm pretty sure it's only implementation defined if the sign bit is involved.
>>
>>53665966
IF he is right, then do it this way

boolean isOdd(int n){
return (n&0b1)&0b1;
}


This isolates the LSB. If this doesn't work then how the fuck does java even work.
>>
File: too easy for me.png (7KB, 274x444px) Image search: [Google] [Yandex] [Bing]
too easy for me.png
7KB, 274x444px
>>53665820
Easy :)
>>
>>53665976
>writing more than 5 lines per module
>in node.js
try moving out the logic into a few more npm packages and then we can talk, anon
>>
>>53665960
>>53665966
>>53665984
>>53665993
Don't talk if you don't know. You are wrong.
>>
File: OP phag.gif (6KB, 427x320px) Image search: [Google] [Yandex] [Bing]
OP phag.gif
6KB, 427x320px
non-retarded thread:

>>53665401
>>53665401
>>53665401
>>
>>53665820
boolean isOdd(int n) {
return !isEven(n);
}

boolean isEven(int n) {
return !isOdd(n);
}

Prove me wrong.
>>
>>53666000
Stop spamming, faggot. Nobody likes your premature troll thread.
>>
>>53665995
FUCKING RETARDED C SPERG MEME SHITTER YOU CRITICIZE JAVA BUT YOU DON'T HAVE THE SLIGHTEST CLUE ABOUT IT OR TYPE SAFETY IN GENERAL
>>
>>53666009
FUCKING RETARD FUCKING KILL YOURSELF LOOK WHO'S SPAMMING >>53665639 >>53665947
>>
>>53665976
>if (i % 2 == 1)

wrong

>>53665984
bitwise is wrong for signed.

>>53665995
>java

This isn't any particular language
>>
>>53666029
>bitwise is wrong for signed.
not for two's-complement ints

>This isn't any particular language
>boolean
ok lad
>>
>>53666028
>hurrr duuurrr some two different people let others know of the actual thread so I will behave like an underage faggot :))
>>
>>53666029
>boolean

That's a java keyword

>>53666011
>>53666028
You're not being very subtle about how butthurt you art
>>
>>53666043
>not for two's-complement ints

That's your assumption, not a given.

>>boolean
>ok lad

Yes, the concept of true/false is unique to java.
>>
>>53666029
>bitwise is wrong for signed.
>>53666043
>not for two's-complement ints
Wrong
>>
>>53666045
this isn't the actual thread, IF one of the threads get deleted before they die naturally it's pretty likely that it's going to be this one because this is the redundant duplicate thread that was posted after >>53665401
>>
>>53666007
can't prove shit, your procedures aren't total
>>
>>53665998
You're right. I should have put the lookup() into a separate NPM module, and also the argument checking.
var lookup = require("listlookup"),
checknum = require("checknum"),
generateOdd = require("generate-odd");

module.exports = function (x, callback, _this) {
checknum(x, function (err) {
if (err)
callback.call(_this, err);
else
generateOdd(1000, function (err, list) {
if (err)
callback.call(_this, err);
else
lookup(list, x, function (err, result) {
if (err)
callback.call(_this, null, false);
else
callback.call(_this, null, true);
});
});
});
};
>>
>>53665820
bool isOdd (int n) {
if(n%2 != 0) {
return false;
}else {
return true;
}
}
>>
>>53666069
Your thread was premature and filled with your shitposts. This one has actual programming discussion.
We talked about this.
>>
>>53666069
1. This has more replies
2. This was clearly posted after the bump limit
3. Your damage control is shit tier
9001. kill yourself
>>
if (n % 2 == 0 || n%2!=0)
{
if(n==0)
{
return(true);
}
else if(n==1)
{
return(true);
}
else if(n==2)
{
return(false);
}
else if(n==3)
{
return(false);
}
else
{
isodd(n+2);
}
>>
File: 1452320376169.jpg (33KB, 307x272px) Image search: [Google] [Yandex] [Bing]
1452320376169.jpg
33KB, 307x272px
>>53666082
>>
>>53666082
ur killin me femanon
>>
>>53665820
boolean isOdd(int n) {
return ( (n & 0x01)==0x01 )
}
>>
>>53666082
delete this
>>
>>53666029
>wrong
It passed my Unit Test (tm), it must be correct!
>>
>>53665820
num =>
num % 2
>>
>>53666101
wrong
>>
>>53666101
Just a tip, use binary instead of hex

n&0b1 == 0b1
>>
>>53666123
non-standard
>>
>>53666135
Says fucking who
>>
>>53665820
bool isOdd(int n) {
int i = 0;
for(i=0;i<=n;i++) {
if(i == n) {
if(i%2 ==0) {
return true;
}
else {
return false;
}
}
}
}
>>
>>53666165
my dad works for oracle (indian branch)
>>
>>53666176
>implying poo-in-loo would be working with binary
>>
>>53666185
that's true

binary only has 0s and 1s, not number 2 wahey!
>>
>>53666185
>implying poo-in-loo is considered human
>>
>>53666175
these fucking memes are golden I swear to god. That else statement is the icing on the cake
>>
>>53666175
>implementing isEven
>>
>>53666213
>Even
>Odd
stop oppressing me with your whites males's mathematics you racist and sexist shitlord
>>
>>53666237
>mfw boolean can only be true or false
>no room for non-binary values or boolean-fluid values
>>
>>53666237
genderfluid is literally the same thing as binaryfluid

it doesn't exist
>>
>>53666276
you're raping me!!!
>>
Im practicing 2d arrays in c. Yeah im a noob
>>
>>53666302
keep it on, C isn't that difficult but you need to know what you do or you'l fuck up pretty fast
>>
>>53666302
After you're done, do that shit with double pointers and delete it afterwards.
>>
My parser causes stack overflow when I have a function nested ~500 times. Is there anything I can do?
>>
<code>
if (n % 2 == 0 || n%2!=0)
{
if(n==0)
{
return(true);
}
else if(n==1)
{
return(true);
}
else if(n==2)
{
return(false);
}
else if(n==3)
{
return(false);
}
else
{
isodd(n+2);
}
</code>
>>
>>53666633
Add the requirement that people don't nest their functions 500 times.
>>
>>53666633
err... Preprocessor?
>>
>>53666705
The test suite for verifying correctness of parsers for this particular language has nesting up to 1000 times.
>>
>>53666633
Transform non-tail recursion into a stack data structure ; you have more heap space than stack space.
That sounds like a bitch to actually implement but it would do the job.
>>
>>53666746
Try replace the recursion with iteration and an explicit stack then.
>>
>>53665493
Where is that anime girl from?
>>
>>53666754
>>53666813
Well, I guess I'll do that.
>>
>>53666862
>filename
>>
>>53666862
>girl
>>
>>53666922
She is actually a girl if you played the VN or watched the anime.
>>
>>53666931
It's a dude, except for that one timeline.
>>
>>53666941
the only acceptable timeline.
>>
>>53666931
>>
>>53667059
I want to lick up those tears.
>>
>>53667073
I want to lick up those feet.
>>
Spent most of today dicking around on my work computer, setting up an ultra-ghetto dev environment. Now I can write and compile C# programs despite not having VS installed. This basically just consists of notepad and csc.exe, but I guess from here I can build a better editor or something.

Wish me luck.
>>
>>53667208
>notepad
>windows
>C#
>>
>>53667142
cute
>>
>>53667142
You know how people learn to draw by tracing anime?
This is what happens.
>>
>>53667223
>(You)
>>
Is windows really frowned upon
>>
>>53667223
Alternatively, I could build and load C# assemblies in Powershell for use in scripts. Having found the compiler at least lets me create standalone executables, though
>>
>>53667208
It took you all day to compile C# outside of VS?

You're employed?
>>
>>53667324
depends. In a poo-in-loo job, no. In a hardware job, yes.
>>
This dpt is too shitposty, so I'm heading over to the non-weeb one
>>
>>53667336
What a load of crap. Windows is prefectly fine.
>>
>>53665493
Today I'm contributing to lo/g/os
>>
>>53667142
that's a terrible drawing
>>
>>53667333
Nah, getting set up to compile only took a couple minutes. The day was spent fucking around with it after, and trying to see what I could get away with not having admin
>>
Is it possible to make an integer power function without using extra memory in the x86 architeture? I tried that, but I coudn't test it.

pow proc x:DWORD, y:DWORD
push ebx
push edi
push esi
mov eax,x
mov ecx,y
xor ebx, ebx
inc ebx
mainLoop:
shr ecx,1
jb noMultiplication
xchg eax, ebx
mul ebx
xchg eax, ebx
noMultiplication:
cdq
mul eax
test ecx,ecx
jnz mainLoop
mov eax, ebx
pop esi
pop edi
pop ebx
ret
pow endp
>>
>>53667324
not in real life, but in /dpt/, literally two thirds are linux-using neckbeards, at least according to a strawpoll that we did
>>
Java Question:

What is the difference between List<?> and List<T>
>>
File: ruka.png (66KB, 582x485px) Image search: [Google] [Yandex] [Bing]
ruka.png
66KB, 582x485px
>>53667142
I want to lick up his cum.
>>
>>53667425
One is written with a question mark and the other with a capital T.
>>
>>53667436
kill yourself samefag trap FAG
>>
>>53667423
I think it boils down to /g/ hating productivity, hence the hate for Windows, languages like C# and Java, and basically anything that could lead to employment or usefulness.

It's a fun place.
>>
>>53666922
>>53666941
Not getting the Luka ending
>>53667436
>ruka
Absolutely disgusting
>>
>>53667436
link to mangu?
>>
File: ruka condom.jpg (250KB, 700x700px) Image search: [Google] [Yandex] [Bing]
ruka condom.jpg
250KB, 700x700px
>>53667460
Yes, Ruka.
>>53667464
http://exhentai.org/g/546089/9071811507/
>>
>>53667455
yup
>>
is this alright for a popAll function for an array stack? top is the next free spot, and also the total number of elements in the array

    public void popAll() {    
for(int i = 0; i < top; i++){
stack[i] = null;
}
top = 0;
}
>>
>>53667208

But notepad and csc.exe are installed on Windows out of the box. At least get something like notepad++ portable...
>>
>>53667618
>for(int i = 0; i < top; i++){
> stack[i] = null;
> }
Why? Looks useless.
>>
>>53667618
Is there a reason you are wasting time clearing the now unused stack entries?
>>
>>53667724
is it not poor form to just set top to 0 and leave a bunch of data left in there?
>>
I would really like an SICP tier(not too easy, but still an intro) book but for systems. I would like to learn how those are programmed and how to program those.

There is the mit ocw one, but they only have the second part online, you have to buy the first part, so I will use the mit courses only when I have a little bit (or a lot) of knoweledge already.
>>
>>53667742
well, it could prevent me from not getting an error when i should. ie you pop all, but then something goes wrong, but instead of getting an error because of trying to access null you just get old data
>>
>>53667745
nope
>>
Hey guys I'm learning Java and was thinking the best way is to learn about the core java principles, piece by piece. That is: Variables, Methods, Classes, etc.

I was wondering if there is a list somewhere someone can link that provides every single topic regarding the core of Java.

My goal right now is to learn a new concept every single day and once I'm done, begin creating a program every day and eventually jumping the ship to larger ones.
>>
>>53667392
>Windows is prefectly fine
Non-broken symlinks, file paths longer than 255 characters, cross-platform build environments, sane dependency management and actually decent disk I/O performance is reason enough to frown upon Windows.
>>
Working with C. This fucking linked list is being an absolute faggot to me. It keeps printing out the first line read from an input file instead of printing out the rest of the data I need. Love you C.
>>
>>53667791
just go to college, i know some fine jewish gentlemen who have ASTOUNDING rates on student loans
>>
>>53667874
>using linked lists
use a circular buffer you fucking pleb
>>
>>53667806
all that stuff doesn't matter
>>
>>53667874
If it's for a school assignment, send this to your teachers https://www.youtube.com/watch?v=YQs6IC-vgmo
>>
>>53667889
fuck you faggot
>>
>>53667902
Can't, required for this project (yay uni)
>>
I want to compress with a password and then access certain files later in the program

How can i compress and extract files? I'm on Visual C++ if it matters, i don't want to use meme libraries or deprecated stuff so i'm asking
>>
>>53667915
Sure thing, faggot.
>>
>>53667937
he's doing what people like me call a shit test. you have to assert your dominance
>>
>>53667970
Well you sure as shit aren't gonna do it with the std libraries. Easily anyways.
>>
>>53668022
External libraries of course but not sure what to use that's why i'm asking
>>
>>53667971
You can frown on it from your corner in the basement, then, while the rest of the world gets on just fine running Windows for their jobs.
>>
>>53668043
linux is vastly more common than windows for actual important things
>>
>try to set up desktop pc to transmit Bluetooth data to test my android app
>motherfucking matlab can't see the device
>keeps giving me null exception


anyone know a good way of setting up Bluetooth data transmission on C#, python or C?
>>
>>53668043
Yeah in IT jobs maybe. I'm in the hardware/embedded systems market and every job I look they require experience in Linux.
>>
>>53665820
 public static bool isOdd(int n)
{
string num = n.ToString();
bool odd = false;
for (int i = 0; i < num.Length; i++)
{
if (i == num.Length - 1)
{
char c = num[i];
switch (c)
{
case '0':
odd = false;
break;
case '1':
odd = true;
break;
case '2':
odd = false;
break;
case '3':
odd = true;
break;
case '4':
odd = false;
break;
case '5':
odd = true;
break;
case '6':
odd = false;
break;
case '7':
odd = true;
break;
case '8':
odd = false;
break;
case '9':
odd = true;
break;
default:
throw new Exception("Something went wrong");
break;
}
}
}
return odd;
}
>>
>>53668142
>hardware/embedded
AKA the outsourced job market
>>
>>53665771
Lmao kill yourself. Here's your (you)
>>
>>53668043
Sure thing, faggot.
>>
>>53667933

Anon, touting the disadvantages of linked lists is not likely to fly in a data structures class. A good professor would likely have already gone over them in the lecture, but would nonetheless point out that you still have to do l create them first the assignment, because if the university graduates a computer science student who can't implement a fucking linked list, it'll be terrible for their reputation, and they'll likely lose accreditation.
>>
>>53668168
lolwut
>>
>>53668094
l0l
>>
>>53668183
Err data structures, I learned about linked lists in an Intro to programming class.
>>
Is the part of the thread, where we pretend to be experts on topics we have no clue about?
>>
>>53668168
Hardware jobs don't get outsourced. They need someone who actually knows what they're doing.
>>
File: 1360901996387.jpg (378KB, 580x864px) Image search: [Google] [Yandex] [Bing]
1360901996387.jpg
378KB, 580x864px
>>53668095

a-anyone?
>>
>>53668250
Get the fuck out of here, we're busy with our OS dick waving and petty offtopic bullshit.

Go ask your real questions in a classroom.
>>
>>53667258
It's bothering me how if you look very closely the artwork is pretty good but if you look at it at a whole it's pretty fucking bad
>>
I can't believe they killed tay
>>
>>53668221
Yeah man, they would never outsource a job to some know-nothing Indian just to save a buck. This has literally never happened.
>>
>>53668169

u first fagt
>>
>>53668294
Lel oh well. I'm not worried about it. With a double major I have a shit load of jobs at my disposal.
>>
>>53668270

well fuck where's a good place to ask online?
>>
Java is the best programming language you are a shitty programmer if you disagree. All hail Java King of /dpt/
>>
>>53668328
stackoverflow
>>
>>53668341
nice

meme

.

jpg

j
a
v
a

i
s

a

s
h
i
t

l
a
n
g
u
a
g
e
>>
>>53668328
Freenode IRC has some good channels for #csharp and #python.

Just stay away from ##c, it's poisonous.
>>
>>53668361
Java is better than whatever shit language you use because YOUR SHIT you are all shit and any java programmer can out program you with one hand because of how superior Java is only the brightest understand it
>>
>>53668386
>your shit

You type like an Indian

Just because you understand it doesn't automatically make it good
>>
>>53668400
Hi this Pajeet I can program you for $5 dollars
>>
>>53668165
i genuinely can't tell if you're joking or not
>>
>>53668424
>realistically a one line return statement function
>can't tell if joking

c'mon
>>
>>53668449
doesn't deal with negatives faggot
maybe should've taken unsigned inte-
AHAHAHAHAHAHAHA
>>
>>53665820
Glorious Java programmer here I'll solve this


public static boolean isOdd(BigInteger n)
{

if( n.divides(2) == 0 )
{
return false;
}
else
{
return true;
}
}

>>
>>53668475
>braces strewn all over the place
>else statement when returning something
>function instead of modulus
>modulus instead of bitwise
>BigInteger

Looks like a java programmer to me
>>
>>53668475
> == 0
don't you mean === new Integer(0)
>>
File: machine_learning.jpg (171KB, 1416x756px) Image search: [Google] [Yandex] [Bing]
machine_learning.jpg
171KB, 1416x756px
I want to get into machine learning and AI shit.
I know C++ and Python.
Where do I start?
>>
>>53668494
>>53668497
GLORIOUS Java master race only uses Big Integer because it's a real man's primitive data type
>>
>>53665820
all these troll replies
if (n%2 == 0){ return true;} // return true
else if (n%2 != 0{ return false;} //return false
else return false; // an error occured

simple
>>
>>53668517
>not using Haskell where you can do the same but it isn't extremely verbose
>and it's also generic, so it works on fixed integers too
Why do people still insist that OOP is a good thing?
>>
>>53668531
>>>>>>>FUCKING ELSE

stop doing this pls
>>
>>53668531
>an error occured
That else condition literally will never be met, no error in the world would cause it to go there
>>
>>53668540
Simple OOP Java is the best in large real manly men applications with 15,000 lines of codes to organize your code
>>
>>53668540
>int = 0 | int + 1
>haskell programmers think this is new
>>
>>53668449
my buddy does java professionally and every now and then he'll show me some scary fucking shit his coworkers do, man, i just don't know anymore

one of them set up a bunch of horrible shit for a date-time function, something like
#define MS_PER SECOND 1000
#define SECONDS_PER_MINUTE 60
#define MINUTES_PER_HOUR 60
#define HOURS_PER_DAY 24
#define DAYS_PER_YEAR 365


etc. instead of just using any number of standard fucking libraries
>>
>>53668589
gay baby retard programmer here, is it better to #define constants or declare constant global variables
>>
>>53668566
You mean "nat"?

>implying I said Haskell invented natural numbers
>implying I was talking about natural numbers, not Integers which are much more efficient
>>

public abstract class chair
{
public Chair(){
String color = "";
int legs = 5;
int buttons = 3;

}

}

public class carChair
{
Chair chair = new Chair(FactoryBeanReset);

}

public class TestChair
{
carChair car = new carChair();
sout(car);

}

>>
>>53668614
>more efficient
You can't even Haskell properly
>>
>>53668612
Literally neither

BUT preprocessors are WAY better than globals
>>
>>53668638
>neither
then how? please humor me im a gay baby
>>
>>53665820
typedef enum { false, true } bool;

bool isOdd(int n) {
return n & 1 == 1
}
>>
>>53668531
>implementing isEven
>>
File: 1374796030634.jpg (58KB, 600x595px) Image search: [Google] [Yandex] [Bing]
1374796030634.jpg
58KB, 600x595px
>>53668589
>>
>>53668650
Or you could not be a retard and #include <stdbool.h>
>>
>>53668612
It depends on the scope.
#define is only used by the precompiler and is limited to the scope of a single file.
static globals can be used from outside the scope of the file (if not private), but should only be accessible if absolutely required.
>>
>>53668650
wrong
>>
>>53668659
My toaster doesn't support C99 compilers.
>>
{code]

public static abstract final int int swap(int num1, int num2)
{
int temp = num1;
num1 = num2;
num2 = temp;

return num1 && num2;
}
[/code]
>>
>>53668494
You're a fucking idiot if you think bitwise is a good choice
>>
Should I try D or Rust?
>>
>>53668659
treeshaking is unreliable in C, you have to define it yourself for good performance. however, you should extract that one line of code into its own header (notstdbool.h) and then dynamically load that at runtime. be sure to put it up on your favorite distro's package repo
>>
>>53668689
Why not try both?
>>
File: 1456078660633.webm (3MB, 1024x768px) Image search: [Google] [Yandex] [Bing]
1456078660633.webm
3MB, 1024x768px
You guys should be able to solve this:

int meaningOfLife() {
// todo
}
>>
>>53668689
D
>>
>>53668689
Rust.
D is completely dead at this point, but Rust still has a chance.
>>
>>53668659
>C99

Uncultured swine
>>
File: 1425318106132-2.png (641KB, 1000x801px) Image search: [Google] [Yandex] [Bing]
1425318106132-2.png
641KB, 1000x801px
Anyone have that programming challenge image?

I just got a job at a SV company, working on a NLP engine in C/C++. Only problem is, I know almost nothing about C++.

Just need some practice. Thanks
>>
>>53668689
Both, but Rust has a better chance of being adopted for more projects.
>>
>>53668701
return 0;
>>
File: 1450934901245.png (302KB, 1920x1080px) Image search: [Google] [Yandex] [Bing]
1450934901245.png
302KB, 1920x1080px
>>53668711
learncpp.com
>>
>>53668711
http://images.lmgtfy.com/?q=programming+challenge+4chan
>>
>>53668709
>Not using C11
ayy lmao
>>
Consider the following:
public class Fighter()
{
int str = 5;
Attack atk = new Attack();
}

public class Attack()
{
public int calculateDamage()
{
int temp;
. . .
//code here
. . .
return temp;
}
}

Is there a way for calculateDamage to access variables in the Fighter class without having calculateDamage including parameters? How would I go about getting the str variable from Fighter without having calculateDamage() become calculateDamage(int strength)?
>>
>>53668701
void meaning_of_life()
{
return;
}
>>
> all the major players in the infrastructure realm are writing their shit in Go (Docker, ELK stack, half the shit Hashicorp does, etc)
> /g/: "meme language go"

Will /dpt/ every graduate beyond CS101 topics?
>>
>>53668701
>implying meaningOfLife isn't void return type
>>
>>53668711
Here's some fun practice anon.

Write this C++ code in C.
Make all the classes using structs and enable dynamic polymorphism by creating your own vtables.

#include <stdio.h>
#include <stdlib.h>

class Unary_Function {
private:
int lower_bound;
int upper_bound;
public:
Unary_Function(int lb, int ub) : lower_bound(lb), upper_bound(ub) {};
virtual double value_at(double x) = 0;
virtual double negative_value_at(double x) {
return -value_at(x);
}
void tabulate() {
for(int x = lower_bound; x <= upper_bound; x++) {
printf("f(%d)=%lf\n", x, value_at(x));
}
};
static bool same_functions_for_ints(Unary_Function *f1, Unary_Function *f2, double tolerance) {
if(f1->lower_bound != f2->lower_bound) return false;
if(f1->upper_bound != f2->upper_bound) return false;
for(int x = f1->lower_bound; x <= f1->upper_bound; x++) {
double delta = f1->value_at(x) - f2->value_at(x);
if(delta < 0) delta = -delta;
if(delta > tolerance) return false;
}
return true;
};
};

class Square : public Unary_Function {
public:
Square(int lb, int ub) : Unary_Function(lb, ub) {};
virtual double value_at(double x) {
return x*x;
};
};

class Linear : public Unary_Function {
private:
double a;
double b;
public:
Linear(int lb, int ub, double a_coef, double b_coef) : Unary_Function(lb, ub), a(a_coef), b(b_coef) {};
virtual double value_at(double x) {
return a*x + b;
};
};

int main() {
Unary_Function *f1 = new Square(-2, 2);
f1->tabulate();
Unary_Function *f2 = new Linear(-2, 2, 5, -2);
f2->tabulate();
printf("f1==f2: %s\n", Unary_Function::same_functions_for_ints(f1, f2, 1E-6) ? "DA" : "NE");
printf("neg_val f2(1) = %lf\n", f2->negative_value_at(1.0));
delete f1;
delete f2;
return 0;
}
>>
>>53668740
C wasn't around in 1911
>>
>>53668754
no generics, fuck off
rust is better
>>
>>53668773
Java is clearly superior
>>
>>53668784
java isn't in its infancy
>>
I don't think that Go and Rust are interchangeable languages for the projects that use Go and that use Rust.
>>
>>53668754
No, because most of the people here are probably in a CS class.
>>
>>53668745
Initialize Attack so that it contains a reference to the parent;
Attack(Fighter fighter)

then use a getter method to get the strength attribute;
int Fighter.getStrength()
>>
>>53668799
i disagree
>>
>>53668773

> muh memory management
>>
>>53668795
Java is an infant
>>
>>53668732
thanks anon, rolling.

>>53668761
ehh... nah. Thanks though. (I know how to do this stuff in C, it would just be tedious)
>>
Why does C++ support both references and pointers?

Why not just pick one.
>>
>>53668834
>why does this language support useful features, it's too many for my brain to hold
are you the same faggots who say c# is too bloated?
>>
>>53668834
Legacy and both are useful for different things.
>>
>>53668834
They have different behaviors... That's like asking why they have different types of smart pointers
>>
>>53668818
>>53668745
Don't listen to that guy. The Fighter and Attack classes should contain no reference to each other. You need a third class to handle the messaging between the Fighter and his Attack.
>>
>>53668850
>>53668855
>>53668857
C++ is a meme language.
>>
>>53668821
Rust should be used when you need speed and Go should be used when you're lazy and you don't need speed, and would rather shit out a lot of simple code.

>>53668834
Pointers should be used sparingly, because references usually do the job. However they are definitely times when you need to use pointers and a reference would not work (e.g. pointing to heap data).
>>
>>53668891
t. retard
>>
>>53668894
rust values safety over speed
if you want speed there's always C
>>
>>53668914
C favors readability over speed.
If you want speed there's always assembly
>>
>>53668834
One's nullable and one's immutable
>>
>>53668914
>rust values safety
No
>>
File: goats.jpg (40KB, 200x200px) Image search: [Google] [Yandex] [Bing]
goats.jpg
40KB, 200x200px
>>53668938
why are you memeing your way into a discussion you know nothing about?
>>
>>53668952
We talked about this some threads ago.
Don't talk about things you have no idea about.
>>
>>53668914
Rust is super comfy and pretty much just as fast and you will have less memory bugs, with a downside of a tiny bit less speed. Why would I want to use C when I could use Rust and get generics and lambdas and enums and memory management for free?

>>53668938
Rust was literally created to be a safe systems programming language
>>
I'm tired of being a babby using Java and Python.
I want to learn a manly language that won't hold my hand.

Should I learn C or C++
>>
>>53668982
>safe
>systems programming
If you try to combine these two, you are a faggot
>>
>>53668973
i'm not here for every /dpt/, i'm sorry.
what did i miss?
>>53668982
>Why would I want to use C when I could use Rust and get generics and lambdas and enums and memory management for free?
rust isn't a good idea to use everywhere C is usd just yet
maybe once every system comes with a rust compiler along with a c compiler
>>
>>53668987
C.
>>
Hey guys

Theres some apparent huge issue with my code in that nothing shows up in the console when I run it and I can't figure out why

There are no errors, and if I add some it gives me red text like usual for errors in the console, but otherwise nothing is there
>>
>>53669009
http://rbt.asia/g/thread/S53582261#p53589172
>>
>>53668987
Learn Haskell.
>>
>>53669090
It wants you to input text into the console. Add some prompts before scanner.nextLine().
>>
>>53669091
fn main() {
let v = vec![1, 2, 3];
println!("{}", v[3]);
}

ayy this compiles
that sucks
>>
>>53669106
oh alright, thanks a lot

seems obvious now lol
>>
I want to practice a language I'm fairly new to. What are some moderately difficult programs I should make?
>>
>>53669175
fizzbuzz
>>
>>53669175
http://arjunsreedharan.org/post/82710718100/kernel-101-lets-write-a-kernel
>>
>>53669175
implement a mersenne twister generator
>>
>>53669090
>>53669106
problem is I had a prompt in a different method below the main method (now I moved it to above it) that was asking the user to enter a # one through six, but its not utilizing that its just using the new code I just added after sc.nextLine();
>>
>>53669204
poo in loo
>>
>>53665622
not learning Android programming anymore
>>
>>53669106
>>53669223
this is said method
>>
File: haxe.png (5KB, 230x230px) Image search: [Google] [Yandex] [Bing]
haxe.png
5KB, 230x230px
Ratings?
>>
am i the only one who does
 
public class myClass()
{
public int myMethod(){
return 0;
}
}

?
i really have no idea how i got in the habit of doing this
>>
You are not the only one.
But you are a gigantic faggot.
>>
>>53669208
Thanks
>>
>>53665919
What language is that?
>>
>>53669309
what seems to be the problem here officer
>>
>>53665493
Writing a celullar automaton that will hopefully support life.
>>
>>53669346
Agda
>>
>>53669346
hask
>>
>>53669351
mixing newline / same-line open braces for declarations
>>
>>53669362
What kind of hardware are you working with?
>>
Hey guys,

how do I into OS programming / designing my own OS? A really simple one, I mean.

Minix?

Xv6?

Xinu?

Basically Im looking for some resource that has assignments based around designing your own complete OS.

any tips?

thanks bruhs
>>
>>53669390
yeah you're a cunt
don't do that
>>
Why is programming so hard
>>
>>53669393
jk lol
>>
>>53669405
I'm not that cunt, though I agree it is cunty.
>>
>>53669413
It isn't. What's the problem?
>>
>>53669434
It is I don't understand it
>>
>>53669463
It's okay if programming just isn't for you. You could try accounting instead.
>>
>>53668982
generics and lambdas make the world worse
and i like rust.
>>
>>53669463
There's either one of two issues. You can't think programmatically or you just started programming.
>>
>>53669496
How does one think programmatically? You forgot the third option I can't math either
>>
>>53669148
>throwing around "dependent types" like it's the end-all solution to everything and magically does bounds checking
>without actually understanding what it does
>>
>>53669405
but sameline on the class line just looks so off to me
>>
>>53669522
Math barely has anything to do with being good at programming. Computational thinking either comes naturally or not at all. You have to think in terms of how a computer would do something, not how you would do something.
>>
>>53669564
k&r style
public class myClass()
{
public int myMethod()
{
if (meme) {
return 0;
} else {
you.commitSuicide();
}
}
>>
>>53669592
>Computational thinking either comes naturally or not at all.
This is a meme
>>
>>53669611
It's a true meme. It's the reason web devs exist.
>>
>>53669592
not really. i remember when i was starting off and how i just couldn't think that way, and now it comes 2nd nature of course
>>
>>53669592
>>53669611
>>53669657
give me an example of how you think computation thinking
>>
>>53669611
it's somewhat true, you have to be non-retarded to be really good at programming, some people are just destined to be fuccbois

>>53669592
if you can't into math you're gonna suck cockballs at programming too
>>
>>53669657
My point was your ability to learn how to think computationally has to come naturally. A lot of people even in programming still are shit at it.
>>
>>53669402
https://littleosbook.github.io/

http://wiki.osdev.org/Main_Page

You're welcome
>>
>>53669543
>like it's the end-all solution to everything and magically does bounds checking
Correct
>>
>>53669689
The computer would tweet racist remarks.
Therefore, I should tweet racist remarks.
It's just natural.
>>
>>53669689
return the maximum of a set of a numbers. a normie hears that and blanks
>>
>>53669692
While being able to solve math problems is good for building intuitive problem solving skills, knowing a lot of math isn't really required. If he does mean he's shit at solving math problems then yes he's gonna be shit at programming.
>>
>Tweaker was written in Visual Basic

What the fucking fuck?
>>
>>53669758
well yeah you don't need much math for most things but i mean if he struggles to understand math and solve math problems he's going to struggle with programming too
>>
>>53669393
Just an average CPU. Thuban 1090t.
If it works really well, I will port it to CUDA or OpenCL
>>
>>53669402
you are basically on your own here, at least with actual code (theory is everywhere.)

Buy Tannenbaums Minixv2 book and start reading, read up on writing bootloaders and then drawing to the screen.

You'll need to learn about the GDT (for jumping from 16 to 32 bits (unless you just use grub)), the IRQ and get to the point where you can controll the PIT so you can begin spawning processes. From there you will start moving pretty quick into memory management and then a file system (do a FAT12 for a simple one) and then you enter userland before to long.

This took me 3 years from no knowledge to bootable, and wasn't very useful for anything but moving around the file system and creating and editing files/directories.

But it was a good learning experience, faggot.
>>
/g/ i just passed my first test in my programming class :D
>>
New thread: >>53669844
>>
>>53669840
Average two ints in C
If you can't, I'll email your professor and tell him to fail you
>>
>>53669722
Thanks m8, ill check these out.

>>53669815
>This took me 3 years from no knowledge to bootable, and wasn't very useful for anything but moving around the file system and creating and editing files/directories.

Yeah I'm sure it won't be super useful.

I took OS last semester and we did "parts" of an OS (memory manager, disk scheduling, etc) but we didn't do a whole OS. I was thinking of trying to build on that and actually write a simple OS. Ill download that shit then and try to figure it out.
>>
>>53669854
i can't do it
go email him
>>
>>53669763
does anybody actually write in visual basic anymore

i used to poke at the thing that came packaged with ms office programs, but that was before i knew what programming was
>>
>>53669874
hey! you're not me!
>>
>>53669763
VB is a fine language. At this point it's essentially C# without braces or semicolons.
>>
>>53669912
how do you know that for sure?
>>
>>53669893
VB is not VBA, though they are related. VBA is closer to VB6, which is the dogshit that gave VB its bad reputation.

Lots of people still use VB, though mainly for legacy maintenance since C# has become the flagship .NET language.
>>
File: 192.png (35KB, 665x520px) Image search: [Google] [Yandex] [Bing]
192.png
35KB, 665x520px
Which one should be the next GNU mascot?
>>
>>53665896

its right, it only looks at 1st bit, in binary if the 1st bit is set then its obviously odd (2^0 = 1..going to get an odd number) dont even need to check anything else
>>
>>53665820
return n%2;

Wow, it's fucking nothing. I swear to god the people in these threads are completely incompetent morons. Have any of you coded anything beyond hello world? Serious question, because judging from these replies I'm guessing the answer is no, none you mongoloids has even a modicum of sense when it comes to programming in ANY language. Normally I'd just tell you all to kill yourselves and move on with my day, but goddamnit this is just ridiculous. Just PLEASE pursue a different career, hobby, or major - whatever it is that you are "programming" for, find another outlet you fucking monkeys.
>>
>>53669738
Okay well this is my thought process you would need an array to store all the numbers

then I would need a loop to go through the array

then I would need a a variable to hold the largest amount. Then I would need to start comparing each one and put larger one in max
>>
>>53670003
youre just mad cuz people posted actually readable solutions unlike your esoteric math solution
>>
>>53670003
bad bait
>>
>>53670012

not the guy you're responding to but i got this in an interview before. after this they asked me to find the sum of the 2 largest numbers of that list
>>
>>53670059
how was my answer
>>
>>53670050
Posting a correct solution in a programming thread where everyone else is incapable of solving a simple problem is "bait"? Back to sociology or where-ever you people come from
>>
>>53670003
>>53670089
I'm pretty sure most if not all the responses were jokes
>>
>>53670089
(You)
>>
>>53670098
>hurr I was only pretending to be retarded
>you fell for it xD
you people are insufferable idiots and no one is believing this "jk lol" excuse either.
>>
>>53670146
>I take every single post as seriously as I can on a Russian throat-singing message forum
>>
>>53670194
>he can't even return whether an integer is odd or not
>he probably can't even return the average of two ints in a safe and efficient manner
This isn't /b/. /g/ and especially /dpt/ are for serious discussion of programming and technology. Now either learn wtf you're talking about, stop "trolling" or fuck off.
>>
>>53670086
just fine man
>>
>>53667425
none.
The ? or T just mean that elements of type ?/T can be stored there

List<String> can only store Strings, for example
>>
>>53670239
return num%2 = 0;
>>
>>53668834

Both serve different purposes. Pointers are used under the hood for data structures like vectors and linked lists, which manage heap memory. References are used for functions arguments that are pass by reference. Eliminating raw pointers completely would be unacceptable, because then you wouldn't be able to manipulate the heap, and you wouldn't be able to interact with memory mapped I/O. References were tacked on because they simplify things.
>>
>>53669728
The only difference between dependent types bounds checking and traditional (run-time) bounds checking is that with dependent types, you explicitly control when the bounds checking happens (sometimes allowing bounds checks to be omitted) while with traditional checks, they always happen, or at best a few cases will be optimized out by a second party.
So dependent types = you get to do the optimization yourself
>>
help i'm fucking retarded
http://pastebin.com/p9Cs0wqK

trying to calculate percentage but it always comes out to zero

C#
>>
>>53671722
>C#

kill yourself, faggot
>>
>>53671722
This is why people who haven't taken basic mathematics should not attempt programming.
>>
>>53671722
I don't know who taught you programming, but.
if both numbers are ints, then 123/2345 = 0
>>
>>53665493
But she's a guy.
Thread replies: 345
Thread images: 23
[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.
If a post contains illegal content, please click on its [Report] button and follow the instructions.
This is a 4chan archive - all of the content originated from them. If you need information for a Poster - you need to contact them.
This website shows only archived content and is not affiliated with 4chan in any way.
If you like this website please support us by donating with Bitcoin at 1XVgDnu36zCj97gLdeSwHMdiJaBkqhtMK