/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

reddit.com/r/anime
docs.microsoft.com/en-us/dotnet/csharp/programming-guide/unsafe-code-pointers/pointer-types
twitter.com/SFWRedditVideos

>>> reddit.com/r/anime

How good math skills do you need if you want to study programming at uni, or whatever?

>anti-oop
Yeah. It's not related to him at all though.
I'm just taking them as an example of how much programmers follow stupid trends.
Pair programming was brought up on stream. It was really popular actually.
I feel OOP is very similar in that it's light on promises and people ignore the downsides.

>study programming at uni
If you're talking about taking individual courses it's not much at all.
If you're talking about a CE or CS degree it's quite a bit.

I don't think you should go to uni for programming courses unless it's to get the merits. You'll learn faster with most online materials or just books.

Thank you for making a non-mudslime /dpt/

I don't approve of this unfair treatment of mudslimes. Mudslimes can be just as programming related as anime as anime girls.

What is the Java of anime?

MUDSLIMES OUT THE SWAMP BELONGS TO THE FROGS
REEE

pair programming is completely worthless corporate bullshit
OOP doesn't have 'downsides' because if your problem doesn't suit OOP, you don't have to use it
but anti-OOP grognards act like using OOP means you have to turn into a terrible Java programmer who has to have an object and encapsulated interface for everything

Dragon Ball Z

k-on

>OOP doesn't have downsides
Wow. You genuinely believe this?

Bleach

>not Naruto
Go to bed grandpa.

>95% of the show is verbose monologues
>the other 5% is cool for exactly 10 seconds before the monologues start again
>characters get increasing absurd
>multiple inheritance POO everywhere

>OOP doesn't have downsides because you can just not use it

I mean it in the sense that it's not an 'ideology' like pair programming is, it's not something that's forced upon you, you can choose to use it or you can choose not to use it

Pair programming isn't an ideology. It's something you're encouraged to do for misguided reasons.
Nobody ever claimed you should never ever program alone.
>it's forced on you
That's true. Much like OOP or TDD or any of these corporate memes.

>It's something you're encouraged to do for misguided reasons.
that's basically what an ideology is
pair programming is completely useless
TTD is only useful when safety matters like code that drives machines
OOP has plenty of uses and the only argument people have come up with against it is by looking at stuff like Java and saying 'well not everything fits this paradigm so OOP sucks'

test

back to ribbit

AIDs doesn't have any downsies; you just don't have to catch it

Ayy lmao it worked

>encouraged to do it for misguided reasons
Perhaps I didn't make myself clear but OOP is exactly the same. It started off with the promise of encapsulating state which was something bad programmers had issue with. People keep adding on promises. Some weak some strong. But I haven't seen OOP deliver on it ever.

>OOP has plenty of uses
Elaborate user. What are these uses?
I hear people list things but tell me how it helps. Let's take the popular example of GUI perhaps.
It has so many drawbacks there it's not even funny. The only reason I see why people think oop fits gui is because it fits their mental model well there. The visual elements can be objects. They do have actions they can manage themselves and they can pass messages in a sane manner.

But among the drawbacks is massive inflexibility in interaction. So much redundant state you need to track.
>but you dont
You do. Through a library or whenever you have to take it on yourself because you don't have the most simple use case for you UI.
Customizing object classes creates massive code coupling for no sensible reason.
It's one of the few retained mode api still in use. We moved away from that shit for very good reason.
You take on a huge amount of initialization effort too.

And I dont see the upsides compared to the alternatives. For a greenhorn it's way more complicated than many of the other ways to do GUI. For senior developers it still introduces a layer where you need to translate your data into presentable form instead of letting your GUI act on the data and present it for you like most other solutions do.

It's a terrible fit yet i hear people claim that's one of the places where oop shines. Not that it matters. I'm not new to this game. These ideologies are just like that. They claim they're the best for everything and slowly their claim erodes until there's next to nothing left.
Just a few years OOP was THE way to program for everything. It's tough to find anyone saying that now.

>that's basically what an ideology is

So you really think companies decide on a whim to introduce things "for the lulz"?
You don't think they measure the results, compare and try to optimize their results?

Goddamn..

>pair programming is completely useless

It has serveral advantages. You can team up experienced devs with newbies and therefore:
-you power-up your code quality, since the review process is already included and the newbie won't make huge mistakes
-the newbie will learn a lot and therefor you can build up good devs faster
-people do less breaks for checking emails or stuff like that (if any)
-people have a minimum of social interaction and therefore don't get dull so fast
-you use the "coding breaks" for reviewing, this way they can regenerate and think about the code at the same time
-people will challenge themseves when their code gets immediate feedback


>TTD is only useful when safety matters like code that drives machines

TDD has so many advantages, I don't even know where to start..

-people usually try to NOT write tests or they do it at the end when they have completely forgotten what they should test
-writing tests after your code always means you test what you just wrote, if you write the tests first you sperate the "what" form the "how" (you think about he behaviour/results first and don't simply imitate your functions)
-writeing tests in the beginning can save you a lot of time, since it forces you to think about the details and edge cases of your implementation. if you find out that you try to accomplish the warong thing, its better to find out with a simple test you can write in 2 minutes and not after implementing a huge function that took you 30 minutes - only to find out you need to redesign/refactor things


>OOP has plenty of uses and the only argument people have come up with against it is by looking at stuff like Java and saying 'well not everything fits this paradigm so OOP sucks'

This is correct.

>pair programming
It cripples any productive developer to at least some degree.
There's no guarantee programmers will agree on approaches or that their arguing will ever lead to improvements compared to having a single programmer implement and prove his case
The overall speed of programming as a pair is lower because both of you need to keep up with the code.

Also you're mistaking mentoring for pair programming. There's no explicit newbie+senior pairing.

To only present one side of an argument like this is misleading and its what causes people to follow these ideologies. You rarely hear of the explicit downsides of them before they're close to dead. You can read all about how pair programming fails. In a few years other ideologies will be born and old stuff will be on the chopping block.

If you're only presented with positives you should be extremely sceptical. People tend to leave scepticism at the door when it's taught at university though. Understandable because they're supposed to teach you hard truths. That's not what happens when CS people talk about software development though.

yeah people treat OOP like an ideology and a crutch for bad programmers, that doesn't mean it's a completely worthless paradigm like pair programming
I'm not sure GUI is the best fit for an OOP model. It's great for objects in a video game. Binding functions to data is something people whine about alot but it makes alot of sense for plain data structures like lists and stacks and maps. Typing List.Add(object) is better than typing AddList(list,object)

>Typing List.Add(object) is better than typing AddList(list,object)
That has literally nothing to do with OOP. That is pure syntactic sugar.

>newbie
yes, they're crutches for bad programmers to limit the amount of damage they can do. Seriously, email breaks and social interaction? Don't try and justify something by applying it to complete retards. A competent programmer does not need to pair program

>UFCS
>has anything to do with OOP
Oh. How silly of me I assumed I wasn't talking with a moron. I should probe more before I make lengthy posts.

>Pair programming
>Not trash
You sound like a project manager.
You're a project manager aren't you?

what do you consider OOP then?

First time poster in dpt. Yesterday I made an Excel macro to set some values in a report I do daily, using a loop for each cell in a defined range, to be copied and pasted as values, to the cell to the right of it (thus becoming the "previous day" value)

I tried doing this with the entire ranges but I can't paste as values it seems.

Can anyone point me to what I'm doing wrong to cause the macro to start off slow, then speed up to normal speed at a seemingly random position? I've tried to not update the screen and disabled page breaks but that did not help.

Here's the loop I'm using:

Dim CDay As Range
Dim Cell As Range
Set CDay = Range("CurrentDay") 'range was set in the spreadsheet with this name
[..]
For Each Cell In CDay
Cell.Copy
Cell.Offset(0, 1).PasteSpecial Paste:=xlPasteValues
Next Cell
Application.CutCopyMode = False

how old can you get while keeping a programming job? im not talking about being promoted, being a sysadmin, or whatever other bullshit niche job that only a few can do. im talking about your average programmer in java, c/c++, webdev, etc. can i keep finding jobs until im 60? 50? im already 27 and i dropped out of college so i am considering what to do.

>There's no guarantee programmers will agree on approaches or that their arguing will ever lead to improvements compared to having a single programmer implement and prove his case

That's one more pro of pair programming:
It develops the character.
Programmers that think like "thi is my code, I do it in my way, don't touch it" aren't good programmers. You need to be able to adapt. If you code something and then someone does it in a different way, that is shorter and more reliable, than you just need to swallow your pride and learn from the other one.


>The overall speed of programming as a pair is lower because both of you need to keep up with the code.

This is a false conclusion. You see, "programming" is not typewriting. It's not about lines of code. Most of the time you THINK about the code, and there is no speed disadvantage in parallel thinking. Often it's better to take a step back every now and then and rethink your design. It pays of in the long run.

"One of my most productive days was throwing away 1,000 lines of code."
-- Ken Thompson


>You rarely hear of the explicit downsides of them before they're close to dead.

That's because the downsides are obvious: you pay two people to do "the same thing".

The advantages are more subtle and you not so obvious, until you try it.


>You can read all about how pair programming fails.

This is also an oversimplification. Yes, Software is not about finding the "silver bullet", there is no "one size fits all". After all you are facing very difficult problems and different approaches offer different solutions to hard problems.


I wasnt talking about OOP yet, did I?
But "seperations of concerns" make sense and MVC makes sense.


That's to illustrate my point. If you have 15 "rock star programmers" that are battle-tested one-man armies that spit out brilliant code like a machine gun, forget pair programming. But who has those? Exactly.

how hard would it be for someone with no programming language to make a GUI program that does this?
>open program
>prompt user to select directory
>promt user to select a mode of sorting (filename/date/size)
>prompt user to configure directory names (1 = C:\ , 2 = D:\Images,) etc
>display first image in set directory
>user presses the 1 key to move image into the director specified as 1
>image is moved to that directory
>display confirmation message
>load next image
>repeat
this would considerably increase the efficiency that I sort images
currently I just manually drag and drop, which doesn't work well when I have to go through tens of thousands of images

The older you get, the more experience you're perceived to have. I've worked with a 55+ year old programmer and he was 10/10

yes I know it's technically possible without, I don't even know what you define OOP as as I haven't used a language with method calls that isn't OOP

>Past the age of 24

Might as well give up now, old timer

Making a meme sorter would be good practice for intermediate learners. Not that difficult either.

On a serious note, why the fuck are there so many people consistently afraid that they've missed the call after 20-something?

Are you guys taking Tech movies/shows as fact or something?

uh, you don't need to be a "rock star" programmer, you just need to be competent

yeah, but all I know is HTML, could never get a handle on programming
it seems like something simple enough to just write a shell script for though

For everyone who isn't an 8 year old savant, apparently it's "too late" and they are doomed to failure.

The "if you arent born a savant or started THING as soon an you were in the womb" meme taken too seriously.

A lot of famous people in all fields started late in life.

A shell script would require an external image previewer and that could take focus away from your shell, requiring you to click back on the window.

>there is no speed disadvantage in parallel thinking
if that was the case then my computer with 4 cores should run programs 4 times as fast

The hardest part of that would be the GUI itself, honestly, and that's just because most GUI frameworks are a pile of horseshit.
Check out C#, putting together a really simple wpf viewing box shouldnt be too difficult. Or you can default back to win forms.

If I increment a pointer that was passed as an argument, like so, does that change the pointer outside of the function? It doesn't seem to but I am new at this and might be wrong/probably am wrong?

int match(char c, char *s)
{
for ( ; *s; s++) {
if (c == *s)
return 1;
}
return 0;
}

The first job is more difficult, but that's about it.
Try to get some practical experience, do internships if you must or at least make your own projects. Then age doesn't really matter that much.

Brains and computers work very different.

To illustrate this:
-Try to let your computer be really creative (i.e. tell a fantasy story)
-Try to solve a simple equation in your head

The former something where a 5 yaer old will beat any computer, the latter is something an oldtime computer will beat any math genius.


That's why reviews, refactoring and testing make sense for humans, but not for computers. 99% of all computer programms are deterministic, so if a computer could into human abstraction and imagination and could write good software, he wouldn't need to test it since he could only reproduce what he already has done.

>does that change the pointer outside of the function?
No, you're only modifying a copy of the pointer you passed to the function.

I hate webdev and C#/java but that's all that's available. Where are the C jobs? How do I get them without 40 years experience?

>Where are the C jobs
Embedded systems jobs.
You don't want to go down that rabbithole.

But I hate everything else. I'm honestly stumped as to what the fuck to do.

Embedded and Operating System jobs, mostly. Unless you win the lottery and land a NASA job.

>How do I get them without XX years experience?
All of that shit is just "best case scenario hire." Put in resumes regardless, fag.

the point is, unless they're twins or something, human communication is a huge overhead. unless you're really bad at programming and can't be trusted to produce satisfactory code I see no reason why you should do it in pairs

Get a job working with C# at a small company.
It, at the very least, has pointer manipulation.
docs.microsoft.com/en-us/dotnet/csharp/programming-guide/unsafe-code-pointers/pointer-types

Can you land a decent prog job without falling for the LinkedIn meme? I have no desire whatsoever to make a fucking account for Job-Specific Facebook.

"So user, do you have a LinkedIn?"
"No"
"Wow, what are you, some kind of Luddite? We are looking for someone who isn't afraid of using new technology in our cool hip development firm."

>Actual words spoken at a small startup in LA

Do startups even use LI anymore?

No, most of them will just take whoever knows a meme framework and will work for dirt cheap

Update.

When I run the macro, Excel is slow on the part of the spreadsheet which is visible on the screen. A few seconds in, the program becomes non-responsive but you can still see the macro go through the cells and do the loop. The CPU usage is under 1% for Excel, basically idling.

Then the page scrolls, and instead of the new cells, there's a grey area. As soon as the cursor hits that grey area, the loop finishes almost instantly and CPU usage goes up to 25%.

What the fuck, Microsoft this worked perfectly yesterday.

For example rust has method syntax without being OOP

Not him, but what sorts of projects can I do to get these sorts of jobs more easily? I have a standard bachelors of computer science.

Write a small operating system

Why don't you just write a Python (or whatever else) script that generates the report for you and saves as .cvs then just import that in Excel instead? Would that work for you?

Try googling: "Embedded Electronics projects" or "Operating System projects"

I can't code for shit.

Why do normies always suggest Ruby or Python as a first language?

It seems like a *terrible* way to learn computer science desu. Both of them have an extensive, inconsistent syntax where feature X is invoked in an entirely different manner than feature Y. It's more like learning a new human language, which is not what computer science is about.

Why aren't we teaching all kids Scheme first? It's literally just (operation operands ...) for everything. Is there some kind of Python lobby pulling the strings at schools across the world?

People who use high-level langs dont give a shit about understanding anything or being good programmers. They just want to get the job done.

also forgot to mention why are you bitching about python when Lisp is just as bad?

1. Scheme is a high-level lang.
2. get the job done != learning computer science

Lisp != Scheme

Because a normalfag can fire up python, import a few modules, and generally get it to do whatever they want. It's not supposed to teach them about compsci or even programming in general, it's just a tool that lets them do what they want to do quickly and easily.

>They just want to get the job done
That's a funny way to say "not think. at all."

>Lisp != Scheme
Scheme is a Lisp.

I thought Scheme was a standardized form of Lisp, since Lisp already had so many different dialects as people added their own features to the language.

>It's not supposed to teach them about compsci or even programming in general, it's just a tool that lets them do what they want to do quickly and easily.
Then why do schools teach it?
Why does /dpt/ recommend it?

This is a series thread for non-brainlets who want to verse themselves in solid theory. "Just get the job done" computer niggers congregate in /wdg/.

That's Common Lisp.

Scheme is a lisp but it's not Lisp, which always refers to Common Lisp in 2017.

It doesn't matter what your first language is

Since when does /dpt/ recommend Python? People who recommend it here are in an absolute minority.

Lisp/Scheme abstract too much away for a novice. When they move to another language theyll basically have to re-learn programming.

The only language id feel okay recommending to a beginner is D. Maybe Rust if it ever sorts out the BC. Maybe Nim when it matures.

you asked and you got your answer faggot

Your answer fucking sucks.

ok

Recursion is way more natural than setting an iterator variable and running a for loop. Think about how fucking abstract that is from an objective standpoint.

You're just a baby duck.

I'm working on a tool that stitches anime.
There, it's ontopic now.

Very well! How's it going so far?

>You're just a baby duck.
>VB-java-C-C++-D-Haskell-Idris
>Recursion is way more natural than setting an iterator variable and running a for loop.
D has many functional aspects, but beginners need to learn iteration. I fear for the people you try to brainwash into your lisp cult.

It already works reasonably well but it is limited to simple motions (translation only, no zoom or rotate) and scene change detection is not quite right sometimes. but it's useful because it's much much faster than doing it manually. For the difficult cases I can still do it manually.

>terrible way to learn CS
Certainly. CS people shouldn't touch programming languages at all. As far as choice of language goes I don't see CS people writing software that isn't trivial so almost any language will do if you wanted them to program.
C++, C and similar would just waste their time though.

>beginners need to learn iteration
Why are you setting the next generation up for failure for no reason at all?
There's nothing inherently "easy" about iteration. It's more abstract actually.

>It's more abstract actually.
its really not.
recursion is more an alien concept to many people. Loops and iteration are the foundation, we need to teach them. Theres nothing that says they then cant branch off and try other things such as a lisp or pascal or asm or FPL.

Stop having this shiity tribe/team mentality as you sound a little baby-duck yourself.

>think about how abstract that is
Compared to having an implicit stack which keeps track of which of the many runs of the function you're on? That's very abstract.

I find for loops way more intuit. They're more like humans would do something. You set up state which you can repeat. Like slicing a tomato. You start at one end, increment it's position as you slice in a perpendicular to the direction you're cutting.
How does that work as a recursive function? It'd be rather contrived.

Now I don't think there should be a general preference (unless your compiler doesn't do TCO). They both vary in clarity based on the task. And every problem can be solved with either.
I'd say that generally the more parameters you pass down in your recursive calls the less suited it is for a recursive call solution.
As for what rookies find easier their confusion with recursion makes it quite clear it's not easier than iteration which people rarely fail. I've taught 2 101 programming courses. So perhaps I'm to blame. But I'd like to think I'm not.

But we always start with iteration. That's how I was made to teach. I don't think it matters that much.

But I learned POO on C++ first. I just wish somebody introduced programming to me through Scheme. Would have saved a lot of hurt.

Anyway I homeschool our son and daughter. They are 9 and 7. I make them do their math lessons in Scheme every day and they don't have a problem understanding.

>Anyway I homeschool our son and daughter. They are 9 and 7. I make them do their math lessons in Scheme every day and they don't have a problem understanding.
Oh god, youre going to ruin any chances they had at giving programming a try. Cant believe you sub-humans actually breed. Lisp is such a terrible way to teach programming even if it does some things right,

>How does that work as a recursive function? It'd be rather contrived.
0. Is the tomato too small to slice?
1. If yes, stop slicing.
2. If no, slice 1mm into the tomato and ask again.

>counting is harder than understanding the concept of a 'base case'

Except for every slice you bring out another knife and eventually end up with knives and waste time picking up new knives.