[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: 335
Thread images: 29

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

Umaru-chan edition, the best of all editions.

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

code of conduct:
no racism
no insult
no sexual harassment
no gender discrimination

wat r u working on, anon-chan ?
>>
>>53805279
What even happened to the last thread?

Did it just get buried under the April Fools shenanigans?
>>
File: CPP functional.png (22KB, 528x536px) Image search: [Google]
CPP functional.png
22KB, 528x536px
>>53805291
It got nuked
No idea why
>>
>>53805291
it was deleted, maybe because of shitposting, maybe to force people who hadn't refreshed the page to see the april fools cancer
>>
reminder that google is cheap as fuck and prioritizes quantity over quality, and they push material design as a cheap cargo cult copy of apple's design
>>
>>53805291
Last thread was not umaru aproved.
>>
>>53805372
>material design
I really want to like some parts of it, but overall it feels too kitschy.
>>
I wrote this for some anon's homework yesterday.

I'd like to know if there's any glaringly retarded things in here:

static void GetLinesOfInputAndReturnLetterCountsOfWords()
{
int lineCount;
var lines = new List<List<string>>();
var counts = new int[10];

WriteLine("How many lines of text are you going to write? (Max 10 lines)");

if (int.TryParse(ReadLine(), out lineCount) && lineCount <= 10)
{
WriteLine($"Input {lineCount} " + (lineCount > 1 ? "lines" : "line" ) + " of text now. Strike the return key after each line.");
foreach(var x in Enumerable.Range(1,lineCount))
{
lines.Add(Regex.Replace(ReadLine(), @"[^\w\s]", "").Split(' ').ToList());
}

foreach(var line in lines)
{
var tempLineCounts = line.Select(x => x.Count());
foreach(var word in tempLineCounts)
{
if(word <= 10) counts[word - 1] += 1;
}
}

WriteLine("--------------------");
WriteLine("Word length counts: ");
for(int i = 0; i < counts.Length; i++)
{
var x = counts[i];

if (x != 0) WriteLine($"{i + 1} " + (x > 1 ? "letters: " : "letter: ") + x);
}
}
else
{
WriteLine("Input invalid. Please try again.");
test();
}
}
>>
File: 1442620447676.jpg (41KB, 500x404px) Image search: [Google]
1442620447676.jpg
41KB, 500x404px
>Tfw my calculator is 4000+ lines and I haven't even started implementing vector math yet.
Should I just give up?
>>
Does anyone with experience in networking know how to check if a UDP datagram was sent by a client to a server in C? I can currently receive datagrams from clients with recvfrom (), but what I really want to do is check if a message was sent on the UDP socket, and if a message was not sent then I want my program to continue running instead of waiting. I tried using the MSG_PEEK flag as a way to check I'd there were any messages on the socket, but this isn't really working for me. I've done a lot of googling for the past 8 hours and I cannot find anything which can help me, and stackoverflow posts aren't helping me with the question I have.
Does anyone here know what I should try next?
>>
Oh jesus, gook moot has gone and done a thing.
>>
If any /dpt/ friends need to block the faggotry, try blocking this URL in Adblock Plus.

Not sure if there's a uBlock alternative:

https://s.4cdn.org/css/md2016.*.css
>>
>>53805479
4 KLOC is nothing for a serious project, especially if it has a GUI
>>
>>53805513
fuck yeah thanks based anon

it works in ublock
>>
>>53805479
refactor
>>
>>53805535
How did you get it to work in uBlock?
>>
>>53805479
Never give up, anon
>>
>>53805547
copy and paste

https://s.4cdn.org/css/md2016.*.css


into "my filters"
>>
>>53805627
Oh, I see.

Still breaks my AppChan X slightly.

Damn it.
>>
>>53805342
>main1
>main2
Yep, in the trash.
>>
>>53805342
The first time I read 'currying' I thought it was an insult to Indians.
>>
File: CPP functional 2.png (12KB, 454x286px) Image search: [Google]
CPP functional 2.png
12KB, 454x286px
>>53805674
>>
Anyone taking cs50 course on edx.com?
>>
>>53805627

For some reason, that does nothing for me.
>>
Xth for null coalescing operators are cute!

CUTE!
>>
>>53805724
same here
>>
>>53805731
>>53805724
Are you using http instead of https?
>>
>>53805725

Not cute, but useful.

>>53805731

I just fixed mine -- not using https, so remove the "s" and it works just fine.
>>
>>53805750
>>53805745
right, had to remove the s.
Still looks pretty fucked on appchan though.
>>
>>53805762
Appchan must be pretty shit. I'm using mayhems 4chanX and got it almost the same as before.
>>
>>53805750
>null coalescing operators
>Not cute

Look at this little slutty minx right here:

int? ayy = null;
int lmao;
lmao = ayy ?? 0;
>>
Hi /dpt/ I'm an aspiring systems programmer
Would it be generally good practice to put my comments in another script, such as Hebrew, Persian, or Russian? Because the code is already in English, so my logic is that only non-english speakers would really need the comments. Or am I totally off base here?
>>
File: fam.png (190KB, 1370x754px) Image search: [Google]
fam.png
190KB, 1370x754px
>>53805780
>how it looks like after filtering the css
>>
>>53805466
I think your version severely lacks LINQ memes
var counts = 
lines.SelectMany(line => line.Select(w => w.Length))
.Where(x => x <= 10)
.Aggregate(new int[10], (acc, val) => { acc[val - 1]++; return acc; });

Like this one.
>>
File: fam.png (130KB, 1370x754px) Image search: [Google]
fam.png
130KB, 1370x754px
>>53805780
>>53805794
>How it's supposed to look like
>>
What the fuck is this layout? You think this is a game, goot?
>>
>>53805279
Trying to work on my printerclass as my very first Java programming task after doing the Oracle tutorial on classes and I get the feeling I am chewing on more than I can handle for now.
FUCK!

any pointers?
Would be nice.

The (commented) abomination is here:
Printerdemo: http://pastebin.com/QtQtYRyj

Printerclass: http://pastebin.com/vr2QqQyN
>>
>>53805794
Do you have greasemonkey?

// ==UserScript==
// @name tomorrow
// @namespace wha
// @include https://boards.4chan.org/*
// @version 1
// @grant none
// ==/UserScript==

//https://s.4cdn.org/css/tomorrow.css

function addStyle(style) {
var head = document.getElementsByTagName("HEAD")[0];
var ele = head.appendChild(window.document.createElement( 'style' ));
ele.innerHTML = style;
return ele;
}

addStyle('@import "https://s.4cdn.org/css/tomorrow.css"');


Change the url to whatever garbage appchan uses.
>>
>>53805627
This worked for me but all the real themes are gone, I'm stuck on fucking Yatsuba. Help
>>
>>53805822
probably as good as you're going to get today without fiddling with the CSS yourself
>>
>>53805819
THANK YOU
>>
>>53805819
>Change the url to whatever garbage appchan uses.

I thought appchans's themes were built in
>>
File: 1455129061410.png (2MB, 707x1000px) Image search: [Google]
1455129061410.png
2MB, 707x1000px
Here's how to disable the theme using uBlock (which you should be using instead of ADB):
>right click on uBlock icon
>options
>my filters
>paste "s.4cdn.org/css/md2016$stylesheet,domain=4chan.org" without quotations
You're welcome.
>>
>>53805803
although fairly sure it won't optimize the lambda in Aggregate and will copy the accumulator array around N times, where N - number of words shorter than 10 letters.
>>
>>53805843
>uBlock (which you should be using instead of ADB)
this
>>
>>53805841
They exist somewhere. The url can also be within the local folder.

This is /dpt/ you should be able to do this yourself.
>>
>>53805861
well I tried it with tomorrow and it seemed to make no difference.
>>
>>53805843
>You're welcome
this
>>
>>53805803
>>53805850
Thanks.

Problem is, this is one of the few times where I don't think I'd want to LINQ it up, as your LINQ only replaces the one foreach statement.

In this case, I think it's much easier to read the non-LINQ:
foreach (var line in lines)
{
var tempLineCounts = line.Select(x => x.Count());
foreach (var word in tempLineCounts)
{
if (word <= 10) counts[word - 1] += 1;
}
}


vs

var counts = 
lines.SelectMany(line => line.Select(w => w.Length))
.Where(x => x <= 10)
.Aggregate(new int[10], (acc, val) => { acc[val - 1]++; return acc; });
>>
>>53805881
Nested loops will NEVER be more readable than nonnested code.
>>
>>53805868
I actually installed appchan and I don't see a problem.
>>
How often do you guys, outside of your job, write down a pseudocode of your algorithm and then implement it the language you are working in.

Today I have the attention span of a toddler, so I wrote down on a piece of paper what I want to do. I don't make programs on my own volition often, but it's the first time I did something like this.
>>
>>53806066
I have a dry erase board that I sketch out basic class design and interactions between GUI and logic.

It's usually simple stuff, but just enough to have a 10,000 foot view of what I'm about to do so I can see if it's retarded.
>>
>>53805850
wrong, it obviously just passes the reference to the array around
>>
>>53805818
What are you trying to do here and what are you having difficulty with?
>>
>>53806066
Literally never. Pseudocode is for plebs.
Sometimes I'll sketch out the logic for a program/algorithm in basic terms of the language before going back and redoing verbose portions in more detail, but if I was going to write pseudocode I'd just use Python instead.
>>
C++ question from a self-taught C n00b:

I have a class I've written that I want to be able to read into from a stream. The stream will be text, and the data for the object will be fairly simple. I can think of a fairly easy solution using scanf, but I want this to work with streams.

My current approach to simple parsing is to first store the position, then attempt to parse one or more desired values, e.g.
// semi-pseudo code
bool successfulRead = false;
String openV = "<";
String closeV = ">";
String sepV = ",";

float fVal;
int iVal;

while( readWS() ); // readWS() returns true and advances the position when it reads a whitespace character

if( !readMatch(openV) ) // readMatch(openV) returns true if opening string was found
return FAILURE;

while( readWS() ); // discard possible whitespace before first value

if( readFloat(fVal) || readInt(iVal) )
successfulRead = true;
else
return FAILURE;

if( !readMatch(sepV) ) // read for separator for other (optional) members
.
.
.
(etc)


The idea being that I can easily deal with optional items because the read functions would advance the stream pointer if they succeeded, or leave it untouched if they failed. I am not sure how to fit that with C++ streams that will work with any stream.

I am more than willing to admit that I know little about parsing, but the task is really simple and I'd rather keep the hassle to a minimum (preferred no libraries or std library, but willing to do what it takes).

Background data:
I am reading vectors (math) from a text file. The vectors can have anywhere from 1 to 4 elements, and the opening, closing, and separator characters may vary, and white-space is ignored. Examples:
<1,2,3> // valid
< 1 , 2 , 3 > // identical to above
[[1, 2, 3]]
[(1, 2, 3, 4 )]
(etc)


The open/close/sep/WS strings are consistent within the file, and known beforehand. For the super-curious, this is for POV-ray Mesh2 objects.
>>
>>53806066
>>53806121
Is it bad practice to just throw code at the wall until it works?
>>
>>53806140
I prefer to type my code into an IDE until it works.
>>
>>53806140
Depends on your school of thought. There are entire disciplines of programming that believe that you shouldn't write a single line of code until you have every aspect of the entire program planned out in minute detail. There are other disciplines that say you should start with a vague idea of what you're doing and just code until it works.
>>
>>53806147
HE DID IT AGAIN

CAPTAIN LITERAL DID IT AGAIN

EVERYBODY WATCH YOUR PROSE, HE'S OUT FOR BLOOD
>>
>>53806147
>IDE
Found the winfag! REAL programmers use GNU Emacs.
>>
>>53806163
I'm not a captain.

I've never served, nor do I own a ship.
>>
>>53806133
std::istream& stream
>>
File: 1234567890.jpg (26KB, 640x480px) Image search: [Google]
1234567890.jpg
26KB, 640x480px
>>53806171
You're one cheeky cunt you know that.
>>
>>53806140
That's more or less what I wanted to ask. Maybe not write the whole pseudocode, but an outline as someone above said.
>>
>>53806190
I prefer to figure it out as I'm going along. I find it easier when treating it like a sculpture, ie you start with an ill defined blob of nothing and gradually carve out the intricate details until you have code that works. Problem is I am really shit at optimization so my code usually ends up being an enormous pile of if statements, but it works which I suppose is the main thing.
>>
>>53806184
I love you anon.

Here, have a ternary operator assignment:
string freeBeer = DateTime.Now.DayOfWeek == DayOfWeek.Friday ? "Free beer!" : "No beer today :(";
>>
>>53806213
Do you work as a programmer? How do they do things in your company?
>>
>>53806237
Thank you. I will be sure to drink it before midnight.
>>
>>53806237
What kind of a business model that is to give out free beer on Friday of all days? Sounds retarded
>>
>>53806246
I would think my lack of structure would make it fairly evident that I don't code professionally. Not yet anyway.
>>
>>53806257
I work at a small IT company.

We get free beer on Fridays. It's pretty nice.

Incidentally, we call them No-Change Fridays as well, as we only maintain, and try not to fuck anything up with changes.
>>
I'm trying to make an little program to calculate the mean deviation of values in a array. I got stuck in the variance as it return values near what they are suposed to be but not exact. FOr Example variance=4,33 it gives =4.7. Can you take a look and try to help me? Needless to day I'm new to coding.


#include <stdio.h>
#include <math.h>
int avr(int a[],int siz){
int i;
int sum = 0;
float mean;
float vari=0; /*variance*/

for(i=0;i<siz;++i){ /*calculates the mean value*/
sum= sum +a[i];
printf("%d\n", sum);
}
mean=sum/siz;

for(i=0;i<siz;++i){ /* calculates (given values)-(mean), squares that result and stores them in a array*/
double dif[siz];
dif[i]= pow(a[i]-mean,2);

for(i=0;i<siz;++i){ /* adds the squared values and assign variance to be them/siz */
double temp=temp+dif[i];
vari=temp/siz;
}
}

printf("The mean distance (variance) of the given values to %0.2f is %f\n", mean, vari);


}

>>
>>53806173
Yes, thank you dear.

But, the problem is that the tell and seek function do not work with all streams, especially with cin or cout. I was hoping for guidance with examples when it comes to parsing stream input. Insight involving strings and streams, possibly including string-streams or the like would be appreciated, but my main problem is how to do things in the "proper C++ way" when it comes to using C functions like scanf and strtok.
>>
>>53806091
I thought all the states and behaviour of a printer belongs in a class, but right now I am "programming" a clusterfuck of behaviours in the main class and made even a mainmenu in it.

But I am disgressing:
I am trying to make the printing steps work and make program go back to the mainmenu.
Either after the user doesn't want anymore, or the maintenance counter I placed in class reached 15 and informs the user of the problem, leading him back to the main menu.

Also Shouldn't the mainmenu be in the printer class and shouldn't the mainfile just create the objects and make it run?

Sorry again, this is my first time after a veeeeeeeery looong time of dabbling.
>>
>>53806140
honestly depends on your goal and time frame, but most of the time I feel I waste less time if I spend a little time planning the structure of what I'm going to write
>>
>>53806397
For the most part, classes shouldn't ever have user interaction like with menus and input. They should simply have functionality.

The setup you have now is fine.

You'll need a while loop around the main logic of your program to do that.
>>
>>53806213
Premature optimization is bad anyway. What you should do is learn some design patterns and techniques for abstraction.

I start a project by just banging out code, and if I start noticing any code smells like repeated code or nested ifs, I'll refactor before I get too far. If you get quick at refactoring, just banging it out isn't a terrible way to start.
>>
>>53806394
if you can't seek then just extract chars or use read
>>
what math library except math.h can i use in C without compiling with -lm?
>>
What is the future of Java? Microsoft shills at my uni keep saying that C# is the best, etc. What is /g/ opinion?
>>
>>53806574
Java is fine.

C# is more comfy to write in, and has a great outlook considering the //build/ conference going on.
>>
>>53806574
There seems to be a significant number of java/scala spring jobs out there.
>>
https://www.kickstarter.com/projects/520965826/basil-the-comprehensive-programming-language thoughts?
>>
>>53806654
fuck off Caolan
>>
>>53806654
>5k euros
>irish faggot who looks 12
>>
>>53806654
>>53806682
>>53806685
holy shit, read his twitter
>>
>>53806654
There's not enough to see. And from what I've seen it probably doesn't do much better than python or Processing at introducing people to programming.
>>
>>53806654
It's an April Fools Joke right?
>>
so a few months ago i was looking for websites which have programming challenges so i could work in python some more. i forgot what the site was, but one of the challenges was cellular automata, and now that's one of my assignments for class but i forget the website to get the code off of that i submitted. all i can really remember is that the code editor was blue-themed with editor on the left, the challenge on the right, and on the bottom left there was the test cases/console. i could ask for hints on each of the problems and the editor was also able to process test cases with one button. does anyone know what site this is?
>>
>>53806654
Not convinced at all. If one want to program, he need to have a good grasp of logic and abstraction. For that you already have top notch materials like sicp htdp or csforall. There already pl suited for total beginners: scheme, scratch (code.org). The code example is shit.
>>
File: haskell-fb-industry.png (1MB, 1128x1080px) Image search: [Google]
haskell-fb-industry.png
1MB, 1128x1080px
>>53806554

come join us in /fpg/ - functional programming general
>>
>>53806815
lame
>>
>>53806321
pls /dpt/
>>
How do you target fragment positions with GLSL?
>>
>>53806321
Fix that dumbass bracket style.

Google "double imprecision".

Doubles are not precise, and doing math with them leads to odd results if you're not careful.

You're dividing by an integer, 'siz', which I believe is going to do integer division, but I'm not a C++ programmer, so I'm not certain.
>>
File: 1459187089725.png (44KB, 240x240px) Image search: [Google]
1459187089725.png
44KB, 240x240px
>>53806237
>>53806321
>>53806394
Don't even know why I come to /g/

You guys make me feel stupid.
>>
i just did this
(instance.*(condition ? class::func : class::otherfunc))(param)
>>
>>53807010
Why?
>>
>>53806901
What do you mean by dumbass brackets? And it's C. Thanks
>>53806968
What do you mean? I'm started learning C a week ago and never had any pratice and decided this was a good exercise.
>>
>>53806901
doubles have pretty good precision, the result probably won't be exact but he's doing something wrong if he's getting 4.7 instead of 4.33
>>
>>53807042
i had something like this

if (condition)
instance.func(param);
else
instance.otherfunc(param);
>>
I need books/resources/tutorials anything related to fundamental Java understanding. Not practical examples, just theory.
I asked this exact same question in the previous thread but someone decided to show me why Java can't be fundametally understood. So I ask again.
>>
>>53807010
whoops, *
&class::func
&class:otherfunc
>>
Anyone here has experience with Free Pascal LCL?
>>
>>53807096
https://docs.oracle.com/javase/specs/
>>
>>53807139
no
>>
>>53806890
gl_FragCoord is available in fragment shaders. X and Y are window coordinates (Y is upside-down), Z is the depth unless you change it.
>>
There is literally nothing wrong with putting ads and micro transactions in all your programs
>>
>>53807175
We know
>>
>>53806321
double temp=temp+dif[i];

You are using temp uninitialized. you would know that if you turned on warnings. Honestly, I'm surprise it even compiled.
>>
>>53805792
If they make programs, they should know Engrish.
>>
>>53805792
Use Hindi, the official language of programmers.
>>
>>53805792

Comments are there to explain parts of the program which may be unintuitive, as well as to document the role of various functions, types, etc... They should be in English, just as the variable names and function names should be in English.

You may think this would make it difficult for non-English speakers. But consider that there are a myriad of other languages you could use, for this purpose, and choosing any one of them would still be difficult for people who don't speak that language. English is more or less a standard for software development -- at least within the open source community -- and those who don't speak it can more or less get lost.
>>
>>53807324
>not Gujarati
>>
>>53807324
True all the best programmers are of Hindi descent
>>
I don't understand
Haskell is the best programming language but Indians are the best programmers, crossdressing improves programming skill but females are better coders. How come most Haskell programmers are white cis males?
>>
>>53805484
Look into async IO, select/poll, possibly multithreading
>>
>>53807513
Here put on this dress
>>
they should make git easier to use
>>
>>53807599
easier to write codes of conduct?
>>
>>53807513
The thing here is that MOST programmers are white cis males, while the best ones are indian female crossdressers. Quite the newbie mistake you made there, but don't worry.
>>53807533
>>
>>53807599
I don't understand how to use it either. I wish someone would help me to show me how to upload all my projects and code to put on it
>>
>>53807599
>>53807619
>i lack the physical capacity of googling for a git tutorial
There, https://git-scm.com/docs/gittutorial
>>
>>53807599
Just read through the tutorial to get the basics. Whenever you come across an issue you don't know how to fix Stack Overflow that bitch.
>>
File: 1443878595513s.jpg (5KB, 125x125px) Image search: [Google]
1443878595513s.jpg
5KB, 125x125px
>>53807599
At least it's better than svn, but I agree that the CL interface is cumbersome and error-prone if you're doing simple basic commits. I use Magit (https://magit.vc/), it's really nice and quick and powerful.

Speaking of CL, although Common Lisp itself is a disgusting mess, it's still better than most "general purpose" domain-specific languages we see those days.

Ask your beloved programming literate anything!
>>
>>53807646
Thanks bro! I love you guys at /dpt/ you guys are so helpful

plus one upvote
>>
>>53807683
Why didn't you use a .webm?
Are you sure you're illiterate?
>>
>>53807683
>general purpose domain-specific
>>
>>53807740
It's voluntary you dumb curry
>>
>>53807740
t. relative of inventor of Haskell
>>
>>53807740
>Curry
>doesn't understand the simple idea of a general purpose domain-specific language
no surprise here
>>
>actually hating this theme
i unironically like it :^)
>>
>>53807683
he 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.

Unlike most languages today, which are focused on defining specialized data types, Lisp provides a few data types which are general. Instead of defining specific types, you build structures from these types. Thus, rather than offering a way to define a list-of-this type and a list-of-that type, Lisp has one type of lists which can hold any sort of data.

Where other languages allow you to define a function to search a list-of-this, and sometimes a way to define a generic list-search function that you can instantiate for list-of-this, Lisp makes it easy to write a function that will search any list — and provides a range of such functions.

In addition, functions and expressions in Lisp are represented as data in a way that makes it easy to operate on them.

When you start a Lisp system, it enters a read-eval-print loop. Most other languages have nothing comparable to `read', nothing comparable to `eval', and nothing comparable to `print'. What gaping deficiencies!

Lisp is no harder to understand than other languages. So if you have never learned to program, and you want to start, start with Lisp. If you learn to edit with Emacs, you can learn Lisp by writing editing commands for Emacs. You can use the Introduction to Programming in Emacs Lisp to learn with: it is free as in freedom, and you can order printed copies from the FSF.

You can learn Scheme (and a lot of deep ideas about programming) from Structure and Interpretation of Computer Programs by Abelson and Sussman. That book is now free/libre although the printed copies do not say so.

Please don't buy books (or anything) from Amazon!
>>
>>53805803
More like it severely lacks Array.fold and |>
>>
Just wanna hop into programming and learn, maybe make some dinky stupid little programs. SHould I start with Python, Java, or C++/C#? I just went through that programming language site and they made it seem like for any kind of remotely successful job you need to know C++.
>>
>>53807851
>most powerful
>Lisp
kekk
>>
>>53807863
Not Python
Not Java
>>
>>53807851
Java is the most superior and you are all plebs if you disagree of Java and all of it's cross dressing glory
>>
>>53807863
Start with C++ and ignore the memesters who tell you otherwise.

Java will make you hate programming, python is for webfags, and you won't be able to understand why C# is good until you know a lot of C++.
>>
>>53807863
java, C++, or java first and then C++

https://docs.oracle.com/javase/tutorial/
>>
>>53807914
Are you retarded?
>>
>>53807863
Learn Java, it's one of the fastest, most used and comfy languages out there.
>>
>>53807929
epic meme smug hipster fag
>>
>>53807914
>>53807930
Samefag
>>
>>53807863
>>53807896
second for c++. It's a clusterfuck of features but very rewarding to learn.
>>
>>53807947
who is >>53807943 then

delusional fag

java and C++ are literally the best programming languages, and best for learning programming
>>
>>53807960
>java
you fell for the meme
>>
>>53807930
There no reason to use it over C# these days
>>
Is this tail recursive?
    def backtrack(self):

moves = []
# make a deep copy to stop any referencing isues.
node = copy.deepcopy(self)

if node.isRootNode():
# The initial state is the final state
return moves


p = self.parent
return moves + [self.transition] + p.backtrack()
>>
>>53807960
Java
1 Is not a good programming language
2 Is not a good language for learning
2 Has some of the worst design decisions
>>
kill yourself retarded memers

java is better than fucking python at the very fucking least
>>
>>53807984
no
>>
no matter what your opinion is about java, you're retarded if you don't think C# is worse than java.

C# is literally a cargo-cult clone of java with massive feature-creep due to a load of dunning-kruger pythonesque "features" tacked onto it that you aren't even supposed to uses

>many of the drawbacks of java
>many of the drawbacks of C++
>few of the benefits of java
>few of the benefits of C++

java is good for its simplicity and ability to scale to large applications. if you don't need simplicity you may as well use C++ instead. the "low level features" in C# still give you shit performance.
>>
>>53807990
Agreed. But there's no reason to use Java over C#.
>>
How to modulo in glsl?
>>
>>53807990
Sure, congratulations on your paralympics win
>>
>>53808007
mod(a, b)
>>
>>53808007
mod(x,y)

>>53808003
get suicided
>>
>>53808021
butthurt Cshart CRUDmonkey weenie detected
>>
>>53807947
really?

>>53807977
There are multiple reasons
>frameworks (see my screenshot above, c# doesn't even come close)
>libraries
>cross platformness (mono fucking sucks and is slow btw)
>speed (jvm is faster than clr)
>reliability
C# is a Java clone anyway
>>
>>53808006
Isn't Meme# mainly used only for Windows apps?
>>
>anything but C
>good
>>
>>53805803
Using Count() on a string is the dumbest shit. Also, it crashes when you start or end a line with whitespace.
>>
>>53808006
The best reason to use Java over C++ is all the jobs these days are all in Java and if you want a better chance of making good money you should learn Java
>>
>>53808042
>i'm too stupid to understand anything but fizzbuzz-tier C
>>
Reminder that ANY company that wants high performance will not let you use Java

Reminder that ANY company that wants security will not let you use Java

Reminder that ANY company that wants good code will not let you use Java

Reminder that ANY company that wants quicker development will not let you use Java
>>
in C you use structs and functions which operate on structs. languages with OOP are basically the same thing but with much cleaner syntax
>>
>>53808034
There are only three operating system that are used by non-autistic people: Windows, ios, android. c# works great on all of these.
>>
>>53808075
>java is too hard for me to learn :'(
>>
>>53807863
Ignore language recommendations. It doesn't really matter what you start with. Any of the big ones (for which there is plenty of learning material) will do. Essentially you want to learn to program, to think about problems in a certain way and come up with solutions for them, rather than learn the syntax of some language. That is the skill that gets you hired.
>>
>>53808083
>ios
>non-autistic
>>
>>53808083
java works great on all of them
>>
>>53808094
iPhone iPod iPad
>>
>>53808092
>>53807863
it DOES matter. at the very least it should be a statically typed language. this means NOT python. python is SHIT
>>
File: Dm5F4ko.webm (229KB, 720x404px) Image search: [Google]
Dm5F4ko.webm
229KB, 720x404px
>>53808101
>>
>>53808094
gay and autism are two different diseases

btw google captchas with disappearing pictures is the worst meme of the century
>>
>>53808075
Java is very popular for a good reason.

Even NASA uses Java
>>
>>53808112
Better than an android device.
>>
>>53808034
What? No. Not remotely.
C# with ASP.NET is one of the larger web frameworks around.
There's also GTK# which can be used to make Linux apps, and Mono which works on Android as well as Linux.
And then there's that one operating system that's being written in managed C#.
>>
>>53805279

what's better: matlab or any of the alternatives mentioned on wikipedia? (GNU Octave, Scilab, FreeMat, Julia, or Sage)


I'm going to do some tests on algorithms for controlling stepper motors
>>
>>53808031
>Frameworks/libraries
true, depending on what you want to do. I've never come across anything i wanted a Java lib for in .NET. It's math and database stuff Java has the edge on right? I do a lot of UI on desktop and mobile. .NET is hard to match for that.

>mono fucking sucks and is slow btw
True. There's also coreclr now.

>speed
depends what you're doing. CLR supports pointers, SIMD and easy native code interaction. There's a lot of ways to make up the raw performance gap.

>reliability
hmm?

Generally I find the advantages of C# far outweigh those downsides. It's nice that coreclr and mono are both MIT licenced. Xamarin is awesome. Working generics is nice. Properties. SIMD. Structs. Good native interop. ASP.NET. MonoGame. Unity. Async functions.

Just as a raw language though, it's hard to say Java is better than C#. C# is basically a clone of Java that fixed all the problems in Java and added a few other nice things.
>>
>>53808075
Then why are all the jobs and most corporations all use Java? Checkmate this Java is not good meme it seriously needs to stop
>>
>>53808090
samefag
>>
>>53808138
They don't.
>>
>>53808138
>Then why are all the jobs and most corporations all use Java?
You need to practice your english more Prajeet.
>>
>>53808127
For me personally Sage was enough (I was doing some basic shit with graphs and calculus)
But it seems that most of more math-heavy oriented people shit on all oss math software and prefer matlab
>>
>>53808107
How does static typing help you learn programming better? It doesn't. Fuck off with your autist advice.
>>
>>53808128
>depends what you're doing. CLR supports pointers, SIMD and easy native code interaction. There's a lot of ways to make up the raw performance gap.
it's still fucking slow even with these things (which require a lot more effort for no gain). use C++ if you want performance.
>>
>>53808178
easier to go from static to dynamic than vice versa
>>
>>53807683
>>53807740
>>53807851
>>53807866
Only Lisps are truly general purpose because only Lisps have macros. If your language doesn't have macros, it's not programming at all, just code monkeying.
>>
>>53808178
KILL YOURSELF FUCKING RETARDED SHITTER
>>
>>53808180
>it's still fucking slow even with these things
It's not though. Even structs alone make a huge performance difference. And they are not difficult to use by any means.

>use C++ if you want performance.
C++ is more difficult to work with and less productive compared to C#.
>>
>>53808208
>only Lisps have macros
nice bait
>>
>>53808178
it intercepts a subset of your inevitable mistakes earlier in the testing process, depending on a compiler - with a sane error message that'll help you fix them.
>>
>>53808221
yeah you're gonna do SIMD as if it's easier to work with and more productive compared to C++ and as if it even makes your C#shit as fast LMFAO KILL YOURSELF IDIOT
>>
>>53808231
>subset
shitty programmer detected
>>
>>53808128
Well maybe C# isn't unreliable but Windows Server is. Basically the entire server stack at our company crashed because of Windows update at work and the company lost some clients because of it. I guess you could say Linux is also unreliable in some other areas but meh.
>>
>>53808258
we're talking about a beginner who has never programmed before of course he's going to be a shitty programmer at least in the beginning fucking idiot
>>
>>53808156
I am a white man but my english sucks this is true you caught me
>>
>>53808238
Calm down dude, even I am a Java dev and you're acting unreasonable.
>>
>>53808262
>Basically the entire server stack at our company crashed because of Windows update at work and the company lost some clients because of it.
ahahahahahahaha Csharts BTFO
>>
>>53808262
lol, that's why people test updates before installing them on production machines
>>
>>53808307
Windows is still superior to Linux and Apple please
>>
>>53808315
it's not Windows it's GNU/Windows
>>
>>53808262
>I guess you could say Linux is also unreliable in some other areas but meh.
well yeah.. i can. Specifically in installing updates like that.
>>
Hi guys my name Pajeet and I wondering why you guys call other my name?
>>
>>53808315
not for servers
>>
>>53808386
nice try Bill
>>
>>53808357
Windows server updates automatically, no distro would do that.
>>
>>53808396
True you got me all my networking courses and Linux courses for servers we all used Linux GG no rematch Still SUPERIOR Java and Windows master race
>>
>>53808199
No evidence to support that. Many CS courses start out with languages like Python and they don't produce handicapped graduates. If there is any difference, it is insignificant.

These are the ramblings of a bunch of pedantic NEETs.
>>
>>53808386
>Pajeet
>Bill

you dun goofd
>>
>>53808418
>Many CS courses start out with languages like Python and they don't produce handicapped graduates
cedric...
>>
>>53808403
>what is wsus
>>
>>53805466
No need to thank me.
let rec calculateShit () =
printfn "How many lines of text are you going to write?"

match Console.ReadLine () |> Int32.TryParse with
| false, _ -> printfn "Input invalid. Please try again."; calculateShit ()
| true, lineCount ->
printfn "Input %d %s of text now. Strike the return key after each line." lineCount (if lineCount = 1 then "line" else "lines")

let processedInput =
[1 .. lineCount]
|> List.map (fun _ -> Console.ReadLine ())
|> String.concat " "
|> fun str -> Regex.Replace (str, """[^\w\s]""", " ")

printfn "-------------------"
printfn "Word length counts:"

processedInput.Split ([|" "|], StringSplitOptions.RemoveEmptyEntries)
|> Array.groupBy (fun w -> w.Length)
|> Array.sortBy fst
|> Array.iter (fun (len, words) -> printfn "%d %s: %d" len (if len = 1 then "letter" else "letters") words.Length)
>>
>>53808557
I think that fucks up if lineCount is 1
>>
>>53808557
>List.
>String.
>Array.
The compiler knows what type these are. Why do you have to specify it over and over again?
>>
>>53808636
based on ocaml
>>
>>53808636
You're not specifying the type, your choosing which module to use a function from. He could ask use Seq. in most of those instances, but that would do something different.
>>
>>53808624
Why would it? (No, it does not)

>>53808636
Those are modules, not types.
>>
File: 1459461823017.jpg (515KB, 1000x1414px) Image search: [Google]
1459461823017.jpg
515KB, 1000x1414px
Working on my file server with torrent support.
I'm currently fixing minor bugs and refactoring some code. Next up is adding torrent support.
>>
>>53808673
>Why would it?
I recall doing that before and it would return an empty list if you have [1 .. 1]. Maybe i'm mistaken.
>>
File: 2016-04-01_18-22-36.png (5KB, 334x215px) Image search: [Google]
2016-04-01_18-22-36.png
5KB, 334x215px
>>53808689
>>
>>53808719
I see. Not sure what happened to me before then... neat
>>
>>53805279
>no racism
nigger
>>
>>53808823
saying nigger isn't racist
>>
>>53805513
based
>>
>>53808636
MLs don't have type classes. Hopefully modular implicits will come soon to OCaml so we can leave all these out
>>
>>53808403
>Windows server updates automatically
You can pick and choose exactly which patches are applied, when they apply, and you can also test these patches on non-production systems first.

If your shit crashed due to Windows patching, the most likely culprit is the applications that the server is being used for, not the interaction with the OS itself.
>>
>>53808922
In F# at least Seq.map and List.map will do different things. So doubt F# will be dropping this stuff soon.
>>
>>53809026
The way that modular implicits work would not stop that from being a possibility, so it's possible that F# could adopt that system, but there are two things currently stopping that:
1) Some functions are overloaded in weird ways that aren't available to user-defined functions (like +, -, *, /)
2) F# doesn't have an ML module system still, and you can't do modular implicits without module types/signatures
For F#, I think Haskell-style typeclasses would actually be a more likely solution in the long-run
>>
>>53809089
A lot of the stuff F# doesn't have is done to make it work better with .NET and C# code based, and be familiar to C# programmers. I wouldn't expect them to make any breaking changes like changing the module system going forward.
>>
Polling Ruby
>>
File: 005.jpg (582KB, 1870x1280px) Image search: [Google]
005.jpg
582KB, 1870x1280px
Anons, I'm new to programming but really good at math. Basically, autism personified, on meds for ADHD, some other crap. Point being, I have 30 days to get a new job or end up in the homeless shelter.

A friend of mine recommended I hire an Indian to make some android apps for me, and sell the apps on the Android market.

Realistically speaking, could I dish out lets say 10 shitty apps like a season count down, a clock, a music player, etc. within 30 days, and learn all the basics of Java programming to do this, within 30 days as well? 30 days guys. I downloaded the gentoomen library but some of the Java books are outdated and need IDE's like galileo, there are also dependency issues with the android downloads and java SDK, basically its very hard to follow or get the older versions working like the book wants me to.

So any help? Point in the right direction? Steam friend sent me a PDF of Java A Beginners Guide, 6th edition. Just start there?
>>
>>53809146
good luck
>>
>>53805513
Holy shit Thank you so much you pretty much saved me from leaving 4chan for a few days until it died down.

>Tfw web dev fags have finally become useful
>>
>>53809146
>Just start there?
sounds as good a place as any
>>
>>53809146
>Realistically speaking, could I dish out lets say 10 shitty apps like a season count down, a clock, a music player, etc. within 30 days, and learn all the basics of Java programming to do this, within 30 days as well?
Nope.
>>
Is this a fucking google productforum
>>
>>53809214
>moot joins google
>4chan got material cancer
>>
Hey guys I am really good at programming logic but I suck at math. I understand what I need to put together but I can't figure out the math to do it.

What it do?
>>
>>53809214
There is plenty of software/hardware discussion of Google, Apple, Microsoft, and Linux, or as I've taken to calling it, Windows+Linux.

Why are you asking this in /dpt/ of all places?
>>
>>53809146
You should spend these 30 days saving/packing stuff, learning about how to apply for whatever monetary help your government provides, visiting homeless shelters to see what you're gonna be dealing with - when to get there/what to have on you - stuff like that; looking for unskilled jobs, places with the cheapest rent, roommates. Learning a skill in a very competitive market + getting a job in 30 days is impossible
>>
>>53809146
>could I dish out lets say 10 shitty apps
No. You might be able to put one app together with heavy copy paste form Stackoverflow but it's going to take you at least a couple of months to understand what you're doing at all.
>>
>>53809146
Don't use old ass books, use internet tutorials if you want to get shit done
>>
File: DS14wallpaper.jpg (138KB, 1920x1080px) Image search: [Google]
DS14wallpaper.jpg
138KB, 1920x1080px
>tfw spill coffee on my copy of the D Programming LanguageTM
>>
Does anyone have that image with the 100 programming projects that gets posted sometimes? I can't find it.
>>
>>53809312
>andnothingofvaluewaslost.wav
>>
>>53809315
just google "dpt roll"
>>
>>53809315
http://better-dpt-roll.github.io/

It shits up the thread when it gets posted.
>>
>>53809315
https://better-dpt-roll.github.io/
>>53809322
I have soiled Andrei's holy writings
I must seek forgiveness
>>
Is GTP here? Do we need a seyonce?
>>
>>53809333
>>53809341
>>53809343
Thanks anons.
>>
>>53809353
Séance

Do you need C# help or what?
>>
>>53809370
french faggot go blow black women
>>
Why do C devs insist on writing ugly hacky looking code?
>>
>>53809353
Post a bunch of black women
Make sure to include things in your post such as "racemixing cuck" and "OOP sucks"
>>
>>53809378
I'm not french.

I'm not OneSlowCuck either. I don't understand how anyone could be attracted to black women in general.
>>
>>53809382
It's not that C devs insist on that, it's the nature of C that makes any code beyond FizzBuzz to look like that.
>>
File: intel.jpg (9KB, 246x227px) Image search: [Google]
intel.jpg
9KB, 246x227px
>D forums are down
>>
>>53809382
>implying hacky is ugly

int exp(int b, unsigned e) {
int acc = 1;
while(e > 0) {
if(e & 1) {
acc *= b;
}
b *= b;
e >>= 1;
}
return acc;
}
>>
>>53809238
Could you give me an example where you feel the math was too hard.
>>
Suppose I have a numpy array with a shitton of rows like
A = numpy.array([[1, 2, 3],
[1, 2, 3],
...
[1, 2, 3]])


I want to have a function which returns a vector of boolean arrays of the size of the rows by evaluating each row element like:
def g(A):
return A[:, 0] + 5 * A[:, 1] - 2 * A[:, 1] > 0.0


This obviously works, however sometimes the input array A only has one column and then I get the exception
IndexError: too many indices for array


Is there any way to access either an entire array's row elements or only one element in a 1xcolumn array? Or do I have to result to if statements and end up in one of those meme pics?
>>
>>53809477
you forgot your goto
>>
class Database
{
public:
void updateFiles(const std::vector<int> &fileIds); // this
void updateFiles(const std::vector<int> &ids); // or this
}
>>
>>53809655
latter
>>
My Fibonacci number sequence


public class Testing {

public static void main(String[] args) {

int fib1 = 1;
int fib2 = 1;

int temp1 = 0;
int temp2 = 0;

System.out.println(fib1);
System.out.println(fib2);


for(int i =3;i< 13;i++)
{

temp1 = fib1 + fib2;
temp2 = fib2;
System.out.println(temp1);

fib1 = temp2;
fib2 = temp1;
}

}

}


>>
>>53809721
I mean.. the former.. lel
>>
>>53809723
unsigned long long int fib(unsigned long long int a, unsigned long long int b, int n)
{
if(!n)
{
return a;
}

return fib(b, a + b, n - 1);
}


Here's mine
>>
>>53809723
As you guys noticed I am using Java so I love to and naturally think in long verbose code solutions
>>
File: K&R watashi kininarimasu.jpg (475KB, 852x973px) Image search: [Google]
K&R watashi kininarimasu.jpg
475KB, 852x973px
>>53809382
C is a small language, it looks nice when you use small variable and function names.
Why do you think all the stdlib function names are truncated like atoi, strcat, fread, etc.
>>
>>53809782
>Why do you think all the stdlib function names are truncated like atoi, strcat, fread, etc.
It's actually because identifiers used to be limited to 6 characters.
>>
>>53809782
>Why do you think all the stdlib function names are truncated like atoi, strcat, fread, etc.

Because they were written in 1972 on 80-column terminals.
>>
>>53809831
you should still respect the 80 columns rules for people like me who program on a single monitor.
>>
>he doesn't program on a VM with 1K memory and no GUI
>>
>>53809933
What shitty monitor are you using that can only display 80 characters horizontally?

Even my vertical monitor has enough room for ~140 horizontally, and that's only 1080 pixels from left to right.
>>
>>53809969
>He doesn't program on an Apple ][
>>
>>53809933
I tried doing that, but it's really fucking hard without sacrificing readablity or one-time use structs just so I can reduce the amount of function arguments
>>
>>53810010
>just so I can reduce the amount of function arguments
You're retarded.
>>
>>53810005
>He doesn't program on his Apple mac in a Flannel shirt in Starbucks
>>
>>53810026
yeah you're right, I should just take a bunch of void pointers and then recast them within the function to stay within 80 character limits

upgrade your fucking computer
>>
>>53809933

100 is pretty reasonable nowadays. 80 is absurd. Are you using an 800x600 monitor?
>>
>>53810026
>>53810050
You should both use Java

Also
>Schwartz

*Rubs hands*
>>
>>53810050
You're missing the point entirely. You can have an arbitrary number of arguments and still not go over 80 characters.

If your function signatures are significantly over 80 characters anyway, you should already probably be doing line breaks to improve readability.
>>
>>53810085
How does one do that anon?
I hate the way GNU coding style looks.
>>
>>53809999
>>53809999
>>53810010
>>53809999
>Even my vertical monitor has enough room for ~140 horizontally, and that's only 1080 pixels from left to right.
yes but its comfy when you want to display multiple files at the same time (pic)
>>
>>53809933
My rule of thumb is half the width of a 1080p monitor with a tab width of 2.
>>
>>53810116
>80 characters
What if I want to display three files at the same time?
>>
>>53809933
>>53810053
I think aiming to be around 80 characters, but letting yourself go over where the alternative is less readable is the sane approach.

>Are you using an 800x600 monitor?
While I obviously don't represent everyone, I use a fairly large font in my text editor because I find it easier on my eyes in comparison to staring at small text for hours on end. I also often have my editor split in to two vertical panes. A quick test indicates the one pane like this has 86 columns with my font size.
>>
>>53810131
tehee
>>
>>53810116
I have line wrap enabled.
There's no reason why you shouldn't be using like wrap.
>>
>>53810159
>files this small
end this meme
>>
>>53810109
Insert line breaks when you get too far in.

Honestly, having to read through a long function signature that isn't broken in to multiple lines is really fucking annoying.
>>
>>53809933
damn i just checked and i can fit 240 chars on a line when my screen is split in half
80 chars is literally 1/6 of my screen and it looks retardedly small
>>
File: umarusfs.jpg (115KB, 1280x720px) Image search: [Google]
umarusfs.jpg
115KB, 1280x720px
>>53810163
all editors don't have line wrap

from Linux kernel coding style (i use that style on emacs)

"""
Coding style is all about readability and maintainability using commonly
available tools.

The limit on the length of lines is 80 columns and this is a strongly
preferred limit.

Statements longer than 80 columns will be broken into sensible chunks, unless
exceeding 80 columns significantly increases readability and does not hide
information. Descendants are always substantially shorter than the parent and
are placed substantially to the right. The same applies to function headers
with a long argument list. However, never break user-visible strings such as
printk messages, because that breaks the ability to grep for them.


[...]

Now, some people will claim that having 8-character indentations makes
the code move too far to the right, and makes it hard to read on a
80-character terminal screen. The answer to that is that if you need
more than 3 levels of indentation, you're screwed anyway, and should fix
your program.

[...]

Functions should be short and sweet, and do just one thing. They should
fit on one or two screenfuls of text (the ISO/ANSI screen size is 80x24,
as we all know), and do one thing and do that well.
"""
>>
>>53810116
>>53810159
What font are you using here?
>>
>>53810224
Or you know, you could just use a text editor made in the last 30 years.

even nano, which has piss all in feature scope, has fucking line wrap
>>
>>53810136

Get better glasses or something. My vision is shot, but I still use 9pt font.
>>
File: Doma.Umaru.full.1901931.jpg (737KB, 852x957px) Image search: [Google]
Doma.Umaru.full.1901931.jpg
737KB, 852x957px
>>53810225
Mandrill
http://wikisend.com/download/310410/Mandrill.ttf
>>
>Tfw You are all really good at programming and it's ridiculous how you are even better than my senior software programmers at my company and I am scared to post programming stuff
>>
>>53805466
>I'd like to know if there's any glaringly retarded things in here:
>
GetLinesOfInputAndReturnLetterCountsOfWords()

Well there's the first one anyway.
>>
>>53810314
Well, Nellie Mueller, you could always shitpost.
>>
>>53810224
>all editors don't have line wrap
Then use another editor, dumbass.
>>
>>53810314
>Tfw You are all really good at programming
HAHAHAHAHAHAHAHA
Good one, Nellie. I'll +1 you for this.
>>
>>53810314
I'm not surprised.

There are people getting paid lots of money that simply suck at what they do, or are not even very knowledgeable.

"10 years in the industry" gets you $80k, even if you're incompetent as all hell.
>>
>>53810329
Actually, writing method names like that is becoming increasingly popular in the Android world. I see more and more libraries with such horrible method names:
>maybeDoSomethingAndReturn
>doSomethingIfNeededAndReturn
>shouldDoSomethingAndReturn
That's what you get for letting normies program.
>>
>>53810390
picking names is probably the hardest part of normal tier programming
>>
>>53810381
I am okay at programming and struggle with some programming things and you guys are so advanced at programming I feel bad
>>
>>53810415
you should
>>
>>53810415
Why are you acting like being advanced at programming is such a divine thing? You've just got to program often and enjoy it.
You should praise people who are good at logical thinking. I know math graduates who are better programmers than self-proclaimed "professionals".
>>
>>53810390
fuck dude, if I was forced to use libraries like that, I'd typedef them first
>>
>>53810390
microsoft also do that. they don't care about 80 lines rule for sure.

eg: https://raw.githubusercontent.com/dotnet/roslyn/master/src/Compilers/Core/Portable/Desktop/DesktopAssemblyIdentityComparer.Fx.cs
>>
>>53810415
spend some more time at it. i'd say that a year ago today i was a much shittier programmer than i am now and a year before that i was even shittier than that. the only way i advanced is just working at it for a few years until i was able to do stuff. right now i try to work on personal projects every day if i can just to get more experience and learn new libraries
>>
>>53810482
>microsoft also do that.

It's the WinApi way. Here's a doozy from WCP.dll:

RtlWriteDecodedUcsDataIntoSmartLBlobUcsWritingContext(...)
>>
>>53810482
Where do they do that in that code?
>>
Given two numbers that should be added, a and b, find the number of carries in their pencil-and-paper addition.

Example

For a = 27 and b = 59, the output should be
CountCarries(a, b) = 1.

1
27
+ 59
----
86

7 + 9 = 16, and the digit 1 is the carry.


int CountCarries(int a, int b)
{
int count = 0;

while(a != 0 && b != 0 )
{
if(a % 10 + b % 10 > 9)
{
count++;
}
a /= 10;
b /= 10;
}
return count;
}



How do I improve my code to work in this test case

a: 8989
b: 11
>>
>>53810390
>>53810482
>>53810519

Is self documenting code a meme, /g/?
>>
>>53810498
>i'd say that a year ago today i was a much shittier programmer than i am now and a year before that i was even shittier than that.

Amen. It's a continuous process of refinement. The change can be so subtle you hardly notice it until you look back at your old source.
>>
>>53810545

Absolutely.
>>
>>53810478
It's written in Java, so you'd be out of luck.
I've had some discussions with the senior Android dev (I'm a medior myself) that using 'maybe', 'ifNeeded', and 'should' in methods is fucking stupid. Calling a method something like 'maybeUpdateState' makes no sense. The word 'maybe' gives me no information about the behavior of the method. That shit should go in the documentation. Too bad the senior dev really likes 80 char length methods, so I'm out of luck.
>>
>>53810533
add 10 to one of them after detecting there's a carry
>>
>>53810545
Absolutely not.
>>
>>53810545
No.

You should only comment your code if it's not immediately obvious what you're doing.
Try to imagine yourself coming back in 6 months and wondering what the fuck your little bitwise hack is supposed to be doing.
>>
File: umaruwp.jpg (112KB, 1920x1080px) Image search: [Google]
umaruwp.jpg
112KB, 1920x1080px
>>53810482
.net code is quite ugly but NTOS code (windows kernel) is one of the most well documented code i ever read.
>>
>>53810591
bitwise hack =/= self documenting code
>>
>>53809333
>dpt roll
*rolls*
>>
new thread when ? :3
>>
>>53810545
As long as your naming is descriptive and consistent.
desu writing documentation is overkill for most projects.
>>
>>53810602
That's what they were saying, no?
>>
>>53810622
for(;rand();); make_new_thread();
>>
NEW THREAD@!!!!!

>>53810655
>>53810655
>>
>>53810600
Isn't it documented with Word? That's what I read when they released some old version. (If not: how did you get access to it?) Are you kidding?
>>
>>53805466
>GetLinesOfInputAndReturnLetterCountsOfWords
Csharts everyone

it doesn't even "get" or "return" anything, it's a void method
Thread posts: 335
Thread images: 29


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

If you need a post removed click on it's [Report] button and follow the instruction.
If you like this website please support us by donating with Bitcoin at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties. Posts and uploaded images are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that website. If you need information about a Poster - contact 4chan. This project is not affiliated in any way with 4chan.