[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
> be me > be programming in college > I look at the
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

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

Thread replies: 206
Thread images: 12
File: RGLFim0.png (41 KB, 890x670) Image search: [Google]
RGLFim0.png
41 KB, 890x670
> be me
> be programming in college
> I look at the screen of the guy next to me
> mfw its 10 lines of strcmp() testing each possible case
> mfw CS graduate meme is real
can people be this dumb senpai
>>
If you want to code you can take a workshop and learn in a few months then get a job, if you want to bullshit your way through a traditional 4 year program with B's then you're going to have a bad time.
>>
>>54669123
Nice, dude. Who are you quoting though?
>>
>>54669123
Did someone actually write that program in earnest or is it just a forced meme?

Please be honest with yourself when answering
>>
>>54669170
I swear to god its real, I know the guy
>>
>>54669123
> mfw its 10 lines of strcmp() testing each possible case
okay, he could use an array of strings and loop over them. or maybe even do a binary search.
big deal.
>>
>>54669123
It's true OP. I had to teach a guy the value of loops cause he too just wrote 10 lines of code. Luckily, he understood and vastly improved. In my opinion though, the class itself was very shitty. If I hadn't already known how to program before coming in I would've gotten lost on at least some bits.
>>
>>54669253
you're doing God's work anon.
>>
update: I just listened to him on the phone asking someone if exit() returns from the calling function or exits the program.
why
>>
>>54669274
>your doing god's work
>>>/leddit/
>>>/9fag/
>>
>>54669546
>your
>misquoting you're
well done!
>>
>>54669488
He's obviously new to programming.
Why are you making a big deal out if someone learning?the fuck is wrong with you?
>>
File: 1376707710231.jpg (139 KB, 600x424) Image search: [Google]
1376707710231.jpg
139 KB, 600x424
>mfw purposely telling my classmates wrong coding etiquette to make myself look better by comparison
>>
>>54669123
What was the exercise?
>>
>>54669123
>mfw its 10 lines of strcmp() testing each possible case

What's particularly wrong with this?
>>
>>54670138
It would make much more sense to just convert whatever string is input to all lowercase letters. That's what I did when I fucked with Java, anyway. Accounting for every single case use isn't only retarded, but it's futile. Even for a simple input like "Jessica," there are over 5,000 different upper-case and lower-case variations.
>>
>>54670299
>128 is 5000
wew lad
>>
the "computer science graduates can't program" meme is completely true

I didn't believe it until I started interviewing people. I didn't think it could be that bad.
>>
>>54669253
What's the value of loops when the compiler ultimately unrolls them anyway?
>>
>>54670337
What did you use to calculate that? Now that I'm dwelling on it, I'm pretty sure I accidentally checked for all variations of "Jessica" accounting for case letters and the letters being swapped around.
Still, let's say there's 128 variations. It would be much more time-efficient and less monotonous to just convert the string to all lowercase, if the string has to say a certain word. If the string doesn't have to say a certain word, then accounting for case makes no fucking sense anyway. Just display whatever the user typed in. Let their phone keyboards correct their spelling for them.
>>
>>54669123
100% coverage is great senpai, you'll get paid six figures just for mentioning that in your interviews
>>
>>54670422
Not all variables are static.

In static uses, it still saves time
>>
>>54669123
what an idiot. he should just use a loop to check for even/odd

Console.Write("Enter a whole number...");
int userNumber = Convert.toInt32(Console.ReadLine());
while (true) {
int i = 0
if userNumber = i {
Console.WriteLine("Your number is even!");
}
else {
Console.WriteLine("Your number is odd!");
}
i += 2
}
>>
>>54670422
Because cleaner code
If you have two ways of writing the same thing, and both will ultimately compile into the same shit, then you should opt for the more readable one.
>>
>>54670422
The ultimate reason for creation of high level languages is TO WRITE LESS code. You can do anything in brainfuck, but do you want to?
>>
>>54670468
1 bit for each character to store upper/lower case, 7 bits -> 2^7 = 128.
>>
>>54670511
>if userNumber = i
Wut.
>>
>>54670422
>when the compiler ultimately unrolls them anyway

JMPing to a previous line of code is not "unrolling"
It's basically goto'ing after an if statement
>>
>>54670575
Google what unrolling is.
>>54670422
You too, it never unrolls the loop entirely.
>>
>>54670511
trash
>>
>>54670299
>convert whatever string is input to all lowercase
>>54670299
>Accounting for every single case

>case
I interpreted this differently, I assumed he meant 'case' as in valid possibilities.
>>
>>54669157
himself
> everyone knows meme arrows are cruise control for cool
>>
>>54670611
>Google what unrolling is.

do you think it makes you smart to use hard words
why cant u just explain like normal human being person
>>
So... what's the "right" way to do this?
>>
>>54670665

i%2==0
>>
>>54670687
not the picture, the op.
>>
>>54670511
Console.Write("Enter a whole number...");
int userNumber = Convert.toInt32(Console.ReadLine());

if ((userNumber % 2) == 0) {
Console.WriteLine("Your number is even!");
}
else {
Console.WriteLine("Your number is odd!");

>>
>>54670700

depends what the fuck he wants to do
he could just lower case it and do 1 str cmp
>>
>>54670705

you are an idiot, how can you be this stupid
>>
>>54670723
lets say writing a shell that takes 10 possible commands.
>>
>>54670655
To avoid frequent use of jumps compiler often repeats content of loops N times, N usually being powers of two. The tradeoff is a bigger program. When the number of times an action is need to be done is not a multiple of N, but rather N+some small M, it jumps to near end of the unrolled loop to execute M instructions first, then to the beginning of the loop(this way it can execute loop multiples of N times, like x*N+M). Depending on how complex the loop is, it can be twice as fast.
>>
>>54670705
 
(userNumber % 2 == 0) ? printf("Even\n") : printf("Odd\n");
>>
>>54670901
Do you take pride in writing unnecessarily obfuscated code? If I were your boss you'd be fired immediately.
>>
>>54670978
>takes pride in not knowing ternary if operator

I hope your children are born with physical and metal disabilities.
>>
>>54670901
if you're going that way, why not
printf((userNumber % 2) ? "Odd\n" : "Even\n");
>>
>>54670978
it's fine for this kind of stuff, but for more complex stuff it gets hard. for example:
int median(int a, int b, int c) {
return (a<b) ? (b<c) ? b : (a<c) ? c : a : (a<c) ? a : (b<c) ? c : b;
}
>>
>>54669190
>i want to act like i know what im talking about
>>
>>54670978
it's a single ternary

complain when someone does this
>>54671039
>>
>>54671019
good point, but i would generalize it more
printf("Your number is %s \n", (userNumber % 2) ? "Odd" : "Even" );
>>
>>54670511
Bait
>>
>>54670575
On the actual CPU level, all loops are handled with gotos anyway.
>>
>>54670643
>meme arrows
GETOUT NEWFAG REEEEEEEEEEEEE
>>
>>54670753
Convert input to lowercase and use multiple if statements to check for matches. Ideally, the most common commands should be at the top of the if block.
>>
>>54670978
>ternary operator is "unnecessary obfuscation"
>>
>>54671169
Wewlad
WEEEEEWWWW
>>
>>54671039

can you explain that
i know when you just have one ? : but when multiple i have no idea
>>
>>54670705
You don't need braces for single statements.
>>
>>54671600
just nest it the way you do an if statement
so if
` a ? b : c`
is
`if a then b else c`
then
`a ? b ? c : d : e`
is
`if a then ( if b then c else d) else e`
>>
>>54671655
You don't, but it's good practice.

>>54671657
Thought code was backticks here, what's the markup?
>>
>>54671657
>>54671672
Read the sticky n00b
>>
public class Main {
public static void main(String[] args) {
System.out.println((new Scanner(System.in).nextInt()) % 2 == 0 ? "Even" : "Odd");
}
}

dont know c#, so here is a java one liner
>>
>>54669609
Seriously, people are so uptight here
>>
>>54669488
He probably just skimmed through the tutorials or books.
>>
>>54671087
You guys missed the whole program:
Console.Write("Enter a whole number:");
Console.Write("Your number is "+ ((Convert.toInt32(Console.ReadLine())%2)==0?"even":"odd") + "!" );


i dont even know, is this shit java ?
>>
>>54670511
Lololol
>>
>>54671655
You don't need them, but you are just bad if you don't have them. Adhere to the style guide, please.
>>
>>54670901
>>54671019
    puts((usernumber % 2) ? "Odd" : "Even");

if you're going to print a string then a newline just use puts.
>>
>>54669123
the code i got for this task so far

while True:
number = float(input("Enter the number you want to see if it is an even number: "))
if number == 1:
print("this is add odd number")
while number > 1:
number = number - 2
if number == 1:
print("this is an odd number")
if number == 0:
print("this is an even number")
>>
>>54669123
Pic is C# right? I'd use a loop and test for the loop specific integer.

Side note: what language would you guys recommend for getting into a software engineering course?
>>
>>54672788
>float(input(...))
is this written in GLSL? I don't remember that being in C++ and it's definitely not in C.
>>
>>54672788
try modulo
>>
>>54672816
It's Python.
>>
>>54669610
Being better than average is not that hard and not being better than average is not such a big deal that you have to be a liar about it.

If you're a liar on top of being a moron, you should sell houses instead of work with computers.
>>
>>54670299
>>54670636
Same here. Careful about how you use that word.
>>
>>54670422
>What's the value of loops when the compiler ultimately unrolls them anyway?
that's why the call it
-FUNroll-loops
right?
>>
File: 1404289873979.jpg (11 KB, 209x200) Image search: [Google]
1404289873979.jpg
11 KB, 209x200
>>54669123
>be me
>get a degree in Finance
>classes are not easy, not hard
>party all the time, fuck tons of girls and have a blast without too much studying
>pass all my classes, get my degree, get 70k starting at a firm
>mfw stemfags who spend all day studying to get their meme degree and make as much or less than me starting
>>
File: 1460483148647.png (276 KB, 466x604) Image search: [Google]
1460483148647.png
276 KB, 466x604
>>54669123
The CS majors at my school are total cancer.

>yeah I failed first year calculus and algorithms but I passed the class on software development and I have side projects like this site I made for my sister's bf
>I'm not looking to be a computer scientist so it's okay that I code like a Pajeet

Then they bitch about every prof that tries to keep the class interesting by assigning nontrivial assignments you actually have to sit down and think about.
>>
>>54670705
inb4
 !(userNumber & 1)

inb4 compiler optimisation
inb4 compiler optimisation is a meme
inb4 who the fuck is moot
>>
>>54671019
>>54670901
>>54671087
For fuck's sake guys, do you have PTSD from getting raped by a piece of code that spans over several lines? You have to make your code legible, customizable and expandable.

$strResultMessage['en'] = "The number is %1.";
$strOdd['en'] = "odd";
$strEven['en'] = "even";
$locale = "en";

if (userNumber % 2 == 0)
{
$strResult = $strEven[$locale];
}
else
{
$strResult = $strOdd[$locale];
}

$strMessage = strParse($strResultMessage[$locale],1,$strResult);
printf($strMessage);


Of coursr, strParse would have been declared earlier. I don't think I need to specify how it'd work.
>>
>>54670978
Rofl everyone getting baited hard.

Also check'em.
>>
bool evenNumber = false;
bool active = false;

do
{

Console.WriteLine("Enter in a number between 1 and 100");
int userNumber = Convert.ToInt32(Console.ReadLine());


for (int counter = 0; counter < 100; counter += 2)
{
if (counter == userNumber)
{
evenNumber = true;
break;
}

else
{
evenNumber = false;
}
}

if (evenNumber == true)
{
Console.WriteLine("Even number!");
}

else
{
Console.WriteLine("Odd number!");
}

Console.ReadLine();
}
while (active == false);


Is this any good?
>>
>>54673014
...No?
>>
>>54672816
yup its python.

make some adjustments.

number = float(input("Enter the number you want to see if it is an even number: "))
while number > 1:
number = number - 2
print("still processing..")
if number == 1 or number == -1:
print("this is an odd number")
if number == 0:
print("this is an even number")


i just cant figure out what to do if the number is a decimal number (floating point).
>>
>>54673014
You should use the modulo operator instead of a for loop
>>
>>54669123
It actually seems politically incorrect for professors to criticize students' code. This is why you get shit like this.
>>
>>54673066
I'm a complete beginner, I'll need to look into that. Thanks!
>>
>tfw fell for the CS meme and can't get a job because replaced by pajeet and friends in India
>>
>>54673046
Instead of
     if number == 1 or number == -1:
print("this is an odd number")
if number == 0:
print("this is an even number")

do:
     if number == 0:
print("this is an even number")
else:
print("this is an odd number")
>>
if num % 2 == 0:
print("your number is even")
else:
print("your number is odd")
>>
>>54673066
>>54673089
OH the percentage thing, yeah I used that for the fizzbang example not long back.
>>
File: 1454905323163.png (60 KB, 200x156) Image search: [Google]
1454905323163.png
60 KB, 200x156
>>54673046
that code is a joke, right?
>>
>>54673089
I genuinely thought you were trolling. Tip: If your solution include cycling through a limited subset of possible inputs, it's terrible and there's a lot of better ones out there. Sorry, I gotta say it like it is.

The modulo operator gives you the remainder of a division. Hence, it will give 0 if dividing an even number by 2.

But that's easy. An approach like >>54673046 and >>54673092 is pretty much like coding the modulo operation yourself. It forces you to understand what you're doing instead of letting the compiler do it.

Just don't actually do it in a professional setting or you'll be made fun of.
>>
>>54670422
>What's the value of functions when the compiler ultimately inlines them anyway?
>>
>>54673104
>hardcoding the same substring twice.

That's 30 bytes of disk space you will never see again.

>>54673154
>>54670422
What is wrong with you guys? Compilers convert loops and functions into gotos. A compiler never unrolls recursive code.
>>
>>54673139
Hey I appreciate the advice, genuine thanks!
>>
>>54673174
>Compilers convert loops and functions into gotos
of course, but there is optimizations some compilers do which is what they are talking about.
>>
>>54673191
My pleasure brosky!
>>
>>54673046
That's really cool, I like the logic behind it.
>>
>>54673230
ahah thanks man. I've just started out
>>
>>54672925
bravo
but wasn't the OP's pic in Java? does it work in java?
>>
>>54671145
>not calling them memic arrows
plebshit
>>
>>54672914
>>yeah I failed first year calculus and algorithms

that's me. i failed calc (analysis) but aced algorithms
>>
>>54671018
tfw your newborn son's metal is disabled
>>
>>54672964
>$strOdd['en']
do you even Perl?
protip it's
>$strOdd{'en'}
>>
>>54670511
Output for userNumber = 8:
Your number is odd!
Your number is odd!
Your number is odd!
Your number is odd!
Your number is even!
Your number is odd!
Your number is odd!
Your number is odd!
Your number is odd!
Your number is odd!
...
>>
>>54673877
>implying
>implying
>implying
>>
>>54673895
I never used Perl. Does it force you to use curly brackets to make associative arrays? Because that's the first language I've heard of that's nigger enough to do this.
>>
>>54673937
your code looks a lot like perl except for that bit. What is it then?
and yes, afaik it does
>>
>>54673974
PHP.

I've learned a few languages at beginner level and PHP is the only one I've ever been genuinely proficient in.

Of course I know there's no "printf" in PHP, I was just trying to make pseudocode that looked compatible with what was being thrown around in this thread.
>>
>>54670299
Or you can do a case-insensitive comparison.
>>
>>54674026
>Of course I know there's no "printf" in PHP,

http://php.net/manual/en/function.printf.php
LOL
>>
>>54674026
>calls perl a nigger language
>uses PHP
ayyy
>>
>>54669123

Are people in CS programs not taught to make code as reusable as possible?

Shit, I've been working a programming job (self-taught) for a while now and I learned real quick that not making code reusable can really just waste a lot of fucking time.
>>
>>54674095
Oh.

Well I just use print. There's no reason to print "formatted" text in PHP.

>>54674119
I consider that it's a good learning language because it doesn't require you to take care of a lot of technicalities. You ever hardly need to worry about variable types and declaration. I'd still use it today if I was working on a webpage because I'm not familiar with any other way to program a webpage and it just werks.
>>
>>54669123
var number = prompt("Enter your number");
if (number % 2 === 0) {
console.log("Your number is even.") }
else if (number % 2 > 0) {
console.log("Your number is odd") }
else if (isNaN(number)) {
console.log("Error. Letters are not allowed.") };
>>
>>54674196
>input %
>letters not allowed

whoa dude you must be a computer science major!
>>
>>54674151
My professor actually has it as part of their syllabus that you're never allowed to reuse code because it's "self-plagiarism".
I ignored that and no one noticed/cared, though.
>>
>>54674225
Yes, I am :^)
>>
>>54674240

So it's part of your professors program to actually enforce god-awful skills?

holy shit, I'm slowly starting to believe that the CS degree is a fucking meme.
>>
>>54672964
MY EYES
>>
>>54674196
If you're not sure that the variable number is assigned a numeric value, you can't use math operators on it before validating that it's a number, especially if you use a language that cares about variable types, which means all languages used to make machine code and then some.
>>
>>54674350
What? My only mistake is not indenting my code, because I wasn't sure on how to do that in a web browser form. Otherwise this is the least amount of code acceptable for such a program.
>>
>>54674379
Ugly programming language, ugly code, too much code, etc.
>>
>>54674393
It is not too much code. This is the proper way to implement a feature that requires printing a string with a part of it depending on a switch. You need to account for localization and possible code changes in the future.
>>
>>54674393
Also, the logic should never be directly handling hardcoded strings. That's a nigger way to code. You should be able to change any text in a program from a single specific area of your code.
>>
>>54674294
my school has a automatic plagarism detector for code which the teacher told everyone about during the first class of the semester. However, so many people still decided to copy some other persons code via literal copy paste and failed out. Renaming variables and such won't prevent you from getting caught. However, they end up getting so many hits from the program they just get the idiots who simply copy pasted in trouble and forget about the rest.
>>
>>54674485
We have this too, I think its pretty standard. Our professor said it will tell him which students had the same number of variables and if they had the same number of integer or String variables and how many methods and things like that each student has so even if you change variable names they get you easy.
>>
>>54673843
Your right, java doesn't evaluate 1 as true. What a shity language. Bitwise operations work fine though.
>>
>>54674485
>>54674574

how do these things possibly work without getting a fuckload of false positives?

Most computer science/engineering problems have one or two canonical solutions, and even considering fringe solutions and outright bad ones, there must be plenty of cases where two people develop work without sharing and it ends up with the same number of variables or same overall structure.
>>
>>54674576
>Your right, java doesn't evaluate 1 as true.

Why should it evaluate a non-boolean value as true? Java is a strongly-typed language.
>>
>>54674576
Why would it evaluate 1 as true, 1 is an integer and true is a boolean :^)
>>
>>54673882
How can you even fail calc?
>>
>>54674659
I too failed calc.
The reason being that I didn't give a shit and neither did the professor teaching.

Also, it was just an all around shit semester for me. In the semester I got a C in a CS course because I didn't hand in any projects and I got a D in physics because the professor was absolute shit.
>>
>>54674754
>The reason being that I didn't give a shit
How could you not give a shit about calc? What the hell did you major in if you couldn't bother to care about something as important (and easy) as calculus?
>>
>>54674957
not that guy but calculus is not important to computer science or software development at all.
>>
>>54674613
Usually you can just tell. The weeaboo who refuses to talk to anyone probably didn't copy the stoner's code, but the feminist might've copied Chad's.
>>
>>54675012
This. Calculus is important for engineering, not programming.
>>
>>54675012
>it's not important for mundane work so i shouldn't WASTE TIME learning it

>knowledge
>a waste of time
pick one
>>
>>54675012
except for stochastics/queue theiry/stats/machine learning/robotics/scientific computation/signal processing/algorithm analysis/physics
>>
>>54669123
There's no such thing as an idiot proof major. My friend went into Computer Administration and says you can't really be an idiot with computersbut that's a goddamn lie.

Just imagine how many complete morons are in law right now
>>
>>54675253
You can make it idiot proof by weeding out the idiots
>>
>>54675412
In theory, that's supposed to happen. The classes get more challenging and thus more people drop out.

In reality however, kids can cheat, share homework, piggyback off group work, and even be forced forward just because their stupidity annoys the teacher to no end and they don't wanna deal with them again
>>
>>54675045

Tell that to the guy doing Graphics programming (Calculus and Algebra outta the ass) or the other guy working for Amazon where a 1% margin of error on some probabilistic equation could mean millions of dollars

>bait
>>
>>54672494
I remember reading the Linux kernel style guide (probably written by the all mighty Torvalds) where it was written that conditionals with one statement shouldn't contain braces to save on readability, since without braces you are putting all the code in one line instead of 3.
>>
I got replace by dumb. It is about people skills. which I don't excel at.

>Looking through code.
>Find a for loop
>the count exceeds bounds on an array.
>lose my shit on how bad this was
>demand that his work gets reviewed
>just worry about yourself anon
from memory, excuse the syntax errors if they exist. This code did run
try {
for (i=0; i < myArray.Count() +1; i++) {
myArray[i] = myArray[i] + 2
}
}
catch {}
>>
>>54675677
Actually, you can use braces and keep your single-statement conditionals on a single line:
if (condition) { doSomething(); }

But there's literally no point to it. And in fact, you can put a single-statement conditional on two lines, without braces, like:
if (condition) 
doSomething();

It all comes down to the compiler ignoring whitespace.
>>
>>54675843
>I got replace by dumb. It is about people skills. which I don't excel at.

This. Middle management can no more discern good code from shit then the average American can discern Egyptian hieroglyphics. In most positions in most companies...increasingly even places like Apple and Google...your passion, your knowledge, your skill as an engineer mean jack shit.

IT career is the worst meme I ever fell for.

>that fucking code
>triggered.jpg

I've seen shit like that and worse.
>>
for (int i = 0; i < 100; ++i)
printf("This loop is %s.", i % 2 ? "odd" : "even");

printf("ur a faget");
>>
File: 1372607772976s.jpg (3 KB, 120x124) Image search: [Google]
1372607772976s.jpg
3 KB, 120x124
>>54673139
are you fucking retarded? modulo 2 is calculated by taking the last digit in the binary representation.
Using a while loop is O(n) whereas checking the last bit is O(1)
you are so dumb it hurts.
>>
>>54676960
>modulo 2 is calculated by taking the last digit in the binary representation.
Although that's a logical way of doing it in the specific case where you are doing modulo 2, I doubt the compiler treats modulo 2 differently than any other modulo. It wouldn't make sense. That would mean compiling it into a different instruction just because it's against 2, and it would have to check for a different bit depending on if the number is a floating point. It's opening the gate wide to errors due to specific situations. If compilers start treating specific operations different because they can be calculated faster when using specific numbers, then there's no limit to how complicated it can get.

Modulo is modulo. It returns the remainder of a simple division. There is no other way to calculate it than substracting y to x until x < y and then returning x.
>>
>>54677147
pplease be a troll
>>
>>54677147
have you taken a compilers course?
>>
>>54677147
>It returns the remainder of a simple division.
That's not true at all. Modulus is calculated using repeated Euclidian division.
Also, have you ever considered googling "compiler optimization"
>>
>>54677211
No. I'm going entirely on presumption. Looking it up on Google and it seems like I was wrong.

Oh well.

>>54677221
>That's not true at all. Modulus is calculated using repeated Euclidian division.
... Yeah, that's pretty much exactly what I'm saying. Are you doing the thing where you're understanding something different to have something to argue about?
>>
>>54677147
I'd imagine many compilers these days would incorporate such a distinction, I think they do something similar with converting multiplication/division by two to bit-shift operations. Yes, it's added complexity, but the compilers that see widespread use are extensively tested to avoid errors like that, and it does pay off by making the compiled executable more efficient.
>>
>>54677270
Yeah apparently they do. I thought it would be silly to get into this kind of pointy optimization, but I guess it's not.

In my opinion, developers should have in mind to optimize their code in such ways.

Proper coding languages have a lightweight construct to get bits out of numbers, right? I'm not asking rethorically, I actually don't know.
>>
>>54677301
>I thought it would be silly to get into this kind of pointy optimization,
that's all that compilers fucking do, retard

>In my opinion, developers should have in mind to optimize their code in such ways.
mind-bogglingly retarded. the compiler is there to make these optimizations so you don't have to write 'clever' unreadable code just to ensure your / 2 operation is implemented as a bitshift.
>>
File: 1358727357678-1024x576.jpg (103 KB, 1023x575) Image search: [Google]
1358727357678-1024x576.jpg
103 KB, 1023x575
>>54677368
>he thinks I'm retarded because I don't want my compiler to wipe my ass for me.
You should be able to optimize your code by yourself. If not, you're an incompetent programmer and don't belong near a computer.
>>
>>54669123
I'm not a coder because I'm fucking retarded but couldn't you do something like num%2=0 then it's even? I'm going off of memory here.

Like, that can't be the right way to do things?
>>
>>54670511
this guy likes dick
>>
>>54671833
omg go away
>>
>>54673014
too many if-else statements for such an easy task
get better m8
>>
>>54677454
You should probably be a programmer. Some people are studying CS and don't even get that right off the bat. You're ahead of them.
>>
>>54673046
you mean raw_input
>>
>>54677397
Computers are FAR more efficient at generating optimized code than even highly skilled programmers are. If you care that much about optimizing everything yourself, just write your programs in asm in the first place.
>>
>>54672964
why do you go out of your way to make perl ugly
>>
>>54677397
Please stop using my waifu to shitpost.
>>
If I pass my finals next week, I am gonna graduate, but I don't even know any programming languages. I gotta google all the syntax.

I'm gonna die in the interviews too, because I get panic attacks when being interviewed by white males. Also, I'm not very presentable.

I don't even know where to look for interviews. Maybe glassdoor?
>>
>>54678866
Sounds like you went to a wonderful school.
>>
>>54677553
That's pretty depressing given I'm going off of memory for what little I know. Don't they teach people this stuff in classes or university?
>>
>>54679414
A proper CS program isn't even supposed to be about programming.

Think of a programming language as a hammer.
You don't go to university to learn to swing a hammer.
>>
>>54677240
>No. I'm going entirely on presumption. Looking it up on Google and it seems like I was wrong.
The thing is compilers run multiple "passes" on the input code. For most of the time, 'x % 2' is just 'x % 2' and nothing special, but during optimization passes it is able to transform it into 'x & 1' (and the resulting associated instruction).
Compiler optimizations are actually absurdly complex and powerful, GCC can do some seriously crazy things to your code.
>>
>>54679414
Colleges will teach you to put what you're doing into code but they won't teach you problem solving. That's a skill.
>>
>>54679414
I don't think I learned about modulo until I took discrete math years after high school. Not surprised that people don't know about it in their first year programming classes.
>>
>>54679106
SJSU, right here in Silicon Valley.
>>
File: 1462791076194.jpg (103 KB, 1300x731) Image search: [Google]
1462791076194.jpg
103 KB, 1300x731
>>54672898
>be me
>get a degree in theoretical physics
>classes hard
>party every weekend (except during exams), fuck long term gf
>pass my classes, get degree, get first job, trader, $25k + 65% of profits
>140k first year
>mfw finfag thinks he is great despite doing pleb tear bean counting finance that probably has little to nothing to do with the actual financial markets
>>
>>54675193
aka 0.1% of jobs
>>
>>54679685
tier*
>>
>>54670511
Why not
Console.Write("Enter a whole number...");
int userNumber = Convert.toInt32(Console.ReadLine());
int i = 0;
do {
if userNumber = i {
Console.WriteLine("Your number is even!");
System.Environment.Exit(1);
}
i += 2;
} while(i);
Console.WriteLine("Your number is odd!");
>>
>>54673909
It wouldn't even do that. i is defined within the loop.
>>
File: squidward.jpg (32 KB, 500x500) Image search: [Google]
squidward.jpg
32 KB, 500x500
>>54679730
>while(i);
>>
>>54670511
pls be bait
>>
>>54674576
stick to scripting languages, ok?
>>
>>54669488
>exit the calling function
Neat. I know you can always return an error value (or set one) then have the function return early based off of that, but (forgive me, I don't know how asm works), could you just pop twice off of the function call stack? could you do that with inline asm? sounds like fuckery to me
>>
>>54677556
no im using python 3.3
>>
>>54670705
That hurts readability. How can people who aren't math majors possibly understand this? It must be wrong.
>>
File: leftpad.jpg (38 KB, 1076x611) Image search: [Google]
leftpad.jpg
38 KB, 1076x611
>tfw you find out that leftpad module everyone hyped over basically demonstrate the CS meme
>then someone creates a PR to modify it
>>
>>54670299
What is the assignment?

I've written 10+ strcmp cases before when I was writing a simple file transfer program in c to learn networking.

For example, if a user sent the command 'ls' to me, it's not the same as sending 'LS' because my program is case sensitive. So it's easier to just have multiple ifs like so

if(!strcmp("ls", cmd))...
if(!strcmp("download", cmd))...
if(!strcmp("upload", cmd))...
if(!strcmp("md5", cmd))...
etc.

I don't see what the problem with that is. Yes I can loop over an array of strings and use the index into an array of function pointers, but what's the point? It's slower and harder to understand.
>>
>be me
>lab session
>guy to my left is lightning fast on vim with his arch rice
>another guys across the table is discussing topcoder problems.
>guy to my right is doing cool projects with VR
>mean while i barely pass my classes
give me some hope /g/
>>
>>54683790
Well the important thing is it was schoolwork and you're no longer doing this.

By the way
>programming
>networking
Does not add up when talking about schoolwork.
>>
>>54679696
>0.1%

You forgot a zero.
>>
>>54683901
Why dont you show an alternative you condensing faggot?

>Does not add up...
What? Network programming in c, what doesn't add up?
>>
>>54683956
You mentioned one yourself you dense fuckign faggot:
>Yes I can loop over an array of strings and use the index into an array of function pointers

Networking degrees do not include programming in any way.
>>
>>54677628
They are just slightly better at speed optimization(even then it depends on language) and absolutely beaten the fuck out by humans in size optimization.
>>
> be me
> trying to pick up a fuckboi in class
> I look at the screen of the guy next to me
> mfw he's changing his enrolment details on the server to be in libby's class
> mfw next day he brings an umbrella to class and makes the sprinklers go off automatically at 9:30
> mfw zero cool meme is real
can people be this elite senpai
>>
>>54670511
if num%2==0
>>
>>54683956
Why would I do that when there are only like 10 options? It's both slower and harder to read.

It was a software engineering course and we had a couple courses on unix network programming, what are you not understanding?
>>
>>54684115
Meant to be for
>>54683973
>>
>>54669123
So why are CS majors so awful at math

I swear, they're worse than civil engineers, here at UCB

How the fuck can someone even fail Calc 2. It's just basic integration techniques and series
>>
>>54669123
I took a computer programming class in high school and the program for even/odd was far shorter than that.
>>
>>54669123
Couldn't he just have checked if the number could be divided by two instead and make another line for 0?
>>
>>54684205
People in general are awful at math nowadays. In fact, one could argue most people always were awful at math, but the very little majority that had an interest in math/were good at it had a lot of opportunities for them, even before the modern era. You had a mathematician per 10000 people, but nowaday high education is accessible to nearly everyone in the western world, so of course, the fields that were once pure are bastardized.
>>
>>54684304
That's the joke son.
>>
File: _68933905_59339.jpg (12 KB, 304x171) Image search: [Google]
_68933905_59339.jpg
12 KB, 304x171
>>54670511
>Inlining the user input request and its conversion.

No! Bad! You are hurting readability.
>>
>>54684205
>How the fuck can someone even fail Calc 2. It's just basic integration techniques and series

There's no set standard for it.
The scope of it means you can produce stuff that you were solving in high school to stuff a math degree graduate could struggle with.

That, coupled with the fact they are taught the very same stuff math majors are, simply on a stricter "budget" means those who can't keep up with a faster pace are screwed.

Of course, you get into higher math after that and after such an experience, they are not even required to take the next one and voilá, you've produced another generation of calculus fearing/hating CS grads.
>>
>>54673091
Implying any actual real developer jobs are outsourced. It's always the bullshit tier business integration shit. Real work is never outsourced.
Thread replies: 206
Thread images: 12

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.