/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/start-mvc?tabs=aspnetcore2x
stackoverflow.com/questions/905551/are-there-any-o1-n-algorithms
repl.it/LBAI
twitter.com/NSFWRedditVideo

Welcome home, big sister!

Does anyone know about a 20-byte structure used internally by VC-compiled binaries for heap allocation management?

>>> 0.2 + 0.2 == 0.4
True
>>> 0.1 + 0.2 == 0.3
False

this is why you should never store money as a floating point value

Are you retarded on purpose or it's just a plan to get (You)s?

I always write code in small pieces that I keep checking to make sure it works, to analyze each step and see how it should evolve.

Is this a good coding practice or not?

What is your approach to writing code?

A single compilation unit should never be more than 200 lines of code.

daily reminder to not read HtDP

You have some sort of neurotic paranoia
Seek help

>Is this a good coding practice or not?
They created procedural programming for this purpose.

#include

int main(){

int c = 5, d;
d = ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c;

printf("%d\n", d);

return 0;

}


How much is d?

Huh.

...

thats more or less how I code. I constantly have to re-prove things about the code to myself. maybe test-driven development would be better, I don't know

UB

If you can't read and comprehend chunks of about 5000 lines of code, you can't call youself a skilled programmer. You're either an intermediate programmer or a total noob. Practice calculation and memorization.

Okay, so here's an idea: What if we made a fully-featured build script language like CMake... but it's actually a DSL of S7 Scheme?

just run a bunch of tests and some expected output.
If a new change broke something, go fix it.

>sequence point baiting
>2017

A multiplayer FPS.

I think that a high iteration rate and a constant feedback loop is super important in development.

Why not?

what is govno? Is that a programming language?

>govnocode
That's just Russian for "shit code".

Why Russian? Russian programmers suck. Best programmers are in USA, India, South Korea, China and Japan.

>write a small program which requires bigass runtime library/language interpreter
Can this be called bloatware?

Yes.

53 bits of precision is vastly more precision than you need for any financial purpose. Just round your outputs and don't use == on floats.

or you could just use an integer and count cents

Here's a better idea: modules

Are there any good resources for intermediate-level Haskell? It seems that everything kinda peters out or diverges into a million different (largely theoretical) topics after monads and monad transformers

Followup on I was offered the job even though I fucked up that question. Very tempted to take it.
There is salvation even for plebs like me.

If you're doing this you might as well be writing unit tests, which is pretty much standard practise everywhere these days.

There's absolutely nothing wrong with doing it. Full code coverage means you can guarantee that outputs remain the same after future refactors.

I needs to do euler programming tasks to become a skilled programmer like you?

Microsoft's documentation is shit. I need to learn to do MVCs in Asp.Net Core 2. What's the best resource for this?

Boss is making us use Vue.js + Typescript + ASP.Net core. I'm going to a career fair tomorrow to look for a new job

>Microsoft's documentation is shit.
you are the first person i've ever heard say that, MSDN is fantastic

docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/start-mvc?tabs=aspnetcore2x

>ded american hours
idk if that's a good thing or a bad thing
on the one hand it might mean americans don't give a shit about programming here
on the other it might mean they've grown out of posting absolute beginner shitter questions on dpt like a lot of euro first year CS retards posting fizzbuzz tier bs

i think it might be the second

fractional cent amounts are a real thing

What does dpt think of F#?

What is a good book to practice Data Structures using C?
C is my main language and I know how to program linked lists, but I am yet to program any kind of tree.

depends on .NET

Is there a more efficient way to compress a large dense matrix array than using a general compression algorithm?

It's just a jumbly mess of API calls with no context as to what the fuck these things mean. MS UI is an endless hierarchy of windows and dropdowns. MS cannot into design

Are there any O(1/n) algos?

Does anyone else here feel that programmers are way overpaid? Earning 6 figures for being able to solve shittly leetcode problems seems a bit outrageous. Programmers should be paid no more than what someone could make at dunkin donuts mixing coollattas.

>literally copypasting questions from stackoverflow
stackoverflow.com/questions/905551/are-there-any-o1-n-algorithms

I'm as shocked as you are

/dpt/ permitted programming languages:

>Rust
>Scheme
>Idris

Using Python? Go to Using JavaScript? Go to Using C/C++? Move to a safer language.

Using Java/C#? Move to a more expressive language.

so basically you can't have a job

>Using C/C++? Move to a safer language.
lmaoing at your life

Perhaps other professions are underpaid.

Why is programming in the modern day so terrible?

Everything is so complicated now. In the 90s you could make a sweet static website using some backend language and build a business out of it. Now everything is about mobile design and frameworks which generate 90% of the real code.

On top of that, there are these backend frameworks. Nobody wants to just write their own software anymore, they just have rails or django or whatever do all the hard work for them.

Even PhD level Computer Science is boring now. Papers from the 1960s are cool and have useful info that anyone can use. Papers today are all micro-improvements on the latest genetic meta-heuristic for a neural network.

What part of any of this do people find fun anymore? Every problem has either been solved and boiled down to a few lines of some framework or is PhD level work.

All these frameworks are memes too. There's like a gajillion of them out there and next year nobody is going to be using them anymore.

The drive for "simple" programming languages

it's because 90% of the programmers hired turn out to be completely and utterly incompetent
as in, literally can't do the job

Then hire better programmers.

What's that? There's not enough of them? Try offering MORE MONEY. Try not using shit stacks and languages. Try letting them work remotely.

>Then hire better programmers.
the issue is you don't know how good they are until you hire them
obviously nobody would waste their time and money on those 90% of hires if they knew beforehand
>Try offering MORE MONEY.
but the post I'm replying to said they're already making too much

A bash function

>India
>China

Maybe stop the obsession with having easily replaceable developers. You can't have that and at the same time have highly skilled people.

>but what if I want to fire the guy? what if we can't find a replacement?
Why would you want to fire him if you know he's good at his job?

Lads, I'm reading a book on x86 assembly. What's the opinions on this? Am I falling for some meme, or can assembly actually be helpful?

Why?

If you're going to do low level shit like C or embedded or whatever, then knowing how everything works at a memory-cell level is very helpful

>Maybe stop the obsession with having easily replaceable developers.
can't
the 10% who can do the job know that they are special and can get a job anywhere
so they often leave whenever they feel like leaving

Looks breddy gud.
From scratch or are you using some shitty game maker engine?

>so they often leave whenever they feel like leaving
Give them a reason to stay, such as more money.

Honestly for no reason whatsoever. I don't work in anything remotely related to computer science or computer engineering. I just want to see how fast I can make some basic programs. I'm currently good at Python, which is supposedly slow, and from what I heat C is very fast, but you could possibly be faster with asm

>you could possibly be faster with asm
True. Compilers are very clever these days though, user.

Have you written much C? It's much more painful than writing Python, and writing asm is much more painful than writing C. It gives you even less safety than C.

>Then hire better programmers.
Easier done than said, right?
>Try offering MORE MONEY
If they have the money what's there to motivate them to do more?
>Try not using shit stacks and languages
A programmer worth his salt will be able to develop on any stack or language
>Try letting them work remotely.
So they don't have to be accountable to what is present?

pick up c or c++ first
then you can ease your way into asm because you can see how your c/c++ compiles to asm when you debug, and you can write inline asm in those languages

Does a loop from 1 to n^n count as O(n^n)?

Python is actually really fast if you know what you're doing. Much of the libraries and such for it are also just C/C++ modules.

yes
assuming you're not skipping elements anywhere or anything sneaky

Skilled programming is a seller's market right now. There aren't enough skilled programmers, so you're going to have to make a better offer than other companies. Why would they work somewhere that uses $shitlang when they can take a similar offer from somewhere else that uses $goodlang instead? The same goes for having to commute vs not having to commute.

Why do you think remote workers aren't accountable?

>There aren't enough skilled programmers, so you're going to have to make a better offer than other companies
This doesn't match up with my experiences.

>Why do you think remote workers aren't accountable?
They wouldn't have to show their faces to take the heat should they screw up.

In C# is better to use a multidimensional array or an ADT ? I ask because in C++ it is usually just easier/more flexible to use a vector in the general case unless you specifically need arrays for some reason.

>This doesn't match up with my experiences.
Depends where you are, I guess. In my area companies are desperate for people.

>They wouldn't have to show their faces to take the heat should they screw up.
You know you can communicate with remote workers, right? Email, phone, video conferencing, ...

>Depends where you are, I guess. In my area companies are desperate for people.
What area is this?

I worked at a SV firm before, and despite being able to do N times more than some of the other people the boss was careful to make sure I was paid less. There was an expectation that the high rent prices would intimidate people to not take risks otherwise they might end up homeless. The other SJW companies basically gave me the cold shoulder when I tried to find a better job.

>You know you can communicate with remote workers, right? Email, phone, video conferencing, ...
There is something to be said about face to face communication and presence that isn't present in remote positions.

>There is something to be said about face to face communication and presence that isn't present in remote positions.
It makes it easier to catch diseases from your coworkers?

Trying to learn Haskell (ooh boy)

Where am I going wrong with this? I'm getting an error related to the function composition part at the last part...

--Make EnumToFrom (etf) for different types
module ETF where
eftChar :: Char -> Char -> [Char]
eftChar begin end
| (begin == end) = end
| (begin > end) = begin : eftChar (succ begin) end
| otherwise = (reverse . eftChar) end begin


Isn't (reverse . eftChar) end begin syntactically equivalent to reverse ( eftChar end begin) ?

No, as eftChar takes two arguments, the types don't match unfortunately

You could do

(reverse . eftChar end) begin

> from what I heat C is very fast, but you could possibly be faster with asm
Theoretically possible, but you have to put in an insane amount of effort before you can generate faster asm than a modern C compiler.

The main reason for learning asm is so that you can read it, not because you'll actually want to write it. Actually writing asm is incredibly rare nowadays; even 8-bit microcontrollers with less than 1K of RAM are typically programmed in C or (increasingly) C++.

There is the alternative of
((reverse .) . eftChar) end begin
(I think)
But I would rather do
reverse (eftChar end begin)

Okay I think I might be a retard, because I'm still getting errors:

--Make EnumToFrom (etf) for different types
module ETF where
eftChar :: Char -> Char -> [Char]
eftChar begin end
| (begin == end) = end
| (begin > end) = begin : eftChar (succ begin) end
| otherwise = reverse (eftChar end begin)


Returns the following error when I load it in ghci:
Prelude> :l EnumToFromTest.hs
[1 of 1] Compiling ETF ( EnumToFromTest.hs, interpreted )

EnumToFromTest.hs:7:22: error:
• Couldn't match expected type ‘[Char]’ with actual type ‘Char’
• In the expression: end
In an equation for ‘eftChar’:
eftChar begin end
| (begin == end) = end
| (begin > end) = begin : eftChar (succ begin) end
| otherwise = reverse (eftChar end begin)
Failed, modules loaded: none.


So I'm guessing it's getting confused with the type of 'end' or something?

If you look at the first case, you're returning "end" which is a Char.
Did you mean [end] ?

Floats are unnecessary anyway, fixed points are better

Yup. I'm a moron.
Thought I could pull a Lisp and just return the value and have the list-syntax automatically take care of it.

Thank you very much, though!

> eftChar :: Char -> Char -> [Char]
Note that this is equivalent to:
> eftChar :: Char -> (Char -> [Char])

"reverse" has the type
> reverse :: [a] -> [a]
and "." is:
> (.) :: (b -> c) -> (a -> b) -> a -> c

So the LHS function's argument type must match the RHS function's result type. But reverse's argument type is [a] while eftChar's result type is (Char -> [Char]), and those can't be unified.

If you uncurried eftChar:
> eftChar :: (Char, Char) -> [Char]
then you could use:
> | otherwise = (reverse . eftChar) (end, begin)

But there really isn't much point in using composition here. If you want to get rid of the parentheses, use $:
> | otherwise = reverse $ eftChar end begin

What is the advantage of using properties as opposed to traditional variables, accessors and mutators? It seems to give me more boilerplate by forcing methods I don't need. Is private get ever not a waste of space? It doesn't feel better to me.

Why are automobiles in the modern day so terrible?

Everything is so complicated now. In the 20s you could make a sweet auto-gyro using some some helicopter parts and build a business out of it. Now everything is about interior design and industrial-scale machine shops that produce 90% of what goes into a car.

On top of that there are these automobile oligarchies. Nobody wants to just build their own car anymore, they just have Ford or Subaru or whatever do all the assembly for them.

Even driving a car is boring now. Cars for the 1960s are cool and have handling characteristics that anyone can enjoy. Cars today are all micro-improvements on the FWD commuter car.

What part of any of this do people find fun anymore? Every car has either been neutered into a Prius-shaped faggotmobile and boiled down to an eco-friendly automatic econobox or is GT-R level expensive.

All these aftermarket cupholders are memes too. There's like a gaillion of them out there and next year nobody is going to be using them anymore.
[spoiler]sorry[/spoiler]

Properties are garbage, don't fall for the bullshit.

>>Python 3.6.1
How to if statement?
if opt == 1:
print("You picked option" +opt)
else:
print("Siike... Das the wrong number.")

It just bypasses the entire command after typing in any numner, What gives!?

>Siike
What did you mean by this?

repl.it/LBAI

sike

It depends whether you want roughly-constant absolute error or roughly-constant relative error. Each has its uses.

Fixed-point still doesn't help with the original problem, which is essentially the use of the wrong base (using binary where you want decimal).

And C does (optionally) have decimal floats:
#include
int main(void)
{
printf("%d\n", 0.2dd + 0.2dd == 0.4dd);
printf("%d\n", 0.1dd + 0.2dd == 0.3dd);
return 0;
}

Son of a bitch how could I have missed that. Thanks user.

Why are people retarded? Like this fellow. Does he not know how big 2^53 is?

Start using C++

No problem anonkun

So how do you go back to the top?
>>Python 3.6.1
# Startup
print(
"Dank Software\n"
"By user |2017\n"
)

opt = int(input("Type an Option: "))
if opt == 1:
print("You Picked The Right Option")
else:
print("Sike... Das the wrong number")