/dpt/ - Daily Programming Thread

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

Attached: 1544927390301.png (750x1000, 1.14M)

Other urls found in this thread:

nim-lang.org/araq/destructors.html
dlang.org/
youtube.com/watch?v=3U3lV5VPmOU
github.com/Smithay/wayland-rs
neuralnetworksanddeeplearning.com/
twitter.com/AnonBabble

merry christmas /dpt/

nth for Nim!

Waiting for v1 release candidate

>What are you working on, Jow Forums?
Image subsampling. Doing it wrong.

Attached: 1544927390301.png (112x150, 47K)

Would dysfunctional programmers please just get tae fuck? You're all fucking abstractionlets.
>waaaaahhhh your code is too succinct why can't you just use good old fashioned imperative style with ten times as much pointless boilerplate
>why can't you just take an int instead of a more precise type and throw an exception if it's outside the correct range
>function composition is too complicated but using this massive framework with magic annotations all over the fucking place is absolutely fine

dependent typing is not practical

.20 (1.0 RC) isn't gonna have any major features.
1.0 is pretty much done, so if you're interested in Nim, you should start learning it now.

>get tae fuck
no idea we had scots here

My team is drowning in work, and there are zero available programmers in this town. We tried using Pajeets for a while, but instead of doing the needful they just made a big mess of the codebase.

Thoughts on teaching programming from scratch to in-house normies? Some guys elsewhere in the company have expressed interest in learning code to join the team, but it's a huge undertaking. On the other hand unlike new hires or consultants they already know the business concerns inside and out and there is no culture clash like with outsourcing. Think it may be worth it?

yes it is

What happened with the new exception handling thing? And where's the destructors? These are major changes, no?

explain.

I think it's a vicious circle of scrum masters and middle managers saying "aint nobody got time for abstractions", so teams never get enough practice, so they keep making shoddy abstractions, and the higher ups keep getting a lower and lower opinion of them.

Switch to a better programming language.

Using C? Switch to C++ or Rust.
Using C++? Switch to Rust or preferably OCaml.
Using Java? Switch to Scala or preferably Haskell.
Using JavaScript? Switch to PureScript.
Using Python? Switch to Haskell.
Using C#? Switch to F# or preferably Haskell.
Using OCaml? Switch to Haskell.
Using Haskell? Switch to Idris.

What's going wrong about it? I'd try convolving with a gaussian and then sampling with weighted nearest pixels. That should result in a decent image with no aliasing.

Don't let lazy programmers off the hook. So many of them refuse to even try to learn anything new.

#include

int main(){
char line[100];
int num_grade;

printf("Please enter the numeric grade: ");
fgets(line, sizeof(line), stdin);
sscanf(line, "%d", &num_grade);

if(num_grade=61 && num_grade=71 && num_grade=81 && num_grade=91 && num_grade

I patched it to slightly change behavior when `row` is an even number. Even numbers now work.
def diamond(rows):
half = rows // 2
o = 1 if rows % 2 else 0 # Is row an odd number?
for i in range(half + o):
# Hack together whatever fucking works
print(" " * (half - i - 1 + o) + "*" * (2 * i + 1))
# Reverse for second half
for i in range(half):
print(" " * (i + o) + "*" * (2 * half - 2 * i - 1))

diamond(1)
diamond(4) # Even numbers work now!
diamond(7)

'''
OUTPUT
*
*
***
***
*
*
***
*****
*******
*****
***
*
'''

>the new exception handling
not entirely sure
>the destructors?
use --newruntime
nim-lang.org/araq/destructors.html

I'd like to do that. In fact it's necessary to cut down on the pointless boilerplate eating up the little time and manpower we have.

And the "we have to use Java because only Java devs are available" becomes a non-argument when there aren't any devs to hire anyway. And we only have to teach the internal hires the good stuff.

Switch/Case

For one, you don't need to put "else if(num_grade>=61" etc., since those cases are covered by the previous clause(s).

void main()
{
import std.stdio : write, writeln, stdout, readf;

write("Enter your numeric grade: ");
stdout.flush();

int num;
readf(" %s\n", &num);

writeln("Your grade is ", num < 60 ? "F." : num < 70 ? "D." : num < 80 ? "C."
: num < 90 ? "B." : "A. Congratulations!");
}

Attached: 1546310069761.jpg (1294x1600, 275K)

faggot

Attached: 1545135228972.jpg (680x993, 64K)

Would you look at that.
The necrophiliac is also a degenerate.

what kind of language is this

Good, I hope you're able to move to a better language. I hope you also have the necessary power to make sure your team doesn't keep writing the old language in the new.

I'm an abstractionlet myself. I don't think it's out of laziness, but lack of opportunity for practice for the aforementioned reason.

I did really well in school building abstractions, but those contrived exercises were a piece of piss. Complex real-world systems with tons of stakeholders who don't have the full picture and struggle to express their requirements is a completely different matter.

why the fuck are using write and flushing manually you heathen.

You may not like it but this is what peak performance looks like
Linear procedural
Flushing is required because there was no \n, and terminals generally are not guaranteed to flush without newlines

Attached: 1496260498328.jpg (549x516, 150K)

"ABCDF"[10-max(min(num_grade/10+1,10),6)]

>Flushing is required because there was no \n, and terminals generally are not guaranteed to flush without newlines
yes that's why you use writeln and readln.

wtf I'm more confused now

Attached: 1545915361535.jpg (513x507, 36K)

What language is this?

C#

>writeln
The specs required no new lines, see
"printf("Please enter the numeric grade: ");"
>readln
reads strings, no? I want int
dlang.org/
No piss off, micro kike

Hey anons I need some advice

In my computing course so far I have got 7/7 straight distinctions but I still have to go to my teacher for help to do with programming when I hit a roadblock and can't figure it out for myself, am I cut out for this? Will I be able to be a successful game developer despite this?

Why? Lots of CS research and innovation happens in Scotland.

You still can make a lot of money despite not being smart

I want to make something fairly gui intensive. Is winapi still the way to go? [spoiler]Is mfc that bad of an idea?[/spoiler]
Please don't tell me to learn some other language than sepples or use some web based rubbish

Attached: 48172347231.jpg (828x518, 78K)

Don't bother with smartass shortcuts user, see

like all pairs shortest path to the pub?

Picking one isn't easy, though.

I have a short list. Haskell because of the succint ML syntax and safe yet flexible type system (I couldn't use Go because it lacks generics, but generics can be pretty dumb sometimes because of no kinds, Haskell has it all). Erlang/Elixir/LFE because of the concurrency model and not having to feel bad for not buying into the microservice meme. Common Lisp for the macros and object system. I haven't tried Rust, but it looks promising. All of these bring something of value to the table, but figuring out what's most valuable to the project is a non-trivial matter. Polyglot is an option, but it's not without overhead.

>go to my teacher for help to do with programming
If you can talk to your teacher, you're nowhere near autistic enough. You're simply not cut out for this type of work, I'm afraid.

'FDCBA'[max((num_grade-1)//10-5,0)]

What stops you from learning new abstractions?

haskell EE
segment :: (Ord a) => a -> [(a,b)] -> Maybe b
segment y = foldr f Nothing
where f (a, b) Nothing = if y > a then Nothing else Just b
f _ x = x

grades = [(100, 'A'), (90, 'B'), (80, 'C'), (70, 'D'), (60, 'F')]

main = do
print "Please enter the numeric grade:"
x do y print "Error: Grade > 100"
_ -> return ()
Nothing -> print "Error: NaN"

nowt wrong wi spendin evenin a a good pub, lad

I am literally autistic though, I've just obsessed with improving my social skills, body language etc. because of the extreme bullying and fights due to me being different.

stay strong, user. My gf gets bullied a lot, even past her school days. But I take care of her.

Attached: 1545908128690.jpg (567x699, 87K)

>I am literally autistic though
Prove it.

just use -XMultiWayIf you spaz

Nobody actually fails fizzbuzz, right?

What do you mean, "learning new abstractions"? What new techniques have come up the last couple of decades? It's all rehashing old stuff.

The problem is that the project management refuses to allocate time for the team to come up with decent designs up-front, but demand a huge mess of spaghetti code because "we're not at school anymore, this is how it works in the real world, when you get older you'll understand".

Vulkan.hpp is pretty comfy desu

I mean "abstractions which are new to you", not "abstractions which are newly discovered/invented". e.g. someone not familiar with functors learning them now even though they've been around for ages.

Well that's a truly destructive attitude from your managers.

Well due to this, I come across as completely normal now but when I am stressed or don't understand something, it quickly reminds me of my handicap, I'm not stupid, I just wish I could understand these things without assistance.
How do I do that?

What's really the point of using Ruby say vs. Python?

>Well that's a truly destructive attitude from your managers
>t. freshman
we're not at school anymore
this is how it works in the real world
when you get older you'll understand

Only JS Artisans.

I haven't done much with GHC extensions, but that looks handy; thanks, user.

>well it looks like there's only C# devs applying for this java position, better train an accounting major from scratch

This is a great introductory video if you're new to statically typed languages:

youtube.com/watch?v=3U3lV5VPmOU

>I mean "abstractions which are new to you", not "abstractions which are newly discovered/invented". e.g. someone not familiar with functors learning them now even though they've been around for ages.
In that case, nothing, nothing stands between me and the docs for whatever clever facilities the language I'm using provides.
>Well that's a truly destructive attitude from your managers.
External project managers paid top dollar from a prestigious consulting firm, no less. I have a pet conspiracy theory that they intentionally go around fucking up companies' codebases so they can charge more hours fixing the mess they caused the previous cycle, racketeering, really.

Wayland-rs 0.22 got released
github.com/Smithay/wayland-rs

Clearly it's not going to be a Java position.

There are no C# devs either. They're all hired by big firms straight out of school, or they are unemployable because they fail fizzbuzz or are dope smokers or other kinds of degenerates.

It's either this or outsourcing to India.

alternatively you could just use guards
grade n
| n

neuralnetworksanddeeplearning.com/
This a good introduction to NN? What would you guys recommend?

Am I correct in surmising that you're a small company? You need to differentiate yourself from the big companies who can just shovel cash to graduates. Given the choice between a Java job that pays $$ and a Java job that pays $$$, I'll take the latter. But if the former were Haskell instead of Java? Then it'd be a more interesting choice.

Yes, another reason to switch to a smarter language. I've talked to other small company owners who have the same struggle, the Java devs they can get are the dross that the big companies skimmed off, but the more obscure language devs they hire are smarter and more motivated. Most of them aren't even CS or SE graduates, they just take personal pleasure in working with the technology.

I suppose there's no reason to try both in parallel, train receptive, tech-minded (probably not accounting majors) co-workers, and trying to attract devs yearning to use smarter languages.

I'm trying to split a string in python on spaces, so every word is a string. However, some words are followed by (some text that might have spaces). How would I be able to keep the text in the parentheses in the same string as the proceeding text?

Honestly once you learn to dissect Haskell and how it works and what it does, the first seems like the most flexible and applicable.
Guards are nice but you're *basically* building a fancier switch statement so isn't nearly as reusable
The python solution and its equivalent are unreadable trash

google and learn regex
nobody just give him the answer

Can it be done without regex? I'm considering manually sifting through each character

Yes, you could build a recursive parser but it would take you 10x as long. Regex isn't hard and solving your problem with it would be a one liner.

>that feel when you have a breakthrough and solve a problem you've been stuck on for days
Non-programmers will never know this

recursion or a stack to balance parentheses

#include

int main(){
char line[100];
int num_grade;

printf("Please enter the numeric grade: ");
fgets(line, sizeof(line), stdin);
sscanf(line, "%d", &num_grade);

if(num_grade=61 && num_grade=64 && num_grade=68 && num_grade=71 && num_grade=74 && num_grade=78 && num_grade=81 && num_grade=84 && num_grade=88 && num_grade=91 && num_grade=94 && num_grade=98 && num_grade

Attached: unknown.png (707x714, 88K)

What would be a better way to write this?

>printf("Your grade is F.");
yep

>hasklets and pythonistats btfo
most readable and maintainable/10

Use grade/10 to determine the letter and then (if not F) grade%10 to determine - or + or neither.

C is important because I need to write garbage that will compile on a very minimal nix server.
Java will get me employed. FP will not.
I unironically like JavaScript. Fite me.
Python allows for fast prototyping and is usually the right tool for the job unlike Haskell.
Idris is one of the few things that’s less relevant than Haskell and I already have Haskell installed and don’t need any other functional language, with the exception of toy languages I might make for fun.

Is this bad code? (python)
if not foo(bar):
while not bool:
bool = foo(*baz())


Basically I want to login with function foo and credentials bar, if wrong credentials than edit config file with baz(), which also returns the credentials and repeat this until True (login succesfull)

Wildly depends on what language you need.

>Switch from (the biggest most popular most efficient fastest well supported languages) to (this meme retarded bullshit)
great advice

>C is important ... so i can write garbage
>I love javascript
>FP isn't in demand
>Python is the right tool for the job
Good fucking christ what third rate backwater community college do you attend?

>Java will get me employed
Java is so low in demand I don't know where you pulled this from, it's way easier to get a job in C/C++ hell even C#

>Java is so low in demand
lol NEET

Attached: 1535935817856.png (1000x1000, 58K)

Are you retarded, user?

>Indeed
nice source. they can't even spell India

wish wagies would fuck off. All they ever want to do is shitpost about jobs and corporate wank.

#include

static const struct {
const char *name;
int min;
} grades[] = {
{ "A+", 98 },
{ "A", 94 },
{ "A-", 91 },
{ "B+", 88 },
{ "B", 84 },
{ "B-", 81 },
{ "C+", 78 },
{ "C", 74 },
{ "C-", 71 },
{ "D+", 78 },
{ "D", 64 },
{ "D-", 61 },
{ "F-", 0 },
};

int main(void)
{
char line[100];
int grade;

printf("Please enter the numeric grade: ");
fflush(stdout);
fgets(line, sizeof line, stdin);

if (sscanf(line, "%d", &grade) != 1 || grade > 100 || grade < 0) {
fprintf(stderr, "Invalid grade entered\n");
return 1;
}

for (size_t i = 0; i < sizeof grades / sizeof grades[0]; ++i) {
if (grade >= grades[i].min) {
printf("Your grade is %s.\n", grades[i].name);
break;
}
}
}

Java is literally an expectation for any job, of course its going to be listed 123978192379875 times. That doesn't mean it's actually in demand. Knowing java doesnt make you an attractive candidate.

SEETHE harder, user

Attached: 1534935983694.jpg (1291x3600, 610K)

100% outsourced

>Retarded """journalists""" writing blog posts based on flawed statistics because they never took a math class
Yeah great source.

seems to work fast enough

Attached: file.png (1920x1080, 330K)

nice