/dpt/ - Daily Programming Thread

Previous thread: What are you working on, Sup Forums?

Other urls found in this thread:

github.com/MatMoul/quickdial-webext
adventofcode.com/
twitter.com/NSFWRedditVideo

sepples hehe

I'm working on programming my brain with chemical equations for my Chemistry exam at Uni.

Is kotlin worth learning for Android apps?

yes, it's the new google pl of choice

Poo poo = nu Poo();

I disable brains of women using magnets, will they sleep with me? I'm asking for a friend.

>news science archeology news
>neurological discovery
What?

>archeologists discover ancient tablet detailing how magnets cause brain damage and liberalism, and why technology had to be abandoned

shit

How do you guys pick stuff to work on? I have a good handle on the basics of logic, program structure, some data structures, some algorithms. Can pick up new languages very quickly. But I never have anything to do with what I know so Ive been stuck for like 6 months.
Just looking to how to progress past say 5th semester programing degree tier knowledge to "real programming".
Any advice or suggestions? I'd love to hear them

How can i get into c++ programing? I have already some experience with C. Does it worht learning c++ in 2018?

>being braindead turns you into a liberal

It's a minefield, don't bother.

C++ is garbage. Stay away from it.

Wait wait wait. THAT EXPLAINS HOW BLACKS LOST THEIR ANCIENT SUPER-TECHNOLOGY, THEY WERE INFECTED WITH LIBERALISM

LIBERALS ARE HOLDING THE BLACKS BACK

HOLY SHIT

>with me
no
pic related; never

C++ is junk. Keep it at bay.

My personal projects are offshoots from things from work.

>nogs and gooks
I'll pass...

ABOLISH BORDERS NOW

>implying you had a chance to begin with

What do you do at work?

back end development?

I've never really understood people not knowing what to work on. I have shitloads of things I want to do, and come up with new ones all of the time.
Usually they're too ambitious in scope and/or too time consuming to get around to doing any of them, so I just try to stick to my "main" project.

If you're really out of ideas, writing a program to automate something you do is usually a good place to start. Other popular things are compilers/interpreters for toy (or even real) languages, or writing some simple game from scratch. You could even try find something open-source to contribute.
You don't necessarily need to write useful software, just write something which you find interesting.

What exactly are you having issue with?
Basic C++ is pretty simple, it's only when you start getting into template and C11+ stuff it gets a bit murky for beginners.

>You could even try find something open-source to contribute.
not him
thats the only thing i havent done from your list

dont really know where to start

C++11 stuff is mandatory for any new sepples programmer.

If someone wants to do anything out of boredom, fork this since it has been seemingly abandoned:
github.com/MatMoul/quickdial-webext

Needs a bit polish regarding the issues page for perfection.

Yeah it is, but not until you grasp basic C++, which he hasn't.

using A = std::decay::type;
using B = std::decay::type;
using C = std::decay::type;
using D = std::decay::type;
using E = std::decay::type;
using F = std::decay::type;
using G = std::decay::type;
using H = std::decay::type;

>implying i care whether i had a chance with nogs and gooks or not

what does that extension do?

Yeah I don't find anything interesting but I always enjoyed working on my school assignments(I went to a community college for 2 years at 23 for computer programming). I don't know I guess i'll try to think harder. I don't think I would be helpful to any open source teams yet but desktop software is what I like the most so I'd like to start working on the stuff I still need on windows that isn't on linux yet but I don't think I'm anywhere good enough yet.
I also fucking love databases, like systems analysis and creating schema and shit but that's even harder to find projects for because I don't have any data

Know that FVD SpeedDial extension for Firefox?
The one that turned to full shit after the Quantum update, is slow as shit and bloated with retardation, adware, and retarded page effects.

Well, plenty of people abandoned it and are looking for a new homepage dial addon.

The one that preforms the best as far as i'm concerned, is good to the eyes and not bloated with shit, is QuickDial there.
The only thing it's missing is a proper backup system and polished and fixed inner communication between the addon and the folders/files regarding the bookmarks.

Completed an interview code challenge in Go. Quite like it, so going to see what else I can develop with it. So far it's a web server that serves a file. Might try and make it serve web pages instead.

>Completed an interview code challenge in Go.
what was the question about?


Also, is this for a position?

This OP image is hideous, why is it being used?

>Is this for a position?

No I just like to do interviews, I don't actually want a job.

u havin a giggle m8?

I'm in the data science world, so I don't really know where I fit on the front-back end spectrum. I guess parts of my job are front end but other parts are back end.

One project was to rewrite a piece of code in C++ to optimise performance. Another was to rewrite an app in JS to get better performance.

Cool.

I had to do a task recently where i had to compare more than 1 million vectors in Python, for machine learning stuff.

I was using numpy but that shit still took ~13 seconds to to all the computations.

Might use multiprocessing to speed things a bit

I'm learning about multithreading and so I'm writing a simple chat toy thing. Is it normal to have a mutex lock/unlock in most functions or is this a Code Smell(r) which should be eliminated with a Pattern(tm Oracle Corp)?

>Quite like it, so going to see what else I can develop with it.
Try doing this year's advent of code. It does a pretty good job at revealing Go's weaknesses and strengths in my opinion.

adventofcode.com/

This one? Thanks, will take a look at it.

Of course it is for a position, why else would I do an interview?

It was about making a web server which could be used at scale. It was a simple "take in x and do y with it" type thing

My experience is that Python doesn't scale well which means that it becomes almost imperative to move to some JVM language to deal with internet scale datasets.

I've had some good results so far with Scala and Clojure is fun to play with.

Who else here deletes resumes if they mention experience with C++ or Haskell? Technically, I'm not supposed to do that, but nobody notices. ;^)

What are some small sized sophisticated projects I can work on to fill my resume?

Use Go! It's built for massive data sets.

Yes. Day 18 part 2 in particular will make you love Go.
For other challenges, those with lots of string manipulations in particular, will make you frustrated about Go's immutable strings (or rune slices). Especially if you're coming from a funlang like ruby or python.

>Go It's built for massive data sets.

really?


didn't know that

Thanks, I will start doing that once my Ubuntu has updated to 18.04.

Yeah, built by Google for their production systems, as C++ was too limting for them.

If you have multiple threads accessing and modifying the same data then yes you either need locks or atomic variables however a thread per connection in a multithreaded networking program is already a bigger code smell, it'll actually slow things down a lot unless you're programming in a language with green threads.

>as C++ was too limting for them.
you mean they started hiring people who couldn't code in order to fill quotes and so had to develop a language they can use with less chance of fucking up.

>Citation needed

I have shared library A with global pointer x, I have executable that links against A and at runtime loads shared library B which is also linked against A. When you check the value of pointer x from B it's 0 while in the main executable it has some proper address.

So I guess the init function in B needs to get all global variables of A from executable or else I have to refactor the code to not use any global variables.
Is there any other way to access x from B if B is always loaded at runtime?

which part?

>The key point here is our programmers are Googlers, they’re not researchers. They’re typically, fairly young, fresh out of school, probably learned Java, maybe learned C or C++, probably learned Python.
>They’re not capable of understanding a brilliant language but we want to use them to build good software.
>So, the language that we give them has to be easy for them to understand and easy to adopt.
- Rob Pike

>else I have to refactor the code to not use any global variables
I have no idea what your problem is, but this.

If you're going to make a wild claim that it's just that they couldn't get good C++ programmers so their only option was to make an "easier" language

Just finished cooking up a fairly elegant and efficient ray-through-grid traversal algorithm:
int x = trunc(x0);
int y = trunc(y0);

int dx = dir_x < 0 ? -1 : 1;
int step_y = dir_y < 0 ? -1 : 1;

float t_per_x = dx / dir_x;
float t_per_y = step_y / dir_y;

float t_rem_x = (dir_x < 0 ? x0 - floor(x0) : ceil(x0) - x0) * t_per_x;
float t_rem_y = (dir_y < 0 ? y0 - floor(y0) : ceil(y0) - y0) * t_per_y;

float t = 0.0;

while(t < max_dist) {
f(data, x, y, t);

if(t_rem_x < t_rem_y) {
x += dx;
t += t_rem_x;
t_rem_y -= t_rem_x;
t_rem_x = t_per_x;
}else {
y += step_y;
t += t_rem_y;
t_rem_x -= t_rem_y;
t_rem_y = t_per_y;
}
}

It's true though, there exists no such thing as a good C++ programmer.

That's not to say that Go isn't perfect for Google's needs. Because it's so easy to write concurrent Go programs, Google can throw tonnes of hardware and hordes of mediocre programmers at the problem and end up with something that's still reasonably fast.

Well in C if I know there will be only one instance of thing ever it makes sense to have global pointer to that.

...

It really doesn't look like he's referring to C++ as a "brilliant language" in your quotes, user. I looks like his reasoning was that Google newcomers are familiar with distinctly non-brilliant turds, so he figured he'll design a language reminiscent of those turds but slightly less bad.

Go can fit in a much wider range though. It can do the low level work of C++, but can also be a more web facing program, like Java and Python.

Not really, no. It just means you CAN have a global pointer to it. It doesn't make it a reasonable idea. Which should be apparent from the fact that it's causing you trouble.

dumb wojak poster

>Google can throw tonnes of hardware and hordes of mediocre programmers at the problem and end up with something that's still reasonably fast.
That's quite clever, really. No matter how much hardware and how many hordes of top-tier C++ programmers (i.e. morons that barely qualify as human) you throw at a problem, it won't get solved with C++ in any reasonable manner.

I didn't mean to imply that, but what else would they use? Go is clearly being contrasted to C++ (and maybe C) and "brilliant language" is a euphemism.

...

Which language should I learn to get PAID

...

Have you seen jblow's jai code?
It's a mess and he tends to write a lot of hacky shit. Not to mention his stance on globals being "necessary"

Because it's funny

Chinese

for i from 1 to 100
if i == 1:
result

after 4 years of """programming""" I implemented my first linked list today :^)

result

>Go is clearly being contrasted to C++
Not in those quotes. C++ is merely mentioned as a language familiar to those who aren't capable of understanding brilliant languages.

If you have a lot of dostuff_Xs, especially with inlining, it might be worse to unroll it, because it will bloat the binary size and put more strain on the i-cache in exchange for eliminating the branching (which would be predicted perfectly after the first few iterations anyway).

>government will fix it: programmer edition

yeah I could write that but why should I make the code magnitudes less readable if the compiler does that automatically

I see, I did not think about that

>the compiler does that automatically
how do you know?

so why do you need to pass flags to the compiler?

A dumb compiler will leave it alone. A clever compiler will unroll the first iteration. A genius compiler will consider that it may be a pessimization (though it may never be in practice, I'm just guessing).

If all else fails, check the object code and profile. Though you probably won't want to waste your time on a loop as insignificant as this one seems to be.

Hey /dpt/, rate my Pharo:

(oh wait, I can't copy paste an image into a board post)

Nvm, I just wrote a class that lets you use infix syntax for expressions consisting of binary message:

Infix new > 2 + 5*3 + 1; eval
(returns 18)

It's gay. Use C++.

Why would it even need to bother ? branching exists for a reason.

>but how can know??

Radix sort in c.

Unless it gets metaclasses, no.

branches seem to make a lot of optimizations hard to apply

You can't do the same thing in C++. Messages (method calls) are not objects. The smalltalk example relies on overriding #doesNotUnderstand to intercept messages sent to the Infix object.

MetaPOO is still POO. Learn C++.

Too slow when allocating millions of new objects of unpredictable sizes. A good Smalltalk JIT with compacting GC is an order of magnitude faster at allocations than the system allocator.

How do I into multithreading (with shared memory) in C ?
Is pthread where I should start or is that yet another library I should avoid using ?


*optimizes your malware*

>allocating millions of new objects of unpredictable sizes
just don't do that

>having a GC
Just fuck off back to Java. C++ solved memory management.

>Learn C++
>Just fuck off back to Java

I have to write some script B which will call another script C. Script C is a timer task and doesnt exit.
So i am using the following code to make B not wait for C to finish.

pid=Process. Spwan(c)
Process. Detach(pid)

However, B is called by A and A seems to go into a hanged state.
How do i make a child process detach from all its parents and become an independant process?

I gave you the benefit of the doubt, but you're clearly not competent enough for C++, since you're clearly incapable of understanding that shared_ptr and weak_ptr make GC obsolete.