/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

harmful.cat-v.org/software/c /
a.uguu.se/bsPS5bH7P60B_ATourofC++,Stroustrup.pdf
stackoverflow.com/questions/231760/what-does-a-type-followed-by-t-underscore-t-represent#231807
momentjs.com
lrde.epita.fr/~tiger/doc/bounds-checking.html
twitter.com/SFWRedditImages

C++ is good in the right hands

Idris is a good language

This, dependent types will revolutionize programming

how does a site know something was posted "2 days ago" for example. At first i thought they just subtract the day integer from the date it was posted with the current day integer but that would fail when it changes months

youre an idiot

No one knows how it works. Programmers pass around the code without understanding it

that's why everyone just stores the date in seconds since 1970 and subtracts when you want the delta between 2 times.

Look up how a datetime library works.

And to just get the days past, you can subtract linux timestamp values and bin by 24 hour slots easily without having to do anything complicated or even using a library.

(you)

how do i get into a good incubator like in the hbo series silicon valley?
how much cash do i need to have saved up to survive SF inflated prices on everything?

c++ is the greatest language of all time

I don't like this meme very much

>fixing microcontroller bugs
>find "PORTC &= 0

What's a good book to learn modern C++? ie one based around templates and such, with exercises so not just another huge 1500 pages reference book

Why learn C++? It's shit

harmful.cat-v.org/software/c /

nvm i just find out effective modern c++ is the recommended one to make the transition to modern practices

i respect your opinion and your willingness to help, but it reeks of Sup Forums contrarianism

sugarjs.com/dates

Can't post this code, lol.

Gives me an error: "Your IP or IP range has been blocked from accessing Sup Forums."

why haven't you purchased this yet?

we track dates as days, we're currently on day 737072 so integer addition works quite well with no risk of integer overflow

Rate my code, /dpt/.

#include
#include

/**
* @param n n
* @return d on success, -1 on failure
*/
int64_t f(uint8_t n)
{
if (n 92) return -1;
n -= 2;

uint64_t a = 1, b = 1, c = 0, d = 1, e = 1, f = 0;

while (n) {
uint64_t g, h;
if (n & 1) {
g = a * d + b * e;
h = b * d + c * e;
f = b * e + c * f;
d = g;
e = h;
}
g = a * b + b * c;
a = a * a + b * b;
c = b * b + c * c;
b = g;
n >>= 1;
}

/* return d */
return d;
}

This page was created in 2006. Do you really expect it to reflect the last 11 years of C++ development?

There are better ways to do this without explicit bit manipulation

that's just hiro range banning IPs to get them to buy Sup Forums passes

Yeah, it's worse now

masterb8/10

because you can download it for free
a.uguu.se/bsPS5bH7P60B_ATourofC++,Stroustrup.pdf

I would never even consider C++ if not for C++11 and onward

defec8/10

But I can post just fine if I exclude the SQL snippet.

Someone give me a good C programming talk.

>62 seconds apart
it was still a bad joke the second time m8

what does this/suppose to do?

Nobody cares about C. There are many very good C++ talks that happen to be relevant to C.

Calculates prime numbers.

what are programs that a lot of people use that are a JAR file? ie.. javas use

that's funny
because literally every cppcon talk ends up complaining about C for stealing away their use cases

Fuck off Disney shill.

Fuck guys, I just started learning Kotlin and it's a boss lang. I've never been this red pilled in my life.

it seems like the other ways are compiler-dependent. so this type of instruction would be the most portable, yes?

if there is a better way, i'm all ears. someone always fucks this kind of thing up.

t. not intelligent enough to use scala

reddit.
post a short blurb about it in a relevant sub at the time when North America is waking up and you're guaranteed some attention. I expected a lot less, though.

>inb4 plebbit XD
XD

>Kotlin
Java-EZ

t. not relevant enough to use kotlin

hell yeah dude kotlin is so BEAST. it makes me HYPE

literally never heard that in a cppcon talk

le n00b here, what does the _t mean in the datatype?

"C is close to hardware, it's basically assembly"
>stdint was standardized too late
>all common C libraries have to redeclare fixed width integer types because they aren't built into the language
???

I don't know who you were trying to reply to, but I agree. Kotlin masterrace. Can't wait for the day of the rope for the Haskell brainlets.

stackoverflow.com/questions/231760/what-does-a-type-followed-by-t-underscore-t-represent#231807

fuck why did I waste my quad 9's on this
kotlin comment meant for it's funny how short-sighted k&r were in some ways. They had no idea what was coming.

Kotlin will fail just like 90% of JVM languages. You don't win by trying to get people to leave Java. Most of them don't want to leave Java. You win by attracting the people who want to target the JVM but don't because there are no good languages for it. Scala is currently the least bad option.

>90% of JVM languages
can you list all the past failed JVM langs?

stdint is optional and you can't depend on having those fixed width types on all systems.

It would make less sense to me having the C programming language defining how many bits in a byte in the late 60s.

I suppose they are compiler dependent, but I think most allow it. So I guess the best way is use a language designed for embedded systems, or give everyone a periodic refresher.

I can't list all of them, but I can say that the only successful ones are Java and Scala. The failures include Groovy, Ceylon, Eta, JRuby, Jython, Frege, Clojure, and Fantom. So perhaps 80% would be more accurate.

How easy is it to make a script that snaps up expired domains?

C++ is literally bloatware

In practice, that site is probably using momentjs momentjs.com

How easy would it be for you not to be a waste of carbon?

and if you don't mind just learn java ( and/or c#)

it's much simpler to learn and get work in

>the best way is use a language designed for embedded systems
it seems like C and C++ are most common, outside of the arduino bullshit world. what language are you alluding to?

I just think the general naming of "int, short, long" and having to type out "signed" and "unsigned" is based on the original syntax where you couldn't define vars midway thru a function. (i.e. only type them once).
Either way, it took far too long for them to decide on required sizes, and the end choices were too late. That's the real failure.

Groovy is #42 most used language, Clojure is #50. They're not failures at all.

Are you the same person who posted in stupid questions thread?

It's not "hard" but you pretty much can't get around auto-renew or a owner that renews it during their grace period.

as consolation, groovy gets to live on in build tools

Does anyone here regularly smoke weed when they program?

Me. Doing it right now...

dude, weed

I know someone that prefers to program high because it's easier to focus

No

C is beast and you're all low test.

>Muh array bounds
>My garbage collection
>new

Laugh at these faggots. C is shit and still 20x better than everything else.

I've tried it a few times, I just end up writing useless shit with "ideas" comments and I delete it all when I wake up the next morning.

Stimulants are the real programming drug.

rust has a compile flag to enable bounds checking (and subsequent panics), but it's disabled when compiling for release. Best of both worlds, I wish C/C++ had this.

where does scala typically find use?

not memeing, Ada if you have the choice.

>Best of both worlds
>not automatic static verification

how do you prove that all accesses are within bounds in a program before running said program?

You don't. There is no generalized solution here.

>I wish C/C++ had this.
There are compiler flags for this...

Types and totality.

And those comments are the dumbest shit ever, a lot of them don't make any sense and sometimes it's just a half-assed ASCII art diagram of some half-baked idea.

I don't smoke weed often but when I do I get bored of media and start programming and shit. Thank you git.

...

> C++

what the fuck do you have when you return a reference to dynamically allocated data inside a function?

interesting - i'll look into it. thanks for the tip, bruv.

which ones?

Your strong type system is nothing compared to THEORY OF COMPUTING that dictates anything can happen in a running program, and the only generalized way to know something about it that happens at runtime is to run the program.

C++ is just like english. You can put things together but don't expect them to make sense.

>Your strong type system is nothing compared to THEORY OF COMPUTING that dictates anything can happen in a running program, and the only generalized way to know something about it that happens at runtime is to run the program.

lrde.epita.fr/~tiger/doc/bounds-checking.html

There's also tons of alternative that are more or less expansive.

We don't want to write programs we can't reason about before runtime.

What do you think type/termination checking does you fucking retard?

You know how you can chain constructors in C# using " : this() "? Is there any way to do the same thing with overloaded methods without having to actually call the other method in the body?

>Your strong type system is nothing compared to THEORY OF COMPUTING that dictates anything can happen in a running program, and the only generalized way to know something about it that happens at runtime is to run the program.
What the fuck am I reading.

>Kotlin will fail
It's already taking over Android dev. Most projects are written in Kotlin now. Almost all the big libs are being ported over to Kotlin. It's happening bro.

I have no idea how your comment relates to what I said so I'll just call you a faggot

Probably because you're stupid.

A cosmic ray could flip a bit in a computer running your program and alter its runtime behavior. Good luck proving anything about that at compile time.

That's really nice, thank you user. I googled the same thing but I didn't find that particular info.

holy shit, do you guys really think you can do generalized bounds checking at compile time? The only way to achieve that is via proof-driven programming, which is insanely hard and not adaptable.

>via proof-driven programming, which is insanely hard and not adaptable.

It's only hard if you're a brainlet

Ever heard of Curry-Howard? You're already writing proofs, user.

Go on then, show me fizzbuzz in ATS mr. smart guy.

Not 100% generalized obviously (that would imply there is a solution to the halting problem) but general enough that you can write useful programs with little to no proof guidance beyond types.

Kotlin? You must have meant Kot Blin