/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?
Last thread:

Attached: Y U N O.png (800x600, 472K)

Other urls found in this thread:

youtube.com/watch?v=AfaNEebCDos
hypothesis.works/
teachyourselfcs.com/
twitter.com/NSFWRedditVideo

So I didn't knew how much could optimizations speed up your code

But it's actually insane

I just adjusted a for loop so that it access the elements sequentially and not randomly, and now my code is 10 TIMES FASTER

10
FUCKING
TIMES
FOR JUST ONE FOR LOOP

And I didn't even do that modulo look-up table, I am actually SCARED how fast it will go if I do it
Like i won't even be able to measure it, lmao

Is there such a thing as QuickCheck for Python or Java ?

youtube.com/watch?v=AfaNEebCDos

Hypothesis for python, I'm not sure about Java but Scala has ScalaCheck.

Hello /dpt/, I got a book on C++ and am using it to study, but I also came across freecodecamp and it piqued my interest. The thing is, it's mostly for web development and from what I see. Is it advisable to just study C++ on my own and also use freecodecamp? I would like to finally be able to seriously have marketable competency in programming after flirting with the idea on and off for a couple of years.

I've gotten conflicting reports on my hirability for programming at my age (22, delayed uni means I'd probably be around 25 when I graduate), as my older college acquaintances have said I'm too old to start now, but most professionals I've come across say any point in your 20's is pretty fair game to employers.

That's what caches do my dude

thanks

Yes I know but I didn't expect the increase in performance to be so dramatic

Now imagine using this, look up tables, multithreading and predictive programming

I want to see how far I can go

I'm new to git and working with a friend making a discord bot. I made a branch to make changes to my friends discord bot, he accepted them when I made a pull request on the master. He's made some additional changes to master and now my branch is out of date. I want to make some more changes on this branch and have them pushed onto the master but I don't to erase the changes he made to the master with my outdated branch.

How do I update my branch to match the master?

Either rebase or merge the current master in your branch.
If you're lucky there won't be any conflicts, but it's probably likely that there will be.

The wikipedia page says that it does and links to this hypothesis.works/

There will be conflicts, I want all the conflicts to be resolved by accepting his changes. I want my branched to be based off the newly updated master. That's where I would use rebase right?

Yes.

thanks dude

If you've got a function that's only in the cpp file and not the header is there any reason to call it static or put it in an anonymous namespace? Because it's not like you can call it from outside that file anyway.

>she somehow managed to use a simple look to access elements randomly rather than sequentially

JavaScript rocks!

Attached: js-rocks.png (1000x494, 286K)

There's still a chance of name conflicts. This is exactly what static was invented for. At the very least it serves as information for the reader.

post yer code

Attached: __.png (484x984, 60K)

I like how Rust manages to be even less readable than C++. Absolutely dreadful language, both aesthetically and functionally.

When you are linking the project if there is another .cpp file with same or different function that's named the same, you will get linker errors.

Well nobody forces you to write unreadable C++

Never wrote C++ professionally so I don't really have much of an authority, but I don't agree.
At worst it's about the same, otherwise rust's more readable to me.

Sort of want to use go but it seems to have this autistic system of storing all go projects in the place it tells you to.

anons, I...

Attached: 1541723200619.png (1020x126, 38K)

>Well nobody forces you to write unreadable C++
By which you mean "nobody forces you to write C++". Anyway, you're obviously a C++ fan, so your opinion is automatically discarded.

noob here
I'm making a pokedex project of the first 151 pokemon just to get used to OOP in Java

one of the instance variables I picked was genderRatio, but I'm not sure if I'm implementing it in the smartest way. Like for Bulbasaur it's "87.5% male 12.5% female". I feel like making that whole thing a string for every single pokemon isn't the best way to implement it, even if I make the default "50% male 50% female" in the main class. Any ideas?

this is your mind on rust

use bool or even better an enum

One real number ranging from 0 to 1 and representing the probability that the creature is male?

>C++ is Rust are the only two languages that exist
>being that bad at basic reading comprehension
This is your "mind" when you're a mindless plusmonkey.

i like this idea, thanks

Pretty much all people who are openly hostile to C++ are rustfags.

I currently have something like this:
List folders = (from string s in Directory.GetDirectories(Constants.Root + path)
select s.Split(Constants.Root)
.Last())
.Select(x => x + "/")
.ToList();

List filesAndFolders = (from string s in Directory.GetFiles(Constants.Root + path)
select s.Split(Constants.Root)
.Last())
.Concat(folders)
.ToList();

Is there any way I could merge it into one linq statement? I need to add a "/" to the end of each folder, which is catching me out.

Pretty much all people who openly embrace C++ are delusional and incapable of basic reading comprehension. You two illustrate this perfectly.

This is hilarious because I never wrote about C++, I just said rust make you look like the poor soul in .

I guess pointing our your glaring lack of reading comprehension isn't enough to help you comprehend your moronic mistake, plustard.

That's not true, even just in systems programming there exist Cfags.

There is no mistake, friend. Even if you don't use Rust, you're clearly disturbed which is illustrated by the post I quoted above, and I simply pointed that Rust has a tendency to make people act this way (which is true even if your disturbances were not caused by Rust).

Thanks for reposting my shitty yuno.

>ToList
woah... so this is... the power of linq...

Okay, I guess I'll have to be even more specific with you, since your IQ is clearly below 80. Hint:

Why do enterprises love Java so much?

They love it because it's standard.
It's standard because the enterprise world is a pile of shit ran by middle-managers who can't program but think their bachelors in business management is the lifeblood of a company.

>Why do enterprises love Java so much?
Large supply of easily replaceable programmers. It's a very mediocre language, so the influence of any single programmer is limited in terms of damage they can do to the code base.

Lisp is the most powerful programming language.

>no dependent types
Fucking dropped.

>no totality checker
Fucking dropped.

I doubt you even know how to use either of those, you little brainlet.

So i came across this link the other day:
>teachyourselfcs.com/
So what /dpt/ thinks about it? It is good or bad? A meme link?

CS is a meme.

Depends on your philosophy.
Some prefer a more pragmatic approach: build things and get involved in projects and learn what you need along the way.

Keep on assuming, you little brainlet.

Prove me wrong, faggot. Post some code. Oh wait, you can't, because you don't know shit lmao

In the REPL, type 'total: myFunction' to test function 'myFunction' for totality. That's how you use it.

Oops, misplaced the colon. It should be ':total myFunction'.

What about struct declarations? Should they go int an anonymous namespace too or nah? It looks like you can't even make them static.

Good going brainlet, you don't even know how to use your REPL.

I do my dear brainlet, but I made a mistake which I correctly shortly after.

Yeah put them in an anonymous namespace, it can't hurt.

struct déclarations are declarations with no definitions. Therefore they don't produce anything into the compiled binary, so there's no linking conflicts and thus no need or meaning for static

#!/bin/python2.7
array1=['a','b','c']
array2=array1
array1.remove('c')
print(array2)
>['a','b']

What the LITERAL FUCK
how do I avoid this

Attached: a8e.png (404x399, 9K)

array2=copy(array1)

Look up pass by reference

Dunno about member functions definitions tho

Reference semantics. They don't go together well with mutation.

What language should I learn (in order to get a job) if I'm not very creative but I'm good at making things efficient and solving problems?

Attached: deloused.jpg (500x500, 71K)

Java

Im in my first year of comp sci, we're learning to code with java at the moment, im bretty good at finding certain numbers in arrays and putting two and two together but i cant see how this knowledge translates to actually working as a developer... How does development work when you go out in the field after your degree?

it's just CRUD apps
pretty boring stuff

You'll learn in your software engineering unit. It's pretty bland and tedious.

>Jow Forums, the "smart" board
>can't write an algorithm that packs 5-dimensional spheres optimally
It's like I'm on /v/

Attached: 1475231349636.png (695x586, 45K)

I couldn't even write it for 2d spheres

Cool, thanks. Im studying in norway so it doesn't translate exactly to what you guys might be studying. This gave me some peace of mind, though.

Optimal 2D circle packing is a hexagonal grid, with circles centered on the hexagons

i don't even know what an hexagon is but alright whatever you say

it's a roundless circle

>not very creative
>good at making things efficient and solve problems

those two things are very very closely related. E.G. the entire thing of Doom The Black Book.

>a board of gadget fans, linux tinkerers and NEET fizbuzzers
>smart

>Jow Forums, the "smart" board
No one claimed this.

I completely fucked a code test. I struggled with all three questions and didn't get a decent answer out for any.
Will I ever get better at these over time or am I just permanently retarded and doomed to a codemonkey life?

Practice makes perfect.

Just keep practicing senpai. We're all gonna make it.

faggot.cpp

nigge.rs

After learning for some time I want to finally write some website based on Spring Boot. Something to get me an internship or perhaps a junior position if I'm very lucky. It could use a database, have some authentification. You know what I mean. However, even if I know how to use different methods and classes provided by Spring Boot I know I will struggle with actually organising my project: deciding the number and structure of classes, how they are connected, the design patterns. How do you learn that? Are there any recommended ways to design the structure of a complete web app?

I bet you never wrote an interrupt routine you MIT naggor

Does anyone know of something like an IACA equivalent for AMD?
It's a tool for statically analyzing instruction pipelining and data dependencies on intel architectures.

Someone has to lose.

Only those who don't work hard enough.

Clang has something like that afaik, Clang-MCA

Serious question, is it a bad habit to debug simple programs with prints rather than a proper debugger?

Attached: 1537705466007.jpg (667x593, 242K)

When will they ever remove ! from Rust. It's so annoying to type it after every macro and they love to fucking shove macros down your throat.

What is a good guide/book on matlab for a beginner?
(I already know a bit of python, root and c)

Kind of. At the very least use a logger rather than printf.

Yes, because then you won't be in the habit of properly debugging when it comes time to write more complex programs.

I-i did
Am I part of the high IQ club guise?!?!??!

Rust is a disgusting language.

Totally fine IMHO. It's easy, Simple, easy to clean-up. Even in massive systems I do it and I don't see any issue.

This is wrong.