/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

ghostbin.com/paste/jtjaa
ghostbin.com/paste/btk34
github.com/rust-lang/rust/pull/25640
github.com/rust-lang-deprecated/rust-buildbot/issues/2
github.com/rust-lang/rust/issues/41646
github.com/rust-lang/rust/pull/25585
stallman.org/microsoft.html
pastebin.com/Fwi71Rk1
en.wikipedia.org/wiki/Arithmetic_progression
twitter.com/NSFWRedditVideo

Why do c++ style casts have to be so much more verbose?

could you give an example

Because verbosity is why you'd use them over C style casts. dynamic_cast aside.

Because they're more restrictive in what they allow, and casting in C++ is widely considered to be code smell.

How do I create a Sup Forums image scraper using C?

why doesnt c++ just become a dynamic typed language?

It can be, if you want. Use std::any.

Modern C++ already looks like Javascript with autos n shit

>type inference is dynamic typing

I don't have a comp sci degree but I was lucky enough to find a programming position that offered on the job training. Been doing it for a year now using Java and Spring, passed Oracle's Java SE 8 Programmer I exam (OCA), but now i'm wondering what to study next. Since I don't have a computer science background I'm probably missing a lot of background knowledge.

What are some must reads for a new programmer in my position? I was thinking of picking up tcp/ip illustrated and unix programming by Richard Stevens, since they have great reviews and cover a lot of what's going on underneath what i'm doing

I was just acknowledging that C# is not a bad language, but my point is it does come from Micro$oft and I'd rather avoid it if at all possible.

>auto means it's got dynamic typing

>full type inference + sum types
Is this the only way to pull a static typelet from the fantasy world where static typing matters?

>fantasy world where static typing matters

I don't understand what you're trying to say.

...

>programming

Justify static typing.

>venture into C++ and Javascript
>come back to C
>feels like literal home, almost crying
;_;

>Justify static typing.

>thinking static typing is anything more than a meme
Lad...

>>thinking static typing is anything more than a meme

dynamic typing is just static typing with dependent existential quantification and rtti

>I don't understand what you're trying to say.
I'm saying you're so dumb you'll probably be happy with that, despite it being practically the same as dynamic typing, because "sum types" sounds like something a mindless static typelet would jerk over.

>dynamic typing is just static typing with dependent existential quantification and rtti

someone brainlet this fool

>posting photos of your entire family on the chong
Why would you do that, user?

Any : Type
Any = ∃(T : Type).T

prove me wrong

>I'm saying you're so dumb you'll probably be happy with that, despite it being practically the same as dynamic typing, because "sum types" sounds like something a mindless static typelet would jerk over.

When did Sup Forums invade

nice mibba. that's actually pretty good. not many people are willing to handle data like that. especially since classes normally start out with javascript or oop. now if you try to dabble in anything low level or make your own library you just get shit like

>hey you don't have to reinvent the wheel just use this library instead and defeat the entire purpose

Thank you. I'll look it up

>prove me wrong

do you think i'm advocating for dynamic typing or something? i'm agreeing that static typing is more fundamental and that dynamic typing has necessary overhead over it as well as less utility

In 10 hours I'm doing a demo at Globecom. It doesn't work, so I'm fixing it.

>do you think i'm advocating for dynamic typing or something?

thanks for the new brainlet image

>tfw cant help but giggle like a girl at these images
help

>What are you working on, Sup Forums?

Exploring the deepest, darkest corners of Racket. Advent of Code 2017.

>le static type face

>it does come from Micro$oft
It's FOSS. You can take it and fork it if you want something that has nothing to do with Microsoft in any way. It's silly to judge a tool by an aspect of a massive entity based on prior experience with another unrelated aspect of a massive entity, especially considering most of the complaints I've seen come from business practices well over a decade ago.

>working

Why is there no good systems programming language?

It's called C++.

C++ is the stuff of nightmares.

Only if you're retarded.

C++ is not bad because it is complicated, it is bad because it is unnecessarily complicated.

Rust

>only retarded people have nightmares from C++
Maybe that's because only retarded people use it in the first place.

Borrow checker.

That's false because I use it.

Could be better but it's not terrible.

>it's not terrible.
It's acceptable for fizzbuzz.

Have you tried Ada?

It needs to not exist. That combined with the immutable a but default bollocks leads you to jump through hoops that ultimately make your program less efficient. A systems pl should get out if my way, not tell me what to do.

I'm currently working on a heap-sort project for my computer science class.
I'm writing the program from scratch and trying to use pointers to generate a heap in the form of an array-based binary tree.
I'm currently receiving a seg fault error, but I can't isolate the bug because when I run the binary after compilation, it goes straight to a seg fault error. It doesn't even read the first cout statements.
Code here(main.cpp): ghostbin.com/paste/jtjaa
Here's the Makefile: ghostbin.com/paste/btk34
I hope it's commented well enough. Thanks for any help. Dunno what I can do in exchange for help.

Just got my first full time software engineering job. $100,000 base salary. Keep going fa/g/s.

>immutable a but default bollocks
Eh?

>leads you to jump through hoops that ultimately make your program less efficient. A systems pl should get out if my way, not tell me what to do.
You can use unsafe to get it out of the way.

How does one stop comparing oneself to others? It's hampering my progress. I get so fucking down on myself and I completely stop programming for days at a time because of it.

Get a socket library, something to handle the http calls, like cURL.
Then just either scrape pages, looking for image html tags, or use the actual Sup Forums API.

C's a great language, but I wouldn't recommend it for anything string/parsing related tho.

Immutability by default is a bad decision for systems programming languages.

Unsafe is a solution but it's needlessly verbose. Unless I can declare a whole module as unsafe it's boilerplate.

>Have you tried Ada?
Nope.

Use the force

You don't stop. Getting down on yourself because others can do things you can't is what drives us to improve

yeah but there is a difference between a little bit that fuels that drive and a lot that makes you borderline suicidal / questioning if you are retarded

Is it me or is dpt becoming worse and worse every time I revisit it.
Like, it's not even summer anymore, and you have absolute bellends spamming and pretty much nothing else.

Oops, was meant for

what do you call system programming?

Rust is a good language.
Prove me wrong
protip:[spoiler]comparing it to c will only make you sound stupid[/spoiler]

Do you feel like it's important to fix a lot of edge cases before the initial commit/public release? I think I might be making a big deal out of not wanting to release something "unfinished" which leads to never releasing anything. How do I break this?

I think it's decent. Unfortunately the borrowing system is missing some IMO obvious changes that would dramatically improve it, and those changes won't be able to be implemented without a complete overhaul. I want to implement them in my own language.

github.com/rust-lang/rust/pull/25640
github.com/rust-lang-deprecated/rust-buildbot/issues/2
github.com/rust-lang/rust/issues/41646
github.com/rust-lang/rust/pull/25585

What is a good language though?

If we go by readability, it's lacking compared to anything higher level, and the macro system seemed atrocious.

If we look at speed, the whole systems thing where it tries to replace C++. It's possible to do with C++, but replacing C borderline impossible.

It's kinda trying to do both things and failing to do either. Decent language, but I don't expect much from it.

Update: I've isolated the issue to line 56. For some reason reference a node's data item with -> causes a seg fault.

...

>What is a good language though?
Haskell.

Get a debugger and step through it.

I'm running VIM right now. Is there a debugger extension for it?

I'm sure there are, though I never used one. Knowing how to use gdb directly is a good experience anyway.

stallman.org/microsoft.html

#include
#include
#include
#include "hw7Book.h"
#include
#include
#include
#include
#include

using namespace std;
void opener(ifstream& reader);
int main()
{
//testing
string bigData;
ifstream reader;
vector library;
int i = 0;


cout

That was a step forward for me, thanks for showing me that debugger.

Do software developers in the likes of Google or Facebook work mad hours, or is it a standard 40hr week? I've heard some people say that they provide a shitload of perks, but only in the hopes that they can keep you in the office for longer.

Is watching the MIT video series on Structure and Interpretation of Computer Programs worth it if you're not new to programming?

Can it act as a substitute for reading the book?

video course is fine, use text as supplement

I've tested the Book constructor extensively by the way, so I know it's not that.

nvm I see it. God I'm an idiot.

Okay, I fixed "library.size() < 10;" to "i < library size()", but it's still only printing one blank object. Any ideas?

Alright, /dpt/. Show me your computer science skills. How do I simplify this grammar:
E -> B | F .
B -> T + T Ts .
Ts -> + T Ts | .
T -> F Fs .
Fs -> * F Fs | .
F -> lit | ( B ) | ( F Bs ) .
Bs -> B Bs | .

ruby beginner here. just started on the euler project and I figured out the first question no problem (find the sum of all multiples of 3 and 5 under 1000). first attempt went like this:
def sum_multiples_old(input)
sum = 0
while input > 0
input -= 1
if (input % 3) == 0 || (input % 5) == 0
sum += input
end
end
puts "#{sum}"
end
sum_multiples_old(1000)

it works fine, but it's specific to the problem so I wrote another one that's more general:
def sum(m, n)
(((n / m) * ((n / m) + 1)) / 2) * m
end
puts sum(3, 999) + sum(5, 999) - sum(15, 999)

the problem is, I can't simplify it any further. I checked my math, but if I write it like this:
def sum2(m, n)
(n * (n + m)) / (2 * m)
end
puts sum2(3, 999) + sum2(5, 999) - sum2(15, 999)

it won't return the correct sum. what am I doing wrong here?

You use a parser that takes precedence into account.

Is there anything that can lead back to the exact compiler I used in my final program?

>You use a parser that takes precedence into account.
What did he mean by this? What parser?

The only reason I could see to need to simplify that grammar is if you are parsing or doing homework and I'm not going to do your homework for you.

>The only reason I could see to need to simplify that grammar is if you are parsing or doing homework
I am parsing, and a recursive descent parser for this grammar would be simple enough (certainly easier than implementing a precedence-aware one), but I'm interested in knowing if it can be simplified even further.

Recursive descent precedence parsing is piss easy, you're barking up the wrong tree here.

UK-based person here. Is there any point in going to college and university for software development / computer science when you have already paid to go to university before? Cannot get loans second time around.

This is the first game I ever made. Good times.

pastebin.com/Fwi71Rk1

en.wikipedia.org/wiki/Arithmetic_progression

I assumed you derived that from n*(a_1 + a_n)/2, with that a_1 = m, a_n = n and n is a_n/a_1.

I think why it's wrong is that unless n is a multiple of m, you have the wrong a_n. For example when you do sum2(5, 999), a_n should be 995, not 999.