/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

strawpoll.me/13999112
gnu.org/software/binutils
infocenter.arm.com/help/topic/com.arm.doc.den0024a/DEN0024A_v8_architecture_PG.pdf
gnu.org/software/binutils/
ftp.gnu.org/gnu/binutils/
ftp.gnu.org/gnu/gcc/
twitter.com/NSFWRedditImage

I want to learn F# any good resources?

>wake up
>suddenly want to webdev for a change
>Grunt/Gulp npm, require.js, browserify, es6, compilers, transpilers, jasmine mocha chai, react/angular/ember, closures, prototypes. *head explodes*
wew lads
why does that field seem so fragmented and overengineered? or am I just a c++ retard

The only things you actually need to learn about are closures and prototypes. Everything else is just trendy webshit that will come and go.

learn rust

I already know Rust. Best soon-to-be-mainstream language.

>i know rust
no you dont. you're a faggot larper

ye, I get that, modern js seems pretty comfy on paper tbqh

it's just UGE amount of tech/libs/tools/terms is absolutely baffling, not like I am newbie at programming but shit's overwhelming and feels like a completely different field

If you had a pacman that could:

- turn 90deg. clockwise (pacman.Right();)
- turn 90deg. counterclockwise (pacman.Left();)
- move one square forward (pacman.Move();)
- move a given amount of squares forward (pacman.MoveMultiple();)
- pick up an item from the current square he's on (pacman.PickUp();)

How would you program him to pick up all the items on the map? If pacman tries to pick up an item from a square where there is no item he dies.

with two for loops

for (int i = array.length - 1; i >= 0; --i) {
for (int j = 0; j < array[i].length; ++j) {
if ((i + j) % 2 == 0)
pacman.PickUp();
pacman.move();
}
if (i % 2 == 0) {
pacman.Left();
pacman.Move();
pacman.Left();
} else {
pacman.Right();
pacman.Move();
pacman.Right();
}
}
Something like that. There might be bugs but hopefully you get the general idea.

wrong

That's very possible. Where's the error?

Do you want to do backend or frontend or both?

Denied further interaction with the Rust community

Both I think. Got an idea for a small internal project for my team.

move line by line in a snake pattern (left to right, right to left etc)

Anyone here employed as a programmer? How many hours a week do you work on average?

I often hear stories of mad hours in tech, or is that typically isolated to American start-up culture? I wonder how many hours a software engineer at Google or Facebook works

>$1

Well, this literally means "take the first argument", while $@ means "take all arguments". If you put quotation marks around it then it should work, unless firefox does some weird shit with its argument parsing.

Has anyone used plan9port before?
I'm trying to play with ramfs, it mounts on /tmp/ns.$USER.\:0/ramfs
But then if try like echo 'asdf' | 9p write /tmp/ns.$USER.\:0/ramfs/0
It says connection refused

Google and Facebook know that making their engineers work more than 40/50 hours a week is counter-productive. Working 70 hours a week is only something done in poorly managed startups and Japan.
If you want to work 35 hours a week move to France (expect to earn half of what you would in the US though. But on the bright side you'll get one of the best healthcare in the world).

What is this type of a problem called?

100 sometimes
gamedev
crunches are my jam

It doesn't have a name, it's basic array traversal.

Updating my RSS downloader written in Scala.

>gamedev

may the lord have mercy on your soul

40 hours per week.

shitposting in /agdg/ doesn't count as gamedev user

Peer to peer encrypted chat app with ncurses and openssl (ECDHE)

>amateur gamedev
not for me

user, he's a Unity 'developer'.

I'm learning C and programming for the first time. I made recursive function that finds an exit to a very simple maze. If maze has any dead ends function stops there, so the path from start and exit must be clear.
How much more difficult/advanced would function need to be to find exit in a maze with dead ends? I imagine it would have to look at all possible ways and try every path starting from staring point?

good for you if you're getting someone to pay you for 100 hours of "work" in a week

>How much more difficult/advanced would function need to be to find exit in a maze with dead ends?
If you brute force it, easy.

Ok, let's settle this down once and for all
strawpoll.me/13999112

Does anyone have an answer to this?

What about
>getting meme degree

Only Rust and Haskell programmers are NEETs. The rest is mostly employed.

Should be very easy to just improve your current recursive function (it won't be tail-recursive anymore but who gives a shit when you're learning) and have it find the exit even with dead ends.

I'm employed as a software developer and work 40-45 hours per week on average. Sometimes we'll have a tight deadline to do something for a new partner or client which will mean 2-3 weeks of 60+ hours, but those aren't too common and my boss is good about making sure they don't happen too often (or for shitty reasons).

I think crazy hours generally happen more in the game industry or startup world. You also might work a lot more when you're starting out (I certainly did, I worked 50-60 hour weeks for about 6 years) simply because you don't know enough to avoid mistakes, estimate effectively, communicate well, etc.

One other note: a smart business-aware developer once said to work at places where your software is part of the company's product offering. That way you're part of the company's profit center, so they will generally treat you better overall. In contrast, if you're a software dev at a manufacturing company that makes physical products (for example), you'll be seen as a cost center so it's more likely that they'll try to cut your budgets, keep compensation low, lay you off, etc.

Im writing my masters thesis still so I'm only working 24 hours, would be 40 though.

Why did you use recursive function?
Is it a requirement or something?

Yeah, exercise in the book specifically instructed to use it.

(defun solve (pac ncols nrows
&aux (n (* ncols nrows)))
(labels
((rec (i)
(cond ((= i n) t)
(t (pac-forward pac)
(when (= 0 (mod i 2))
(pac-pickup pac))
(cond
; 7-23-...
((let ((x (- i ncols -1)))
(and (>= x 0) (member (mod x (* 2 ncols)) '(0 1))))
(pac-left pac))
; 15-31-...
((let ((x (- i (* 2 ncols) -1)))
(and (> x 0) (member (mod x (* 2 ncols)) '(0 1))))
(pac-right pac)))
(rec (1+ i))))))
(rec 0)))

Boy, that sure is ugly.

Have no idea what that means.
Could you do it in C# while using two for loops? I already solved it the dumb way because I couldn't figure out how the two for loops interacted with each other.

If you have less than 100 tiles in your maze, it might be reason reasonable to try every path.

For a more complex maze, you should try to optimize it to be more like A* (check only the shortest path first then go back if hit a dead end)

>muh prototypes
yet another thing that js got wrong

>Sometimes we'll have a tight deadline to do something for a new partner or client which will mean 2-3 weeks of 60+ hours
This means the company is understaffed, and should hire more people. Not abuse the people it already has.

>got wrong
Why do class-based OOP brainlets have prototypal inheritance so much?

Smalltalk-like inheritance is the best, you're just a freedom-hating commie.

Prototypal inheritance is good, JavaScript's implementation of it is garbage.

I found it hard too in the beginning now I understand some things.
webdev is confuse because lack of standards, w3c says something and vendors implement their own way, so to make your app look the same on _all_ platforms you need to abstract a few things:
css -> every browser handles styles their own way, so to use a feature you need to have a general way to describe it hence less,sass which is transpiled to normal css code with browser extensions.
js -> writing pure js is a PITA, so to make it easier you write in something else like ECMAScript, coffescript, JSX and such and then you transpile it to something that will run in a browser with a transpiler like babel.
then you have templates so you don't have to manually write repetitive stuff.

So now that you have tons of stuff that don't run in a browser and need to be compiled into the real stuff. that's how you use webpack (to get all the dependent parts into static stuff html, css, js) and to correctly do that you use a build system to automate a lot of stuff with packaging your app that's when you use gulp/grunt.

What's bad about javascript's implementation? Which languages did it better and why is it better?

Or you could stick to HTML and ditch CSS and JS. Like the web was intended to be.

Let's start with having two different prototype keywords which mean totally different things.

mentioned smalltalk.

> Like the web was intended to be.
static, no interaction web?

Too lazy, there is no need for two loops just one is sufficient.

What do you mean? I only know of object.prototype which is the object's prototype and __proto__ which is the parent prototype. If you're talking about the class keyword you're retarded, it's just syntax sugar.
Also you didn't explain how smalltalk is better.

Yes, exactly. No tracking ads. No malware. No hidden bitcoin miners. No XSS. No slow websites.

>JavaScript's implementation of it is garbage
There's actually nothing special about the JS implementation of it.

var proto = Object.create(null);
proto.x = 4;
proto.y = 5;

var obj = Object.create(proto);
obj.z = 6;
console.log(obj.x, obj.y, obj.z, proto.z);


>smalltalk.
Smalltalk is class-based, you pleb.

Any of you guys have a job without the compsci degree?
t. Psychology degree of poor lifestyle and want to change

why does xxd group data into 2 byte chunks?

>What are you working on, Sup Forums?
Still working on a remote controlled """car""". Kind of works for the moment. Still not able to check if both motors are running on the same speed, but thats not relevant for the moment.
Wanted to go for ROS, but atm cant get the arduino shit installed. Apperently too dumb for it. Will tinker around a little more and do my own shit.

Connection is
arduino

are you smart? get a csci bachelors as well, go into AI research and get a phd

here's a picture.

Finally got a project for my old raspberry pi b+ kek

Tbqh it's not that bad.
C++ has far worse features. It could be used in lieu of decent metaprogramming features for certain things.
Of course any of us have better ideas for implementing DSLs in C++ (something the article touches on when invalidating xy as a symbol where x, y exist).

I think this may be Bjarne trying to get an April fools joke into the language, just as a funny piece of history. But unsurprisingly when the ministry of bad ideas say they're making a joke nobody takes their ideas seriously.
Really, how bad is this compared to the piece of shit that is if statement initializers (but only for if statements, never for else if or else).
Or the half-assed job with doing multiple return values (structured bindings) which is motivated by the idea that (somehow) using std::tie is better in that instance. And weakly points out it complicates parsing (we need 1 lookahead).

Nice project, Mohammed.

Yes but it relies on hard work and proving your ability through projects done during my free time.
I'm told it's easier now than 10 years ago though.
And sorry for being prejudice but the kind of person that'd take a psychology major (i.e you didn't take a STEM degree or interest yourself autistically in programming) is not the kind of person you hear about as being.
But do ask stackoverflow chat for this instead. I'm not sure we're a good group to ask really.

Nice work user.
Get a PID controller (or do it in arduino) and an accelerometer. Then make it a robot that balances on the wheels and give it a camera mounted in the head position.

Seems like most of my C programs are using very few registers when I look at the disassembled code. Is this because the caches are more efficient than trying to keep track of everything in registers?

Most likely not enough for AI research.
It was because I was supposed to go into the family practice once I got a masters forward but I don't want to be stuck relying on my family and their work for my life.
>Was going to major in IT/Networking
>Learned vb.net (Is that even a thing anymore?) way back in high school
>Defaulted on psychology degree and now regret it years down the line

>what is x86?

no, it's because your compiler doesn't produce code that runs fast as a skilled assembly programmer can. registers are faster than all other forms of cache

Yeah I'm not saying you should be ashamed. I'm just saying you're not the kind of person I'd expect to manage this, just prejudice.
But having a degree is good. The ability to learn well is valued in software. Having a degree is good because it proves an ability to learn at a high level.
>most likely not enough for AI research
Not that hard.

because compilers are retarded and cant into registers so they use the stack for everything

>your compiler doesn't produce code that runs fast as a skilled assembly programmer can.
I know this is bait, but there are a lot of Sup Forums-tards who actually believe shit like this. stop it.

Are you finding the program to shuffle different pieces of data in and out unnecessarily? If not then why should it use the larger range of registers?
Guys register allocation is considered a well solved problem. It dropped out of SSA form. I'd never argue a human can't beat it but presuming user is seeing this issue and is an expert programmer that trivially beats compiler register allocations is a bit naive imo.

You have to use memory anyway if you're doing *any* address/pointer stuff. Also the stack is typically used in function calls too.

>that trivially beats compiler register allocations is a bit naive imo.
not really because this is x86 and there are less registers than for ex Aarch64 where you got 32 64 bit registers, he knows his data necessities so it'd be easy for him to set a good placement. I've been debugging with gcc and it's objdump disassembler for a long time and I can tell you that a novice assembly dev would beat its register / memory usage algorithm.

I'll admit I haven't looked into it a lot. But I find that surprising form the theory I've read.
>x86
Why did we assume that?

It's easy to waste time in OOP

class Time {
private:
int hours{0}, minutes{0};
Time(int m) {
minutes = m % 60;
hours = ((m - minutes) / 60) % 24;
}

public:
Time() {}

Time(int h, int m) {
minutes = m % 60;
hours = (h + (m - minutes) / 60) % 24;
}
int totalMinutes() { return hours * 60 + minutes; }

bool operator>(Time& t) { return this->totalMinutes() > t.totalMinutes(); }
bool operatortotalMinutes() < t.totalMinutes(); }
bool operator==(Time& t) { return this->totalMinutes() == t.totalMinutes(); }

friend Time operator-(Time& t1, Time& t2) {
if (t1 > t2) {
return Time(24 * 60 + t1.totalMinutes() - t2.totalMinutes());
} else if (t1 < t2) {
return Time(0);
} else
return t1;
}

friend std::istream& operator>>(std::istream& in, Time& t) {
int h, m;
in >> h >> m;
t = Time(h, m);
return in;
}

friend std::ostream& operator

You were right about the compilers being efficient with register usage, as icc and msvc (lol) does that, the exception seems to be gcc, where they sacrifice performance for compiler simplicity and reduced build time (computing placement of data in registers adds an extra task in compilation)

i guess its because i dont expect anyone on Sup Forums besides a few to be smart enough to work on another arch

if you did this for a living you'd know objdump is part of binutils and entirely unrelated to gcc, but here's your (you).

it's true, and if you knew about assembly and compilers you'd understand that

nu "programmers" have a vehement reaction against assembly because they don't understand it, and their entire existence hinges on being coddled by (based) compiler developers who will actually have a job in 10 years

whomst are you quoting

good post lad

t. unemployed greasy neckbeard butthurt at being replaced by a cheap and hardworking indian at his last job

>whomst
ancient meme. almost as old as the cuckio meme

only worthwhile post in this stinking cesspit of a thread

It's just that I'd assume x86_64 or x64 now.
>I don't expect Sup Forums to be smart h to work on another arch
Sure. I don't expect Sup Forums to be programming for their ARM CPUs in assembly either. But smart enough? It's not that different, it's difficult to argue there's an intelligence gap. And x64 is bleh. I guess you'd be dumb to work in that if you don't have to lol.

the binutils package ships gcc, ar, as, objdump, objcopy, readline so nice try at sounding knowledgeable, dont give up.

>hard working Indian
Where do you find those?
Assembly fear is pretty annoying. Anyone should at least read their asm for the code that runs for 90%+ of the program execution.

x64dbg is pretty good

Not that user but you disgrace me.

You sure? gnu.org/software/binutils

Indeed, CISC architectures feel like writing in an abstract language built on top of the real assembly, where one instruction actually means 4 that you could've had full control over.

If you enjoy low level check out this document infocenter.arm.com/help/topic/com.arm.doc.den0024a/DEN0024A_v8_architecture_PG.pdf

Aarch64 is a beautiful arch with instructions like CBNZ (jump if non zero) you might like it

it absolutely doesn't -- gnu.org/software/binutils/

ftp.gnu.org/gnu/binutils/
ftp.gnu.org/gnu/gcc/

nice try though

What bare bones tools do I need to program and put a website up.
I have old lenovo thinkcentres that can operate as servers.
I have experience programming in PHP, Python, HTML, CSS, Javascript, and C++.

and readline is its own package too, it obviously has no place in binutils as a general line-editing library